Documentation
¶
Overview ¶
Code generated by scripts from manifest.yaml. DO NOT EDIT.
Package ups is a non-official Go SDK for UPS REST APIs.
Generated OpenAPI clients live under internal/generated and are accessed through this package. You must supply your own UPS developer OAuth credentials.
Package ups is an unofficial Go client for UPS REST APIs.
Overview ¶
- OAuth2 client-credentials with in-memory token cache
- Sandbox (CIE) vs Production base URLs per API
- Convenience methods: Rate, CreateShipment, VoidShipment, LabelRecovery, Track, ValidateAddress
- Accessors for every UPS API listed in scripts/manifest.yaml (*Client methods)
Generated OpenAPI clients live in internal/generated and are not imported by downstream modules directly; use this package instead.
This project is not affiliated with UPS. See DISCLAIMER.md at the module root.
Code generated by generate.sh from scripts/manifest.yaml. DO NOT EDIT.
Index ¶
- Constants
- func BaseURL(env string) string
- func BasicAuth(clientID, clientSecret string) oauthgen.RequestEditorFn
- func BearerToken(token string) func(context.Context, *http.Request) error
- func IsProduction(env string) bool
- func ServerURL(env, apiPackage string) string
- type APIError
- type AddressValidationClient
- type AddressValidationHTTPResponse
- type AddressValidationOptions
- type AddressValidationParams
- type AddressValidationRequest
- type Client
- func (c *Client) AccessToken(ctx context.Context) (string, error)
- func (c *Client) AddressValidationClient() (*AddressValidationClient, error)
- func (c *Client) AuthedEditors(ctx context.Context, transID, transactionSrc string) ([]func(context.Context, *http.Request) error, error)
- func (c *Client) CommerceGuardClient() (*commerceguard.ClientWithResponses, error)
- func (c *Client) CreateShipment(ctx context.Context, body ShipmentRequest, opt *ShipmentOptions) (*SHIPResponseWrapper, error)
- func (c *Client) CustomsDetailClient() (*customsdetail.ClientWithResponses, error)
- func (c *Client) DangerousGoodsClient() (*dangerousgoods.ClientWithResponses, error)
- func (c *Client) DeliveryDefenseClient() (*deliverydefense.ClientWithResponses, error)
- func (c *Client) DeliveryInterceptClient() (*deliveryintercept.ClientWithResponses, error)
- func (c *Client) Environment() string
- func (c *Client) ExportAssureClient() (*exportassure.ClientWithResponses, error)
- func (c *Client) ForwardingClient() (*forwarding.ClientWithResponses, error)
- func (c *Client) GlobalCheckoutClient() (*globalcheckout.ClientWithResponses, error)
- func (c *Client) HTTPClient() *http.Client
- func (c *Client) InteractiveGuidanceClient() (*interactiveguidance.ClientWithResponses, error)
- func (c *Client) InvalidateToken()
- func (c *Client) LabelRecovery(ctx context.Context, body LabelRecoveryRequest, opt *LabelRecoveryOptions) (*LABELRECOVERYResponseWrapper, error)
- func (c *Client) LandedCostClient() (*landedcost.ClientWithResponses, error)
- func (c *Client) LocatorClient() (*locator.ClientWithResponses, error)
- func (c *Client) OAuthAuthCodeClient() (*oauthauthcode.ClientWithResponses, error)
- func (c *Client) PaperlessClient() (*paperless.ClientWithResponses, error)
- func (c *Client) PickupClient() (*pickup.ClientWithResponses, error)
- func (c *Client) PickupNotificationClient() (*pickupnotification.ClientWithResponses, error)
- func (c *Client) PickupPointsClient() (*pickuppoints.ClientWithResponses, error)
- func (c *Client) PreNotificationClient() (*prenotification.ClientWithResponses, error)
- func (c *Client) ProtectedDeliveryTokenClient() (*protecteddeliverytoken.ClientWithResponses, error)
- func (c *Client) QuantumViewClient() (*quantumview.ClientWithResponses, error)
- func (c *Client) Rate(ctx context.Context, body RateRequest, opt *RateOptions) (*RATEResponseWrapper, error)
- func (c *Client) RatingClient() (*RateClient, error)
- func (c *Client) SCSInventoryClient() (*scsinventory.ClientWithResponses, error)
- func (c *Client) SCSLogisticsClient() (*scslogistics.ClientWithResponses, error)
- func (c *Client) SCSTransportationClient() (*scstransportation.ClientWithResponses, error)
- func (c *Client) ShippingClient() (*ShippingClient, error)
- func (c *Client) SmartPickupClient() (*smartpickup.ClientWithResponses, error)
- func (c *Client) TimeInTransitClient() (*timeintransit.ClientWithResponses, error)
- func (c *Client) Track(ctx context.Context, inquiryNumber string, opt *TrackOptions) (*TrackApiResponse, error)
- func (c *Client) TrackAlertClient() (*trackalert.ClientWithResponses, error)
- func (c *Client) TrackAlertEnhancedClient() (*trackalertenhanced.ClientWithResponses, error)
- func (c *Client) TrackByReference(ctx context.Context, referenceNumber string, params *ReferenceTrackingParams, ...) (*TrackApiResponse, error)
- func (c *Client) TrackingClient() (*TrackingClient, error)
- func (c *Client) TradeDirectClient() (*tradedirect.ClientWithResponses, error)
- func (c *Client) ValidateAddress(ctx context.Context, body AddressValidationRequest, ...) (*XAVResponseWrapper, error)
- func (c *Client) VoidShipment(ctx context.Context, shipmentID string, opt *VoidOptions) (*VOIDSHIPMENTResponseWrapper, error)
- func (c *Client) WorldEaseClient() (*worldease.ClientWithResponses, error)
- type Config
- type LABELRECOVERYRequestWrapper
- type LABELRECOVERYResponseWrapper
- type LabelRecoveryOptions
- type LabelRecoveryParams
- type LabelRecoveryRequest
- type Logger
- type RATERequestWrapper
- type RATEResponseWrapper
- type RateClient
- type RateHTTPResponse
- type RateOptions
- type RateParams
- type RateRequest
- type ReferenceTrackingParams
- type SHIPRequestWrapper
- type SHIPResponseWrapper
- type ShipmentHTTPResponse
- type ShipmentOptions
- type ShipmentParams
- type ShipmentRequest
- type ShipmentTrackingParams
- type ShippingClient
- type TrackApiResponse
- type TrackHTTPResponse
- type TrackOptions
- type TrackParams
- type TrackingClient
- type VOIDSHIPMENTResponseWrapper
- type VoidOptions
- type VoidShipmentHTTPResponse
- type VoidShipmentParams
- type XAVRequestWrapper
- type XAVResponseWrapper
Constants ¶
const ( // EnvSandbox is the UPS Customer Integration Environment (CIE). EnvSandbox = "sandbox" // EnvProduction is the UPS production environment. EnvProduction = "production" // DefaultAPIVersion is the path version used by Rate/Ship wrappers when omitted. DefaultAPIVersion = "v2409" )
Variables ¶
This section is empty.
Functions ¶
func BasicAuth ¶
func BasicAuth(clientID, clientSecret string) oauthgen.RequestEditorFn
BasicAuth returns a request editor that sets HTTP Basic auth (OAuth token call).
func BearerToken ¶
BearerToken sets Authorization: Bearer on the request.
func IsProduction ¶
IsProduction reports whether env is production.
Types ¶
type APIError ¶
type APIError struct {
Op string // e.g. "rate", "ship", "track", "oauth"
StatusCode int
Code string
Message string
Body string
Err error
}
APIError is a normalized UPS / transport error.
type AddressValidationClient ¶
type AddressValidationClient = av.ClientWithResponses
Re-exported Address Validation types.
type AddressValidationHTTPResponse ¶
type AddressValidationHTTPResponse = av.AddressValidationResponse
Re-exported Address Validation types.
type AddressValidationOptions ¶
type AddressValidationOptions struct {
Version string // default "v2"
RequestOption int // 1=validation, 2=classification, 3=both; default 1
TransID string
TransactionSrc string
Params *AddressValidationParams
}
AddressValidationOptions controls ValidateAddress.
type AddressValidationParams ¶
type AddressValidationParams = av.AddressValidationParams
Re-exported Address Validation types.
type AddressValidationRequest ¶
type AddressValidationRequest = av.AddressValidationJSONRequestBody
Re-exported Address Validation types.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the hand-written UPS facade (OAuth, retries, API accessors).
func (*Client) AccessToken ¶
AccessToken returns a cached or freshly fetched OAuth access token (client credentials).
func (*Client) AddressValidationClient ¶
func (c *Client) AddressValidationClient() (*AddressValidationClient, error)
AddressValidationClient returns a generated Address Validation client.
func (*Client) AuthedEditors ¶
func (c *Client) AuthedEditors(ctx context.Context, transID, transactionSrc string) ([]func(context.Context, *http.Request) error, error)
AuthedEditors returns Bearer (+ optional headers) request editors after ensuring a token.
func (*Client) CommerceGuardClient ¶
func (c *Client) CommerceGuardClient() (*commerceguard.ClientWithResponses, error)
CommerceGuardClient returns a generated CommerceGuard API client for the configured environment.
func (*Client) CreateShipment ¶
func (c *Client) CreateShipment(ctx context.Context, body ShipmentRequest, opt *ShipmentOptions) (*SHIPResponseWrapper, error)
CreateShipment creates a shipment and returns label payload (base64 in response GraphicImage when requested).
func (*Client) CustomsDetailClient ¶
func (c *Client) CustomsDetailClient() (*customsdetail.ClientWithResponses, error)
CustomsDetailClient returns a generated CustomsDetailV2 API client for the configured environment.
func (*Client) DangerousGoodsClient ¶
func (c *Client) DangerousGoodsClient() (*dangerousgoods.ClientWithResponses, error)
DangerousGoodsClient returns a generated DangerousGoods API client for the configured environment.
func (*Client) DeliveryDefenseClient ¶
func (c *Client) DeliveryDefenseClient() (*deliverydefense.ClientWithResponses, error)
DeliveryDefenseClient returns a generated DeliveryDefense API client for the configured environment.
func (*Client) DeliveryInterceptClient ¶
func (c *Client) DeliveryInterceptClient() (*deliveryintercept.ClientWithResponses, error)
DeliveryInterceptClient returns a generated DeliveryIntercept API client for the configured environment.
func (*Client) Environment ¶
Environment returns the configured environment name.
func (*Client) ExportAssureClient ¶
func (c *Client) ExportAssureClient() (*exportassure.ClientWithResponses, error)
ExportAssureClient returns a generated UPSExportAssure API client for the configured environment.
func (*Client) ForwardingClient ¶
func (c *Client) ForwardingClient() (*forwarding.ClientWithResponses, error)
ForwardingClient returns a generated Forwarding API client for the configured environment.
func (*Client) GlobalCheckoutClient ¶
func (c *Client) GlobalCheckoutClient() (*globalcheckout.ClientWithResponses, error)
GlobalCheckoutClient returns a generated GlobalCheckout API client for the configured environment.
func (*Client) HTTPClient ¶
HTTPClient returns the underlying HTTP client.
func (*Client) InteractiveGuidanceClient ¶
func (c *Client) InteractiveGuidanceClient() (*interactiveguidance.ClientWithResponses, error)
InteractiveGuidanceClient returns a generated InteractiveDescriptionGuidance API client for the configured environment.
func (*Client) InvalidateToken ¶
func (c *Client) InvalidateToken()
InvalidateToken clears the cached access token (forces refresh on next call).
func (*Client) LabelRecovery ¶
func (c *Client) LabelRecovery(ctx context.Context, body LabelRecoveryRequest, opt *LabelRecoveryOptions) (*LABELRECOVERYResponseWrapper, error)
LabelRecovery recovers a previously generated label.
func (*Client) LandedCostClient ¶
func (c *Client) LandedCostClient() (*landedcost.ClientWithResponses, error)
LandedCostClient returns a generated LandedCost API client for the configured environment.
func (*Client) LocatorClient ¶
func (c *Client) LocatorClient() (*locator.ClientWithResponses, error)
LocatorClient returns a generated Locator API client for the configured environment.
func (*Client) OAuthAuthCodeClient ¶
func (c *Client) OAuthAuthCodeClient() (*oauthauthcode.ClientWithResponses, error)
OAuthAuthCodeClient returns a generated OAuthAuthCode API client for the configured environment.
func (*Client) PaperlessClient ¶
func (c *Client) PaperlessClient() (*paperless.ClientWithResponses, error)
PaperlessClient returns a generated Paperless API client for the configured environment.
func (*Client) PickupClient ¶
func (c *Client) PickupClient() (*pickup.ClientWithResponses, error)
PickupClient returns a generated Pickup API client for the configured environment.
func (*Client) PickupNotificationClient ¶
func (c *Client) PickupNotificationClient() (*pickupnotification.ClientWithResponses, error)
PickupNotificationClient returns a generated PickupNotificationPreferences API client for the configured environment.
func (*Client) PickupPointsClient ¶
func (c *Client) PickupPointsClient() (*pickuppoints.ClientWithResponses, error)
PickupPointsClient returns a generated UPSPickupPoints API client for the configured environment.
func (*Client) PreNotificationClient ¶
func (c *Client) PreNotificationClient() (*prenotification.ClientWithResponses, error)
PreNotificationClient returns a generated PreNotification API client for the configured environment.
func (*Client) ProtectedDeliveryTokenClient ¶
func (c *Client) ProtectedDeliveryTokenClient() (*protecteddeliverytoken.ClientWithResponses, error)
ProtectedDeliveryTokenClient returns a generated ProtectedDeliveryToken API client for the configured environment.
func (*Client) QuantumViewClient ¶
func (c *Client) QuantumViewClient() (*quantumview.ClientWithResponses, error)
QuantumViewClient returns a generated QuantumView API client for the configured environment.
func (*Client) Rate ¶
func (c *Client) Rate(ctx context.Context, body RateRequest, opt *RateOptions) (*RATEResponseWrapper, error)
Rate quotes a shipment (supports multi-package via RateRequest.RateRequest.Shipment.Package).
func (*Client) RatingClient ¶
func (c *Client) RatingClient() (*RateClient, error)
RatingClient returns a generated Rating client pointed at the configured environment.
func (*Client) SCSInventoryClient ¶
func (c *Client) SCSInventoryClient() (*scsinventory.ClientWithResponses, error)
SCSInventoryClient returns a generated SCSIngestInventory API client for the configured environment.
func (*Client) SCSLogisticsClient ¶
func (c *Client) SCSLogisticsClient() (*scslogistics.ClientWithResponses, error)
SCSLogisticsClient returns a generated SCSIngestLogistics API client for the configured environment.
func (*Client) SCSTransportationClient ¶
func (c *Client) SCSTransportationClient() (*scstransportation.ClientWithResponses, error)
SCSTransportationClient returns a generated UPSSCSTransportation API client for the configured environment.
func (*Client) ShippingClient ¶
func (c *Client) ShippingClient() (*ShippingClient, error)
ShippingClient returns a generated Shipping client for the configured environment.
func (*Client) SmartPickupClient ¶
func (c *Client) SmartPickupClient() (*smartpickup.ClientWithResponses, error)
SmartPickupClient returns a generated Smart-Pickup-Account-Management API client for the configured environment.
func (*Client) TimeInTransitClient ¶
func (c *Client) TimeInTransitClient() (*timeintransit.ClientWithResponses, error)
TimeInTransitClient returns a generated TimeInTransit API client for the configured environment.
func (*Client) Track ¶
func (c *Client) Track(ctx context.Context, inquiryNumber string, opt *TrackOptions) (*TrackApiResponse, error)
Track retrieves tracking details for an inquiry number (1Z…, etc.).
func (*Client) TrackAlertClient ¶
func (c *Client) TrackAlertClient() (*trackalert.ClientWithResponses, error)
TrackAlertClient returns a generated UPSTrackAlert API client for the configured environment.
func (*Client) TrackAlertEnhancedClient ¶
func (c *Client) TrackAlertEnhancedClient() (*trackalertenhanced.ClientWithResponses, error)
TrackAlertEnhancedClient returns a generated UPSTrackAlertEnhanced API client for the configured environment.
func (*Client) TrackByReference ¶
func (c *Client) TrackByReference(ctx context.Context, referenceNumber string, params *ReferenceTrackingParams, opt *TrackOptions) (*TrackApiResponse, error)
TrackByReference tracks by reference number.
func (*Client) TrackingClient ¶
func (c *Client) TrackingClient() (*TrackingClient, error)
TrackingClient returns a generated Tracking client for the configured environment.
func (*Client) TradeDirectClient ¶
func (c *Client) TradeDirectClient() (*tradedirect.ClientWithResponses, error)
TradeDirectClient returns a generated TradeDirect API client for the configured environment.
func (*Client) ValidateAddress ¶
func (c *Client) ValidateAddress(ctx context.Context, body AddressValidationRequest, opt *AddressValidationOptions) (*XAVResponseWrapper, error)
ValidateAddress validates / classifies an address.
func (*Client) VoidShipment ¶
func (c *Client) VoidShipment(ctx context.Context, shipmentID string, opt *VoidOptions) (*VOIDSHIPMENTResponseWrapper, error)
VoidShipment cancels/voids a shipment by shipment identification number.
func (*Client) WorldEaseClient ¶
func (c *Client) WorldEaseClient() (*worldease.ClientWithResponses, error)
WorldEaseClient returns a generated WorldEaseShipmentManagement API client for the configured environment.
type Config ¶
type Config struct {
ClientID string // required for authenticated calls
ClientSecret string // required for authenticated calls
AccountNumber string // optional; sent as x-merchant-id on token requests
Environment string // "sandbox" (default) or "production"
HTTPClient *http.Client
Timeout time.Duration // applied when HTTPClient is nil; default 60s
TransactionSrc string // optional default transactionSrc header
MaxRetries int // HTTP retries on 429/5xx; default 2
Logger Logger // optional; nil = no logging
}
Config holds UPS client credentials and runtime options. Pass ClientID / ClientSecret explicitly (from your secret store, DB, flags, etc.). The SDK does not read credentials from the environment.
type LABELRECOVERYRequestWrapper ¶
type LABELRECOVERYRequestWrapper = shipping.LABELRECOVERYRequestWrapper
Re-exported Shipping types.
type LABELRECOVERYResponseWrapper ¶
type LABELRECOVERYResponseWrapper = shipping.LABELRECOVERYResponseWrapper
Re-exported Shipping types.
type LabelRecoveryOptions ¶
type LabelRecoveryOptions struct {
Version string
TransID string
TransactionSrc string
Params *LabelRecoveryParams
}
LabelRecoveryOptions controls LabelRecovery.
type LabelRecoveryParams ¶
type LabelRecoveryParams = shipping.LabelRecoveryOpParams
Re-exported Shipping types.
type LabelRecoveryRequest ¶
type LabelRecoveryRequest = shipping.LabelRecoveryOpJSONRequestBody
Re-exported Shipping types.
type RATERequestWrapper ¶
type RATERequestWrapper = rating.RATERequestWrapper
Re-exported Rating types (import path stays github.com/befship/ups-sdk/ups).
type RATEResponseWrapper ¶
type RATEResponseWrapper = rating.RATEResponseWrapper
Re-exported Rating types (import path stays github.com/befship/ups-sdk/ups).
type RateClient ¶
type RateClient = rating.ClientWithResponses
Re-exported Rating types (import path stays github.com/befship/ups-sdk/ups).
type RateHTTPResponse ¶
type RateHTTPResponse = rating.RateOpResponse
Re-exported Rating types (import path stays github.com/befship/ups-sdk/ups).
type RateOptions ¶
type RateOptions struct {
Version string // default DefaultAPIVersion
RequestOption string // Rate | Shop | Ratetimeintransit | Shoptimeintransit; default "Rate"
AdditionalInfo string // e.g. "timeintransit"
TransID string
TransactionSrc string
}
RateOptions controls the Rate API call.
type RateParams ¶
type RateParams = rating.RateOpParams
Re-exported Rating types (import path stays github.com/befship/ups-sdk/ups).
type RateRequest ¶
type RateRequest = rating.RateOpJSONRequestBody
Re-exported Rating types (import path stays github.com/befship/ups-sdk/ups).
type ReferenceTrackingParams ¶
type ReferenceTrackingParams = tracking.ReferenceTrackingAPIParams
Re-exported Tracking types.
type SHIPRequestWrapper ¶
type SHIPRequestWrapper = shipping.SHIPRequestWrapper
Re-exported Shipping types.
type SHIPResponseWrapper ¶
type SHIPResponseWrapper = shipping.SHIPResponseWrapper
Re-exported Shipping types.
type ShipmentHTTPResponse ¶
type ShipmentHTTPResponse = shipping.ShipmentOpResponse
Re-exported Shipping types.
type ShipmentOptions ¶
type ShipmentOptions struct {
Version string // default DefaultAPIVersion
AdditionalAddressValidation string
TransID string
TransactionSrc string
}
ShipmentOptions controls CreateShipment.
type ShipmentRequest ¶
type ShipmentRequest = shipping.ShipmentOpJSONRequestBody
Re-exported Shipping types.
type ShipmentTrackingParams ¶
type ShipmentTrackingParams = tracking.ShipmentTrackingAPIParams
Re-exported Tracking types.
type ShippingClient ¶
type ShippingClient = shipping.ClientWithResponses
Re-exported Shipping types.
type TrackApiResponse ¶
type TrackApiResponse = tracking.TrackApiResponse
Re-exported Tracking types.
type TrackHTTPResponse ¶
type TrackHTTPResponse = tracking.GetSingleTrackResponseUsingGETResponse
Re-exported Tracking types.
type TrackOptions ¶
type TrackOptions struct {
TransID string
TransactionSrc string
Params *TrackParams
}
TrackOptions controls Track.
type TrackParams ¶
type TrackParams = tracking.GetSingleTrackResponseUsingGETParams
Re-exported Tracking types.
type TrackingClient ¶
type TrackingClient = tracking.ClientWithResponses
Re-exported Tracking types.
type VOIDSHIPMENTResponseWrapper ¶
type VOIDSHIPMENTResponseWrapper = shipping.VOIDSHIPMENTResponseWrapper
Re-exported Shipping types.
type VoidOptions ¶
type VoidOptions struct {
Version string
TransID string
TransactionSrc string
Params *VoidShipmentParams
}
VoidOptions controls VoidShipment.
type VoidShipmentHTTPResponse ¶
type VoidShipmentHTTPResponse = shipping.VoidShipmentOpResponse
Re-exported Shipping types.
type VoidShipmentParams ¶
type VoidShipmentParams = shipping.VoidShipmentOpParams
Re-exported Shipping types.
type XAVRequestWrapper ¶
type XAVRequestWrapper = av.XAVRequestWrapper
Re-exported Address Validation types.
type XAVResponseWrapper ¶
type XAVResponseWrapper = av.XAVResponseWrapper
Re-exported Address Validation types.