flexops

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 15 Imported by: 0

README

FlexOps Go SDK

Official Go SDK for the FlexOps multi-carrier shipping platform. Supports USPS, UPS, FedEx, DHL, OnTrac, Australia Post, Canada Post, Royal Mail, and LSO with rate shopping, label generation, tracking, webhooks, wallet, insurance, returns, and more.

Installation

go get github.com/BillEisenman/flexops-sdk-go

Quick Start

package main

import (
    "context"
    "fmt"
    "log"

    flexops "github.com/BillEisenman/flexops-sdk-go"
)

func main() {
    // API key authentication (recommended for server-to-server)
    client := flexops.NewClient(flexops.Config{
        APIKey:      "fxk_live_...",
        WorkspaceID: "ws_abc123",
    })

    ctx := context.Background()

    // Get shipping rates from all carriers
    rates, err := client.Shipping.GetRates(ctx, flexops.RateRequest{
        FromAddress: flexops.Address{Street1: "123 Main St", City: "New York",    State: "NY", Zip: "10001", Country: "US"},
        ToAddress:   flexops.Address{Street1: "456 Oak Ave", City: "Los Angeles", State: "CA", Zip: "90210", Country: "US"},
        Parcel:      flexops.Parcel{Weight: 16, WeightUnit: "oz"},
    })
    if err != nil {
        log.Fatal(err)
    }

    // Create a label with the cheapest rate
    cheapest := rates.Data[0] // rates are returned sorted by total cost
    label, err := client.Shipping.CreateLabel(ctx, flexops.CreateLabelRequest{
        Carrier:     cheapest.Carrier,
        Service:     cheapest.Service,
        FromAddress: flexops.Address{Name: "Warehouse", Street1: "123 Main St", City: "New York",    State: "NY", Zip: "10001", Country: "US"},
        ToAddress:   flexops.Address{Name: "Customer",  Street1: "456 Oak Ave", City: "Los Angeles", State: "CA", Zip: "90210", Country: "US"},
        Parcel:      flexops.Parcel{Weight: 16, WeightUnit: "oz"},
    })
    if err != nil {
        log.Fatal(err)
    }

    fmt.Printf("Label URL: %s\n", label.Data.LabelURL)
    fmt.Printf("Tracking:  %s\n", label.Data.TrackingNumber)

    // Track a shipment
    info, err := client.Shipping.Track(ctx, "9400111899223456789012")
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Status: %s\n", info.Data.Status)
}

Authentication

client := flexops.NewClient(flexops.Config{
    APIKey:      "fxk_live_...",
    WorkspaceID: "ws_abc123",
})
Email / password
client := flexops.NewClient(flexops.Config{BaseURL: "https://gateway.flexops.io"})
if err := client.Auth.Login(ctx, "user@example.com", "password"); err != nil {
    log.Fatal(err)
}
client.WorkspaceID = "ws_abc123"

Sandbox / test keys

Use fxk_test_... (instead of fxk_live_...) to route to the sandbox environment. Mock carriers respond, nothing hits real carrier APIs, no charges, no real labels. Perfect for CI and integration tests.

client := flexops.NewClient(flexops.Config{
    APIKey:      "fxk_test_...",
    WorkspaceID: "ws_abc123",
})

Direct carrier operations

Access carrier-specific endpoints when you need full control. The carrier-specific services are typed:

// USPS domestic label
label, err := client.Carriers.USPS.CreateDomesticLabel(ctx, flexops.UspsLabelRequest{
    ImageType:      "PDF",
    MailClass:      "PRIORITY_MAIL",
    WeightInOunces: 16,
})

// FedEx rate quote
rates, err := client.Carriers.FedEx.GetRates(ctx, flexops.FedExRateRequest{...})

// UPS tracking
info, err := client.Carriers.UPS.Track(ctx, "1Z999AA10123456784")

// DHL shipment
shipment, err := client.Carriers.DHL.CreateShipment(ctx, flexops.DhlShipmentRequest{...})

Webhook verification

import flexops "github.com/BillEisenman/flexops-sdk-go"

valid := flexops.VerifyWebhookSignature(
    payload,   // []byte of the raw request body
    signature, // value of the X-FlexOps-Signature header
    "whsec_...",
)

Curl quickstart

Every SDK method is a thin wrapper around the FlexOps REST API. If you want to verify the API before committing to the SDK — or you're integrating from a language we don't ship a SDK for — these curl invocations hit the same endpoints:

# Shop rates across all connected carriers
curl -X POST https://gateway.flexops.io/api/workspaces/ws_abc123/shipping/rates \
  -H "X-API-Key: fxk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "fromAddress": {"street1": "123 Main St", "city": "New York", "state": "NY", "zip": "10001", "country": "US"},
    "toAddress":   {"street1": "456 Oak Ave", "city": "Los Angeles", "state": "CA", "zip": "90210", "country": "US"},
    "parcel":      {"weight": 16, "weightUnit": "oz"}
  }'

# Create a label
curl -X POST https://gateway.flexops.io/api/workspaces/ws_abc123/shipping/labels \
  -H "X-API-Key: fxk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "carrier":  "USPS",
    "service":  "PRIORITY_MAIL",
    "fromAddress": {"name": "Warehouse", "street1": "123 Main St", "city": "New York", "state": "NY", "zip": "10001", "country": "US"},
    "toAddress":   {"name": "Customer",  "street1": "456 Oak Ave", "city": "Los Angeles", "state": "CA", "zip": "90210", "country": "US"},
    "parcel":   {"weight": 16, "weightUnit": "oz"}
  }'

# Track a shipment
curl https://gateway.flexops.io/api/workspaces/ws_abc123/shipping/track/9400111899223456789012 \
  -H "X-API-Key: fxk_live_..."

# Cancel a label (via the unified carrier-agnostic endpoint)
curl -X DELETE https://gateway.flexops.io/api/v3.0/shipping/Usps/cancel/9400111899223456789012 \
  -H "X-API-Key: fxk_live_..."

