-
Notifications
You must be signed in to change notification settings - Fork 55
feat: add go snippets #735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
b2a246f
be4cddd
070a91a
2a4835a
c0f4414
514ce00
65366ea
cf637a5
466470a
e1be9cf
d61d69c
b5e06a9
57ee230
7e22e43
1a3af11
35f7446
fef2763
ee04ceb
2e465af
a8e6c4f
915c72a
c581fe3
de15589
0a9a684
af4ed0c
8638ec3
f889a1c
cdc4a5f
0cb5634
d6b0cd2
2812c4a
d78b91c
ed89da3
c4da92f
0aa6f8c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's not update the spec version yet (since we don't want to show grant spent amounts API being available before have the docs for the grant spent amount feature).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dont remember exactly what commit we were on before, and I didn't figure out a clean way to revert, so I changed it to the previous commit ( |
| +1 −1 | VERSION | |
| +1 −1 | openapi/auth-server.yaml | |
| +39 −1 | openapi/resource-server.yaml | |
| +1 −1 | openapi/wallet-address-server.yaml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package main | ||
|
|
||
| //@! start chunk 1 | title=Import dependencies | ||
| import ( | ||
| "context" | ||
| "encoding/json" | ||
| "fmt" | ||
| "log" | ||
| "os" | ||
|
|
||
| op "github.com/interledger/open-payments-go" | ||
| ) | ||
|
|
||
| //@! end chunk 1 | ||
|
|
||
| func main() { | ||
| walletAddressURL := os.Getenv("WALLET_ADDRESS") | ||
| if walletAddressURL == "" { | ||
| log.Fatalf("WALLET_ADDRESS environment variable is required\n") | ||
| } | ||
| privateKeyBase64 := os.Getenv("PRIVATE_KEY") | ||
| if privateKeyBase64 == "" { | ||
| log.Fatalf("PRIVATE_KEY environment variable is required\n") | ||
| } | ||
| keyID := os.Getenv("KEY_ID") | ||
| if keyID == "" { | ||
| log.Fatalf("KEY_ID environment variable is required\n") | ||
| } | ||
|
|
||
| //@! start chunk 2 | title=Initialize Open Payments client | ||
| client, err := op.NewAuthenticatedClient(walletAddressURL, privateKeyBase64, keyID) | ||
| if err != nil { | ||
| log.Fatalf("Error creating authenticated client: %v\n", err) | ||
| } | ||
| //@! end chunk 2 | ||
|
|
||
| //@! start chunk 3 | title=Get wallet address keys | ||
| walletAddressKeys, err := client.WalletAddress.GetKeys(context.TODO(), op.WalletAddressGetKeysParams{ | ||
| URL: walletAddressURL, | ||
| }) | ||
| if err != nil { | ||
| log.Fatalf("Error fetching wallet address keys: %v\n", err) | ||
| } | ||
| //@! end chunk 3 | ||
|
|
||
| //@! start chunk 4 | title=Output | ||
| keysJSON, err := json.MarshalIndent(walletAddressKeys, "", " ") | ||
| if err != nil { | ||
| log.Fatalf("Error marshaling wallet address keys: %v\n", err) | ||
| } | ||
| fmt.Println("WALLET ADDRESS KEYS:", string(keysJSON)) | ||
| //@! end chunk 4 | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package main | ||
|
|
||
| //@! start chunk 1 | title=Import dependencies | ||
| import ( | ||
| "context" | ||
| "encoding/json" | ||
| "fmt" | ||
| "log" | ||
| "os" | ||
|
|
||
| op "github.com/interledger/open-payments-go" | ||
| ) | ||
|
|
||
| //@! end chunk 1 | ||
|
|
||
| func main() { | ||
| walletAddressURL := os.Getenv("WALLET_ADDRESS") | ||
| if walletAddressURL == "" { | ||
| log.Fatalf("WALLET_ADDRESS environment variable is required\n") | ||
| } | ||
| privateKeyBase64 := os.Getenv("PRIVATE_KEY") | ||
| if privateKeyBase64 == "" { | ||
| log.Fatalf("PRIVATE_KEY environment variable is required\n") | ||
| } | ||
| keyID := os.Getenv("KEY_ID") | ||
| if keyID == "" { | ||
| log.Fatalf("KEY_ID environment variable is required\n") | ||
| } | ||
|
|
||
| //@! start chunk 2 | title=Initialize Open Payments client | ||
| client, err := op.NewAuthenticatedClient(walletAddressURL, privateKeyBase64, keyID) | ||
| if err != nil { | ||
| log.Fatalf("Error creating authenticated client: %v\n", err) | ||
| } | ||
| //@! end chunk 2 | ||
|
|
||
| //@! start chunk 3 | title=Get wallet address | ||
| walletAddress, err := client.WalletAddress.Get(context.TODO(), op.WalletAddressGetParams{ | ||
| URL: walletAddressURL, | ||
| }) | ||
| if err != nil { | ||
| log.Fatalf("Error fetching wallet address: %v\n", err) | ||
| } | ||
| //@! end chunk 3 | ||
|
|
||
| //@! start chunk 4 | title=Output | ||
| walletAddressJSON, err := json.MarshalIndent(walletAddress, "", " ") | ||
| if err != nil { | ||
| log.Fatalf("Error marshaling wallet address: %v\n", err) | ||
| } | ||
| fmt.Println("WALLET ADDRESS:", string(walletAddressJSON)) | ||
| //@! end chunk 4 | ||
| } | ||
|
|
Uh oh!
There was an error while loading. Please reload this page.