Go SDK
Installation
Section titled “Installation”go get github.com/tracktile/tracktile-goQuick Start
Section titled “Quick Start”package main
import ( "context" "fmt" "log"
tracktile "github.com/tracktile/tracktile-go")
func main() { client := tracktile.New( tracktile.WithJWT("your-api-token"), )
products, err := client.Products.List(context.Background()) if err != nil { log.Fatal(err) } fmt.Println(products)}Authentication
Section titled “Authentication”client := tracktile.New( tracktile.WithJWT("your-api-token"),)Available Resources
Section titled “Available Resources”| Resource | Methods |
|---|---|
client.Inventory | Receive, Move, Update, Waste, Assign, Unassign, Bundle, Merge, Unmerge |
client.Orders | List, Create, Get, Update, Delete, GetProductAttributes |
client.Products | List, Create, Get, Update, Delete, BatchUpdate, FetchByIDs |
client.PurchaseOrders | List, Create, Get, Update, Delete |
client.Shipments | List, Create, Get, Update, Patch, Delete, GetItems |
client.Suppliers | List, Create, Get, Update, Delete, GetDefaultOrder |
client.Transports | List, Create, Get, Update, Delete |
Context Support
Section titled “Context Support”All methods accept a context.Context as the first argument for cancellation and timeouts:
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)defer cancel()
products, err := client.Products.List(ctx)if err != nil { if errors.Is(err, context.DeadlineExceeded) { // Handle timeout }}Error Handling
Section titled “Error Handling”import "github.com/tracktile/tracktile-go/models/errors"
product, err := client.Products.Get(ctx, "invalid-id")if err != nil { var badRequest *errors.BadRequestError var unauthorized *errors.UnauthorizedError var forbidden *errors.ForbiddenError var notFound *errors.NotFoundError var serverError *errors.ServerError
switch { case errors.As(err, &badRequest): // Handle 400 errors case errors.As(err, &unauthorized): // Handle 401 errors case errors.As(err, &forbidden): // Handle 403 errors case errors.As(err, ¬Found): // Handle 404 errors case errors.As(err, &serverError): // Handle 500 errors default: // Handle other errors }}Retries
Section titled “Retries”client := tracktile.New( tracktile.WithJWT("your-api-token"), tracktile.WithRetryConfig(tracktile.RetryConfig{ Strategy: "backoff", Backoff: tracktile.BackoffStrategy{ InitialInterval: 1, MaxInterval: 50, Exponent: 1.1, MaxElapsedTime: 100, }, RetryConnectionErrors: false, }),)Custom HTTP Client
Section titled “Custom HTTP Client”httpClient := &http.Client{ Timeout: 30 * time.Second,}
client := tracktile.New( tracktile.WithJWT("your-api-token"), tracktile.WithHTTPClient(httpClient),)Debug Logging
Section titled “Debug Logging”client := tracktile.New( tracktile.WithJWT("your-api-token"), tracktile.WithDebugLogger(log.Default()),)Runtime Support
Section titled “Runtime Support”| Runtime | Version |
|---|---|
| Go | 1.21+ |
The SDK follows idiomatic Go patterns and has minimal external dependencies.