Use an fxk_test_... key instead of fxk_live_... to hit the sandbox environment; mock carriers respond, no real charges, no real labels.

Services

Service Description
client.Auth Login, register, password management
client.Workspaces Workspace CRUD, membership, branding
client.Shipping Rate shopping, labels, tracking, batch, cancel
client.Carriers USPS, UPS, FedEx, DHL direct endpoints
client.Webhooks Subscription CRUD, signature verification, delivery logs
client.Wallet Balance, transactions, auto-reload
client.Insurance Quotes, purchase, claims (first-party + U-PIC)
client.Returns RMA lifecycle: create, batch, QR codes, photo upload, cost recovery
client.ApiKeys Key creation, rotation, revocation
client.Analytics Shipments, orders, carrier performance
client.Orders Order management
client.Inventory Warehouse inventory
client.Pickups Carrier pickup scheduling
client.ScanForms USPS scan forms
client.Rules Shipping automation rules
client.Offsets Carbon offset purchases
client.HsCodes HS code lookup for international customs
client.RecurringShipments Scheduled recurring shipments
client.EmailTemplates Branded post-purchase email templates
client.Reports Report generation and scheduled delivery

Configuration

client := flexops.NewClient(flexops.Config{
    BaseURL:     "https://gateway.flexops.io", // API base URL
    APIKey:      "fxk_live_...",           // API key auth
    WorkspaceID: "ws_abc123",              // Default workspace
    Timeout:     30 * time.Second,         // Request timeout
    MaxRetries:  3,                        // Retry on transient failures
})

Requirements

  • Go 1.22+

License

MIT © FlexOps, LLC. See LICENSE for full text.

Documentation

Overview

Package flexops provides the official Go SDK for the FlexOps multi-carrier shipping platform API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VerifySignature

func VerifySignature(payload, signature, secret string) bool

VerifySignature verifies an HMAC-SHA256 webhook signature.

Types

type Address

type Address struct {
	Name    string `json:"name,omitempty"`
	Street1 string `json:"street1"`
	Street2 string `json:"street2,omitempty"`
	City    string `json:"city"`
	State   string `json:"state"`
	Zip     string `json:"zip"`
	Country string `json:"country"`
	Phone   string `json:"phone,omitempty"`
}

type AddressValidationResult

type AddressValidationResult struct {
	IsValid     bool      `json:"isValid"`
	Normalized  *Address  `json:"normalized,omitempty"`
	Suggestions []Address `json:"suggestions,omitempty"`
	Errors      []string  `json:"errors,omitempty"`
}

type AnalyticsService

type AnalyticsService struct {
	// contains filtered or unexported fields
}

func (*AnalyticsService) CarrierPerformance

func (s *AnalyticsService) CarrierPerformance(ctx context.Context, startDate, endDate string) (ApiResponse[any], error)

func (*AnalyticsService) CarrierSummary

func (s *AnalyticsService) CarrierSummary(ctx context.Context, startDate, endDate string) (ApiResponse[[]CarrierSummary], error)

func (*AnalyticsService) DeliveryPerformance

func (s *AnalyticsService) DeliveryPerformance(ctx context.Context, startDate, endDate string) (ApiResponse[any], error)

func (*AnalyticsService) InventoryMetrics

func (s *AnalyticsService) InventoryMetrics(ctx context.Context) (ApiResponse[any], error)

func (*AnalyticsService) OrderMetrics

func (s *AnalyticsService) OrderMetrics(ctx context.Context, startDate, endDate string) (ApiResponse[any], error)

func (*AnalyticsService) OrderTrend

func (s *AnalyticsService) OrderTrend(ctx context.Context, startDate, endDate string) (ApiResponse[any], error)

func (*AnalyticsService) PerformanceMetrics

func (s *AnalyticsService) PerformanceMetrics(ctx context.Context, startDate, endDate string) (ApiResponse[any], error)

func (*AnalyticsService) ReturnReasons

func (s *AnalyticsService) ReturnReasons(ctx context.Context, startDate, endDate string) (ApiResponse[any], error)

func (*AnalyticsService) ReturnsMetrics

func (s *AnalyticsService) ReturnsMetrics(ctx context.Context, startDate, endDate string) (ApiResponse[any], error)

func (*AnalyticsService) ReturnsTrend

func (s *AnalyticsService) ReturnsTrend(ctx context.Context, startDate, endDate string) (ApiResponse[any], error)

func (*AnalyticsService) ShipmentsTrend

func (s *AnalyticsService) ShipmentsTrend(ctx context.Context, startDate, endDate string) (ApiResponse[[]ShipmentsTrend], error)

func (*AnalyticsService) ShippingCostAnalytics

func (s *AnalyticsService) ShippingCostAnalytics(ctx context.Context, startDate, endDate string) (ApiResponse[any], error)

func (*AnalyticsService) StockByWarehouse

func (s *AnalyticsService) StockByWarehouse(ctx context.Context) (ApiResponse[any], error)

func (*AnalyticsService) TopDestinations

func (s *AnalyticsService) TopDestinations(ctx context.Context, startDate, endDate string, limit string) (ApiResponse[any], error)

func (*AnalyticsService) TopSellingProducts

func (s *AnalyticsService) TopSellingProducts(ctx context.Context, startDate, endDate string, limit string) (ApiResponse[any], error)

type ApiKeyInfo

type ApiKeyInfo struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	Prefix    string `json:"prefix"`
	CreatedAt string `json:"createdAt"`
}

type ApiKeysService

type ApiKeysService struct {
	// contains filtered or unexported fields
}

func (*ApiKeysService) Create

func (*ApiKeysService) List

func (*ApiKeysService) Revoke

func (s *ApiKeysService) Revoke(ctx context.Context, keyID string) error

func (*ApiKeysService) Rotate

type ApiResponse

