fedex

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fedex is an unofficial Go client for FedEx REST APIs.

Overview

  • OAuth2 client-credentials with in-memory token cache
  • Sandbox vs Production base URLs
  • Typed OpenAPI client via API() / AuthedClient

Spec pipeline (see generate.sh):

official Postman collections → postman2openapi → merge → patch → oapi-codegen

Official Postman/OpenAPI files are never committed. See DISCLAIMER.md.

Index

Constants

View Source
const (
	EnvSandbox    = "sandbox"
	EnvProduction = "production"
)
View Source
const ClientCredentials = fedexapi.ClientCredentials

Variables

This section is empty.

Functions

func BaseURL

func BaseURL(env string) string

BaseURL returns the FedEx API host for env.

func CheckJSON

func CheckJSON(method, rawURL string, status int, body []byte, json200 *map[string]interface{}) (map[string]any, error)

CheckJSON maps a JSON-200 style response into a map.

func LocaleParams

func LocaleParams() (txid XCustomerTransactionId, locale XLocale)

LocaleParams returns x-customer-transaction-id and x-locale for request params.

Types

type APIError

type APIError struct {
	Op         string
	StatusCode int
	Code       string
	Message    string
	Body       string
	Err        error
}

APIError is a normalized FedEx / transport error.

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) Unwrap

func (e *APIError) Unwrap() error

type CancelShipmentJSONRequestBody

type CancelShipmentJSONRequestBody = fedexapi.CancelShipmentJSONRequestBody

type CancelShipmentParams

type CancelShipmentParams = fedexapi.CancelShipmentParams

type Client

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

Client is the hand-written FedEx facade (OAuth cache, retries, typed API access).

func New

func New(cfg Config) *Client

New builds a Client.

func NewFromCreds

func NewFromCreds(cr Creds) *Client

NewFromCreds builds a Client from a Creds bundle (adapter-friendly).

func (*Client) AccessToken

func (c *Client) AccessToken(ctx context.Context) (string, error)

AccessToken returns a cached or freshly fetched OAuth bearer token.

func (*Client) AccountNumber

func (c *Client) AccountNumber() string

func (*Client) AuthedClient

func (c *Client) AuthedClient(ctx context.Context) (*ClientWithResponses, RequestEditorFn, error)

AuthedClient returns a generated client plus a Bearer RequestEditorFn.

func (*Client) Environment

func (c *Client) Environment() string

func (*Client) HTTPClient

func (c *Client) HTTPClient() *http.Client

func (*Client) InvalidateToken

func (c *Client) InvalidateToken()

InvalidateToken clears the cached token for this client.

func (*Client) Raw

func (c *Client) Raw() (*ClientWithResponses, error)

Raw returns a generated client without auth editor.

type ClientWithResponses

type ClientWithResponses = fedexapi.ClientWithResponses

type Config

type Config struct {
	ClientID      string
	ClientSecret  string
	AccountNumber string
	Environment   string // sandbox (default) | production
	BaseURL       string // optional override

	HTTPClient *http.Client
	Timeout    time.Duration
	MaxRetries int
	Logger     Logger
}

Config holds FedEx OAuth credentials and runtime options.

type CreateShipmentJSONRequestBody

type CreateShipmentJSONRequestBody = fedexapi.CreateShipmentJSONRequestBody

type CreateShipmentParams

type CreateShipmentParams = fedexapi.CreateShipmentParams

type Creds

type Creds struct {
	ClientID      string
	ClientSecret  string
	AccountNumber string
	Environment   string
}

Creds is a compact credential bundle (adapter-friendly).

type Logger

type Logger interface {
	Debugf(format string, args ...any)
	Errorf(format string, args ...any)
}

Logger is a minimal structured logger hook.

type OauthTokenFormdataBody

type OauthTokenFormdataBody = fedexapi.OauthTokenFormdataBody

type OauthTokenFormdataRequestBody

type OauthTokenFormdataRequestBody = fedexapi.OauthTokenFormdataRequestBody

type RateQuotesJSONRequestBody

type RateQuotesJSONRequestBody = fedexapi.RateQuotesJSONRequestBody

type RateQuotesParams

type RateQuotesParams = fedexapi.RateQuotesParams

type RequestEditorFn

type RequestEditorFn = fedexapi.RequestEditorFn

type ResolveAddressJSONRequestBody

type ResolveAddressJSONRequestBody = fedexapi.ResolveAddressJSONRequestBody

type ResolveAddressParams

type ResolveAddressParams = fedexapi.ResolveAddressParams

type ShipmentResultsJSONRequestBody

type ShipmentResultsJSONRequestBody = fedexapi.ShipmentResultsJSONRequestBody

type ShipmentResultsParams

type ShipmentResultsParams = fedexapi.ShipmentResultsParams

type TrackByNumbersJSONRequestBody

type TrackByNumbersJSONRequestBody = fedexapi.TrackByNumbersJSONRequestBody

type TrackByNumbersParams

type TrackByNumbersParams = fedexapi.TrackByNumbersParams

type XCustomerTransactionId

type XCustomerTransactionId = fedexapi.XCustomerTransactionId

type XLocale

type XLocale = fedexapi.XLocale

Jump to

Keyboard shortcuts

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