Skip to main content

Examples

package main

import (
"context"
"fmt"
"log"
"net/http"

wallet "github.com/triveria-com/wallet-sdk-go"
)

func main() {
client, err := wallet.NewAuthenticatedClient(&wallet.Config{
WalletUrl: os.Getenv("WALLET_URL"), // "https://wallet.triveria.io"
AuthenticationType: wallet.AuthenticationTypeOAuth,
AuthenticationOAuth: wallet.AuthenticationOAuth{
TokenUrl: fmt.Sprintf("%s/oauth/token", os.Getenv("AUTH_DOMAIN")),
ClientId: os.Getenv("OAUTH_CLIENT_ID"),
ClientSecret: os.Getenv("OAUTH_CLIENT_SECRET"),
},
})
if err != nil {
log.Panicf("failed to create authenticated client: %+v", err)
}

ctx := context.Background()

resp, err := client.HealthCheckWithResponse(ctx, func(ctx context.Context, req *http.Request) error { return nil })
if err != nil {
log.Panicf("failed to list creds: %+v", err)
}

fmt.Printf("body: %+v\n", string(resp.Body))

if resp.StatusCode() != http.StatusOK {
log.Panic("status code not 200")
}
}