type ApiResponse[T any] struct {
	Success bool     `json:"success"`
	Data    T        `json:"data"`
	Message string   `json:"message,omitempty"`
	Errors  []string `json:"errors,omitempty"`
}

ApiResponse is the standard API response wrapper.

type AuthError

type AuthError struct {
	FlexOpsError
}

AuthError is returned for 401 responses.

type AuthService

type AuthService struct {
	// contains filtered or unexported fields
}

func (*AuthService) ChangePassword

func (s *AuthService) ChangePassword(ctx context.Context, currentPassword, newPassword string) (ApiResponse[any], error)

func (*AuthService) ForgotPassword

func (s *AuthService) ForgotPassword(ctx context.Context, email string) (ApiResponse[any], error)

func (*AuthService) GetProfile

func (s *AuthService) GetProfile(ctx context.Context) (ApiResponse[any], error)

func (*AuthService) Login

func (s *AuthService) Login(ctx context.Context, email, password string) (ApiResponse[LoginResponse], error)

func (*AuthService) Logout

func (s *AuthService) Logout(ctx context.Context) error

func (*AuthService) RefreshToken

func (s *AuthService) RefreshToken(ctx context.Context, refreshToken string) (ApiResponse[LoginResponse], error)

func (*AuthService) Register

func (s *AuthService) Register(ctx context.Context, req RegisterRequest) (ApiResponse[any], error)

func (*AuthService) ResetPassword

func (s *AuthService) ResetPassword(ctx context.Context, token, newPassword string) (ApiResponse[any], error)

func (*AuthService) UpdateProfile

func (s *AuthService) UpdateProfile(ctx context.Context, data any) (ApiResponse[any], error)

func (*AuthService) VerifyEmail

func (s *AuthService) VerifyEmail(ctx context.Context, token string) (ApiResponse[any], error)

type BatchLabelJob

type BatchLabelJob struct {
	JobID     string `json:"jobId"`
	Status    string `json:"status"`
	Total     int    `json:"total"`
	Completed int    `json:"completed"`
	Failed    int    `json:"failed"`
}

type BatchLabelRequest

type BatchLabelRequest struct {
	Items []CreateLabelRequest `json:"items"`
}

type CarrierRecommendation

type CarrierRecommendation struct {
	CarrierCode    string  `json:"carrierCode"`
	Score          float64 `json:"score"`
	OnTimePercent  float64 `json:"onTimePercent"`
	AvgTransitDays float64 `json:"avgTransitDays"`
	AvgCost        float64 `json:"avgCost"`
	ShipmentCount  int     `json:"shipmentCount"`
	ExceptionRate  float64 `json:"exceptionRate"`
	Reason         string  `json:"reason,omitempty"`
}

type CarrierRecommendationRequest

type CarrierRecommendationRequest struct {
	OriginPostalCode      string  `json:"originPostalCode"`
	DestinationPostalCode string  `json:"destinationPostalCode"`
	WeightOz              float64 `json:"weightOz"`
	Priority              string  `json:"priority,omitempty"`
}

type CarrierRecommendationResponse

type CarrierRecommendationResponse struct {
	Lane            string                  `json:"lane"`
	SampleSize      int                     `json:"sampleSize"`
	Recommendations []CarrierRecommendation `json:"recommendations"`
}

type CarrierSummary

type CarrierSummary struct {
	Carrier    string  `json:"carrier"`
	Shipments  int     `json:"shipments"`
	TotalSpend float64 `json:"totalSpend"`
}

type CarriersService

type CarriersService struct {
	USPS  *UspsService
	UPS   *UpsService
	FedEx *FedExService
	DHL   *DhlService
	// contains filtered or unexported fields
}

type Client

type Client struct {
	WorkspaceID        string
	Auth               *AuthService
	Workspaces         *WorkspacesService
	Shipping           *ShippingService
	Carriers           *CarriersService
	Webhooks           *WebhooksService
	Wallet             *WalletService
	Insurance          *InsuranceService
	Returns            *ReturnsService
	ApiKeys            *ApiKeysService
	Analytics          *AnalyticsService
	Orders             *OrdersService
	Inventory          *InventoryService
	Pickups            *PickupsService
	ScanForms          *ScanFormsService
	Rules              *RulesService
	Offsets            *OffsetService
	HsCodes            *HsCodesService
	RecurringShipments *RecurringShipmentsService
	EmailTemplates     *EmailTemplatesService
	Reports            *ReportsService
	// contains filtered or unexported fields
}

Client is the main entry point for the FlexOps SDK.

func NewClient

func NewClient(cfg Config) *Client

NewClient creates a new FlexOps API client.

func (*Client) SetAPIKey

func (c *Client) SetAPIKey(key string)

SetAPIKey sets the API key.

func (*Client) SetAccessToken

func (c *Client) SetAccessToken(token string)

SetAccessToken sets the JWT access token.

type Config

type Config struct {
	BaseURL     string
	APIKey      string
	AccessToken string
	WorkspaceID string
	Timeout     time.Duration
	MaxRetries  int
}

Config configures the FlexOps client.

type CreateApiKeyRequest

type CreateApiKeyRequest struct {
	Name string `json:"name"`
}

type CreateApiKeyResponse

type CreateApiKeyResponse struct {
	ID  string `json:"id"`
	Key string `json:"key"`
}

type CreateLabelRequest

type CreateLabelRequest struct {
	Carrier     string   `json:"carrier"`
	Service     string   `json:"service"`
	FromAddress *Address `json:"fromAddress"`
	ToAddress   *Address `json:"toAddress"`
	Parcel      *Parcel  `json:"parcel"`
}

type CreateWebhookRequest

type CreateWebhookRequest struct {
	URL    string   `json:"url"`
	Events []string `json:"events"`
}

type CreateWorkspaceRequest

type CreateWorkspaceRequest struct {
	Name string `json:"name"`
	Slug string `json:"slug,omitempty"`
}

type DeliveryPredictionRequest

