package netclient import ( "bytes" "context" "encoding/json" "fmt" "github.com/bluesky-social/indigo/atproto/repo" "github.com/bluesky-social/indigo/atproto/syntax" ) func ExampleNetClient_GetRepoCAR() { ctx := context.Background() nc := NewNetClient() did := syntax.DID("did:plc:ewvi7nxzyoun6zhxrhs64oiz") stream, err := nc.GetRepoCAR(ctx, did) if err != nil { panic("failed to download CAR: " + err.Error()) } defer stream.Close() // NOTE: could also use LoadCommitFromCAR commit, _, err := repo.LoadRepoFromCAR(ctx, stream) if err != nil { panic("failed to parse CAR: " + err.Error()) } ident, _ := nc.Dir.LookupDID(ctx, did) pub, _ := ident.PublicKey() if err := commit.VerifySignature(pub); err != nil { panic("failed to verify commit signature: " + err.Error()) } fmt.Println(commit.DID) // did:plc:ewvi7nxzyoun6zhxrhs64oiz } func ExampleNetClient_GetBlob() { ctx := context.Background() nc := NewNetClient() did := syntax.DID("did:plc:ewvi7nxzyoun6zhxrhs64oiz") cid := syntax.CID("bafkreieya7iitpu4okjtm7iexiwikj7t63ttlthad32ojsvjqhqbc3iwmi") buf := bytes.Buffer{} if err := nc.GetBlob(ctx, did, cid, &buf); err != nil { panic("failed to download blob: " + err.Error()) } fmt.Println(buf.Len()) // 518394 } func ExampleNetClient_GetAccountStatus() { ctx := context.Background() nc := NewNetClient() did := syntax.DID("did:plc:ewvi7nxzyoun6zhxrhs64oiz") active, status, err := nc.GetAccountStatus(ctx, did) if err != nil { panic("failed to check account status: " + err.Error()) } fmt.Printf("active=%t status=%s\n", active, status) // active=true status= } func ExampleNetClient_GetRecordUnverified() { ctx := context.Background() nc := NewNetClient() did := syntax.DID("did:plc:ewvi7nxzyoun6zhxrhs64oiz") collection := syntax.NSID("app.bsky.actor.profile") rkey := syntax.RecordKey("self") raw, _, err := nc.GetRecordUnverified(ctx, did, collection, rkey) if err != nil { panic("failed to fetch record: " + err.Error()) } var record map[string]any _ = json.Unmarshal(*raw, &record) fmt.Println(record["displayName"]) // AT Protocol Developers } func ExampleNetClient_GetRecord() { ctx := context.Background() nc := NewNetClient() did := syntax.DID("did:plc:ewvi7nxzyoun6zhxrhs64oiz") collection := syntax.NSID("app.bsky.actor.profile") rkey := syntax.RecordKey("self") var record map[string]any _, err := nc.GetRecord(ctx, did, collection, rkey, &record) if err != nil { panic("failed to fetch record: " + err.Error()) } fmt.Println(record["displayName"]) // Output: AT Protocol Developers }