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
- func BaseURL(env string) string
- func CheckJSON(method, rawURL string, status int, body []byte, ...) (map[string]any, error)
- func LocaleParams() (txid XCustomerTransactionId, locale XLocale)
- type APIError
- type CancelShipmentJSONRequestBody
- type CancelShipmentParams
- type Client
- func (c *Client) AccessToken(ctx context.Context) (string, error)
- func (c *Client) AccountNumber() string
- func (c *Client) AuthedClient(ctx context.Context) (*ClientWithResponses, RequestEditorFn, error)
- func (c *Client) Environment() string
- func (c *Client) HTTPClient() *http.Client
- func (c *Client) InvalidateToken()
- func (c *Client) Raw() (*ClientWithResponses, error)
- type ClientWithResponses
- type Config
- type CreateShipmentJSONRequestBody
- type CreateShipmentParams
- type Creds
- type Logger
- type OauthTokenFormdataBody
- type OauthTokenFormdataRequestBody
- type RateQuotesJSONRequestBody
- type RateQuotesParams
- type RequestEditorFn
- type ResolveAddressJSONRequestBody
- type ResolveAddressParams
- type ShipmentResultsJSONRequestBody
- type ShipmentResultsParams
- type TrackByNumbersJSONRequestBody
- type TrackByNumbersParams
- type XCustomerTransactionId
- type XLocale
Constants ¶
const ( EnvSandbox = "sandbox" EnvProduction = "production" )
const ClientCredentials = fedexapi.ClientCredentials
Variables ¶
This section is empty.
Functions ¶
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 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 NewFromCreds ¶
NewFromCreds builds a Client from a Creds bundle (adapter-friendly).
func (*Client) AccessToken ¶
AccessToken returns a cached or freshly fetched OAuth bearer token.
func (*Client) AccountNumber ¶
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 (*Client) HTTPClient ¶
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 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