type DeliveryPredictionRequest struct {
	CarrierCode           string `json:"carrierCode"`
	ServiceCode           string `json:"serviceCode"`
	OriginPostalCode      string `json:"originPostalCode"`
	DestinationPostalCode string `json:"destinationPostalCode"`
	ShipDate              string `json:"shipDate"`
}

type DeliveryPredictionResponse

type DeliveryPredictionResponse struct {
	CarrierCode           string  `json:"carrierCode"`
	PredictedDeliveryDate string  `json:"predictedDeliveryDate"`
	EarliestDelivery      string  `json:"earliestDelivery"`
	LatestDelivery        string  `json:"latestDelivery"`
	WorstCaseDelivery     string  `json:"worstCaseDelivery"`
	PredictedTransitDays  int     `json:"predictedTransitDays"`
	Confidence            float64 `json:"confidence"`
	OnTimeRate            float64 `json:"onTimeRate"`
	SampleSize            int     `json:"sampleSize"`
}

type DhlService

type DhlService struct {
	// contains filtered or unexported fields
}

func (*DhlService) CalculateLandedCost

func (s *DhlService) CalculateLandedCost(ctx context.Context, body any) (any, error)

func (*DhlService) CancelPickup

func (s *DhlService) CancelPickup(ctx context.Context) error

func (*DhlService) CreatePickup

func (s *DhlService) CreatePickup(ctx context.Context, body any) (any, error)

func (*DhlService) CreateShipment

func (s *DhlService) CreateShipment(ctx context.Context, body any) (any, error)

func (*DhlService) FindServicePoints

func (s *DhlService) FindServicePoints(ctx context.Context, params map[string]string) (any, error)

func (*DhlService) GetMultiPieceRates

func (s *DhlService) GetMultiPieceRates(ctx context.Context, body any) (any, error)

func (*DhlService) GetProducts

func (s *DhlService) GetProducts(ctx context.Context, params map[string]string) (any, error)

func (*DhlService) GetProofOfDelivery

func (s *DhlService) GetProofOfDelivery(ctx context.Context, params map[string]string) (any, error)

func (*DhlService) GetRates

func (s *DhlService) GetRates(ctx context.Context, params map[string]string) (any, error)

func (*DhlService) GetReferenceData

func (s *DhlService) GetReferenceData(ctx context.Context, params map[string]string) (any, error)

func (*DhlService) ScreenShipment

func (s *DhlService) ScreenShipment(ctx context.Context, body any) (any, error)

func (*DhlService) Track

func (s *DhlService) Track(ctx context.Context, params map[string]string) (any, error)

func (*DhlService) TrackMultiple

func (s *DhlService) TrackMultiple(ctx context.Context, params map[string]string) (any, error)

func (*DhlService) UpdatePickup

func (s *DhlService) UpdatePickup(ctx context.Context, body any) (any, error)

func (*DhlService) UploadInvoice

func (s *DhlService) UploadInvoice(ctx context.Context, body any) (any, error)

func (*DhlService) ValidateAddress

func (s *DhlService) ValidateAddress(ctx context.Context, params map[string]string) (any, error)

type EmailTemplatesService

type EmailTemplatesService struct {
	// contains filtered or unexported fields
}

func (*EmailTemplatesService) Create

func (s *EmailTemplatesService) Create(ctx context.Context, req any) (ApiResponse[any], error)

func (*EmailTemplatesService) Delete

func (s *EmailTemplatesService) Delete(ctx context.Context, id string) error

func (*EmailTemplatesService) Get

func (*EmailTemplatesService) List

func (*EmailTemplatesService) Preview

func (s *EmailTemplatesService) Preview(ctx context.Context, id string, context_ any) (ApiResponse[any], error)

func (*EmailTemplatesService) Update

func (s *EmailTemplatesService) Update(ctx context.Context, id string, req any) (ApiResponse[any], error)

type FedExService

type FedExService struct {
	// contains filtered or unexported fields
}

func (*FedExService) AddPackagesToOpenShipment

func (s *FedExService) AddPackagesToOpenShipment(ctx context.Context, body any) (any, error)

func (*FedExService) CancelPickup

func (s *FedExService) CancelPickup(ctx context.Context, body any) (any, error)

func (*FedExService) CancelShipment

func (s *FedExService) CancelShipment(ctx context.Context, body any) (any, error)

func (*FedExService) ConfirmOpenShipment

func (s *FedExService) ConfirmOpenShipment(ctx context.Context, body any) (any, error)

func (*FedExService) CreateFreightShipment

func (s *FedExService) CreateFreightShipment(ctx context.Context, body any) (any, error)

func (*FedExService) CreateOpenShipment

func (s *FedExService) CreateOpenShipment(ctx context.Context, body any) (any, error)

func (*FedExService) CreatePickup

func (s *FedExService) CreatePickup(ctx context.Context, body any) (any, error)

func (*FedExService) CreateReturnShipment

func (s *FedExService) CreateReturnShipment(ctx context.Context, body any) (any, error)

func (*FedExService) CreateShipment

func (s *FedExService) CreateShipment(ctx context.Context, body any) (any, error)

func (*FedExService) GetFreightRate

func (s *FedExService) GetFreightRate(ctx context.Context, body any) (any, error)

func (*FedExService) GetRates

func (s *FedExService) GetRates(ctx context.Context, body any) (any, error)

func (*FedExService) GetServiceStandards

func (s *FedExService) GetServiceStandards(ctx context.Context, body any) (any, error)

func (*FedExService) GroundClose

func (s *FedExService) GroundClose(ctx context.Context, body any) (any, error)

func (*FedExService) RegisterTrackingNotification

func (s *FedExService) RegisterTrackingNotification(ctx context.Context, body any) (any, error)

func (*FedExService) SearchLocations

func (s *FedExService) SearchLocations(ctx context.Context, body any) (any, error)

func (*FedExService) Track

