Loading Settler...
Loading Settler...
Loading documentation...
Production-grade Go SDK with context support and concurrent safety.
Follows Go best practices and conventions
Safe for concurrent use with goroutines
Full type safety with Go interfaces
Lightweight with minimal external deps
Install using go get
go get github.com/settler/settler-goReview the package quickstart
package main
import (
"fmt"
"log"
"github.com/settler/settler-go/settler"
)
func main() {
// Initialize client
client, err := settler.NewClient("sk_your_api_key")
if err != nil {
log.Fatal(err)
}
// Create a reconciliation job
job, err := client.Jobs().Create(settler.CreateJobRequest{
Name: "Shopify-Stripe Reconciliation",
Source: settler.AdapterConfig{
Adapter: "shopify",
Config: map[string]interface{}{
"api_key": "your_shopify_api_key",
"shop": "your-shop",
},
},
Target: settler.AdapterConfig{
Adapter: "stripe",
Config: map[string]interface{}{
"api_key": "sk_your_stripe_key",
},
},
Rules: settler.MatchingRules{
Matching: []settler.MatchingRule{
{Field: "order_id", Type: "exact"},
{Field: "amount", Type: "exact", Tolerance: 0.01},
},
},
})
if err != nil {
log.Fatal(err)
}
// Run the job
execution, err := client.Jobs().Run(job.ID)
if err != nil {
log.Fatal(err)
}
// Get report
report, err := client.Reports().Get(job.ID, "")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Matched: %d\n", report.Summary.Matched)
}Common use cases and patterns
import (
"github.com/settler/settler-go/settler"
"github.com/settler/settler-go/errors"
)
job, err := client.Jobs().Create(req)
if err != nil {
switch e := err.(type) {
case *errors.ValidationError:
fmt.Printf("Validation error: %s\n", e.Message)
fmt.Printf("Field: %s\n", e.Field)
case *errors.AuthError:
fmt.Printf("Authentication failed: %s\n", e.Message)
case *errors.RateLimitError:
fmt.Printf("Rate limit exceeded. Retry after: %v\n", e.RetryAfter)
case *errors.NetworkError:
fmt.Printf("Network error: %s\n", e.Message)
default:
fmt.Printf("Error: %s\n", err)
}
}import (
"context"
"time"
)
// Use context for timeouts and cancellation
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
job, err := client.Jobs().CreateWithContext(ctx, req)
if err != nil {
if err == context.DeadlineExceeded {
fmt.Println("Request timed out")
}
}