๐Ÿ€ ATproto library for gleam
atproto library gleam
35

Configure Feed

Select the types of activity you want to include in your feed.

possum: add put_record

kacaii.dev (Jul 2, 2026, 1:45 PM -0300) 2a114daa 1bf9fe3a

+93 -1
+1 -1
gleam.toml
··· 1 1 name = "possum" 2 - version = "1.0.5" 2 + version = "1.0.6" 3 3 4 4 description = "๐Ÿ€ ATproto library for gleam" 5 5 licences = ["Apache-2.0"]
+92
src/possum.gleam
··· 713 713 |> request.set_method(http.Post) 714 714 |> request.set_path(com_atproto_repo <> ".deleteRecord") 715 715 } 716 + 717 + /// Write a repository record, creating or updating it as needed. 718 + /// Requires auth, implemented by PDS. 719 + /// 720 + /// ## Body 721 + /// 722 + /// - **collection**: The NSID of the record collection. 723 + /// - **record** 724 + /// - **repo**: The handle or DID of the repo (aka, current account). 725 + /// - **rkey**: The Record Key. 726 + /// - **swapCommit**: Compare and swap with the previous commit by CID. 727 + /// - **swapRecord**: Compare and swap with the previous record by CID. 728 + /// WARNING: nullable and optional field; 729 + /// - **validate**: Can be set to `false` to skip Lexicon schema validation 730 + /// of record data, 'true' to require it, or leave unset to validate only 731 + /// for known Lexicons. 732 + /// 733 + /// ## Examples 734 + /// 735 + /// ```gleam 736 + /// import gleam/http/request 737 + /// import possum 738 + /// 739 + /// let request = 740 + /// request.new() 741 + /// |> request.set_host("personal.data-server.pds") 742 + /// |> possum.authorized("access-token") 743 + /// |> possum.put_record( 744 + /// did, 745 + /// collection: "target.collection.data", 746 + /// rkey: "wibble-wobble", 747 + /// record: [], 748 + /// swap_commit: option.None, 749 + /// swap_record: option.None, 750 + /// validate: option. 751 + /// ) 752 + /// ``` 753 + /// 754 + /// ## Response 755 + /// 756 + /// ```json 757 + /// { 758 + /// "cid": "string", 759 + /// "uri": "string", 760 + /// "commit": { 761 + /// "cid": "string", 762 + /// "rev": "string" 763 + /// }, 764 + /// "validationStatus": "valid" 765 + /// } 766 + /// ``` 767 + /// 768 + /// Endpoint Docs: [/xrpc/com.atproto.repo.putRecord](https://endpoints.bsky.app/#bluesky-app/tag/comatprotorepo/POST/xrpc/com.atproto.repo.putRecord) 769 + pub fn put_record( 770 + request: request.Request(_), 771 + did: did.Did, 772 + collection collection: String, 773 + rkey rkey: String, 774 + record record: List(#(String, json.Json)), 775 + swap_commit swap_commit: option.Option(String), 776 + swap_record swap_record: option.Option(String), 777 + validate validate: option.Option(Bool), 778 + ) -> request.Request(_) { 779 + let body = [ 780 + #("collection", json.string(collection)), 781 + #("record", json.object(record)), 782 + #("repo", json.string(did.to_string(did))), 783 + #("rkey", json.string(rkey)), 784 + ] 785 + 786 + let body = case swap_commit { 787 + option.Some(value) -> [#("swapCommit", json.string(value)), ..body] 788 + option.None -> body 789 + } 790 + 791 + let body = case swap_record { 792 + option.Some(value) -> [#("swapRecord", json.string(value)), ..body] 793 + option.None -> body 794 + } 795 + 796 + let body = case validate { 797 + option.Some(value) -> [#("validate", json.bool(value)), ..body] 798 + option.None -> body 799 + } 800 + 801 + request 802 + |> request.prepend_header("accept", "application/json") 803 + |> request.prepend_header("content-type", "application/json") 804 + |> request.set_body(json.to_string(json.object(body))) 805 + |> request.set_method(http.Post) 806 + |> request.set_path(com_atproto_repo <> ".putRecord") 807 + }