func (s *FedExService) Track(ctx context.Context, body any) (any, error)

func (*FedExService) TrackMultiPiece

func (s *FedExService) TrackMultiPiece(ctx context.Context, body any) (any, error)

func (*FedExService) UploadTradeDocuments

func (s *FedExService) UploadTradeDocuments(ctx context.Context, body any) (any, error)

func (*FedExService) ValidateAddress

func (s *FedExService) ValidateAddress(ctx context.Context, body any) (any, error)

func (*FedExService) ValidatePostalCode

func (s *FedExService) ValidatePostalCode(ctx context.Context, body any) (any, error)

func (*FedExService) ValidateShipment

func (s *FedExService) ValidateShipment(ctx context.Context, body any) (any, error)

type FlexOpsError

type FlexOpsError struct {
	StatusCode int
	Code       string
	Message    string
	Errors     []string
}

FlexOpsError represents an API error response.

func (*FlexOpsError) Error

func (e *FlexOpsError) Error() string

type HsCodesService

type HsCodesService struct {
	// contains filtered or unexported fields
}

func (*HsCodesService) EstimateLandedCost

func (s *HsCodesService) EstimateLandedCost(ctx context.Context, req any) (ApiResponse[any], error)

func (*HsCodesService) Lookup

func (s *HsCodesService) Lookup(ctx context.Context, code string) (ApiResponse[any], error)

func (*HsCodesService) Search

func (s *HsCodesService) Search(ctx context.Context, query string, params url.Values) (ApiResponse[any], error)

type InsurancePolicy

type InsurancePolicy struct {
	PolicyID       string  `json:"policyId"`
	TrackingNumber string  `json:"trackingNumber"`
	Provider       string  `json:"provider"`
	Coverage       float64 `json:"coverage"`
	Premium        float64 `json:"premium"`
	Status         string  `json:"status"`
}

type InsuranceQuote

type InsuranceQuote struct {
	Provider string  `json:"provider"`
	Premium  float64 `json:"premium"`
	Coverage float64 `json:"coverage"`
}

type InsuranceService

type InsuranceService struct {
	// contains filtered or unexported fields
}

func (*InsuranceService) FileClaim

func (s *InsuranceService) FileClaim(ctx context.Context, policyID string, claim any) (ApiResponse[any], error)

func (*InsuranceService) GetProviders

func (s *InsuranceService) GetProviders(ctx context.Context) (ApiResponse[[]string], error)

func (*InsuranceService) GetQuote

func (*InsuranceService) Purchase

func (*InsuranceService) Void

func (s *InsuranceService) Void(ctx context.Context, policyID string) error

type InventoryService

type InventoryService struct {
	// contains filtered or unexported fields
}

func (*InventoryService) GetCompleteSnapshot

func (s *InventoryService) GetCompleteSnapshot(ctx context.Context, params url.Values) (ApiResponse[any], error)

func (*InventoryService) GetPartNumbers

func (s *InventoryService) GetPartNumbers(ctx context.Context, params url.Values) (ApiResponse[any], error)

func (*InventoryService) GetWarehouseSnapshot

func (s *InventoryService) GetWarehouseSnapshot(ctx context.Context, params url.Values) (ApiResponse[any], error)

func (*InventoryService) PostAsnReceipt

func (s *InventoryService) PostAsnReceipt(ctx context.Context, receipt any) (ApiResponse[any], error)

func (*InventoryService) UpdateInventory

func (s *InventoryService) UpdateInventory(ctx context.Context, data any) (ApiResponse[any], error)

type Label

type Label struct {
	LabelID        string  `json:"labelId"`
	TrackingNumber string  `json:"trackingNumber"`
	Carrier        string  `json:"carrier"`
	Service        string  `json:"service"`
	LabelData      string  `json:"labelData"`
	LabelFormat    string  `json:"labelFormat"`
	Rate           float64 `json:"rate"`
	CreatedAt      string  `json:"createdAt"`
}

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type LoginResponse

type LoginResponse struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
	ExpiresIn    int    `json:"expiresIn"`
}

type OffsetService

type OffsetService struct {
	// contains filtered or unexported fields
}

func (*OffsetService) BatchOffset

func (s *OffsetService) BatchOffset(ctx context.Context, labelIDs []string) (ApiResponse[any], error)

func (*OffsetService) GetEmissions

func (s *OffsetService) GetEmissions(ctx context.Context, labelID string) (ApiResponse[any], error)

func (*OffsetService) Offset

func (s *OffsetService) Offset(ctx context.Context, labelID string) (ApiResponse[any], error)

type Order

type Order struct {
	OrderNumber string      `json:"orderNumber"`
	Status      string      `json:"status"`
	Items       []OrderItem `json:"items,omitempty"`
	CreatedAt   string      `json:"createdAt"`
}

type OrderItem

type OrderItem struct {
	SKU      string  `json:"sku"`
	Name     string  `json:"name"`
	Quantity int     `json:"quantity"`
	Price    float64 `json:"price"`
}

type OrdersService

type OrdersService struct {
	// contains filtered or unexported fields
}

func (*OrdersService) Cancel

func (s *OrdersService) Cancel(ctx context.Context, orderNumber string) (ApiResponse[any], error)

func (*OrdersService) Create

func (s *OrdersService) Create(ctx context.Context, order any) (ApiResponse[any], error)

func (*OrdersService) GetByStatus

func (s *OrdersService) GetByStatus(ctx context.Context, params url.Values) (ApiResponse[[]Order], error)

func (*OrdersService) GetCountryCodes

func (s *OrdersService) GetCountryCodes(ctx context.Context) (ApiResponse[any], error)

func (*OrdersService) GetDetails

func (s *OrdersService) GetDetails(ctx context.Context, orderNumber string) (ApiResponse[Order], error)

func (*OrdersService) GetExtendedDetails

func (s *OrdersService) GetExtendedDetails(ctx context.Context, orderNumber string) (ApiResponse[any], error)

