Skip to content
This repository was archived by the owner on May 31, 2023. It is now read-only.

Commit 769f6b7

Browse files
author
Richard Patel
committed
query: add ExampleClient_GetAllProducts
1 parent a5f463e commit 769f6b7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

query_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ package pyth
1717
import (
1818
"context"
1919
"encoding/base64"
20+
"encoding/json"
21+
"fmt"
2022
"io"
2123
"net/http"
2224
"net/http/httptest"
@@ -27,6 +29,23 @@ import (
2729
"github.com/stretchr/testify/require"
2830
)
2931

32+
func ExampleClient_GetAllProducts() {
33+
client := NewClient(Devnet, "https://api.devnet.solana.com", "wss://api.devnet.solana.com")
34+
products, _ := client.GetAllProducts(context.TODO())
35+
// Print first product as JSON.
36+
jsonData, _ := json.MarshalIndent(&products[0], "", " ")
37+
fmt.Println(string(jsonData))
38+
// Output:
39+
// {
40+
// "asset_type": "Crypto",
41+
// "base": "BCH",
42+
// "description": "BCH/USD",
43+
// "generic_symbol": "BCHUSD",
44+
// "quote_currency": "USD",
45+
// "symbol": "Crypto.BCH/USD"
46+
// }
47+
}
48+
3049
func TestClient_GetProductAccount(t *testing.T) {
3150
server := httptest.NewServer(http.HandlerFunc(func(wr http.ResponseWriter, req *http.Request) {
3251
buf, err := io.ReadAll(req.Body)

0 commit comments

Comments
 (0)