func (*OrdersService) GetItems

func (s *OrdersService) GetItems(ctx context.Context, orderNumber string) (ApiResponse[any], error)

func (*OrdersService) GetNewOrders

func (s *OrdersService) GetNewOrders(ctx context.Context, params url.Values) (ApiResponse[[]Order], error)

func (*OrdersService) GetShipMethods

func (s *OrdersService) GetShipMethods(ctx context.Context) (ApiResponse[any], error)

func (*OrdersService) GetStatus

func (s *OrdersService) GetStatus(ctx context.Context, orderNumber string) (ApiResponse[any], error)

func (*OrdersService) GetStatusTypes

func (s *OrdersService) GetStatusTypes(ctx context.Context) (ApiResponse[any], error)

func (*OrdersService) GetWarehouses

func (s *OrdersService) GetWarehouses(ctx context.Context) (ApiResponse[any], error)

type PaginatedResponse

type PaginatedResponse[T any] struct {
	Items      []T `json:"items"`
	TotalCount int `json:"totalCount"`
	Page       int `json:"page"`
	PageSize   int `json:"pageSize"`
	TotalPages int `json:"totalPages"`
}

PaginatedResponse wraps paginated results.

type Parcel

type Parcel struct {
	Weight     float64 `json:"weight"`
	WeightUnit string  `json:"weightUnit"`
	Length     float64 `json:"length,omitempty"`
	Width      float64 `json:"width,omitempty"`
	Height     float64 `json:"height,omitempty"`
	DimUnit    string  `json:"dimUnit,omitempty"`
}

type PickupConfirmation

type PickupConfirmation struct {
	ID      string `json:"id"`
	Carrier string `json:"carrier"`
	Date    string `json:"date"`
	Status  string `json:"status"`
}

type PickupRequest

type PickupRequest struct {
	Carrier   string `json:"carrier"`
	Date      string `json:"date"`
	TimeStart string `json:"timeStart,omitempty"`
	TimeEnd   string `json:"timeEnd,omitempty"`
}

type PickupsService

type PickupsService struct {
	// contains filtered or unexported fields
}

func (*PickupsService) Cancel

func (s *PickupsService) Cancel(ctx context.Context, pickupID string) error

func (*PickupsService) Get

func (*PickupsService) List

func (*PickupsService) Schedule

type RateLimitError

type RateLimitError struct {
	FlexOpsError
	RetryAfter int
}

RateLimitError is returned for 429 responses.

type RateRequest

type RateRequest struct {
	FromZip    string   `json:"fromZip,omitempty"`
	ToZip      string   `json:"toZip,omitempty"`
	Weight     float64  `json:"weight,omitempty"`
	WeightUnit string   `json:"weightUnit,omitempty"`
	From       *Address `json:"fromAddress,omitempty"`
	To         *Address `json:"toAddress,omitempty"`
	Parcel     *Parcel  `json:"parcel,omitempty"`
}

type RecurringShipmentsService

type RecurringShipmentsService struct {
	// contains filtered or unexported fields
}

func (*RecurringShipmentsService) Create

func (*RecurringShipmentsService) Delete

func (*RecurringShipmentsService) Get

func (*RecurringShipmentsService) List

func (*RecurringShipmentsService) Pause

func (*RecurringShipmentsService) Resume

func (*RecurringShipmentsService) Trigger

func (*RecurringShipmentsService) Update

type RegisterRequest

type RegisterRequest struct {
	Email     string `json:"email"`
	Password  string `json:"password"`
	FirstName string `json:"firstName,omitempty"`
	LastName  string `json:"lastName,omitempty"`
}

type ReportsService

type ReportsService struct {
	// contains filtered or unexported fields
}

func (*ReportsService) Create

func (s *ReportsService) Create(ctx context.Context, req any) (ApiResponse[any], error)

func (*ReportsService) Delete

func (s *ReportsService) Delete(ctx context.Context, id string) error

func (*ReportsService) Get

func (*ReportsService) List

func (*ReportsService) Update

func (s *ReportsService) Update(ctx context.Context, id string, req any) (ApiResponse[any], error)

type ReturnAuthorization

type ReturnAuthorization struct {
	ID          string       `json:"id"`
	OrderNumber string       `json:"orderNumber"`
	Status      string       `json:"status"`
	Items       []ReturnItem `json:"items"`
}

type ReturnItem

type ReturnItem struct {
	SKU      string `json:"sku"`
	Quantity int    `json:"quantity"`
	Reason   string `json:"reason,omitempty"`
}

type ReturnRequest

type ReturnRequest struct {
	OrderNumber string       `json:"orderNumber"`
	Reason      string       `json:"reason"`
	Items       []ReturnItem `json:"items"`
}

type ReturnsService

type ReturnsService struct {
	// contains filtered or unexported fields
}

func (*ReturnsService) Approve

func (*ReturnsService) Cancel

func (s *ReturnsService) Cancel(ctx context.Context, returnID string) error

func (*ReturnsService) Create

func (*ReturnsService) GenerateLabel

func (s *ReturnsService) GenerateLabel(ctx context.Context, returnID string) (ApiResponse[any], error)

func (*ReturnsService) Get

func (*ReturnsService) List

func (*ReturnsService) MarkReceived

func (s *ReturnsService) MarkReceived(ctx context.Context, returnID string, items any) (ApiResponse[any], error)

func (*ReturnsService) ProcessRefund

func (s *ReturnsService) ProcessRefund(ctx context.Context, returnID string) (ApiResponse[any], error)

func (*ReturnsService) Reject

func (s *ReturnsService) Reject(ctx context.Context, returnID, reason string) (ApiResponse[ReturnAuthorization], error)

type RuleAction

type RuleAction struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

type RuleCondition

type RuleCondition struct {
	Field    string `json:"field"`
	Operator string `json:"operator"`
	Value    string `json:"value"`
	Group    int    `json:"group,omitempty"`
}

type RulesService

type RulesService struct {
	// contains filtered or unexported fields
}

func (*RulesService) Create

func (s *RulesService) Create(ctx context.Context, rule any) (ApiResponse[ShippingRule], error)

func (*RulesService) Delete

func (s *RulesService) Delete(ctx context.Context, ruleID string) error

func (*RulesService) Get

func (*RulesService) List

func (*RulesService) Reorder

func (s *RulesService) Reorder(ctx context.Context, ruleIDs []string) (ApiResponse[any], error)

func (*RulesService) Update

func (s *RulesService) Update(ctx context.Context, ruleID string, rule any) (ApiResponse[ShippingRule], error)

type ScanForm

type ScanForm struct {
	ID        string `json:"id"`
	Carrier   string `json:"carrier"`
	FormURL   string `json:"formUrl"`
	CreatedAt string `json:"createdAt"`
}

type ScanFormRequest

type ScanFormRequest struct {
	Carrier         string   `json:"carrier"`
	TrackingNumbers []string `json:"trackingNumbers"`
}

type ScanFormsService

type ScanFormsService struct {
	// contains filtered or unexported fields
}

func (*ScanFormsService) Create

func (*ScanFormsService) Get

func (s *ScanFormsService) Get(ctx context.Context, scanFormID string) (ApiResponse[ScanForm], error)

func (*ScanFormsService) List

type ShipmentsTrend

type ShipmentsTrend struct {
	Date  string `json:"date"`
	Count int    `json:"count"`
}

type ShippingRate

type ShippingRate struct {
	Carrier       string  `json:"carrier"`
	Service       string  `json:"service"`
	Rate          float64 `json:"rate"`
	Currency      string  `json:"currency"`
	EstimatedDays int     `json:"estimatedDays"`
	DeliveryDate  string  `json:"deliveryDate,omitempty"`
}

type ShippingRule

type ShippingRule struct {
	ID         string          `json:"id"`
	Name       string          `json:"name"`
	Priority   int             `json:"priority"`
	IsActive   bool            `json:"isActive"`
	Conditions []RuleCondition `json:"conditions"`
	Actions    []RuleAction    `json:"actions"`
}

type ShippingService

type ShippingService struct {
	// contains filtered or unexported fields
}

func (*ShippingService) CancelLabel

func (s *ShippingService) CancelLabel(ctx context.Context, labelID string) error

func (*ShippingService) CreateBatch

func (*ShippingService) CreateLabel

func (*ShippingService) DownloadBatchLabel

func (s *ShippingService) DownloadBatchLabel(ctx context.Context, jobID, itemID string) ([]byte, error)

func (*ShippingService) GetBatchStatus

func (s *ShippingService) GetBatchStatus(ctx context.Context, jobID string) (ApiResponse[BatchLabelJob], error)

func (*ShippingService) GetCarriers

func (s *ShippingService) GetCarriers(ctx context.Context) (ApiResponse[any], error)

func (*ShippingService) GetCheapestRate

func (s *ShippingService) GetCheapestRate(ctx context.Context, req RateRequest) (ApiResponse[ShippingRate], error)

func (*ShippingService) GetFastestRate

func (s *ShippingService) GetFastestRate(ctx context.Context, req RateRequest) (ApiResponse[ShippingRate], error)

func (*ShippingService) GetRates

func (*ShippingService) GetSavings

func (s *ShippingService) GetSavings(ctx context.Context) (ApiResponse[any], error)

func (*ShippingService) PreviewBatch

func (*ShippingService) Track

func (s *ShippingService) Track(ctx context.Context, trackingNumber string) (ApiResponse[TrackingInfo], error)

func (*ShippingService) ValidateAddress

func (s *ShippingService) ValidateAddress(ctx context.Context, address Address) (ApiResponse[AddressValidationResult], error)

type TrackingEvent

type TrackingEvent struct {
	Timestamp   string `json:"timestamp"`
	Status      string `json:"status"`
	Description string `json:"description"`
	Location    string `json:"location,omitempty"`
}

type TrackingInfo

type TrackingInfo struct {
	TrackingNumber    string          `json:"trackingNumber"`
	Carrier           string          `json:"carrier"`
	Status            string          `json:"status"`
	StatusDetail      string          `json:"statusDetail"`
	EstimatedDelivery string          `json:"estimatedDelivery,omitempty"`
	Events            []TrackingEvent `json:"events"`
}

type UpsService

type UpsService struct {
	// contains filtered or unexported fields
}

func (*UpsService) CancelPickup

func (s *UpsService) CancelPickup(ctx context.Context) error

func (*UpsService) CreateFreightShipment

func (s *UpsService) CreateFreightShipment(ctx context.Context, body any) (any, error)

func (*UpsService) CreateLabel

func (s *UpsService) CreateLabel(ctx context.Context, body any) (any, error)

func (*UpsService) CreatePickup

func (s *UpsService) CreatePickup(ctx context.Context, body any) (any, error)

func (*UpsService) GetFreightRate

func (s *UpsService) GetFreightRate(ctx context.Context, body any) (any, error)

func (*UpsService) GetLandedCost

func (s *UpsService) GetLandedCost(ctx context.Context, body any) (any, error)

func (*UpsService) GetRates

func (s *UpsService) GetRates(ctx context.Context, body any) (any, error)

func (*UpsService) GetTransitTimes

func (s *UpsService) GetTransitTimes(ctx context.Context, body any) (any, error)

func (*UpsService) SearchLocations

func (s *UpsService) SearchLocations(ctx context.Context, body any) (any, error)

func (*UpsService) Track

func (s *UpsService) Track(ctx context.Context, params map[string]string) (any, error)

func (*UpsService) UploadDocument

func (s *UpsService) UploadDocument(ctx context.Context, body any) (any, error)

func (*UpsService) ValidateAddress

func (s *UpsService) ValidateAddress(ctx context.Context, body any) (any, error)

type UspsService

type UspsService struct {
	// contains filtered or unexported fields
}

--- USPS ---

func (*UspsService) CancelDomesticLabel

func (s *UspsService) CancelDomesticLabel(ctx context.Context) error

func (*UspsService) CancelInternationalLabel

func (s *UspsService) CancelInternationalLabel(ctx context.Context) error

func (*UspsService) CancelPickup

func (s *UspsService) CancelPickup(ctx context.Context) error

func (*UspsService) CityStateLookup

func (s *UspsService) CityStateLookup(ctx context.Context, zipCode string) (any, error)

func (*UspsService) CreateDomesticLabel

func (s *UspsService) CreateDomesticLabel(ctx context.Context, body any) (any, error)

func (*UspsService) CreateInternationalLabel

func (s *UspsService) CreateInternationalLabel(ctx context.Context, body any) (any, error)

func (*UspsService) CreatePickup

func (s *UspsService) CreatePickup(ctx context.Context, body any) (any, error)

func (*UspsService) CreateReturnLabel

func (s *UspsService) CreateReturnLabel(ctx context.Context, body any) (any, error)

func (*UspsService) CreateScanForm

func (s *UspsService) CreateScanForm(ctx context.Context, body any) (any, error)

func (*UspsService) DeliveryStandards

func (s *UspsService) DeliveryStandards(ctx context.Context, params map[string]string) (any, error)

func (*UspsService) FindDropOffLocations

func (s *UspsService) FindDropOffLocations(ctx context.Context, params map[string]string) (any, error)

func (*UspsService) FindPostOffices

func (s *UspsService) FindPostOffices(ctx context.Context, params map[string]string) (any, error)

func (*UspsService) GetDomesticPrices

func (s *UspsService) GetDomesticPrices(ctx context.Context, body any) (any, error)

func (*UspsService) GetDomesticProducts

func (s *UspsService) GetDomesticProducts(ctx context.Context, body any) (any, error)

func (*UspsService) GetDomesticRates

func (s *UspsService) GetDomesticRates(ctx context.Context, body any) (any, error)

func (*UspsService) GetInternationalPrices

func (s *UspsService) GetInternationalPrices(ctx context.Context, body any) (any, error)

func (*UspsService) GetInternationalRates

func (s *UspsService) GetInternationalRates(ctx context.Context, body any) (any, error)

func (*UspsService) TrackDetail

func (s *UspsService) TrackDetail(ctx context.Context, params map[string]string) (any, error)

func (*UspsService) TrackSummary

func (s *UspsService) TrackSummary(ctx context.Context, params map[string]string) (any, error)

func (*UspsService) ValidateAddress

func (s *UspsService) ValidateAddress(ctx context.Context, params map[string]string) (any, error)

func (*UspsService) ZipCodeLookup

func (s *UspsService) ZipCodeLookup(ctx context.Context, params map[string]string) (any, error)

type WalletBalance

type WalletBalance struct {
	Balance           float64 `json:"balance"`
	Currency          string  `json:"currency"`
	AutoReloadEnabled bool    `json:"autoReloadEnabled"`
}

type WalletService

type WalletService struct {
	// contains filtered or unexported fields
}

func (*WalletService) AddFunds

func (s *WalletService) AddFunds(ctx context.Context, amount float64) (ApiResponse[any], error)

func (*WalletService) ConfigureAutoReload

func (s *WalletService) ConfigureAutoReload(ctx context.Context, config any) (ApiResponse[any], error)

func (*WalletService) GetBalance

func (*WalletService) ListTransactions

func (s *WalletService) ListTransactions(ctx context.Context, params url.Values) (ApiResponse[any], error)

type WebhookSubscription

type WebhookSubscription struct {
	ID       string   `json:"id"`
	URL      string   `json:"url"`
	Events   []string `json:"events"`
	IsActive bool     `json:"isActive"`
}

type WebhooksService

type WebhooksService struct {
	// contains filtered or unexported fields
}

func (*WebhooksService) Create

func (*WebhooksService) Delete

func (s *WebhooksService) Delete(ctx context.Context, webhookID string) error

func (*WebhooksService) Get

func (*WebhooksService) List

func (*WebhooksService) ListDeliveryLogs

func (s *WebhooksService) ListDeliveryLogs(ctx context.Context, webhookID string) (ApiResponse[[]any], error)

func (*WebhooksService) RotateSecret

func (s *WebhooksService) RotateSecret(ctx context.Context, webhookID string) (ApiResponse[map[string]string], error)

func (*WebhooksService) Update

func (s *WebhooksService) Update(ctx context.Context, webhookID string, data any) (ApiResponse[WebhookSubscription], error)

type Workspace

type Workspace struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Slug     string `json:"slug"`
	PlanID   string `json:"planId"`
	IsActive bool   `json:"isActive"`
}

type WorkspaceMember

type WorkspaceMember struct {
	UserID string `json:"userId"`
	Email  string `json:"email"`
	Role   string `json:"role"`
}

type WorkspacesService

type WorkspacesService struct {
	// contains filtered or unexported fields
}

func (*WorkspacesService) Create

func (*WorkspacesService) Get

func (s *WorkspacesService) Get(ctx context.Context, workspaceID string) (ApiResponse[Workspace], error)

func (*WorkspacesService) InviteMember

func (s *WorkspacesService) InviteMember(ctx context.Context, email, role string) (ApiResponse[any], error)

func (*WorkspacesService) List

func (*WorkspacesService) ListMembers

func (*WorkspacesService) RemoveMember

func (s *WorkspacesService) RemoveMember(ctx context.Context, userID string) error

func (*WorkspacesService) Update

func (s *WorkspacesService) Update(ctx context.Context, data any) (ApiResponse[Workspace], error)

func (*WorkspacesService) UpdateMemberRole

func (s *WorkspacesService) UpdateMemberRole(ctx context.Context, userID, role string) (ApiResponse[any], error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL