easypost

package module
v4.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: ISC Imports: 21 Imported by: 0

README

EasyPost Go Client Library

CI Coverage Status GitHub version GoDoc

EasyPost, the simple shipping solution. You can sign up for an account at https://easypost.com.

Install

go get -u github.com/EasyPost/easypost-go/v4
// Import the library
import (
    "github.com/EasyPost/easypost-go/v4"
)

Usage

A simple create & buy shipment example:

package main

import (
    "encoding/json"
    "fmt"
    "os"

    "github.com/EasyPost/easypost-go/v4"
)

func main() {
    apiKey := os.Getenv("EASYPOST_API_KEY")
    if apiKey == "" {
        fmt.Fprintln(os.Stderr, "missing API key")
        os.Exit(1)
    }
    client := easypost.New(apiKey)

    fromAddress := &easypost.Address{
        Company: "EasyPost",
        Street1: "One Montgomery St",
        Street2: "Ste 400",
        City:    "San Francisco",
        State:   "CA",
        Zip:     "94104",
        Phone:   "415-555-1212",
    }

    toAddress := &easypost.Address{
        Name:    "Bugs Bunny",
        Street1: "4000 Warner Blvd",
        City:    "Burbank",
        State:   "CA",
        Zip:     "91522",
        Phone:   "8018982020",
    }

    parcel := &easypost.Parcel{
        Length: 10.2,
        Width:  7.8,
        Height: 4.3,
        Weight: 21.2,
    }

    shipment, err := client.CreateShipment(
        &easypost.Shipment{
            FromAddress: fromAddress,

            ToAddress:   toAddress,
            Parcel:      parcel,
        },
    )
    if err != nil {
        fmt.Fprintln(os.Stderr, "error creating shipment:", err)
        os.Exit(1)
    }

    lowestRate, err := client.LowestRate(shipment)
    if err != nil {
        fmt.Fprintln(os.Stderr, "error getting lowest rate:", err)
        os.Exit(1)
    }

    shipment, err = client.BuyShipment(shipment.ID, &easypost.Rate{ID: lowestRate.ID}, "")
    if err != nil {
        fmt.Fprintln(os.Stderr, "error buying shipment:", err)
        os.Exit(1)
    }

    prettyJSON, err := json.MarshalIndent(shipment, "", "    ")
    if err != nil {
        fmt.Fprintln(os.Stderr, "error creating JSON:", err)
        os.Exit(1)
    }

    fmt.Println(string(prettyJSON))
}

HTTP Hooks

Users can audit the HTTP requests and responses being made by the library by setting the Hooks property of a Client with a set of event subscriptions. Available subscriptions include:

  • RequestHookEventSubscriber - Called before an HTTP request is made. A RequestHookEvent object, containing details about the request that will be sent to the server, is passed to the subscription's RequestHookEventSubscriberCallback
    • Modifying any data in the callback will NOT affect the actual request that is sent to the server.
  • ResponseHookEventSubscriber - Called after an HTTP request is made. A ResponseHookEvent object, containing details about the response that was received from the server, is passed to the subscription's ResponseHookEventSubscriberCallback
    • Modifying any data in the callback will NOT affect the actual response that was received from the server, and will NOT affect the data deserialized into the library's models.

Users can interact with these details in their callbacks as they see fit (e.g. logging).

func myRequestHookEventSubscriberCallback(ctx context.Context, event easypost.RequestHookEvent) error {
    // Interact with details about the request here
    fmt.Printf("Making HTTP call to %s\n", event.URL)
	return nil
}

func myResponseHookEventSubscriberCallback(ctx context.Context, event easypost.ResponseHookEvent) error {
    // Interact with details about the response here
    fmt.Printf("Received HTTP response with status code %d\n", event.StatusCode)
    return nil
}

requestSubscriber := easypost.RequestHookEventSubscriber{
    Callback: myRequestHookEventSubscriberCallback,
    HookEventSubscriber: easypost.HookEventSubscriber{
        ID: "my-request-hook",
    },
}

responseSubscriber := easypost.ResponseHookEventSubscriber{
    Callback: myResponseHookEventSubscriberCallback,
    HookEventSubscriber: easypost.HookEventSubscriber{
        ID: "my-response-hook",
    },
}

client := easypost.New("EASYPOST_API_KEY")

client.Hooks.AddRequestEventSubscriber(requestSubscriber)
client.Hooks.AddResponseEventSubscriber(responseSubscriber)

Users can unsubscribe from these events at any time by removing the subscription from the Hooks property of a client.

client.Hooks.RemoveRequestEventSubscriber(requestSubscriber)
client.Hooks.RemoveResponseEventSubscriber(responseSubscriber)

Documentation

API documentation can be found at: https://easypost.com/docs/api.

Library documentation can be found on the web at GoDoc.

Upgrading major versions of this project? Refer to the Upgrade Guide.

Support

New features and bug fixes are released on the latest major release of this library. If you are on an older major release of this library, we recommend upgrading to the most recent release to take advantage of new features, bug fixes, and security patches. Older versions of this library will continue to work and be available as long as the API version they are tied to remains active; however, they will not receive updates and are considered EOL.

For additional support, see our org-wide support policy.

Development

# Install dependencies
make install

# Lint project (requires `golangci-lint` to be installed - not included)
make lint

# Run tests
EASYPOST_TEST_API_KEY=123... EASYPOST_PROD_API_KEY=123... make test
EASYPOST_TEST_API_KEY=123... EASYPOST_PROD_API_KEY=123... make coverage

# Run security analysis on the project (requires `gosec` to be installed - not included)
make scan

# Update submodules
make update-examples-submodule
Testing

The test suite in this project was specifically built to produce consistent results on every run, regardless of when they run or who is running them. This project uses VCR to record and replay HTTP requests and responses via "cassettes". When the suite is run, the HTTP requests and responses for each test function will be saved to a cassette if they do not exist already and replayed from this saved file if they do, which saves the need to make live API calls on every test run. If you receive errors about a cassette expiring, delete and re-record the cassette to ensure the data is up-to-date.

Sensitive Data: We've made every attempt to include scrubbers for sensitive data when recording cassettes so that PII or sensitive info does not persist in version control; however, please ensure when recording or re-recording cassettes that prior to committing your changes, no PII or sensitive information gets persisted by inspecting the cassette.

Making Changes: If you make an addition to this project, the request/response will get recorded automatically for you. When making changes to this project, you'll need to re-record the associated cassette to force a new live API call for that test which will then record the request/response used on the next run.

Test Data: The test suite has been populated with various helpful fixtures that are available for use, each completely independent of a particular user with the exception of the USPS carrier account ID (see Unit Test API Keys for more information) which has a fallback value of our internal testing user's ID. Some fixtures use hard-coded dates that may need to be incremented if cassettes get re-recorded (such as reports or pickups).

Unit Test API Keys

The following are required on every test run:

  • EASYPOST_TEST_API_KEY
  • EASYPOST_PROD_API_KEY

Some tests may require an EasyPost user with a particular set of enabled features such as a Partner user when creating referrals. We have attempted to call out these functions in their respective docstrings. The following are required when you need to re-record cassettes for applicable tests:

  • USPS_CARRIER_ACCOUNT_ID (eg: one-call buying a shipment for non-EasyPost employees)
  • PARTNER_USER_PROD_API_KEY (eg: creating a referral user)
  • REFERRAL_CUSTOMER_PROD_API_KEY (eg: adding a credit card to a referral user)
Mocking

Some of our unit tests require HTTP calls that cannot be easily tested with live/recorded calls (e.g. HTTP calls that trigger payments or interact with external APIs).

We have implemented a custom, lightweight HTTP mocking functionality in this library that allows us to mock HTTP calls and responses.

The mock client is the same as a normal client, with a set of mock request-response pairs stored as a property.

At the time to make a real HTTP request, the mock client will instead check which mock request entry matches the queued request (matching by HTTP method and a regex pattern for the URL), and will return the corresponding mock response (HTTP status code and body).

NOTE: If a client is configured with any mock request entries, it will ONLY make mock requests. If it attempts to make a request that does not match any of the configured mock requests, the request will fail and trigger an exception.

To use the mock client:

import "github.com/EasyPost/easypost-go/v4"

// create  a list of mock request-response pairs
mockRequests := []easypost.MockRequest{
    {
        MatchRule: easypost.MockRequestMatchRule{
            // HTTP method and regex pattern for the URL must both pass for the request to match
            Method:          "POST",
            UrlRegexPattern: "v2\\/bank_accounts\\/\\S*\\/charges$",
        },
        ResponseInfo: easypost.MockRequestResponseInfo{
            // HTTP status code and body to return when this request is matched
            StatusCode: 200,
            Body:       `{}`,
        },
    }
}

// create a new client with the mock requests
client := easypost.Client{
    APIKey:       "some_key",
    Client:       &http.Client{Transport: c.recorder},
    MockRequests: mockRequests,
}

// use the client as normal

Documentation

Index

Constants

View Source
const Version = "4.3.0"

Variables

View Source
var ApiDidNotReturnErrorDetails = "API did not return error details"
View Source
var ApiErrorDetailsParsingError = "RESPONSE.PARSE_ERROR"
View Source
var EndOfPaginationError = &LocalError{LibraryError{Message: NoPagesLeftToRetrieve}}

EndOfPaginationError is raised when there are no more pages to retrieve.

View Source
var InvalidParameter = "Invalid parameter: "
View Source
var JsonDeserializationErrorMessage = "Error deserializing JSON into object of type "
View Source
var JsonNoDataErrorMessage = "No data was provided to serialize"
View Source
var JsonSerializationErrorMessage = "Error serializing object of type "
View Source
var MismatchWebhookSignature = "Webhook received did not originate from EasyPost or had a webhook secret mismatch"
View Source
var MismatchWebhookSignatureError = &LocalError{LibraryError{Message: MismatchWebhookSignature}}

MismatchWebhookSignatureError is raised when a webhook received did not originate from EasyPost or had a webhook secret mismatch.

View Source
var MissingProperty = "Missing property: "
View Source
var MissingRequiredParameter = "Missing required parameter: "
View Source
var MissingWebhookSignature = "Webhook does not contain a valid HMAC signature."
View Source
var MissingWebhookSignatureError = &LocalError{LibraryError{Message: MissingWebhookSignature}}

MissingWebhookSignatureError is raised when a webhook does not contain a valid HMAC signature.

View Source
var NoMatchingPaymentMethod = "No matching payment method type found"
View Source
var NoPagesLeftToRetrieve = "There are no more pages to retrieve"
View Source
var NoPaymentMethods = "No payment methods are set up. Please add a payment method and try again."
View Source
var NoRatesFoundMatchingFilters = "No rates found matching the given filters"
View Source
var NoUserFoundForId = "No user found for the given ID"
View Source
var PaymentMethodNotSetUp = "The chosen payment method is not set up yet"

Functions

func BoolPtr

func BoolPtr(b bool) *bool

BoolPtr returns a pointer to a bool with the given value.

func BuildErrorFromResponse

func BuildErrorFromResponse(response *http.Response) error

BuildErrorFromResponse returns an APIError-based object based on the HTTP response. Do not pass a non-error response to this function.

func StringPtr

func StringPtr(s string) *string

StringPtr returns a pointer to a string with the given value.

func UnmarshalJSONObject

func UnmarshalJSONObject(data []byte) (interface{}, error)

UnmarshalJSONObject attempts to unmarshal an easypost object from JSON data. An error is only returned if data is non-zero length and JSON decoding fails. If data contains a valid JSON object with an "object" key/value that matches a known object type, it will return a pointer to the corresponding object type from this package, e.g. *Address, *Batch, *Refund, etc. If the decoded JSON doesn't match, the return value will be the default type stored by json.Unmarshal.

Types

type APIError

type APIError struct {
	LibraryError
	// Code is a machine-readable status of the problem encountered.
	Code string
	// StatusCode is the HTTP numerical status code of the response.
	StatusCode int
	// Errors may be provided if there are details about server-side issues that caused the API request to fail.
	Errors []*Error `json:"errors,omitempty"`
}

APIError represents an error that occurred while communicating with the EasyPost API.

This is typically due to a specific HTTP status code, such as 4xx or 5xx.

This is different from the Error class, which represents information about what triggered the failed request.

The information from the top-level Error class is used to generate this error, and any sub-errors are stored in the Errors field.

func (*APIError) Error

func (e *APIError) Error() string

Error provides a pretty printed string of an APIError object based on present data.

type APIKey

type APIKey struct {
	Object    string    `json:"object,omitempty"`
	Mode      string    `json:"mode,omitempty"`
	CreatedAt *DateTime `json:"created_at,omitempty"`
	Key       string    `json:"key,omitempty"`
}

APIKey represents a single API key.

type APIKeys

type APIKeys struct {
	ID       string     `json:"id,omitempty"`
	Children []*APIKeys `json:"children,omitempty"`
	Keys     []*APIKey  `json:"keys,omitempty"`
}

APIKeys contains information about a list of API keys for the given user and any child users.

type Address

type Address struct {
	ID              string                `json:"id,omitempty"`
	Object          string                `json:"object,omitempty"`
	Reference       string                `json:"reference,omitempty"`
	Mode            string                `json:"mode,omitempty"`
	CreatedAt       *DateTime             `json:"created_at,omitempty"`
	UpdatedAt       *DateTime             `json:"updated_at,omitempty"`
	Street1         string                `json:"street1,omitempty"`
	Street2         string                `json:"street2,omitempty"`
	City            string                `json:"city,omitempty"`
	State           string                `json:"state,omitempty"`
	Zip             string                `json:"zip,omitempty"`
	Country         string                `json:"country,omitempty"`
	Name            string                `json:"name,omitempty"`
	Company         string                `json:"company,omitempty"`
	Phone           string                `json:"phone,omitempty"`
	Email           string                `json:"email,omitempty"`
	Residential     bool                  `json:"residential,omitempty"`
	CarrierFacility string                `json:"carrier_facility,omitempty"`
	FederalTaxID    string                `json:"federal_tax_id,omitempty"`
	StateTaxID      string                `json:"state_tax_id,omitempty"`
	Verifications   *AddressVerifications `json:"verifications,omitempty"`
}

Address objects are used to represent people, places, and organizations in a number of contexts.

type AddressVerification

type AddressVerification struct {
	Success bool                             `json:"success"`
	Errors  []*AddressVerificationFieldError `json:"errors"`
	Details *AddressVerificationDetails      `json:"details"`
}

AddressVerification holds data relating to address verification status.

type AddressVerificationDetails

type AddressVerificationDetails struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
	TimeZone  string  `json:"time_zone"`
}

AddressVerificationDetails contains extra information related to address verification.

type AddressVerificationFieldError

type AddressVerificationFieldError struct {
	Code       string `json:"code,omitempty"`
	Field      string `json:"field,omitempty"`
	Message    string `json:"message,omitempty"`
	Suggestion string `json:"suggestion,omitempty"`
}

AddressVerificationFieldError provides additional information on address validation errors.

type AddressVerifications

type AddressVerifications struct {
	ZIP4     *AddressVerification `json:"zip4"`
	Delivery *AddressVerification `json:"delivery"`
}

AddressVerifications contains the result of the requested address verifications.

type AddressVerifyResponse

type AddressVerifyResponse struct {
	Address *Address `json:"address,omitempty"`
}

type BadRequestError

type BadRequestError struct {
	APIError
}

BadRequestError is raised when the API returns a 400 status code.

type Batch

type Batch struct {
	ID           string       `json:"id,omitempty"`
	Object       string       `json:"object,omitempty"`
	Reference    string       `json:"reference,omitempty"`
	Mode         string       `json:"mode,omitempty"`
	CreatedAt    *DateTime    `json:"created_at,omitempty"`
	UpdatedAt    *DateTime    `json:"updated_at,omitempty"`
	State        string       `json:"state,omitempty"`
	NumShipments int          `json:"num_shipments,omitempty"`
	Shipments    []*Shipment  `json:"shipments,omitempty"`
	Status       *BatchStatus `json:"status,omitempty"`
	LabelURL     string       `json:"label_url,omitempty"`
	ScanForm     *ScanForm    `json:"scan_form,omitempty"`
	Pickup       *Pickup      `json:"pickup,omitempty"`
}

Batch represents a batch of shipments.

type BatchStatus

type BatchStatus struct {
	PostagePurchased      int `json:"postage_purchased,omitempty"`
	PostagePurchaseFailed int `json:"postage_purchase_failed,omitempty"`
	QueuedForPurchase     int `json:"queued_for_purchase,omitempty"`
	CreationFailed        int `json:"creation_failed,omitempty"`
}

BatchStatus contains counts of statuses for the shipments in a batch.

type BetaPaymentRefund

type BetaPaymentRefund struct {
	RefundedAmount      int        `json:"refunded_amount,omitempty"`
	RefundedPaymentLogs []string   `json:"refunded_payment_log,omitempty"`
	PaymentLogId        string     `json:"payment_log_id,omitempty"`
	Errors              []APIError `json:"errors,omitempty"`
}

A BetaPaymentRefund that has the refund details for the refund request.

type Brand

type Brand struct {
	ID              string `json:"id,omitempty"`
	BackgroundColor string `json:"background_color,omitempty"`
	Color           string `json:"color,omitempty"`
	LogoHref        string `json:"logo_href,omitempty"`
	Ad              string `json:"ad,omitempty"`
	AdHref          string `json:"ad_href,omitempty"`
	Name            string `json:"name,omitempty"`
	UserID          string `json:"user_id,omitempty"`
	Theme           string `json:"theme,omitempty"`
}

Brand contains data for a user brand

type CarrierAccount

type CarrierAccount struct {
	ID               string                 `json:"id,omitempty"`
	Object           string                 `json:"object,omitempty"`
	Reference        string                 `json:"reference,omitempty"`
	CreatedAt        *DateTime              `json:"created_at,omitempty"`
	UpdatedAt        *DateTime              `json:"updated_at,omitempty"`
	Type             string                 `json:"type,omitempty"`
	Fields           *CarrierFields         `json:"fields,omitempty"`
	Clone            bool                   `json:"clone,omitempty"`
	Description      string                 `json:"description,omitempty"`
	Readable         string                 `json:"readable,omitempty"`
	Credentials      map[string]string      `json:"credentials,omitempty"`
	TestCredentials  map[string]string      `json:"test_credentials,omitempty"`
	RegistrationData map[string]interface{} `json:"registration_data,omitempty"`
	BillingType      string                 `json:"billing_type,omitempty"`
}

CarrierAccount encapsulates credentials and other information related to a carrier account.

type CarrierField

type CarrierField struct {
	Visibility string `json:"visibility,omitempty"`
	Label      string `json:"label,omitempty"`
	Value      string `json:"value,omitempty"`
}

CarrierField provides data for a single field in a carrier account.

type CarrierFields

type CarrierFields struct {
	Credentials     map[string]*CarrierField `json:"credentials,omitempty"`
	TestCredentials map[string]*CarrierField `json:"test_credentials,omitempty"`
	AutoLink        bool                     `json:"auto_link,omitempty"`
	CustomWorkflow  bool                     `json:"custom_workflow,omitempty"`
}

CarrierFields contains the data for carrier account fields for production and/or test credentials.

type CarrierMessage

type CarrierMessage struct {
	Carrier          string `json:"carrier,omitempty"`
	Type             string `json:"type,omitempty"`
	Message          string `json:"message,omitempty"`
	CarrierAccountID string `json:"carrier_account_id,omitempty"`
}

CarrierMessage contains additional status data that is provided by some carriers for certain operations.

type CarrierMetadata

type CarrierMetadata struct {
	Name               string                       `json:"name,omitempty"`
	HumanReadable      string                       `json:"human_readable,omitempty"`
	ServiceLevels      []*MetadataServiceLevel      `json:"service_levels,omitempty"`
	PredefinedPackages []*MetadataPredefinedPackage `json:"predefined_packages,omitempty"`
	ShipmentOptions    []*MetadataShipmentOption    `json:"shipment_options,omitempty"`
	SupportedFeatures  []*MetadataSupportedFeature  `json:"supported_features,omitempty"`
}

CarrierMetadata represents all the metadata for a carrier.

type CarrierType

type CarrierType struct {
	Object string         `json:"object,omitempty"`
	Type   string         `json:"type,omitempty"`
	Fields *CarrierFields `json:"fields,omitempty"`
}

CarrierType contains information on a supported carrier. It can be used to determine the valid fields for a carrier account.

type Client

type Client struct {
	// BaseURL specifies the location of the API. It is used with
	// ResolveReference to create request URLs. (If 'Path' is specified, it
	// should end with a trailing slash.) If nil, the default will be used.
	BaseURL *url.URL
	// Client is an HTTP client used to make API requests. If nil,
	// http.DefaultClient will be used.
	Client *http.Client
	// APIKey is the user's API key. It is required.
	// Note: Treat your API Keys as passwords—keep them secret. API Keys give
	// full read/write access to your account, so they should not be included in
	// public repositories, emails, client side code, etc.
	APIKey string
	// UserAgent is a User-Agent to be sent with API HTTP requests. If empty,
	// a default will be used.
	UserAgent string
	// Timeout specifies the time limit (in milliseconds) for requests made by this Client. The
	// timeout includes connection time, any redirects, and reading the
	// response body.
	Timeout int
	// MockRequests is a list of requests that will be mocked by the client.
	MockRequests []MockRequest
	// Hooks is a collection of HookEventSubscriber instances for various hooks available in the client
	Hooks Hooks
}

A Client provides an HTTP client for EasyPost API operations.

func New

func New(apiKey string) *Client

New returns a new Client with the given API key.

func (*Client) AddReferralCustomerCreditCard

func (c *Client) AddReferralCustomerCreditCard(referralCustomerApiKey string, creditCardOptions *CreditCardOptions, priority PaymentMethodPriority) (out *PaymentMethodObject, err error)

AddReferralCustomerCreditCard adds a credit card to a referral customer's account.

func (*Client) AddReferralCustomerCreditCardWithContext

func (c *Client) AddReferralCustomerCreditCardWithContext(ctx context.Context, referralCustomerApiKey string, creditCardOptions *CreditCardOptions, priority PaymentMethodPriority) (out *PaymentMethodObject, err error)

AddReferralCustomerCreditCardWithContext performs the same operation as AddReferralCustomerCreditCard, but allows specifying a context that can interrupt the request.

func (*Client) AddShipmentsToBatch

func (c *Client) AddShipmentsToBatch(batchID string, shipments ...*Shipment) (out *Batch, err error)

AddShipmentsToBatch adds shipments to an existing batch, and returns the updated batch object.

func (*Client) AddShipmentsToBatchWithContext

func (c *Client) AddShipmentsToBatchWithContext(ctx context.Context, batchID string, shipments ...*Shipment) (out *Batch, err error)

AddShipmentsToBatchWithContext performs the same operation as AddShipmentsToBatch, but allows specifying a context that can interrupt the request.

func (*Client) BetaAddPaymentMethod

func (c *Client) BetaAddPaymentMethod(stripeCustomerId string, paymentMethodReference string, priority PaymentMethodPriority) (out *PaymentMethodObject, err error)

BetaAddPaymentMethod adds Stripe payment method to referral customer.

func (*Client) BetaAddPaymentMethodWithContext

func (c *Client) BetaAddPaymentMethodWithContext(ctx context.Context, stripeCustomerId string, paymentMethodReference string, priority PaymentMethodPriority) (out *PaymentMethodObject, err error)

BetaAddPaymentMethodWithContext performs the same operation as BetaAddPaymentMethod, but allows specifying a context that can interrupt the request.

func (*Client) BetaGetStatelessRates

func (c *Client) BetaGetStatelessRates(in *Shipment) (out []*StatelessRate, err error)

BetaGetStatelessRates fetches a list of stateless rates.

func (*Client) BetaGetStatelessRatesWithContext

func (c *Client) BetaGetStatelessRatesWithContext(ctx context.Context, in *Shipment) (out []*StatelessRate, err error)

BetaGetStatelessRatesWithContext performs the same operation as BetaGetStatelessRates, but allows specifying a context that can interrupt the request.

func (*Client) BetaRefundByAmount

func (c *Client) BetaRefundByAmount(refundAmount int) (out *BetaPaymentRefund, err error)

BetaRefundByAmount refunds a recent payment by amount in cents.

func (*Client) BetaRefundByAmountWithContext

func (c *Client) BetaRefundByAmountWithContext(ctx context.Context, refundAmount int) (out *BetaPaymentRefund, err error)

BetaRefundByAmountWithContext performs the same operation as BetaRefundByAmount, but allows specifying a context that can interrupt the request.

func (*Client) BetaRefundByPaymentLog

func (c *Client) BetaRefundByPaymentLog(paymentLogId string) (out *BetaPaymentRefund, err error)

BetaRefundByPaymentLog refunds a payment by payment log ID.

func (*Client) BetaRefundByPaymentLogWithContext

func (c *Client) BetaRefundByPaymentLogWithContext(ctx context.Context, paymentLogId string) (out *BetaPaymentRefund, err error)

BetaRefundByPaymentLogWithContext performs the same operation as BetaRefundByPaymentLog, but allows specifying a context that can interrupt the request.

func (*Client) BuyBatch

func (c *Client) BuyBatch(batchID string) (out *Batch, err error)

BuyBatch initializes purchases for the shipments in the batch. The updated batch object is returned.

func (*Client) BuyBatchWithContext

func (c *Client) BuyBatchWithContext(ctx context.Context, batchID string) (out *Batch, err error)

BuyBatchWithContext performs the same operation as BuyBatch, but allows specifying a context that can interrupt the request.

func (*Client) BuyOrder

func (c *Client) BuyOrder(orderID, carrier, service string) (out *Order, err error)

BuyOrder purchases an order. This operation populates the TrackingCode and PostageLabel attributes of each Shipment.

c := easypost.New(MyEasyPostAPIKey)
out, err := c.Buy("order_1", "FedEx", "FEDEX_GROUND")

func (*Client) BuyOrderWithContext

func (c *Client) BuyOrderWithContext(ctx context.Context, orderID, carrier, service string) (out *Order, err error)

BuyOrderWithContext performs the same operation as GBuyOrder, but allows specifying a context that can interrupt the request.

func (*Client) BuyPickup

func (c *Client) BuyPickup(pickupID string, rate *PickupRate) (out *Pickup, err error)

BuyPickup purchases and schedules a pickup.

	c := easypost.New(MyEasyPostAPIKey)
 rate := &PickupRate{Carrier: "UPS", Service: "Same-Day Pickup"}
	out, err := c.BuyPickup("pck_1", rate)

func (*Client) BuyPickupWithContext

func (c *Client) BuyPickupWithContext(ctx context.Context, pickupID string, rate *PickupRate) (out *Pickup, err error)

BuyPickupWithContext performs the same operation as BuyPickup, but allows specifying a context that can interrupt the request.

func (*Client) BuyShipment

func (c *Client) BuyShipment(shipmentID string, rate *Rate, insurance string) (out *Shipment, err error)

BuyShipment purchases a shipment. If successful, the returned Shipment will have the PostageLabel attribute populated.

c := easypost.New(MyEasyPostAPIKey)
out, err := c.Buy("shp_100", &easypost.Rate{ID: "rate_1001"}, "249.99")

func (*Client) BuyShipmentWithContext

func (c *Client) BuyShipmentWithContext(ctx context.Context, shipmentID string, rate *Rate, insurance string) (out *Shipment, err error)

BuyShipmentWithContext performs the same operation as BuyShipment, but allows specifying a context that can interrupt the request.

func (*Client) BuyShipmentWithEndShipper

func (c *Client) BuyShipmentWithEndShipper(shipmentID string, rate *Rate, insurance string, endShipperID string) (out *Shipment, err error)

BuyShipmentWithEndShipper performs the same operation as BuyShipment, but includes an EndShipper ID.

func (*Client) BuyShipmentWithEndShipperWithContext

func (c *Client) BuyShipmentWithEndShipperWithContext(ctx context.Context, shipmentID string, rate *Rate, insurance string, endShipperID string) (out *Shipment, err error)

BuyShipmentWithEndShipperWithContext performs the same operation as BuyShipmentWithEndShipper, but allows specifying a context that can interrupt the request.

func (*Client) CancelPickup

func (c *Client) CancelPickup(pickupID string) (out *Pickup, err error)

CancelPickup cancels a scheduled pickup.

func (*Client) CancelPickupWithContext

func (c *Client) CancelPickupWithContext(ctx context.Context, pickupID string) (out *Pickup, err error)

CancelPickupWithContext performs the same operation as CancelPickup, but allows specifying a context that can interrupt the request.

func (*Client) CreateAddress

func (c *Client) CreateAddress(in *Address, opts *CreateAddressOptions) (out *Address, err error)

CreateAddress submits a request to create a new address, and returns the result.

c := easypost.New(MyEasyPostAPIKey)
out, err := c.CreateAddress(
	&easypost.Address{
		Street1: "417 Montgomery Street",
		Street2: "Floor 5",
		City:    "San Francisco",
		State:   "CA",
		Zip:     "94104",
		Country: "US",
		Company: "EasyPost",
		Phone:   "415-123-4567",
	},
	&CreateAddressOptions{Verify: []string{"delivery"}},
)

func (*Client) CreateAddressWithContext

func (c *Client) CreateAddressWithContext(ctx context.Context, in *Address, opts *CreateAddressOptions) (out *Address, err error)

CreateAddressWithContext performs the same operation as CreateAddress, but allows specifying a context that can interrupt the request.

func (*Client) CreateAndVerifyAddress

func (c *Client) CreateAndVerifyAddress(in *Address, opts *CreateAddressOptions) (out *Address, err error)

CreateAndVerifyAddress Create Address object and immediately verify it.

func (*Client) CreateAndVerifyAddressWithContext

func (c *Client) CreateAndVerifyAddressWithContext(ctx context.Context, in *Address, opts *CreateAddressOptions) (out *Address, err error)

CreateAndVerifyAddressWithContext performs the same operation as CreateAndVerifyAddress, but allows specifying a context that can interrupt the request.

func (*Client) CreateBatch

func (c *Client) CreateBatch(in ...*Shipment) (out *Batch, err error)

CreateBatch creates a new batch of shipments. It optionally accepts one or more shipments to add to the new batch. If successful, a new batch object is returned.

c := easypost.New(MyEasyPostAPIKey)
out, err := c.CreateBatch(
	&easypost.Shipment{ID: "shp_100"},
	&easypost.Shipment{ID: "shp_101"},
	&easypost.Shipment{ID: "shp_102"},
)

func (*Client) CreateBatchScanForms

func (c *Client) CreateBatchScanForms(batchID, format string) (out *Batch, err error)

CreateBatchScanForms generates a scan form for the batch.

func (*Client) CreateBatchScanFormsWithContext

func (c *Client) CreateBatchScanFormsWithContext(ctx context.Context, batchID, format string) (out *Batch, err error)

CreateBatchScanFormsWithContext performs the same operation as CreateBatchScanForms, but allows specifying a context that can interrupt the request.

func (*Client) CreateBatchWithContext

func (c *Client) CreateBatchWithContext(ctx context.Context, in ...*Shipment) (out *Batch, err error)

CreateBatchWithContext performs the same operation as CreateBatch, but allows specifying a context that can interrupt the request.

func (*Client) CreateCarrierAccount

func (c *Client) CreateCarrierAccount(in *CarrierAccount) (out *CarrierAccount, err error)

CreateCarrierAccount creates a new carrier account. It can only be used with a production API key.

c := easypost.New(MyEasyPostAPIKey)
out, err := c.CreateCarrierAccount(
	&easypost.CarrierAccount{
		Type:        "UpsAccount",
		Description: "NY Location UPS Account",
		Reference:   "my reference",
		Credentials: map[string]string{
			"user_id":               "USERID",
			"password":              "PASSWORD",
			"access_license_number": "ALN",
		},
	},
)

func (*Client) CreateCarrierAccountWithContext

func (c *Client) CreateCarrierAccountWithContext(ctx context.Context, in *CarrierAccount) (out *CarrierAccount, err error)

CreateCarrierAccountWithContext performs the same operation as CreateCarrierAccount, but allows specifying a context that can interrupt the request.

func (*Client) CreateCustomsInfo

func (c *Client) CreateCustomsInfo(in *CustomsInfo) (out *CustomsInfo, err error)

CreateCustomsInfo creates a new CustomsInfo object.

c := easypost.New(MyEasyPostAPIKey)
out, err := c.CreateCustomsInfo(
	&easypost.CustomsInfo{
		CustomsCertify:  true,
		CustomsSigner:   "Steve Brule",
		CustomsType:     "merchandise",
		RestrictionType: "none",
		EELPFC:          "NOEEI 30.37(a)",
		CustomsItems:    []*easypost.CustomsItem{
			&easypost.CustomsItem{ID: "cstitem_2002"},
			&easypost.CustomsItem{
				Description:     "Sweet shirts",
				Quantity:        2,
				Value:           23,
				Weight:          11,
				HSTariffNumber: "654321",
				OriginCountry:   "US",
			},
		},
	},
)

func (*Client) CreateCustomsInfoWithContext

func (c *Client) CreateCustomsInfoWithContext(ctx context.Context, in *CustomsInfo) (out *CustomsInfo, err error)

CreateCustomsInfoWithContext performs the same operation as CreateCustomsInfo, but allows specifying a context that can interrupt the request.

func (*Client) CreateCustomsItem

func (c *Client) CreateCustomsItem(in *CustomsItem) (out *CustomsItem, err error)

CreateCustomsItem creates a new CustomsItem object.

c := easypost.New(MyEasyPostAPIKey)
out, err := c.CreateCustomsItem(
	&easypost.CustomsItem{
		Description:    "T-shirt",
		Quantity:       1,
		Weight:         5,
		Value:          10,
		HSTariffNumber: "123456",
		OriginCountry:  "US",
	},
)

func (*Client) CreateCustomsItemWithContext

func (c *Client) CreateCustomsItemWithContext(ctx context.Context, in *CustomsItem) (out *CustomsItem, err error)

CreateCustomsItemWithContext performs the same operation as CreateCustomsItem, but allows specifying a context that can interrupt the request.

func (*Client) CreateEndShipper

func (c *Client) CreateEndShipper(in *Address) (out *Address, err error)

CreateEndShipper submits a request to create a new endshipper, and returns the result.

func (*Client) CreateEndShipperWithContext

func (c *Client) CreateEndShipperWithContext(ctx context.Context, in *Address) (out *Address, err error)

CreateEndShipperWithContext performs the same operation as CreateEndShipper, but allows specifying a context that can interrupt the request.

func (*Client) CreateInsurance

func (c *Client) CreateInsurance(in *Insurance) (out *Insurance, err error)

CreateInsurance creates an insurance object for a shipment purchased outside EasyPost. ToAddress, FromAddress, TrackingCode and Amount fields must be provided. Providing a value in the Carrier field is optional, but can help avoid ambiguity and provide a shorter response time.

c := easypost.New(MyEasyPostAPIKey)
out, err := c.CreateInsurance(
	&easypost.Insurance{
		ToAddress:    &easypost.Address{ID: "adr_102"},
		FromAddress:  &easypost.Address{ID: "adr_101"},
		TrackingCode: "9400110898825022579493",
		Carrier:      "USPS",
		Reference:    "insuranceRef1",
		Amount:       100,
)

func (*Client) CreateInsuranceWithContext

func (c *Client) CreateInsuranceWithContext(ctx context.Context, in *Insurance) (out *Insurance, err error)

CreateInsuranceWithContext performs the same operation as CreateInsurance, but allows specifying a context that can interrupt the request.

func (*Client) CreateOrder

func (c *Client) CreateOrder(in *Order, accounts ...*CarrierAccount) (out *Order, err error)

CreateOrder creates a new order object. If the `accounts` parameter is given, the provided carrier accounts will be used to limit the returned rates to the given carrier(s).

c := easypost.New(MyEasyPostAPIKey)
out, err := c.CreateOrder(
	&easypost.Order{
		ToAddress:   &easypost.Address{ID: "adr_1001"},
		FromAddress: &easypost.Address{Id: "adr_101"},
		Shipments:   []*easypost.Shipment{
			&easypost.Shipment{
				Parcel: &easypost.Parcel{
					PredefinedPackage: "FedExBox",
					Weight:            10.2,
				},
			},
			&easypost.Shipment{
				Parcel: &easypost.Parcel{
					PredefinedPackage: "FedExBox",
					Weight:            17.5,
				},
			},
		},
	},
	&easypost.CarrierAccount{ID: "ca_101"},
	&easypost.CarrierAccount{ID: "ca_102"},
)

func (*Client) CreateOrderWithContext

func (c *Client) CreateOrderWithContext(ctx context.Context, in *Order, accounts ...*CarrierAccount) (out *Order, err error)

CreateOrderWithContext performs the same operation as CreateOrder, but allows specifying a context that can interrupt the request.

func (*Client) CreateParcel

func (c *Client) CreateParcel(in *Parcel) (out *Parcel, err error)

CreateParcel creates a new Parcel object.

c := easypost.New(MyEasyPostAPIKey)
out, err := c.CreateParcel(
	&easypost.Parcel{
		Length: 20.2,
		Width:  10.9,
		Height: 5,
		Weight: 65.9,
	},
)

func (*Client) CreateParcelWithContext

func (c *Client) CreateParcelWithContext(ctx context.Context, in *Parcel) (out *Parcel, err error)

CreateParcelWithContext performs the same operation as CreateParcel, but allows specifying a context that can interrupt the request.

func (*Client) CreatePickup

func (c *Client) CreatePickup(in *Pickup) (out *Pickup, err error)

CreatePickup creates a new Pickup object, and automatically fetches rates for the given time and location.

c := easypost.New(MyEasyPostAPIKey)
out, err := c.CreatePickup(
	&easypost.Pickup{
		Reference:        "my-first-pickup",
		MinDatetime:      time.Date(2014, 10, 21, 0, 10, 0, 0, time.UTC),
		MaxDatetime:      time.Date(2014, 10, 21, 15, 30, 0, 0, time.UTC),
		Shipment:         &easypost.Shipment{ID: "shp_1"},
		Address:          &easypost.Address{ID: "ad_1001"},
		IsAccountAddress: false,
		Instructions:     "Special pickup instructions",
	},
)

func (*Client) CreatePickupWithContext

func (c *Client) CreatePickupWithContext(ctx context.Context, in *Pickup) (out *Pickup, err error)

CreatePickupWithContext performs the same operation as CreatePickup, but allows specifying a context that can interrupt the request.

func (*Client) CreateReferralCustomer

func (c *Client) CreateReferralCustomer(in *UserOptions) (out *ReferralCustomer, err error)

CreateReferralCustomer creates a new referral customer.

func (*Client) CreateReferralCustomerWithContext

func (c *Client) CreateReferralCustomerWithContext(ctx context.Context, in *UserOptions) (out *ReferralCustomer, err error)

CreateReferralCustomerWithContext performs the same operation as CreateReferralCustomer, but allows specifying a context that can interrupt the request.

func (*Client) CreateRefund

func (c *Client) CreateRefund(in map[string]interface{}) (out []*Refund, err error)

CreateRefund submits a refund request and return a list of refunds.

func (*Client) CreateRefundWithContext

func (c *Client) CreateRefundWithContext(ctx context.Context, in map[string]interface{}) (out []*Refund, err error)

CreateRefundWithContext performs the same operation as CreateRefund, but allows specifying a context that can interrupt the request.

func (*Client) CreateReport

func (c *Client) CreateReport(typ string, in *Report) (out *Report, err error)

CreateReport generates a new report. Valid Fields for input are StartDate, EndDate and SendEmail. A new Report object is returned. Once the Status is available, the report can be downloaded from the provided URL for 30 seconds.

c := easypost.New(MyEasyPostAPIKey)
c.CreateReport(
	"payment_log",
	&easypost.Report{StartDate: "2016-10-01", EndDate: "2016-10-31"},
)

func (*Client) CreateReportWithContext

func (c *Client) CreateReportWithContext(ctx context.Context, typ string, in *Report) (out *Report, err error)

CreateReportWithContext performs the same operation as CreateReport, but allows specifying a context that can interrupt the request.

func (*Client) CreateScanForm

func (c *Client) CreateScanForm(shipmentIDs ...string) (out *ScanForm, err error)

CreateScanForm creates a scan form for the given Shipments.

c := easypost.New(MyEasyPostAPIKey)
out, err := c.CreateScanForm("shp_1", "shp_2")

func (*Client) CreateScanFormWithContext

func (c *Client) CreateScanFormWithContext(ctx context.Context, shipmentIDs ...string) (out *ScanForm, err error)

CreateScanFormWithContext performs the same operation as CreateScanForm, but allows specifying a context that can interrupt the request.

func (*Client) CreateShipment

func (c *Client) CreateShipment(in *Shipment) (out *Shipment, err error)

CreateShipment creates a new Shipment object. The ToAddress, FromAddress and Parcel attributes are required. These objects may be fully-specified to create new ones at the same time as creating the Shipment, or they can refer to existing objects via their ID attribute. Passing in one or more carrier accounts to CreateShipment limits the returned rates to the specified carriers.

c := easypost.New(MyEasyPostAPIKey)
out, err := c.CreateShipment(
	&easypost.Shipment{
		ToAddress: &easypost.Address{
			Name:    "Dr. Steve Brule",
			Street1: "179 N Harbor Dr",
			City:    "Redondo Beach",
			State:   "CA",
			Zip:     "90277",
			Country: "US",
			Phone:   "8573875756",
			Email:   "dr_steve_brule@gmail.com",
		},
		FromAddress: &easypost.Address{ID: "adr_101"},
		Parcel: &easypost.Parcel{
			Length: 20.2,
			Width:  10.9,
			Height: 5,
			Weight: 65.9,
		},
		CustomsInfo: &easypost.CustomsInfo{ID: "cstinfo_1"},
	},
)

func (*Client) CreateShipmentWithContext

func (c *Client) CreateShipmentWithContext(ctx context.Context, in *Shipment) (out *Shipment, err error)

CreateShipmentWithContext performs the same operation as CreateShipment, but allows specifying a context that can interrupt the request.

func (*Client) CreateTracker

func (c *Client) CreateTracker(opts *CreateTrackerOptions) (out *Tracker, err error)

CreateTracker creates a new Tracker object with the provided options. Providing a carrier is optional, but helps to avoid ambiguity in detecting the carrier based on the tracking code format.

func (*Client) CreateTrackerList

func (c *Client) CreateTrackerList(param map[string]interface{}) (bool, error)

CreateTrackerList asynchronously creates multiple trackers. Input a map of maps that contains multiple tracking codes

func (*Client) CreateTrackerListWithContext

func (c *Client) CreateTrackerListWithContext(ctx context.Context, param map[string]interface{}) (bool, error)

CreateTrackerListWithContext performs the same operation as CreateTrackerList, but allows specifying a context that can interrupt the request.

func (*Client) CreateTrackerWithContext

func (c *Client) CreateTrackerWithContext(ctx context.Context, opts *CreateTrackerOptions) (out *Tracker, err error)

CreateTrackerWithContext performs the same operation as CreateTracker, but allows specifying a context that can interrupt the request.

func (*Client) CreateUser

func (c *Client) CreateUser(in *UserOptions) (out *User, err error)

CreateUser creates a new child user.

 c := easypost.New(MyEasyPostAPIKey)
 opts := &easypost.UserOptions{Name: easypost.StringPtr("Child User")}
	out, err := c.CreateUser(opts)

func (*Client) CreateUserWithContext

func (c *Client) CreateUserWithContext(ctx context.Context, in *UserOptions) (out *User, err error)

CreateUserWithContext performs the same operation as CreateUser, but allows specifying a context that can interrupt the request.

func (*Client) CreateWebhookWithDetails

func (c *Client) CreateWebhookWithDetails(data *CreateUpdateWebhookOptions) (out *Webhook, err error)

CreateWebhookWithDetails creates a new webhook with the provided details.

func (*Client) CreateWebhookWithDetailsWithContext

func (c *Client) CreateWebhookWithDetailsWithContext(ctx context.Context,
	data *CreateUpdateWebhookOptions) (out *Webhook, err error)

CreateWebhookWithDetailsWithContext performs the same operation as CreateWebhookWithDetails, but allows specifying a context that can interrupt the request.

func (*Client) DeleteCarrierAccount

func (c *Client) DeleteCarrierAccount(carrierAccountID string) error

DeleteCarrierAccount removes the carrier account with the given ID.

func (*Client) DeleteCarrierAccountWithContext

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

DeleteCarrierAccountWithContext performs the same operation as DeleteCarrierAccount, but allows specifying a context that can interrupt the request.

func (*Client) DeletePaymentMethod

func (c *Client) DeletePaymentMethod(priority PaymentMethodPriority) (err error)

DeletePaymentMethod allows you to delete a payment method in your wallet.

func (*Client) DeletePaymentMethodWithContext

func (c *Client) DeletePaymentMethodWithContext(ctx context.Context, priority PaymentMethodPriority) (err error)

DeletePaymentMethodWithContext performs the same as DeletePaymentMethod, but allows specifying a context that can interrupt the request.

func (*Client) DeleteUser

func (c *Client) DeleteUser(userID string) error

DeleteUser removes a child user.

func (*Client) DeleteUserWithContext

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

DeleteUserWithContext performs the same operation as DeleteUser, but allows specifying a context that can interrupt the request.

func (*Client) DeleteWebhook

func (c *Client) DeleteWebhook(webhookID string) error

DeleteWebhook removes a webhook.

func (*Client) DeleteWebhookWithContext

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

DeleteWebhookWithContext performs the same operation as DeleteWebhook, but allows specifying a context that can interrupt the request.

func (*Client) FundWallet

func (c *Client) FundWallet(amount string, priority PaymentMethodPriority) (err error)

FundWallet allows you to fund your EasyPost wallet by charging your primary or secondary payment method on file.

func (*Client) FundWalletWithContext

func (c *Client) FundWalletWithContext(ctx context.Context, amount string, priority PaymentMethodPriority) (err error)

FundWalletWithContext performs the same as FundWallet, but allows specifying a context that can interrupt the request.

func (*Client) GenerateShipmentForm

func (c *Client) GenerateShipmentForm(shipmentID string, formType string) (out *Shipment, err error)

GenerateShipmentForm generates a form of a given type for a shipment

func (*Client) GenerateShipmentFormWithContext

func (c *Client) GenerateShipmentFormWithContext(ctx context.Context, shipmentID string, formType string) (out *Shipment, err error)

GenerateShipmentFormWithContext performs the same operation as GenerateShipmentForm, but allows specifying a context that can interrupt the request.

func (*Client) GenerateShipmentFormWithOptions

func (c *Client) GenerateShipmentFormWithOptions(shipmentID string, formType string, formOptions map[string]interface{}) (out *Shipment, err error)

GenerateShipmentFormWithOptions generates a form of a given type for a shipment, using provided options

func (*Client) GenerateShipmentFormWithOptionsWithContext

func (c *Client) GenerateShipmentFormWithOptionsWithContext(ctx context.Context, shipmentID string, formType string, formOptions map[string]interface{}) (out *Shipment, err error)

GenerateShipmentFormWithOptionsWithContext performs the same operation as GenerateShipmentFormWithOptions, but allows specifying a context that can interrupt the request.

func (*Client) GetAPIKeys

func (c *Client) GetAPIKeys() (out *APIKeys, err error)

GetAPIKeys returns the list of API keys associated with the current user.

func (*Client) GetAPIKeysForUser

func (c *Client) GetAPIKeysForUser(userID string) (out *APIKeys, err error)

GetAPIKeysForUser returns the list of API keys associated with the given user ID.

func (*Client) GetAPIKeysForUserWithContext

func (c *Client) GetAPIKeysForUserWithContext(ctx context.Context, userID string) (out *APIKeys, err error)

GetAPIKeysForUserWithContext performs the same operation as GetAPIKeysForUser, but allows specifying a context that can interrupt the request.

func (*Client) GetAPIKeysWithContext

func (c *Client) GetAPIKeysWithContext(ctx context.Context) (out *APIKeys, err error)

GetAPIKeysWithContext performs the same operation as GetAPIKeys, but allows specifying a context that can interrupt the request.

func (*Client) GetAddress

func (c *Client) GetAddress(addressID string) (out *Address, err error)

GetAddress retrieves a previously-created address by its ID.

func (*Client) GetAddressWithContext

func (c *Client) GetAddressWithContext(ctx context.Context, addressID string) (out *Address, err error)

GetAddressWithContext performs the same operation as GetAddress, but allows specifying a context that can interrupt the request.

func (*Client) GetBatch

func (c *Client) GetBatch(batchID string) (out *Batch, err error)

GetBatch retrieves a Batch object by ID.

func (*Client) GetBatchLabels

func (c *Client) GetBatchLabels(batchID, format string) (out *Batch, err error)

GetBatchLabels generates a label for the batch. This can only be done once per batch, and all shipments must have a "postage_purchased" status.

func (*Client) GetBatchLabelsWithContext

func (c *Client) GetBatchLabelsWithContext(ctx context.Context, batchID, format string) (out *Batch, err error)

GetBatchLabelsWithContext performs the same operation as GetBatchLabels, but allows specifying a context that can interrupt the request.

func (*Client) GetBatchWithContext

func (c *Client) GetBatchWithContext(ctx context.Context, batchID string) (out *Batch, err error)

GetBatchWithContext performs the same operation as GetBatch, but allows specifying a context that can interrupt the request.

func (*Client) GetCarrierAccount

func (c *Client) GetCarrierAccount(carrierAccountID string) (out *CarrierAccount, err error)

GetCarrierAccount retrieves a carrier account by its ID or reference.

func (*Client) GetCarrierAccountWithContext

func (c *Client) GetCarrierAccountWithContext(ctx context.Context, carrierAccountID string) (out *CarrierAccount, err error)

GetCarrierAccountWithContext performs the same operation as GetCarrierAccount, but allows specifying a context that can interrupt the request.

func (*Client) GetCarrierMetadata

func (c *Client) GetCarrierMetadata() (out []*CarrierMetadata, err error)

GetCarrierMetadata retrieves all metadata for all carriers on the EasyPost platform.

func (*Client) GetCarrierMetadataWithCarriers

func (c *Client) GetCarrierMetadataWithCarriers(carriers []string) (out []*CarrierMetadata, err error)

GetCarrierMetadataWithCarriers retrieves carrier metadata for a list of carriers.

func (*Client) GetCarrierMetadataWithCarriersAndTypes

func (c *Client) GetCarrierMetadataWithCarriersAndTypes(carriers []string, types []string) (out []*CarrierMetadata, err error)

GetCarrierMetadataWithTypes retrieves carrier metadata for a list of carriers and a list of types.

func (*Client) GetCarrierMetadataWithContext

func (c *Client) GetCarrierMetadataWithContext(ctx context.Context, carriers []string, types []string) (out []*CarrierMetadata, err error)

GetCarrierMetadataWithContext performs the same operation as GetCarrierMetadata, but allows specifying a context that can interrupt the request.

func (*Client) GetCarrierMetadataWithTypes

func (c *Client) GetCarrierMetadataWithTypes(types []string) (out []*CarrierMetadata, err error)

GetCarrierMetadataWithTypes retrieves carrier metadata for a list of carriers.

func (*Client) GetCarrierTypes

func (c *Client) GetCarrierTypes() (out []*CarrierType, err error)

GetCarrierTypes returns a list of supported carrier types for the current user.

func (*Client) GetCarrierTypesWithContext

func (c *Client) GetCarrierTypesWithContext(ctx context.Context) (out []*CarrierType, err error)

GetCarrierTypesWithContext performs the same operation as GetCarrierTypes, but allows specifying a context that can interrupt the request.

func (*Client) GetCustomsInfo

func (c *Client) GetCustomsInfo(customsInfoID string) (out *CustomsInfo, err error)

GetCustomsInfo returns the CustomsInfo object with the given ID or reference.

func (*Client) GetCustomsInfoWithContext

func (c *Client) GetCustomsInfoWithContext(ctx context.Context, customsInfoID string) (out *CustomsInfo, err error)

GetCustomsInfoWithContext performs the same operation as GetCustomsInfo, but allows specifying a context that can interrupt the request.

func (*Client) GetCustomsItem

func (c *Client) GetCustomsItem(customsItemID string) (out *CustomsItem, err error)

GetCustomsItem returns the CustomsInfo object with the given ID or reference.

func (*Client) GetCustomsItemWithContext

func (c *Client) GetCustomsItemWithContext(ctx context.Context, customsItemID string) (out *CustomsItem, err error)

GetCustomsItemWithContext performs the same operation as GetCustomsItem, but allows specifying a context that can interrupt the request.

func (*Client) GetEndShipper

func (c *Client) GetEndShipper(endshipperID string) (out *Address, err error)

GetEndShipper retrieves a previously created endshipper by its ID.

func (*Client) GetEndShipperWithContext

func (c *Client) GetEndShipperWithContext(ctx context.Context, endshipperID string) (out *Address, err error)

GetEndShipperWithContext performs the same operation as GetEndShipper, but allows specifying a context that can interrupt the request.

func (*Client) GetEvent

func (c *Client) GetEvent(eventID string) (out *Event, err error)

GetEvent retrieves a previously-created event by its ID.

func (*Client) GetEventPayload

func (c *Client) GetEventPayload(eventID, payloadID string) (out *EventPayload, err error)

GetEventPayload retrieves a specific payload result of a previous webhook call.

func (*Client) GetEventPayloadWithContext

func (c *Client) GetEventPayloadWithContext(ctx context.Context, eventID, payloadID string) (out *EventPayload, err error)

GetEventPayloadWithContext performs the same operation as GetEventPayload, but allows specifying a context that can interrupt the request.

func (*Client) GetEventWithContext

func (c *Client) GetEventWithContext(ctx context.Context, eventID string) (out *Event, err error)

GetEventWithContext performs the same operation as GetEvent, but allows specifying a context that can interrupt the request.

func (*Client) GetInsurance

func (c *Client) GetInsurance(insuranceID string) (out *Insurance, err error)

GetInsurance returns the Insurance object with the given ID or reference.

func (*Client) GetInsuranceWithContext

func (c *Client) GetInsuranceWithContext(ctx context.Context, insuranceID string) (out *Insurance, err error)

GetInsuranceWithContext performs the same operation as GetInsurance, but allows specifying a context that can interrupt the request.

func (*Client) GetNextAddressPage

func (c *Client) GetNextAddressPage(collection *ListAddressResult) (out *ListAddressResult, err error)

GetNextAddressPage returns the next page of addresses

func (*Client) GetNextAddressPageWithContext

func (c *Client) GetNextAddressPageWithContext(ctx context.Context, collection *ListAddressResult) (out *ListAddressResult, err error)

GetNextAddressPageWithContext performs the same operation as GetNextAddressPage, but allows specifying a context that can interrupt the request.

func (*Client) GetNextAddressPageWithPageSize

func (c *Client) GetNextAddressPageWithPageSize(collection *ListAddressResult, pageSize int) (out *ListAddressResult, err error)

GetNextAddressPageWithPageSize returns the next page of addresses with a specific page size

func (*Client) GetNextAddressPageWithPageSizeWithContext

func (c *Client) GetNextAddressPageWithPageSizeWithContext(ctx context.Context, collection *ListAddressResult, pageSize int) (out *ListAddressResult, err error)

GetNextAddressPageWithPageSizeWithContext performs the same operation as GetNextAddressPageWithPageSize, but allows specifying a context that can interrupt the request.

func (*Client) GetNextChildUserPage added in v4.1.1

func (c *Client) GetNextChildUserPage(collection *ListChildUsersResult) (out *ListChildUsersResult, err error)

GetNextChildUserPage returns the next page of child users.

func (*Client) GetNextChildUserPageWithContext added in v4.1.1

func (c *Client) GetNextChildUserPageWithContext(ctx context.Context, collection *ListChildUsersResult) (out *ListChildUsersResult, err error)

GetNextChildUserPageWithContext performs the same operation as GetNextChildUserPage, but allows specifying a context that can interrupt the request.

func (*Client) GetNextChildUserPageWithPageSize added in v4.1.1

func (c *Client) GetNextChildUserPageWithPageSize(collection *ListChildUsersResult, pageSize int) (out *ListChildUsersResult, err error)

GetNextChildUserPageWithPageSize returns the next page of child users with a specific page size.

func (*Client) GetNextChildUserPageWithPageSizeWithContext added in v4.1.1

func (c *Client) GetNextChildUserPageWithPageSizeWithContext(ctx context.Context, collection *ListChildUsersResult, pageSize int) (out *ListChildUsersResult, err error)

GetNextChildUserPageWithPageSizeWithContext performs the same operation as GetNextChildUserPageWithPageSize, but allows specifying a context that can interrupt the request.

func (*Client) GetNextEventPage

func (c *Client) GetNextEventPage(collection *ListEventsResult) (out *ListEventsResult, err error)

GetNextEventPage returns the next page of events

func (*Client) GetNextEventPageWithContext

func (c *Client) GetNextEventPageWithContext(ctx context.Context, collection *ListEventsResult) (out *ListEventsResult, err error)

GetNextEventPageWithContext performs the same operation as GetNextEventPage, but allows specifying a context that can interrupt the request.

func (*Client) GetNextEventPageWithPageSize

func (c *Client) GetNextEventPageWithPageSize(collection *ListEventsResult, pageSize int) (out *ListEventsResult, err error)

GetNextEventPageWithPageSize returns the next page of events with a specific page size

func (*Client) GetNextEventPageWithPageSizeWithContext

func (c *Client) GetNextEventPageWithPageSizeWithContext(ctx context.Context, collection *ListEventsResult, pageSize int) (out *ListEventsResult, err error)

GetNextEventPageWithPageSizeWithContext performs the same operation as GetNextEventPageWithPageSize, but allows specifying a context that can interrupt the request.

func (*Client) GetNextInsurancePage

func (c *Client) GetNextInsurancePage(collection *ListInsurancesResult) (out *ListInsurancesResult, err error)

GetNextInsurancePage returns the next page of insurance records

func (*Client) GetNextInsurancePageWithContext

func (c *Client) GetNextInsurancePageWithContext(ctx context.Context, collection *ListInsurancesResult) (out *ListInsurancesResult, err error)

GetNextInsurancePageWithContext performs the same operation as GetNextInsurancePage, but allows specifying a context that can interrupt the request.

func (*Client) GetNextInsurancePageWithPageSize

func (c *Client) GetNextInsurancePageWithPageSize(collection *ListInsurancesResult, pageSize int) (out *ListInsurancesResult, err error)

GetNextInsurancePageWithPageSize returns the next page of insurance records with a specific page size

func (*Client) GetNextInsurancePageWithPageSizeWithContext

func (c *Client) GetNextInsurancePageWithPageSizeWithContext(ctx context.Context, collection *ListInsurancesResult, pageSize int) (out *ListInsurancesResult, err error)

GetNextInsurancePageWithPageSizeWithContext performs the same operation as GetNextInsurancePageWithPageSize, but allows specifying a context that can interrupt the request.

func (*Client) GetNextPickupPage

func (c *Client) GetNextPickupPage(collection *ListPickupResult) (out *ListPickupResult, err error)

GetNextPickupPage returns the next page of pickups

func (*Client) GetNextPickupPageWithContext

func (c *Client) GetNextPickupPageWithContext(ctx context.Context, collection *ListPickupResult) (out *ListPickupResult, err error)

GetNextPickupPageWithContext performs the same operation as GetNextPickupPage, but allows specifying a context that can interrupt the request.

func (*Client) GetNextPickupPageWithPageSize

func (c *Client) GetNextPickupPageWithPageSize(collection *ListPickupResult, pageSize int) (out *ListPickupResult, err error)

GetNextPickupPageWithPageSize returns the next page of pickups with a specific page size

func (*Client) GetNextPickupPageWithPageSizeWithContext

func (c *Client) GetNextPickupPageWithPageSizeWithContext(ctx context.Context, collection *ListPickupResult, pageSize int) (out *ListPickupResult, err error)

GetNextPickupPageWithPageSizeWithContext performs the same operation as GetNextPickupPageWithPageSize, but allows specifying a context that can interrupt the request.

func (*Client) GetNextReferralCustomerPage

func (c *Client) GetNextReferralCustomerPage(collection *ListReferralCustomersResult) (out *ListReferralCustomersResult, err error)

GetNextReferralCustomerPage returns the next page of referral customers

func (*Client) GetNextReferralCustomerPageWithContext

func (c *Client) GetNextReferralCustomerPageWithContext(ctx context.Context, collection *ListReferralCustomersResult) (out *ListReferralCustomersResult, err error)

GetNextReferralCustomerPageWithContext performs the same operation as GetNextReferralCustomerPage, but allows specifying a context that can interrupt the request.

func (*Client) GetNextReferralCustomerPageWithPageSize

func (c *Client) GetNextReferralCustomerPageWithPageSize(collection *ListReferralCustomersResult, pageSize int) (out *ListReferralCustomersResult, err error)

GetNextReferralCustomerPageWithPageSize returns the next page of referral customers with a specific page size

func (*Client) GetNextReferralCustomerPageWithPageSizeWithContext

func (c *Client) GetNextReferralCustomerPageWithPageSizeWithContext(ctx context.Context, collection *ListReferralCustomersResult, pageSize int) (out *ListReferralCustomersResult, err error)

GetNextReferralCustomerPageWithPageSizeWithContext performs the same operation as GetNextReferralCustomerPageWithPageSize, but allows specifying a context that can interrupt the request.

func (*Client) GetNextRefundPage

func (c *Client) GetNextRefundPage(collection *ListRefundResult) (out *ListRefundResult, err error)

GetNextRefundPage returns the next page of refunds

func (*Client) GetNextRefundPageWithContext

func (c *Client) GetNextRefundPageWithContext(ctx context.Context, collection *ListRefundResult) (out *ListRefundResult, err error)

GetNextRefundPageWithContext performs the same operation as GetNextRefundPage, but allows specifying a context that can interrupt the request.

func (*Client) GetNextRefundPageWithPageSize

func (c *Client) GetNextRefundPageWithPageSize(collection *ListRefundResult, pageSize int) (out *ListRefundResult, err error)

GetNextRefundPageWithPageSize returns the next page of refunds with a specific page size

func (*Client) GetNextRefundPageWithPageSizeWithContext

func (c *Client) GetNextRefundPageWithPageSizeWithContext(ctx context.Context, collection *ListRefundResult, pageSize int) (out *ListRefundResult, err error)

GetNextRefundPageWithPageSizeWithContext performs the same operation as GetNextRefundPageWithPageSize, but allows specifying a context that can interrupt the request.

func (*Client) GetNextReportPage

func (c *Client) GetNextReportPage(collection *ListReportsResult) (out *ListReportsResult, err error)

GetNextReportPage returns the next page of reports

func (*Client) GetNextReportPageWithContext

func (c *Client) GetNextReportPageWithContext(ctx context.Context, collection *ListReportsResult) (out *ListReportsResult, err error)

GetNextReportPageWithContext performs the same operation as GetNextReportPage, but allows specifying a context that can interrupt the request.

func (*Client) GetNextReportPageWithPageSize

func (c *Client) GetNextReportPageWithPageSize(collection *ListReportsResult, pageSize int) (out *ListReportsResult, err error)

GetNextReportPageWithPageSize returns the next page of reports with a specific page size

func (*Client) GetNextReportPageWithPageSizeWithContext

func (c *Client) GetNextReportPageWithPageSizeWithContext(ctx context.Context, collection *ListReportsResult, pageSize int) (out *ListReportsResult, err error)

GetNextReportPageWithPageSizeWithContext performs the same operation as GetNextReportPageWithPageSize, but allows specifying a context that can interrupt the request.

func (*Client) GetNextScanFormPage

func (c *Client) GetNextScanFormPage(collection *ListScanFormsResult) (out *ListScanFormsResult, err error)

GetNextScanFormPage returns the next page of scan forms

func (*Client) GetNextScanFormPageWithContext

func (c *Client) GetNextScanFormPageWithContext(ctx context.Context, collection *ListScanFormsResult) (out *ListScanFormsResult, err error)

GetNextScanFormPageWithContext performs the same operation as GetNextScanFormPage, but allows specifying a context that can interrupt the request.

func (*Client) GetNextScanFormPageWithPageSize

func (c *Client) GetNextScanFormPageWithPageSize(collection *ListScanFormsResult, pageSize int) (out *ListScanFormsResult, err error)

GetNextScanFormPageWithPageSize returns the next page of scan forms with a specific page size

func (*Client) GetNextScanFormPageWithPageSizeWithContext

func (c *Client) GetNextScanFormPageWithPageSizeWithContext(ctx context.Context, collection *ListScanFormsResult, pageSize int) (out *ListScanFormsResult, err error)

GetNextScanFormPageWithPageSizeWithContext performs the same operation as GetNextScanFormPageWithPageSize, but allows specifying a context that can interrupt the request.

func (*Client) GetNextShipmentPage

func (c *Client) GetNextShipmentPage(collection *ListShipmentsResult) (out *ListShipmentsResult, err error)

GetNextShipmentPage returns the next page of shipments

func (*Client) GetNextShipmentPageWithContext

func (c *Client) GetNextShipmentPageWithContext(ctx context.Context, collection *ListShipmentsResult) (out *ListShipmentsResult, err error)

GetNextShipmentPageWithContext performs the same operation as GetNextShipmentPage, but allows specifying a context that can interrupt the request.

func (*Client) GetNextShipmentPageWithPageSize

func (c *Client) GetNextShipmentPageWithPageSize(collection *ListShipmentsResult, pageSize int) (out *ListShipmentsResult, err error)

GetNextShipmentPageWithPageSize returns the next page of shipments with a specific page size

func (*Client) GetNextShipmentPageWithPageSizeWithContext

func (c *Client) GetNextShipmentPageWithPageSizeWithContext(ctx context.Context, collection *ListShipmentsResult, pageSize int) (out *ListShipmentsResult, err error)

GetNextShipmentPageWithPageSizeWithContext performs the same operation as GetNextShipmentPageWithPageSize, but allows specifying a context that can interrupt the request.

func (*Client) GetNextTrackerPage

func (c *Client) GetNextTrackerPage(collection *ListTrackersResult) (out *ListTrackersResult, err error)

GetNextTrackerPage returns the next page of trackers

func (*Client) GetNextTrackerPageWithContext

func (c *Client) GetNextTrackerPageWithContext(ctx context.Context, collection *ListTrackersResult) (out *ListTrackersResult, err error)

GetNextTrackerPageWithContext performs the same operation as GetNextTrackerPage, but allows specifying a context that can interrupt the request.

func (*Client) GetNextTrackerPageWithPageSize

func (c *Client) GetNextTrackerPageWithPageSize(collection *ListTrackersResult, pageSize int) (out *ListTrackersResult, err error)

GetNextTrackerPageWithPageSize returns the next page of trackers with a specific page size

func (*Client) GetNextTrackerPageWithPageSizeWithContext

func (c *Client) GetNextTrackerPageWithPageSizeWithContext(ctx context.Context, collection *ListTrackersResult, pageSize int) (out *ListTrackersResult, err error)

GetNextTrackerPageWithPageSizeWithContext performs the same operation as GetNextTrackerPageWithPageSize, but allows specifying a context that can interrupt the request.

func (*Client) GetOrder

func (c *Client) GetOrder(orderID string) (out *Order, err error)

GetOrder retrieves an existing Order object by ID.

func (*Client) GetOrderRates

func (c *Client) GetOrderRates(orderID string) (out *Order, err error)

GetOrderRates refreshes rates for an Order.

func (*Client) GetOrderRatesWithContext

func (c *Client) GetOrderRatesWithContext(ctx context.Context, orderID string) (out *Order, err error)

GetOrderRatesWithContext performs the same operation as GetOrderRates, but allows specifying a context that can interrupt the request.

func (*Client) GetOrderWithContext

func (c *Client) GetOrderWithContext(ctx context.Context, orderID string) (out *Order, err error)

GetOrderWithContext performs the same operation as GetOrder, but allows specifying a context that can interrupt the request.

func (*Client) GetParcel

func (c *Client) GetParcel(parcelID string) (out *Parcel, err error)

GetParcel retrieves an existing Parcel object by ID.

func (*Client) GetParcelWithContext

func (c *Client) GetParcelWithContext(ctx context.Context, parcelID string) (out *Parcel, err error)

GetParcelWithContext performs the same operation as GetParcel, but allows specifying a context that can interrupt the request.

func (*Client) GetPaymentEndpointByPrimaryOrSecondary

func (c *Client) GetPaymentEndpointByPrimaryOrSecondary(primaryOrSecondary PaymentMethodPriority) (out string)

GetPaymentEndpointByPrimaryOrSecondary gets the payment priority based on primaryOrSecondary parameter.

func (*Client) GetPickup

func (c *Client) GetPickup(pickupID string) (out *Pickup, err error)

GetPickup retrieves an existing Pickup object by ID.

func (*Client) GetPickupWithContext

func (c *Client) GetPickupWithContext(ctx context.Context, pickupID string) (out *Pickup, err error)

GetPickupWithContext performs the same operation as GetPickup, but allows specifying a context that can interrupt the request.

func (*Client) GetRate

func (c *Client) GetRate(rateID string) (out *Rate, err error)

GetRate retrieves a previously-created rate by its ID.

func (*Client) GetRateWithContext

func (c *Client) GetRateWithContext(ctx context.Context, rateID string) (out *Rate, err error)

GetRateWithContext performs the same operation as GetRate, but allows specifying a context that can interrupt the request.

func (*Client) GetRefund

func (c *Client) GetRefund(refundID string) (out *Refund, err error)

retrieves a previously-created Refund by its ID.

func (*Client) GetRefundWithContext

func (c *Client) GetRefundWithContext(ctx context.Context, refundID string) (out *Refund, err error)

GetRefundWithContext performs the same operation as GetRefund, but allows specifying a context that can interrupt the request.

func (*Client) GetReport

func (c *Client) GetReport(typ, reportID string) (out *Report, err error)

GetReport fetches a Report object by report type and ID.

func (*Client) GetReportWithContext

func (c *Client) GetReportWithContext(ctx context.Context, typ, reportID string) (out *Report, err error)

GetReportWithContext performs the same operation as GetReport, but allows specifying a context that can interrupt the request.

func (*Client) GetScanForm

func (c *Client) GetScanForm(scanFormID string) (out *ScanForm, err error)

GetScanForm retrieves a ScanForm object by ID.

func (*Client) GetScanFormWithContext

func (c *Client) GetScanFormWithContext(ctx context.Context, scanFormID string) (out *ScanForm, err error)

GetScanFormWithContext performs the same operation as GetScanForm, but allows specifying a context that can interrupt the request.

func (*Client) GetShipment

func (c *Client) GetShipment(shipmentID string) (out *Shipment, err error)

GetShipment retrieves a Shipment object by ID.

func (*Client) GetShipmentEstimatedDeliveryDate

func (c *Client) GetShipmentEstimatedDeliveryDate(shipmentID, plannedShipDate string) (out []*EstimatedDeliveryDate, err error)

GetShipmentEstimatedDeliveryDate retrieves the estimated delivery date of each Rate via SmartRate.

func (*Client) GetShipmentEstimatedDeliveryDateWithContext

func (c *Client) GetShipmentEstimatedDeliveryDateWithContext(ctx context.Context, shipmentID string, plannedShipDate string) (out []*EstimatedDeliveryDate, err error)

GetShipmentEstimatedDeliveryDateWithContext performs the same operation as GetShipmentEstimatedDeliveryDate, but allows specifying a context that can interrupt the request.

func (*Client) GetShipmentLabel

func (c *Client) GetShipmentLabel(shipmentID, format string) (out *Shipment, err error)

GetShipmentLabel enables retrieving the label for a shipment in a different format. The PostageLabel field in the returned Shipment object will reflect the new format.

func (*Client) GetShipmentLabelWithContext

func (c *Client) GetShipmentLabelWithContext(ctx context.Context, shipmentID, format string) (out *Shipment, err error)

GetShipmentLabelWithContext performs the same operation as GetShipmentLabel, but allows specifying a context that can interrupt the request.

func (*Client) GetShipmentSmartrates

func (c *Client) GetShipmentSmartrates(shipmentID string) (out []*SmartRate, err error)

GetShipmentSmartrates fetches the available smartrates for a shipment.

func (*Client) GetShipmentSmartratesWithContext

func (c *Client) GetShipmentSmartratesWithContext(ctx context.Context, shipmentID string) (out []*SmartRate, err error)

GetShipmentSmartratesWithContext performs the same operation as GetShipmentRates, but allows specifying a context that can interrupt the request.

func (*Client) GetShipmentWithContext

func (c *Client) GetShipmentWithContext(ctx context.Context, shipmentID string) (out *Shipment, err error)

GetShipmentWithContext performs the same operation as GetShipment, but allows specifying a context that can interrupt the request.

func (*Client) GetTracker

func (c *Client) GetTracker(trackerID string) (out *Tracker, err error)

GetTracker retrieves a Tracker object by ID.

func (*Client) GetTrackerWithContext

func (c *Client) GetTrackerWithContext(ctx context.Context, trackerID string) (out *Tracker, err error)

GetTrackerWithContext performs the same operation as GetTracker, but allows specifying a context that can interrupt the request.

func (*Client) GetUser

func (c *Client) GetUser(userID string) (out *User, err error)

GetUser retrieves a User object by ID.

func (*Client) GetUserWithContext

func (c *Client) GetUserWithContext(ctx context.Context, userID string) (out *User, err error)

GetUserWithContext performs the same operation as GetUser, but allows specifying a context that can interrupt the request.

func (*Client) GetWebhook

func (c *Client) GetWebhook(webhookID string) (out *Webhook, err error)

GetWebhook retrieves a Webhook object with the given ID.

func (*Client) GetWebhookWithContext

func (c *Client) GetWebhookWithContext(ctx context.Context, webhookID string) (out *Webhook, err error)

GetWebhookWithContext performs the same operation as GetWebhook, but allows specifying a context that can interrupt the request.

func (*Client) InsureShipment

func (c *Client) InsureShipment(shipmentID, amount string) (out *Shipment, err error)

InsureShipment purchases insurance for the shipment. Insurance should be purchased after purchasing the shipment, but before it has been processed by the carrier. On success, the purchased insurance will be reflected in the returned Shipment object's Insurance field.

func (*Client) InsureShipmentWithContext

func (c *Client) InsureShipmentWithContext(ctx context.Context, shipmentID, amount string) (out *Shipment, err error)

InsureShipmentWithContext performs the same operation as InsureShipment, but allows specifying a context that can interrupt the request.

func (*Client) ListAddresses

func (c *Client) ListAddresses(opts *ListOptions) (out *ListAddressResult, err error)

ListAddresses provides a paginated result of Address objects.

func (*Client) ListAddressesWithContext

func (c *Client) ListAddressesWithContext(ctx context.Context, opts *ListOptions) (out *ListAddressResult, err error)

ListAddressesWithContext performs the same operation as ListAddresses, but allows specifying a context that can interrupt the request.

func (*Client) ListBatches

func (c *Client) ListBatches(opts *ListOptions) (out *ListBatchesResult, err error)

ListBatches provides a paginated result of Insurance objects.

func (*Client) ListBatchesWithContext

func (c *Client) ListBatchesWithContext(ctx context.Context, opts *ListOptions) (out *ListBatchesResult, err error)

ListBatchesWithContext performs the same operation as ListBatches, but allows specifying a context that can interrupt the request.

func (*Client) ListCarrierAccounts

func (c *Client) ListCarrierAccounts() (out []*CarrierAccount, err error)

ListCarrierAccounts returns a list of all carrier accounts available to the authenticated account.

func (*Client) ListCarrierAccountsWithContext

func (c *Client) ListCarrierAccountsWithContext(ctx context.Context) (out []*CarrierAccount, err error)

ListCarrierAccountsWithContext performs the same operation as ListCarrierAccounts, but allows specifying a context that can interrupt the request.

func (*Client) ListChildUsers added in v4.1.1

func (c *Client) ListChildUsers(opts *ListOptions) (out *ListChildUsersResult, err error)

ListChildUsers retrieves a list of child users.

func (*Client) ListChildUsersWithContext added in v4.1.1

func (c *Client) ListChildUsersWithContext(ctx context.Context, opts *ListOptions) (out *ListChildUsersResult, err error)

ListChildUsersWithContext performs the same operation as ListChildUsers, but allows specifying a context that can interrupt the request.

func (*Client) ListEndShippers

func (c *Client) ListEndShippers(opts *ListOptions) (out *ListEndShipperResult, err error)

ListEndShippers provides a paginated result of EndShipper objects.

func (*Client) ListEndShippersWithContext

func (c *Client) ListEndShippersWithContext(ctx context.Context, opts *ListOptions) (out *ListEndShipperResult, err error)

ListEndShippersWithContext performs the same operation as ListEndShippers, but allows specifying a context that can interrupt the request.

func (*Client) ListEventPayloads

func (c *Client) ListEventPayloads(eventID string) (out []*EventPayload, err error)

ListEventPayloads retrieves the payload results of a previous webhook call.

func (*Client) ListEventPayloadsWithContext

func (c *Client) ListEventPayloadsWithContext(ctx context.Context, eventID string) (out []*EventPayload, err error)

ListEventPayloadsWithContext performs the same operation as GetEventPayload, but allows specifying a context that can interrupt the request.

func (*Client) ListEvents

func (c *Client) ListEvents(opts *ListOptions) (out *ListEventsResult, err error)

ListEvents provides a paginated result of Event objects.

func (*Client) ListEventsWithContext

func (c *Client) ListEventsWithContext(ctx context.Context, opts *ListOptions) (out *ListEventsResult, err error)

ListEventsWithContext performs the same operation as ListEvents, but allows specifying a context that can interrupt the request.

func (*Client) ListInsurances

func (c *Client) ListInsurances(opts *ListOptions) (out *ListInsurancesResult, err error)

ListInsurances provides a paginated result of Insurance objects.

func (*Client) ListInsurancesWithContext

func (c *Client) ListInsurancesWithContext(ctx context.Context, opts *ListOptions) (out *ListInsurancesResult, err error)

ListInsurancesWithContext performs the same operation as ListInsurances, but allows specifying a context that can interrupt the request.

func (*Client) ListPickups

func (c *Client) ListPickups(opts *ListOptions) (out *ListPickupResult, err error)

ListPickups provides a paginated result of Pickup objects.

func (*Client) ListPickupsWithContext

func (c *Client) ListPickupsWithContext(ctx context.Context, opts *ListOptions) (out *ListPickupResult, err error)

ListPickupsWithContext performs the same operation as ListPickups, but allows specifying a context that can interrupt the request.

func (*Client) ListReferralCustomers

func (c *Client) ListReferralCustomers(opts *ListOptions) (out *ListReferralCustomersResult, err error)

ListReferralCustomers provides a paginated result of ReferralCustomer objects.

func (*Client) ListReferralCustomersWithContext

func (c *Client) ListReferralCustomersWithContext(ctx context.Context, opts *ListOptions) (out *ListReferralCustomersResult, err error)

ListReferralCustomersWithContext performs the same operation as ListReferralCustomers, but allows specifying a context that can interrupt the request.

func (*Client) ListRefunds

func (c *Client) ListRefunds(opts *ListOptions) (out *ListRefundResult, err error)

ListRefunds provides a paginated result of Refund objects.

func (*Client) ListRefundsWithContext

func (c *Client) ListRefundsWithContext(ctx context.Context, opts *ListOptions) (out *ListRefundResult, err error)

ListRefundsWithContext performs the same operation as ListRefunds, but allows specifying a context that can interrupt the request.

func (*Client) ListReports

func (c *Client) ListReports(typ string, opts *ListOptions) (out *ListReportsResult, err error)

ListReports provides a paginated result of Report objects of the given type.

func (*Client) ListReportsWithContext

func (c *Client) ListReportsWithContext(ctx context.Context, typ string, opts *ListOptions) (out *ListReportsResult, err error)

ListReportsWithContext performs the same operation as ListReports, but allows specifying a context that can interrupt the request.

func (*Client) ListScanForms

func (c *Client) ListScanForms(opts *ListOptions) (out *ListScanFormsResult, err error)

ListScanForms provides a paginated result of ScanForm objects.

func (*Client) ListScanFormsWithContext

func (c *Client) ListScanFormsWithContext(ctx context.Context, opts *ListOptions) (out *ListScanFormsResult, err error)

ListScanFormsWithContext performs the same operation as ListScanForms, but allows specifying a context that can interrupt the request.

func (*Client) ListShipments

func (c *Client) ListShipments(opts *ListShipmentsOptions) (out *ListShipmentsResult, err error)

ListShipments provides a paginated result of Shipment objects.

func (*Client) ListShipmentsWithContext

func (c *Client) ListShipmentsWithContext(ctx context.Context, opts *ListShipmentsOptions) (out *ListShipmentsResult, err error)

ListShipmentsWithContext performs the same operation as ListShipments, but allows specifying a context that can interrupt the request.

func (*Client) ListTrackers

func (c *Client) ListTrackers(opts *ListTrackersOptions) (out *ListTrackersResult, err error)

ListTrackers provides a paginated result of Tracker objects.

func (*Client) ListTrackersWithContext

func (c *Client) ListTrackersWithContext(ctx context.Context, opts *ListTrackersOptions) (out *ListTrackersResult, err error)

ListTrackersWithContext performs the same operation as ListTrackers, but allows specifying a context that can interrupt the request.

func (*Client) ListWebhooks

func (c *Client) ListWebhooks() (out []*Webhook, err error)

ListWebhooks returns all webhooks associated with the EasyPost account.

func (*Client) ListWebhooksWithContext

func (c *Client) ListWebhooksWithContext(ctx context.Context) (out []*Webhook, err error)

ListWebhooksWithContext performs the same operation as ListWebhooksWithContext, but allows specifying a context that can interrupt the request.

func (*Client) LowestOrderRate

func (c *Client) LowestOrderRate(order *Order) (out Rate, err error)

LowestOrderRate gets the lowest rate of an order

func (*Client) LowestOrderRateWithCarrier

func (c *Client) LowestOrderRateWithCarrier(order *Order, carriers []string) (out Rate, err error)

LowestOrderRateWithCarrier performs the same operation as LowestOrderRate, but allows specifying a list of carriers for the lowest rate

func (*Client) LowestOrderRateWithCarrierAndService

func (c *Client) LowestOrderRateWithCarrierAndService(order *Order, carriers []string, services []string) (out Rate, err error)

LowestOrderRateWithCarrierAndService performs the same operation as LowestOrderRate, but allows specifying a list of carriers and service for the lowest rate

func (*Client) LowestPickupRate

func (c *Client) LowestPickupRate(pickup *Pickup) (out PickupRate, err error)

LowestPickupRate gets the lowest rate of a pickup

func (*Client) LowestPickupRateWithCarrier

func (c *Client) LowestPickupRateWithCarrier(pickup *Pickup, carriers []string) (out PickupRate, err error)

LowestPickupRateWithCarrier performs the same operation as LowestPickupRate, but allows specifying a list of carriers for the lowest rate

func (*Client) LowestPickupRateWithCarrierAndService

func (c *Client) LowestPickupRateWithCarrierAndService(pickup *Pickup, carriers []string, services []string) (out PickupRate, err error)

LowestPickupRateWithCarrierAndService performs the same operation as LowestPickupRate, but allows specifying a list of carriers and service for the lowest rate

func (*Client) LowestShipmentRate

func (c *Client) LowestShipmentRate(shipment *Shipment) (out Rate, err error)

LowestShipmentRate gets the lowest rate of a shipment

func (*Client) LowestShipmentRateWithCarrier

func (c *Client) LowestShipmentRateWithCarrier(shipment *Shipment, carriers []string) (out Rate, err error)

LowestShipmentRateWithCarrier performs the same operation as LowestShipmentRate, but allows specifying a list of carriers for the lowest rate

func (*Client) LowestShipmentRateWithCarrierAndService

func (c *Client) LowestShipmentRateWithCarrierAndService(shipment *Shipment, carriers []string, services []string) (out Rate, err error)

LowestShipmentRateWithCarrierAndService performs the same operation as LowestShipmentRate, but allows specifying a list of carriers and service for the lowest rate

func (*Client) LowestSmartrate

func (c *Client) LowestSmartrate(shipment *Shipment, deliveryDays int, deliveryAccuracy string) (out SmartRate, err error)

LowestSmartrate gets the lowest smartrate of a shipment with the specified delivery days and accuracy

func (*Client) LowestStatelessRate

func (c *Client) LowestStatelessRate(rates []*StatelessRate) (out StatelessRate, err error)

LowestStatelessRate gets the lowest stateless rate from a list of stateless rates

func (*Client) LowestStatelessRateWithCarrier

func (c *Client) LowestStatelessRateWithCarrier(rates []*StatelessRate, carriers []string) (out StatelessRate, err error)

LowestStatelessRateWithCarrier performs the same operation as LowestStatelessRate, but allows specifying a list of carriers for the lowest rate

func (*Client) LowestStatelessRateWithCarrierAndService

func (c *Client) LowestStatelessRateWithCarrierAndService(rates []*StatelessRate, carriers []string, services []string) (out StatelessRate, err error)

LowestStatelessRateWithCarrierAndService performs the same operation as LowestStatelessRate, but allows specifying a list of carriers and service for the lowest rate

func (*Client) RefundInsurance added in v4.2.0

func (c *Client) RefundInsurance(insuranceID string) (out *Insurance, err error)

RefundInsurance refunds the Insurance object with the given ID.

func (*Client) RefundInsuranceWithContext added in v4.2.0

func (c *Client) RefundInsuranceWithContext(ctx context.Context, insuranceID string) (out *Insurance, err error)

RefundInsuranceWithContext performs the same operation as RefundInsurance, but allows specifying a context that can interrupt the request.

func (*Client) RefundShipment

func (c *Client) RefundShipment(shipmentID string) (out *Shipment, err error)

RefundShipment requests a refund from the carrier.

func (*Client) RefundShipmentWithContext

func (c *Client) RefundShipmentWithContext(ctx context.Context, shipmentID string) (out *Shipment, err error)

RefundShipmentWithContext performs the same operation as RefundShipment, but allows specifying a context that can interrupt the request.

func (*Client) RemoveShipmentsFromBatch

func (c *Client) RemoveShipmentsFromBatch(batchID string, shipments ...*Shipment) (out *Batch, err error)

RemoveShipmentsFromBatch removes shipments from an existing batch, and returns the updated batch object.

func (*Client) RemoveShipmentsFromBatchWithContext

func (c *Client) RemoveShipmentsFromBatchWithContext(ctx context.Context, batchID string, shipments ...*Shipment) (out *Batch, err error)

RemoveShipmentsFromBatchWithContext performs the same operation as RemoveShipmentsFromBatch, but allows specifying a context that can interrupt the request.

func (*Client) RerateShipment

func (c *Client) RerateShipment(shipmentID string) (out []*Rate, err error)

RerateShipment fetches the available rates for a shipment with the current rates.

func (*Client) RerateShipmentWithContext

func (c *Client) RerateShipmentWithContext(ctx context.Context, shipmentID string) (out []*Rate, err error)

RerateShipmentWithContext performs the same operation as RerateShipment, but allows specifying a context that can interrupt the request.

func (*Client) RetrieveMe

func (c *Client) RetrieveMe() (out *User, err error)

RetrieveMe retrieves the current user.

func (*Client) RetrieveMeWithContext

func (c *Client) RetrieveMeWithContext(ctx context.Context) (out *User, err error)

RetrieveMeWithContext performs the same operation as RetrieveMe, but allows specifying a context that can interrupt the request.

func (*Client) RetrievePaymentMethods

func (c *Client) RetrievePaymentMethods() (out *PaymentMethod, err error)

RetrievePaymentMethods returns the payment methods associated with the current user.

func (*Client) RetrievePaymentMethodsWithContext

func (c *Client) RetrievePaymentMethodsWithContext(ctx context.Context) (out *PaymentMethod, err error)

RetrievePaymentMethodsWithContext performs the same as RetrievePaymentMethods, but allows specifying a context that can interrupt the request.

func (*Client) UpdateBrand

func (c *Client) UpdateBrand(params map[string]interface{}, userID string) (out *Brand, err error)

UpdateBrand updates the user brand.

func (*Client) UpdateBrandWithContext

func (c *Client) UpdateBrandWithContext(ctx context.Context, params map[string]interface{}, userID string) (out *Brand, err error)

UpdateBrandWithContext performs the same operation as UpdateBrand, but allows specifying a context that can interrupt the request.

func (*Client) UpdateCarrierAccount

func (c *Client) UpdateCarrierAccount(in *CarrierAccount) (out *CarrierAccount, err error)

UpdateCarrierAccount updates the carrier account. Only the Description, Reference, Credentials and TestCredentials attributes can be updated.

c := easypost.New(MyEasyPostAPIKey)
out, err := c.UpdateCarrierAccount(
	&easypost.CarrierAccount{
		ID: "ca_1001",
		Description: "FL Location UPS Account",
		Credentials: map[string]string{
			"account_number": "B2B2B2",
		},
	},
)

func (*Client) UpdateCarrierAccountWithContext

func (c *Client) UpdateCarrierAccountWithContext(ctx context.Context, in *CarrierAccount) (out *CarrierAccount, err error)

UpdateCarrierAccountWithContext performs the same operation as UpdateCarrierAccount, but allows specifying a context that can interrupt the request.

func (*Client) UpdateEndShippers

func (c *Client) UpdateEndShippers(in *Address) (out *Address, err error)

UpdateEndShippers updates previously created endshipper

func (*Client) UpdateEndShippersWithContext

func (c *Client) UpdateEndShippersWithContext(ctx context.Context, in *Address) (out *Address, err error)

UpdateEndShippersWithContext performs the same operation as UpdateEndShippers, but allows specifying a context that can interrupt the request.

func (*Client) UpdateReferralCustomerEmail

func (c *Client) UpdateReferralCustomerEmail(userId string, email string) (out *ReferralCustomer, err error)

UpdateReferralCustomerEmail updates a ReferralCustomer's email address

func (*Client) UpdateReferralCustomerEmailWithContext

func (c *Client) UpdateReferralCustomerEmailWithContext(ctx context.Context, userId string, email string) (out *ReferralCustomer, err error)

UpdateReferralCustomerEmailWithContext performs the same operation as UpdateReferralCustomerEmail, but allows specifying a context that can interrupt the request.

func (*Client) UpdateUser

func (c *Client) UpdateUser(in *UserOptions) (out *User, err error)

UpdateUser updates a user with the attributes given in the UpdateUserOptions parameter. If the ID field of UpdateUserOptions is empty, the operation is done on the current user. All other fields are updated if they are non-nil.

func (*Client) UpdateUserWithContext

func (c *Client) UpdateUserWithContext(ctx context.Context, in *UserOptions) (out *User, err error)

UpdateUserWithContext performs the same operation as UpdateUser, but allows specifying a context that can interrupt the request.

func (*Client) UpdateWebhook

func (c *Client) UpdateWebhook(webhookID string, data *CreateUpdateWebhookOptions) (out *Webhook, err error)

UpdateWebhook updates a webhook. Automatically re-enables webhook if it is disabled.

func (*Client) UpdateWebhookWithContext

func (c *Client) UpdateWebhookWithContext(ctx context.Context,
	webhookID string, data *CreateUpdateWebhookOptions) (out *Webhook, err error)

UpdateWebhookWithContext performs the same operation as UpdateWebhook, but allows specifying a context that can interrupt the request.

func (*Client) ValidateWebhook

func (c *Client) ValidateWebhook(eventBody []byte, headers map[string]interface{}, webhookSecret string) (out *Event, err error)

ValidateWebhook validates a webhook by comparing the HMAC signature header sent from EasyPost to your shared secret. If the signatures do not match, an error will be raised signifying the webhook either did not originate from EasyPost or the secrets do not match. If the signatures do match, the `event_body` will be returned as JSON.

func (*Client) ValidateWebhookWithContext

func (c *Client) ValidateWebhookWithContext(ctx context.Context, eventBody []byte, headers map[string]interface{}, webhookSecret string) (out *Event, err error)

ValidateWebhookWithContext performs the same operation as ValidateWebhook, but allows specifying a context that can interrupt the request.

func (*Client) VerifyAddress

func (c *Client) VerifyAddress(addressID string) (out *Address, err error)

VerifyAddress performs address verification.

func (*Client) VerifyAddressWithContext

func (c *Client) VerifyAddressWithContext(ctx context.Context, addressID string) (out *Address, err error)

VerifyAddressWithContext performs the same operation as VerifyAddress, but allows specifying a context that can interrupt the request.

type ConnectionError

type ConnectionError struct {
	APIError
}

ConnectionError is raised when the API returns a 0 status code.

type CreateAddressOptions

type CreateAddressOptions struct {
	// TODO: These should be booleans, not strings, like the other libs
	Verify       []string `json:"verify,omitempty"`
	VerifyStrict []string `json:"verify_strict,omitempty"`
}

CreateAddressOptions is used to specify verification options for address creation.

type CreateTrackerOptions

type CreateTrackerOptions struct {
	TrackingCode   string
	Carrier        string
	Amount         string
	CarrierAccount string
	IsReturn       bool
}

CreateTrackerOptions specifies options for creating a new tracker.

type CreateUpdateWebhookOptions

type CreateUpdateWebhookOptions struct {
	URL           string `json:"url,omitempty"`
	WebhookSecret string `json:"webhook_secret,omitempty"`
}

CreateUpdateWebhookOptions is used to specify parameters for creating and updating EasyPost webhooks.

type CreditCardOptions

type CreditCardOptions struct {
	Number   string `json:"number,omitempty"`
	ExpMonth string `json:"expiration_month,omitempty"`
	ExpYear  string `json:"expiration_year,omitempty"`
	Cvc      string `json:"cvc,omitempty"`
}

CreditCardOptions specifies options for creating or updating a credit card.

type CustomsInfo

type CustomsInfo struct {
	ID                  string         `json:"id,omitempty"`
	Object              string         `json:"object,omitempty"`
	CreatedAt           *DateTime      `json:"created_at,omitempty"`
	UpdatedAt           *DateTime      `json:"updated_at,omitempty"`
	EELPFC              string         `json:"eel_pfc,omitempty"`
	ContentsType        string         `json:"contents_type,omitempty"`
	ContentsExplanation string         `json:"contents_explanation,omitempty"`
	CustomsCertify      bool           `json:"customs_certify,omitempty"`
	CustomsSigner       string         `json:"customs_signer,omitempty"`
	NonDeliveryOption   string         `json:"non_delivery_option,omitempty"`
	RestrictionType     string         `json:"restriction_type,omitempty"`
	CustomsItems        []*CustomsItem `json:"customs_items,omitempty"`
	Declaration         string         `json:"declaration,omitempty"`
}

CustomsInfo objects contain CustomsItem objects and all necessary information for the generation of customs forms required for international shipping.

type CustomsItem

type CustomsItem struct {
	ID             string    `json:"id,omitempty"`
	Object         string    `json:"object,omitempty"`
	CreatedAt      *DateTime `json:"created_at,omitempty"`
	UpdatedAt      *DateTime `json:"updated_at,omitempty"`
	Description    string    `json:"description,omitempty"`
	Quantity       float64   `json:"quantity,omitempty"`
	Value          float64   `json:"value,omitempty,string"`
	Weight         float64   `json:"weight,omitempty"`
	HSTariffNumber string    `json:"hs_tariff_number,omitempty"`
	Code           string    `json:"code,omitempty"`
	OriginCountry  string    `json:"origin_country,omitempty"`
	Currency       string    `json:"currency,omitempty"`
}

A CustomsItem object describes goods for international shipment.

type DateTime

type DateTime time.Time

func DateTimeFromTime

func DateTimeFromTime(t time.Time) DateTime

DateTimeFromTime construct a DateTime from a time.Time

func NewDateTime

func NewDateTime(year int, month time.Month, day, hour, min, sec, nsec int, loc *time.Location) DateTime

NewDateTime returns the DateTime corresponding to

yyyy-mm-dd hh:mm:ss + nsec nanoseconds

in the appropriate zone for that time in the given location.

The month, day, hour, min, sec, and nsec values may be outside their usual ranges and will be normalized during the conversion. For example, October 32 converts to November 1.

A daylight savings time transition skips or repeats times. For example, in the United States, March 13, 2011 2:15am never occurred, while November 6, 2011 1:15am occurred twice. In such cases, the choice of time zone, and therefore the time, is not well-defined. NewDateTime returns a time that is correct in one of the two zones involved in the transition, but it does not guarantee which.

NewDateTime panics if loc is nil.

func (*DateTime) AsTime

func (dt *DateTime) AsTime() time.Time

func (*DateTime) EncodeValues added in v4.1.1

func (dt *DateTime) EncodeValues(key string, values *url.Values) error

EncodeValues implements the query.Encoder interface of how to encode the DateTime for a URL query string

func (*DateTime) MarshalJSON

func (dt *DateTime) MarshalJSON() ([]byte, error)

func (*DateTime) String

func (dt *DateTime) String() string

func (*DateTime) UnmarshalJSON

func (dt *DateTime) UnmarshalJSON(b []byte) (err error)

type EasyPostTimeInTransitData

type EasyPostTimeInTransitData struct {
	DaysInTransit                 TimeInTransit `json:"days_in_transit,omitempty"`
	EasyPostEstimatedDeliveryDate string        `json:"easypost_estimated_delivery_date,omitempty"`
	PlannedShipDate               string        `json:"planned_ship_date,omitempty"`
}

type Error

type Error struct {
	// Code is a machine-readable code of the problem encountered.
	Code string `json:"code,omitempty"`
	// Errors may be provided if there are multiple errors, for example if
	// multiple fields have invalid values.
	Errors []*Error `json:"errors,omitempty"`
	// Field may be provided when the error relates to a specific field.
	Field string `json:"field,omitempty"`
	// Message is a human-readable description of the problem encountered.
	Message interface{} `json:"message,omitempty"`
	// Suggestion may be provided if the API can provide a suggestion to fix
	// the error.
	Suggestion string `json:"suggestion,omitempty"`
}

Error represents an Error object returned by the EasyPost API.

These are typically informational about why a request failed (server-side validation issues, missing data, etc.).

This is different from the LibraryError class, which represents exceptions in the EasyPost library, such as bad HTTP status codes or local validation issues.

func (*Error) Error

func (e *Error) Error() string

Error provides a pretty printed string of an Error object based on present data.

func (*Error) UnmarshalJSON

func (e *Error) UnmarshalJSON(data []byte) error

type EstimatedDeliveryDate

type EstimatedDeliveryDate struct {
	EasyPostTimeInTransitData EasyPostTimeInTransitData `json:"easypost_time_in_transit_data,omitempty"`
	Rate                      SmartRate                 `json:"rate,omitempty"`
}

type Event

type Event struct {
	ID                 string                 `json:"id,omitempty"`
	UserID             string                 `json:"user_id,omitempty"`
	Object             string                 `json:"object,omitempty"`
	Mode               string                 `json:"mode,omitempty"`
	CreatedAt          *DateTime              `json:"created_at,omitempty"`
	UpdatedAt          *DateTime              `json:"updated_at,omitempty"`
	Description        string                 `json:"description,omitempty"`
	PreviousAttributes map[string]interface{} `json:"previous_attributes,omitempty"`
	// Result will be populated with the relevant object type, i.e.
	// *Batch, *Insurance, *PaymentLog, *Refund, *Report, *Tracker or *ScanForm.
	// It will be nil if no 'result' field is present, which is the case for
	// the ListEvents and GetEvents methods. The RequestBody field of the
	// EventPayload type will generally be an instance of *Event with this field
	// present. Having the field here also enables re-using this type to
	// implement a webhook handler.
	Result        interface{} `json:"result,omitempty"`
	Status        string      `json:"status,omitempty"`
	PendingURLs   []string    `json:"pending_urls,omitempty"`
	CompletedURLs []string    `json:"completed_urls,omitempty"`
}

Event objects contain details about changes to EasyPost objects

func (*Event) UnmarshalJSON

func (e *Event) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON will attempt to convert an event response to an *Event type, but it may be set to a default type if decoding to an object fails.

type EventPayload

type EventPayload struct {
	ID             string            `json:"id,omitempty"`
	Object         string            `json:"object,omitempty"`
	CreatedAt      *DateTime         `json:"created_at,omitempty"`
	UpdatedAt      *DateTime         `json:"updated_at,omitempty"`
	RequestURL     string            `json:"request_url,omitempty"`
	RequestHeaders map[string]string `json:"request_headers,omitempty"`
	// RequestBody is the raw request body that was sent to the webhook. This is
	// expected to be an Event object. It may either be encoded in the API
	// response as a string (with JSON delimiters escaped) or as base64. The
	// UnmarshalJSON method will attempt to convert it to an *Event type, but it
	// may be set to a default type if decoding to an object fails.
	RequestBody     interface{}       `json:"request_body,omitempty"`
	ResponseHeaders map[string]string `json:"response_headers,omitempty"`
	ResponseBody    string            `json:"response_body,omitempty"`
	ResponseCode    int               `json:"response_code,omitempty"`
	TotalTime       int               `json:"total_time,omitempty"`
}

EventPayload represents the result of a webhook call.

func (*EventPayload) UnmarshalJSON

func (e *EventPayload) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON will attempt to convert an event payload response to an *EventPayload type, but it may be set to a default type if decoding to an object fails.

type ExternalApiError

type ExternalApiError struct {
	LibraryError
}

ExternalApiError represents an error caused by an external API, such as a 3rd party HTTP API (not EasyPost).

type Fee

type Fee struct {
	Object   string `json:"object,omitempty"`
	Type     string `json:"type,omitempty"`
	Amount   string `json:"amount,omitempty"`
	Charged  bool   `json:"charged,omitempty"`
	Refunded bool   `json:"refunded,omitempty"`
}

Fee objects are used to represent the breakdown of charges made when purchasing an item on EasyPost.

type FilteringError

type FilteringError struct {
	LocalError
}

FilteringError is raised when there is an issue while running a filtering operation.

type ForbiddenError

type ForbiddenError struct {
	APIError
}

ForbiddenError is raised when the API returns a 403 status code.

type Form

type Form struct {
	ID                      string    `json:"id,omitempty"`
	Object                  string    `json:"object,omitempty"`
	Mode                    string    `json:"mode,omitempty"`
	CreatedAt               *DateTime `json:"created_at,omitempty"`
	UpdatedAt               *DateTime `json:"updated_at,omitempty"`
	FormType                string    `json:"form_type,omitempty"`
	FormURL                 string    `json:"form_url,omitempty"`
	SubmittedElectronically bool      `json:"submitted_electronically,omitempty"`
}

A Form represents a form associated with a Shipment.

type GatewayTimeoutError

type GatewayTimeoutError struct {
	APIError
}

GatewayTimeoutError is raised when the API returns a 504 status code.

type HookEvent

type HookEvent struct {
}

HookEvent is the base type for all hook events

type HookEventSubscriber

type HookEventSubscriber struct {
	ID string // need unique ID for removal
}

HookEventSubscriber is the base type for all hook event subscribers. ID needs to be unique in order to find and remove the subscriber

type Hooks

type Hooks struct {
	RequestHookEventSubscriptions  []RequestHookEventSubscriber // these are directly accessible by the user, but should not be modified directly (use Add/Remove methods)
	ResponseHookEventSubscriptions []ResponseHookEventSubscriber
}

Hooks is a collection of HookEventSubscriber instances for various hooks available in the client

func (*Hooks) AddRequestEventSubscriber

func (h *Hooks) AddRequestEventSubscriber(subscriber RequestHookEventSubscriber)

AddRequestEventSubscriber adds a RequestHookEventSubscriber to the Hooks instance to be executed when a RequestHookEvent is fired

func (*Hooks) AddResponseEventSubscriber

func (h *Hooks) AddResponseEventSubscriber(subscriber ResponseHookEventSubscriber)

AddResponseEventSubscriber adds a ResponseHookEventSubscriber to the Hooks instance to be executed when a ResponseHookEvent is fired

func (*Hooks) RemoveRequestEventSubscriber

func (h *Hooks) RemoveRequestEventSubscriber(subscriber RequestHookEventSubscriber)

RemoveRequestEventSubscriber removes a RequestHookEventSubscriber from the Hooks instance

func (*Hooks) RemoveResponseEventSubscriber

func (h *Hooks) RemoveResponseEventSubscriber(subscriber ResponseHookEventSubscriber)

RemoveResponseEventSubscriber removes a ResponseHookEventSubscriber from the Hooks instance

type Insurance

type Insurance struct {
	ID           string    `json:"id,omitempty"`
	Object       string    `json:"object,omitempty"`
	Reference    string    `json:"reference,omitempty"`
	Mode         string    `json:"mode,omitempty"`
	CreatedAt    *DateTime `json:"created_at,omitempty"`
	UpdatedAt    *DateTime `json:"updated_at,omitempty"`
	Amount       string    `json:"amount,omitempty"`
	Carrier      string    `json:"carrier,omitempty"`
	Provider     string    `json:"provider,omitempty"`
	ProviderID   string    `json:"provider_id,omitempty"`
	ShipmentID   string    `json:"shipment_id,omitempty"`
	TrackingCode string    `json:"tracking_code,omitempty"`
	Status       string    `json:"status,omitempty"`
	Tracker      *Tracker  `json:"tracker,omitempty"`
	ToAddress    *Address  `json:"to_address,omitempty"`
	FromAddress  *Address  `json:"from_address,omitempty"`
	Fee          *Fee      `json:"fee,omitempty"`
	Messages     []string  `json:"messages,omitempty"`
}

An Insurance object represents insurance for packages purchased both via the EasyPost API and shipments purchased through third parties and later registered with EasyPost.

type InternalServerError

type InternalServerError struct {
	APIError
}

InternalServerError is raised when the API returns a 500 status code.

type InvalidObjectError

type InvalidObjectError struct {
	LocalError
}

InvalidObjectError is raised when an object is invalid.

type InvalidRequestError

type InvalidRequestError struct {
	APIError
}

InvalidRequestError is raised when the API returns a 422 status code.

type LibraryError

type LibraryError struct {
	// Message is a human-readable error description.
	Message string
}

LibraryError is the base type for all errors/exceptions in this EasyPost library.

func (*LibraryError) Error

func (e *LibraryError) Error() string

Error provides a pretty printed string of a LibraryError object.

type ListAddressResult

type ListAddressResult struct {
	Addresses []*Address `json:"addresses,omitempty"`
	PaginatedCollection
}

ListAddressResult holds the results from the list addresses API.

type ListBatchesResult

type ListBatchesResult struct {
	Batch []*Batch `json:"batches,omitempty"`
	PaginatedCollection
}

ListBatchesResult holds the results from the list insurances API.

type ListChildUsersResult added in v4.1.1

type ListChildUsersResult struct {
	Children []*User `json:"children,omitempty"`
	PaginatedCollection
}

type ListEndShipperResult

type ListEndShipperResult struct {
	EndShippers []*Address `json:"endshippers,omitempty"`
	HasMore     bool       `json:"has_more,omitempty"`
}

ListEndShipperResult holds the results from the list EndShippers API.

type ListEventsResult

type ListEventsResult struct {
	Events []*Event `json:"events,omitempty"`
	PaginatedCollection
}

ListEventsResult holds the results from the list events API.

type ListInsurancesResult

type ListInsurancesResult struct {
	Insurances []*Insurance `json:"insurances,omitempty"`
	PaginatedCollection
}

ListInsurancesResult holds the results from the list insurances API.

type ListOptions

type ListOptions struct {
	BeforeID      string    `url:"before_id,omitempty"`
	AfterID       string    `url:"after_id,omitempty"`
	StartDateTime *DateTime `url:"start_datetime,omitempty"`
	EndDateTime   *DateTime `url:"end_datetime,omitempty"`
	PageSize      int       `url:"page_size,omitempty"`
}

ListOptions is used to specify query parameters for listing EasyPost objects.

type ListPickupResult

type ListPickupResult struct {
	Pickups []*Pickup `json:"pickups,omitempty"`
	PaginatedCollection
}

ListPickupResult holds the results from the list Pickup API.

type ListReferralCustomersResult

type ListReferralCustomersResult struct {
	ReferralCustomers []*ReferralCustomer `json:"referral_customers,omitempty"`
	PaginatedCollection
}

ListReferralCustomersResult holds the results from the list referral customers API call.

type ListRefundResult

type ListRefundResult struct {
	Refunds []*Refund `json:"refunds,omitempty"`
	PaginatedCollection
}

type ListReportsResult

type ListReportsResult struct {
	Reports []*Report `json:"reports,omitempty"`
	Type    string    `json:"type,omitempty"`
	PaginatedCollection
}

ListReportsResult holds the results from the list reports API.

type ListScanFormsResult

type ListScanFormsResult struct {
	ScanForms []*ScanForm `json:"scan_forms,omitempty"`
	PaginatedCollection
}

ListScanFormsResult holds the results from the list scan forms API.

type ListShipmentsOptions

type ListShipmentsOptions struct {
	BeforeID        string    `url:"before_id,omitempty"`
	AfterID         string    `url:"after_id,omitempty"`
	StartDateTime   *DateTime `url:"start_datetime,omitempty"`
	EndDateTime     *DateTime `url:"end_datetime,omitempty"`
	PageSize        int       `url:"page_size,omitempty"`
	Purchased       *bool     `url:"purchased,omitempty"`
	IncludeChildren *bool     `url:"include_children,omitempty"`
}

ListShipmentsOptions is used to specify query parameters for listing Shipment objects.

type ListShipmentsResult

type ListShipmentsResult struct {
	Shipments       []*Shipment `json:"shipments,omitempty"`
	Purchased       *bool       `json:"purchased,omitempty"`
	IncludeChildren *bool       `json:"include_children,omitempty"`
	PaginatedCollection
}

ListShipmentsResult holds the results from the list shipments API.

type ListTrackersOptions

type ListTrackersOptions struct {
	BeforeID      string    `url:"before_id,omitempty"`
	AfterID       string    `url:"after_id,omitempty"`
	StartDateTime *DateTime `url:"start_datetime,omitempty"`
	EndDateTime   *DateTime `url:"end_datetime,omitempty"`
	PageSize      int       `url:"page_size,omitempty"`
	TrackingCode  string    `url:"tracking_code,omitempty"`
	Carrier       string    `url:"carrier,omitempty"`
}

ListTrackersOptions is used to specify query parameters for listing Tracker objects.

type ListTrackersResult

type ListTrackersResult struct {
	Trackers     []*Tracker `json:"trackers,omitempty"`
	TrackingCode string     `json:"tracking_code,omitempty"`
	Carrier      string     `json:"carrier,omitempty"`
	PaginatedCollection
}

ListTrackersResult holds the results from the list trackers API.

type ListTrackersUpdatedOptions

type ListTrackersUpdatedOptions struct {
	Page                 int       `json:"page,omitempty"`
	PageSize             int       `json:"page_size,omitempty"`
	StatusStart          *DateTime `json:"status_start,omitempty"`
	StatusEnd            *DateTime `json:"status_end,omitempty"`
	TrackingDetailsStart *DateTime `json:"tracking_details_start,omitempty"`
	TrackingDetailsEnd   *DateTime `json:"tracking_details_end,omitempty"`
}

ListTrackersUpdatedOptions specifies options for the list trackers updated API.

type LocalError

type LocalError struct {
	LibraryError
}

LocalError represents an error caused by the EasyPost library itself, such as validation or JSON serialization issues.

type MetadataPredefinedPackage

type MetadataPredefinedPackage struct {
	Name          string   `json:"name,omitempty"`
	Carrier       string   `json:"carrier,omitempty"`
	HumanReadable string   `json:"human_readable,omitempty"`
	Description   string   `json:"description,omitempty"`
	Dimensions    []string `json:"dimensions,omitempty"`
	MaxWeight     float64  `json:"max_weight,omitempty"`
}

MetadataPredefinedPackage represents an available predefined package of a carrier.

type MetadataServiceLevel

type MetadataServiceLevel struct {
	Name          string   `json:"name,omitempty"`
	Carrier       string   `json:"carrier,omitempty"`
	HumanReadable string   `json:"human_readable,omitempty"`
	Description   string   `json:"description,omitempty"`
	Dimensions    []string `json:"dimensions,omitempty"`
	MaxWeight     float64  `json:"max_weight,omitempty"`
}

MetadataServiceLevel represents an available service level of a carrier.

type MetadataShipmentOption

type MetadataShipmentOption struct {
	Name          string `json:"name,omitempty"`
	Carrier       string `json:"carrier,omitempty"`
	HumanReadable string `json:"human_readable,omitempty"`
	Description   string `json:"description,omitempty"`
	Deprecated    bool   `json:"deprecated,omitempty"`
	Type          string `json:"type,omitempty"`
}

MetadataShipmentOption represents an available shipment option of a carrier.

type MetadataSupportedFeature

type MetadataSupportedFeature struct {
	Name        string `json:"name,omitempty"`
	Carrier     string `json:"carrier,omitempty"`
	Description string `json:"description,omitempty"`
	Supported   bool   `json:"supported,omitempty"`
}

MetadataSupportedFeature represents a supported feature of a carrier.

type MethodNotAllowedError

type MethodNotAllowedError struct {
	APIError
}

MethodNotAllowedError is raised when the API returns a 405 status code.

type MinifiedRate

type MinifiedRate struct {
	ID      string `json:"id,omitempty"`
	Service string `json:"service,omitempty"`
	Carrier string `json:"carrier,omitempty"`
	Rate    string `json:"rate,omitempty"`
}

type MissingPropertyError

type MissingPropertyError struct {
	LocalError
}

MissingPropertyError is raised when a required property is missing.

type MockRequest

type MockRequest struct {
	MatchRule    MockRequestMatchRule
	ResponseInfo MockRequestResponseInfo
}

type MockRequestMatchRule

type MockRequestMatchRule struct {
	Method          string
	UrlRegexPattern string
}

type MockRequestResponseInfo

type MockRequestResponseInfo struct {
	StatusCode int
	Body       string
}

func (*MockRequestResponseInfo) AsResponse

func (r *MockRequestResponseInfo) AsResponse() *http.Response

func (*MockRequestResponseInfo) MockBody

func (r *MockRequestResponseInfo) MockBody() io.ReadCloser

type NotFoundError

type NotFoundError struct {
	APIError
}

NotFoundError is raised when the API returns a 404 status code.

type Order

type Order struct {
	ID            string            `json:"id,omitempty"`
	Object        string            `json:"object,omitempty"`
	Reference     string            `json:"reference,omitempty"`
	Mode          string            `json:"mode,omitempty"`
	CreatedAt     *DateTime         `json:"created_at,omitempty"`
	UpdatedAt     *DateTime         `json:"updated_at,omitempty"`
	ToAddress     *Address          `json:"to_address,omitempty"`
	FromAddress   *Address          `json:"from_address,omitempty"`
	ReturnAddress *Address          `json:"return_address,omitempty"`
	BuyerAddress  *Address          `json:"buyer_address,omitempty"`
	Shipments     []*Shipment       `json:"shipments,omitempty"`
	Rates         []*Rate           `json:"rates,omitempty"`
	Messages      []*CarrierMessage `json:"messages,omitempty"`
	IsReturn      bool              `json:"is_return"`
	Service       string            `json:"service,omitempty"`
	CustomsInfo   *CustomsInfo      `json:"customs_info,omitempty"`
}

An Order object represents a collection of packages and can be used for multi-piece Shipments.

type PaginatedCollection

type PaginatedCollection struct {
	// HasMore indicates if there are more responses to be fetched. If True,
	// additional responses can be fetched by updating the AfterID parameter
	// with the ID of the last item in this object's collection list.
	HasMore bool `json:"has_more,omitempty"`
}

PaginatedCollection holds the results of a paginated API response.

type Parcel

type Parcel struct {
	ID                string    `json:"id,omitempty"`
	Object            string    `json:"object,omitempty"`
	Mode              string    `json:"mode,omitempty"`
	CreatedAt         *DateTime `json:"created_at,omitempty"`
	UpdatedAt         *DateTime `json:"updated_at,omitempty"`
	Length            float64   `json:"length,omitempty"`
	Width             float64   `json:"width,omitempty"`
	Height            float64   `json:"height,omitempty"`
	PredefinedPackage string    `json:"predefined_package,omitempty"`
	Weight            float64   `json:"weight,omitempty"`
}

A Parcel objects represent a physical container being shipped.

type Payment

type Payment struct {
	Type       string `json:"type,omitempty"`
	Account    string `json:"account,omitempty"`
	Country    string `json:"country,omitempty"`
	PostalCode string `json:"postal_code,omitempty"`
}

Payment provides information on how a shipment is billed.

type PaymentError

type PaymentError struct {
	APIError
}

PaymentError is raised when the API returns a 402 status code.

type PaymentLog

type PaymentLog struct {
	ID         string    `json:"id,omitempty"`
	Object     string    `json:"object,omitempty"`
	CreatedAt  *DateTime `json:"created_at,omitempty"`
	UpdatedAt  *DateTime `json:"updated_at,omitempty"`
	SourceType string    `json:"source_type,omitempty"`
	TargetType string    `json:"target_type,omitempty"`
	Date       string    `json:"date,omitempty"`
	ChargeType string    `json:"charge_type,omitempty"`
	Status     string    `json:"status,omitempty"`
	Amount     string    `json:"amount,omitempty"`
	Last4      string    `json:"last4,omitempty"`
}

type PaymentMethod

type PaymentMethod struct {
	ID                     string               `json:"id,omitempty"`
	Object                 string               `json:"object,omitempty"`
	PrimaryPaymentMethod   *PaymentMethodObject `json:"primary_payment_method,omitempty"`
	SecondaryPaymentMethod *PaymentMethodObject `json:"secondary_payment_method,omitempty"`
}

type PaymentMethodObject

type PaymentMethodObject struct {
	BankName        string `json:"bank_name,omitempty"`   // bank account
	Brand           string `json:"brand,omitempty"`       // credit card
	Country         string `json:"country,omitempty"`     // bank account
	DisabledAt      string `json:"disabled_at,omitempty"` // both
	ExpirationMonth int    `json:"exp_month,omitempty"`   // credit card
	ExpirationYear  int    `json:"exp_year,omitempty"`    // credit card
	ID              string `json:"id,omitempty"`          // both
	Last4           string `json:"last4,omitempty"`       // both
	Name            string `json:"name,omitempty"`        // credit card
	Object          string `json:"object,omitempty"`      // both
	Verified        bool   `json:"verified,omitempty"`    // bank account
}

type PaymentMethodPriority

type PaymentMethodPriority int64
const (
	PrimaryPaymentMethodPriority PaymentMethodPriority = iota
	SecondaryPaymentMethodPriority
)

type PaymentMethodType

type PaymentMethodType int64
const (
	CreditCardPaymentType PaymentMethodType = iota
	BankAccountPaymentType
)

type Pickup

type Pickup struct {
	ID               string            `json:"id,omitempty"`
	Object           string            `json:"object,omitempty"`
	Reference        string            `json:"reference,omitempty"`
	Mode             string            `json:"mode,omitempty"`
	CreatedAt        *DateTime         `json:"created_at,omitempty"`
	UpdatedAt        *DateTime         `json:"updated_at,omitempty"`
	Status           string            `json:"status,omitempty"`
	MinDatetime      *DateTime         `json:"min_datetime,omitempty"`
	MaxDatetime      *DateTime         `json:"max_datetime,omitempty"`
	IsAccountAddress bool              `json:"is_account_address,omitempty"`
	Instructions     string            `json:"instructions,omitempty"`
	Messages         []*CarrierMessage `json:"messages,omitempty"`
	Confirmation     string            `json:"confirmation,omitempty"`
	Shipment         *Shipment         `json:"shipment,omitempty"`
	Address          *Address          `json:"address,omitempty"`
	Batch            *Batch            `json:"batch,omitempty"`
	CarrierAccounts  []*CarrierAccount `json:"carrier_accounts,omitempty"`
	PickupRates      []*PickupRate     `json:"pickup_rates,omitempty"`
}

A Pickup object represents a pickup from a carrier at a customer's residence or place of business.

type PickupRate

type PickupRate struct {
	ID        string    `json:"id,omitempty"`
	Object    string    `json:"object,omitempty"`
	Mode      string    `json:"mode,omitempty"`
	CreatedAt *DateTime `json:"created_at,omitempty"`
	UpdatedAt *DateTime `json:"updated_at,omitempty"`
	Service   string    `json:"service,omitempty"`
	Carrier   string    `json:"carrier,omitempty"`
	Rate      string    `json:"rate,omitempty"`
	Currency  string    `json:"currency,omitempty"`
	PickupID  string    `json:"pickup_id,omitempty"`
}

PickupRate contains data about the cost of a pickup.

type PostageLabel

type PostageLabel struct {
	ID              string    `json:"id,omitempty"`
	Object          string    `json:"object,omitempty"`
	CreatedAt       *DateTime `json:"created_at,omitempty"`
	UpdatedAt       *DateTime `json:"updated_at,omitempty"`
	IntegratedForm  string    `json:"integrated_form,omitempty"`
	LabelDate       *DateTime `json:"label_date,omitempty"`
	LabelEPL2URL    string    `json:"label_epl2_url,omitempty"`
	LabelFileType   string    `json:"label_file_type,omitempty"`
	LabelPDFURL     string    `json:"label_pdf_url,omitempty"`
	LabelResolution float64   `json:"label_resolution,omitempty"`
	LabelSize       string    `json:"label_size,omitempty"`
	LabelType       string    `json:"label_type,omitempty"`
	LabelURL        string    `json:"label_url,omitempty"`
	LabelZPLURL     string    `json:"label_zpl_url,omitempty"`
}

PostageLabel provides details of a shipping label for a purchased shipment.

type ProxyError

type ProxyError struct {
	APIError
}

ProxyError is raised when the API returns a 407 status code.

type Rate

type Rate struct {
	ID                     string    `json:"id,omitempty"`
	Object                 string    `json:"object,omitempty"`
	Mode                   string    `json:"mode,omitempty"`
	CreatedAt              *DateTime `json:"created_at,omitempty"`
	UpdatedAt              *DateTime `json:"updated_at,omitempty"`
	Service                string    `json:"service,omitempty"`
	Carrier                string    `json:"carrier,omitempty"`
	CarrierAccountID       string    `json:"carrier_account_id,omitempty"`
	ShipmentID             string    `json:"shipment_id,omitempty"`
	Rate                   string    `json:"rate,omitempty"`
	Currency               string    `json:"currency,omitempty"`
	RetailRate             string    `json:"retail_rate,omitempty"`
	RetailCurrency         string    `json:"retail_currency,omitempty"`
	ListRate               string    `json:"list_rate,omitempty"`
	ListCurrency           string    `json:"list_currency,omitempty"`
	DeliveryDays           int       `json:"delivery_days,omitempty"`
	DeliveryDate           *DateTime `json:"delivery_date,omitempty"`
	DeliveryDateGuaranteed bool      `json:"delivery_date_guaranteed,omitempty"`
	EstDeliveryDays        int       `json:"est_delivery_days,omitempty"`
	BillingType            string    `json:"billing_type,omitempty"`
}

A Rate contains information on shipping cost and delivery time.

type RateLimitError

type RateLimitError struct {
	APIError
}

RateLimitError is raised when the API returns a 429 status code.

type RedirectError

type RedirectError struct {
	APIError
}

RedirectError is raised when the API returns a 3xx status code.

type ReferralCustomer

type ReferralCustomer struct {
	User
}

A ReferralCustomer contains data about an EasyPost referral customer.

type Refund

type Refund struct {
	ID                 string    `json:"id,omitempty"`
	Object             string    `json:"object,omitempty"`
	CreatedAt          *DateTime `json:"created_at,omitempty"`
	UpdatedAt          *DateTime `json:"updated_at,omitempty"`
	TrackingCode       string    `json:"tracking_code,omitempty"`
	ConfirmationNumber string    `json:"confirmation_number,omitempty"`
	Status             string    `json:"status,omitempty"`
	Carrier            string    `json:"carrier,omitempty"`
	ShipmentID         string    `json:"shipment_id,omitempty"`
}

type Report

type Report struct {
	ID                string    `json:"id,omitempty"`
	Object            string    `json:"object,omitempty"`
	Mode              string    `json:"mode,omitempty"`
	CreatedAt         *DateTime `json:"created_at,omitempty"`
	UpdatedAt         *DateTime `json:"updated_at,omitempty"`
	Status            string    `json:"status,omitempty"`
	StartDate         string    `json:"start_date,omitempty"`
	EndDate           string    `json:"end_date,omitempty"`
	IncludeChildren   bool      `json:"include_children,omitempty"`
	URL               string    `json:"url,omitempty"`
	URLExpiresAt      *DateTime `json:"url_expires_at,omitempty"`
	SendEmail         bool      `json:"send_email,omitempty"`
	Columns           []string  `json:"columns,omitempty"`
	AdditionalColumns []string  `json:"additional_columns,omitempty"`
}

Report represents a CSV-formatted file that is a log of all the objects created within a certain time frame.

type RequestHookEvent

type RequestHookEvent struct {
	HookEvent        // implements HookEvent
	Method           string
	Url              *url.URL
	RequestBody      io.ReadCloser
	Headers          map[string][]string
	RequestTimestamp time.Time
	Id               uuid.UUID
}

RequestHookEvent is the data passed to a RequestHookEventSubscriberCallback function

type RequestHookEventSubscriber

type RequestHookEventSubscriber struct {
	HookEventSubscriber // implements HookEventSubscriber
	Callback            RequestHookEventSubscriberCallback
}

RequestHookEventSubscriber is a HookEventSubscriber that executes a RequestHookEventSubscriberCallback function when a RequestHookEvent is fired

func (RequestHookEventSubscriber) Execute

Execute executes the RequestHookEventSubscriberCallback function of the RequestHookEventSubscriber

type RequestHookEventSubscriberCallback

type RequestHookEventSubscriberCallback func(ctx context.Context, event RequestHookEvent) error

RequestHookEventSubscriberCallback is the type of the callback function executed by an RequestHookEventSubscriber

type ResponseHookEvent

type ResponseHookEvent struct {
	HookEvent         // implements HookEvent
	HttpStatus        int
	Method            string
	Url               *url.URL
	Headers           map[string][]string
	ResponseBody      io.ReadCloser
	RequestTimestamp  time.Time
	ResponseTimestamp time.Time
	Id                uuid.UUID
}

ResponseHookEvent is the data passed to a ResponseHookEventSubscriberCallback function

type ResponseHookEventSubscriber

type ResponseHookEventSubscriber struct {
	HookEventSubscriber // implements HookEventSubscriber
	Callback            ResponseHookEventSubscriberCallback
}

ResponseHookEventSubscriber is a HookEventSubscriber that executes a ResponseHookEventSubscriberCallback function when a ResponseHookEvent is fired

func (ResponseHookEventSubscriber) Execute

Execute executes the ResponseHookEventSubscriberCallback function of the ResponseHookEventSubscriber

type ResponseHookEventSubscriberCallback

type ResponseHookEventSubscriberCallback func(ctx context.Context, event ResponseHookEvent) error

ResponseHookEventSubscriberCallback is the type of the callback function executed by an ResponseHookEventSubscriber

type RetryError

type RetryError struct {
	APIError
}

RetryError is raised when the API returns a 1xx status code.

type SSLError

type SSLError struct {
	APIError
}

SSLError is raised when there is an issue with the SSL certificate.

type ScanForm

type ScanForm struct {
	ID            string    `json:"id,omitempty"`
	Object        string    `json:"object,omitempty"`
	CreatedAt     *DateTime `json:"created_at,omitempty"`
	UpdatedAt     *DateTime `json:"updated_at,omitempty"`
	Status        string    `json:"status,omitempty"`
	Message       string    `json:"message,omitempty"`
	Address       *Address  `json:"address,omitempty"`
	TrackingCodes []string  `json:"tracking_codes,omitempty"`
	FormURL       string    `json:"form_url,omitempty"`
	FormFileType  string    `json:"form_file_type,omitempty"`
	BatchID       string    `json:"batch_id,omitempty"`
}

A ScanForm object represents a document that can be scanned to mark all included tracking codes as "Accepted for Shipment" by the carrier.

type ServiceUnavailableError

type ServiceUnavailableError struct {
	APIError
}

ServiceUnavailableError is raised when the API returns a 503 status code.

type Shipment

type Shipment struct {
	ID                string            `json:"id,omitempty"`
	Object            string            `json:"object,omitempty"`
	Reference         string            `json:"reference,omitempty"`
	Mode              string            `json:"mode,omitempty"`
	CreatedAt         *DateTime         `json:"created_at,omitempty"`
	UpdatedAt         *DateTime         `json:"updated_at,omitempty"`
	ToAddress         *Address          `json:"to_address,omitempty"`
	FromAddress       *Address          `json:"from_address,omitempty"`
	ReturnAddress     *Address          `json:"return_address,omitempty"`
	BuyerAddress      *Address          `json:"buyer_address,omitempty"`
	Parcel            *Parcel           `json:"parcel,omitempty"`
	Carrier           string            `json:"carrier,omitempty"`
	Service           string            `json:"service,omitempty"`
	CarrierAccountIDs []string          `json:"carrier_accounts,omitempty"`
	CustomsInfo       *CustomsInfo      `json:"customs_info,omitempty"`
	ScanForm          *ScanForm         `json:"scan_form,omitempty"`
	Forms             []*Form           `json:"forms,omitempty"`
	Insurance         string            `json:"insurance,omitempty"`
	Rates             []*Rate           `json:"rates,omitempty"`
	SelectedRate      *Rate             `json:"selected_rate,omitempty"`
	PostageLabel      *PostageLabel     `json:"postage_label,omitempty"`
	Messages          []*CarrierMessage `json:"messages,omitempty"`
	Options           *ShipmentOptions  `json:"options,omitempty"`
	IsReturn          bool              `json:"is_return,omitempty"`
	TrackingCode      string            `json:"tracking_code,omitempty"`
	USPSZone          int               `json:"usps_zone,omitempty"`
	Status            string            `json:"status,omitempty"`
	Tracker           *Tracker          `json:"tracker,omitempty"`
	Fees              []*Fee            `json:"fees,omitempty"`
	RefundStatus      string            `json:"refund_status,omitempty"`
	BatchID           string            `json:"batch_id,omitempty"`
	BatchStatus       string            `json:"batch_status,omitempty"`
	BatchMessage      string            `json:"batch_message,omitempty"`
	TaxIdentifiers    []*TaxIdentifier  `json:"tax_identifiers,omitempty"`
}

A Shipment represents its namesake, and is made up of a "to" and "from" addresses, the Parcel being shipped, and any customs forms required for international deliveries.

type ShipmentOptions

type ShipmentOptions struct {
	AdditionalHandling          bool      `json:"additional_handling,omitempty"`
	AddressValidationLevel      string    `json:"address_validation_level,omitempty"`
	Alcohol                     bool      `json:"alcohol,omitempty"`
	BillingRef                  string    `json:"billing_ref,omitempty"`
	BillReceiverAccount         string    `json:"bill_receiver_account,omitempty"`
	BillReceiverPostalCode      string    `json:"bill_receiver_postal_code,omitempty"`
	BillThirdPartyAccount       string    `json:"bill_third_party_account,omitempty"`
	BillThirdPartyCountry       string    `json:"bill_third_party_country,omitempty"`
	BillThirdPartyPostalCode    string    `json:"bill_third_party_postal_code,omitempty"`
	ByDrone                     bool      `json:"by_drone,omitempty"`
	CarbonNeutral               bool      `json:"carbon_neutral,omitempty"`
	CertifiedMail               bool      `json:"certified_mail,omitempty"`
	CODAmount                   string    `json:"cod_amount,omitempty"`
	CODMethod                   string    `json:"cod_method,omitempty"`
	CODAddressID                string    `json:"cod_address_id,omitempty"`
	CommercialInvoiceSignature  string    `json:"commercial_invoice_signature,omitempty"`
	CommercialInvoiceLetterhead string    `json:"commercial_invoice_letterhead,omitempty"`
	ContentDescription          string    `json:"content_description,omitempty"`
	Currency                    string    `json:"currency,omitempty"`
	DeliveryConfirmation        string    `json:"delivery_confirmation,omitempty"`
	DeliveryMaxDatetime         *DateTime `json:"delivery_max_datetime,omitempty"`
	DutyPayment                 *Payment  `json:"duty_payment,omitempty"`
	DutyPaymentAccount          string    `json:"duty_payment_account,omitempty"`
	DropoffMaxDatetime          *DateTime `json:"dropoff_max_datetime,omitempty"`
	DropoffType                 string    `json:"dropoff_type,omitempty"`
	DryIce                      bool      `json:"dry_ice,omitempty"`
	DryIceMedical               bool      `json:"dry_ice_medical,omitempty,string"`
	DryIceWeight                float64   `json:"dry_ice_weight,omitempty,string"`
	Endorsement                 string    `json:"endorsement,omitempty"`
	EndShipperID                string    `json:"end_shipper_id,omitempty"`
	FreightCharge               float64   `json:"freight_charge,omitempty"`
	HandlingInstructions        string    `json:"handling_instructions,omitempty"`
	Hazmat                      string    `json:"hazmat,omitempty"`
	HoldForPickup               bool      `json:"hold_for_pickup,omitempty"`
	Incoterm                    string    `json:"incoterm,omitempty"`
	InvoiceNumber               string    `json:"invoice_number,omitempty"`
	LabelDate                   *DateTime `json:"label_date,omitempty"`
	LabelFormat                 string    `json:"label_format,omitempty"`
	LabelSize                   string    `json:"label_size,omitempty"`
	Machinable                  bool      `json:"machinable,omitempty"`
	Payment                     *Payment  `json:"payment,omitempty"`
	PickupMinDatetime           *DateTime `json:"pickup_min_datetime,omitempty"`
	PickupMaxDatetime           *DateTime `json:"pickup_max_datetime,omitempty"`
	PrintCustom1                string    `json:"print_custom_1,omitempty"`
	PrintCustom2                string    `json:"print_custom_2,omitempty"`
	PrintCustom3                string    `json:"print_custom_3,omitempty"`
	PrintCustom1BarCode         bool      `json:"print_custom_1_barcode,omitempty"`
	PrintCustom2BarCode         bool      `json:"print_custom_2_barcode,omitempty"`
	PrintCustom3BarCode         bool      `json:"print_custom_3_barcode,omitempty"`
	PrintCustom1Code            string    `json:"print_custom_1_code,omitempty"`
	PrintCustom2Code            string    `json:"print_custom_2_code,omitempty"`
	PrintCustom3Code            string    `json:"print_custom_3_code,omitempty"`
	RegisteredMail              bool      `json:"registered_mail,omitempty"`
	RegisteredMailAmount        float64   `json:"registered_mail_amount,omitempty"`
	ReturnReceipt               bool      `json:"return_receipt,omitempty"`
	SaturdayDelivery            bool      `json:"saturday_delivery,omitempty"`
	SpecialRatesEligibility     string    `json:"special_rates_eligibility,omitempty"`
	SmartpostHub                string    `json:"smartpost_hub,omitempty"`
	SmartpostManifest           string    `json:"smartpost_manifest,omitempty"`
	SuppressETD                 bool      `json:"suppress_etd,omitempty"`
}

ShipmentOptions represents the various options that can be applied to a shipment at creation.

type SmartRate

type SmartRate struct {
	ID                     string         `json:"id,omitempty"`
	Object                 string         `json:"object,omitempty"`
	Mode                   string         `json:"mode,omitempty"`
	CreatedAt              *DateTime      `json:"created_at,omitempty"`
	UpdatedAt              *DateTime      `json:"updated_at,omitempty"`
	Service                string         `json:"service,omitempty"`
	Carrier                string         `json:"carrier,omitempty"`
	CarrierAccountID       string         `json:"carrier_account_id,omitempty"`
	ShipmentID             string         `json:"shipment_id,omitempty"`
	Rate                   float64        `json:"rate,omitempty"`
	Currency               string         `json:"currency,omitempty"`
	RetailRate             float64        `json:"retail_rate,omitempty"`
	RetailCurrency         string         `json:"retail_currency,omitempty"`
	ListRate               float64        `json:"list_rate,omitempty"`
	ListCurrency           string         `json:"list_currency,omitempty"`
	DeliveryDays           int            `json:"delivery_days,omitempty"`
	DeliveryDate           *DateTime      `json:"delivery_date,omitempty"`
	DeliveryDateGuaranteed bool           `json:"delivery_date_guaranteed,omitempty"`
	EstDeliveryDays        int            `json:"est_delivery_days,omitempty"`
	TimeInTransit          *TimeInTransit `json:"time_in_transit,omitempty"`
	BillingType            string         `json:"billing_type,omitempty"`
}

A SmartRate contains information on shipping cost and delivery time in addition to time-in-transit details.

type StatelessRate

type StatelessRate struct {
	BillingType            string    `json:"billing_type,omitempty"`
	Carrier                string    `json:"carrier,omitempty"`
	CarrierAccountID       string    `json:"carrier_account_id,omitempty"`
	Currency               string    `json:"currency,omitempty"`
	DeliveryDate           *DateTime `json:"delivery_date,omitempty"`
	DeliveryDateGuaranteed bool      `json:"delivery_date_guaranteed,omitempty"`
	DeliveryDays           int       `json:"delivery_days,omitempty"`
	EstDeliveryDays        int       `json:"est_delivery_days,omitempty"`
	ListCurrency           string    `json:"list_currency,omitempty"`
	ListRate               string    `json:"list_rate,omitempty"`
	Mode                   string    `json:"mode,omitempty"`
	Object                 string    `json:"object,omitempty"`
	Rate                   string    `json:"rate,omitempty"`
	RetailCurrency         string    `json:"retail_currency,omitempty"`
	RetailRate             string    `json:"retail_rate,omitempty"`
	Service                string    `json:"service,omitempty"`
	ShipmentID             string    `json:"shipment_id,omitempty"`
}

A StatelessRate contains information on shipping cost and delivery time, but does not have an ID (is ephemeral).

type TaxIdentifier

type TaxIdentifier struct {
	Entity         string `json:"entity,omitempty"`
	TaxIdType      string `json:"tax_id_type,omitempty"`
	TaxId          string `json:"tax_id,omitempty"`
	IssuingCountry string `json:"issuing_country,omitempty"`
}

TaxIdentifier objects contain tax information used by carriers.

type TimeInTransit

type TimeInTransit struct {
	Percentile50 int `json:"percentile_50,omitempty"`
	Percentile75 int `json:"percentile_75,omitempty"`
	Percentile85 int `json:"percentile_85,omitempty"`
	Percentile90 int `json:"percentile_90,omitempty"`
	Percentile95 int `json:"percentile_95,omitempty"`
	Percentile97 int `json:"percentile_97,omitempty"`
	Percentile99 int `json:"percentile_99,omitempty"`
}

TimeInTransit provides details on the probability your package will arrive within a certain number of days

type TimeoutError

type TimeoutError struct {
	APIError
}

TimeoutError is raised when the API returns a 408 status code.

type Tracker

type Tracker struct {
	ID              string                 `json:"id,omitempty"`
	Object          string                 `json:"object,omitempty"`
	Mode            string                 `json:"mode,omitempty"`
	CreatedAt       *DateTime              `json:"created_at,omitempty"`
	UpdatedAt       *DateTime              `json:"updated_at,omitempty"`
	TrackingCode    string                 `json:"tracking_code,omitempty"`
	Status          string                 `json:"status,omitempty"`
	StatusDetail    string                 `json:"status_detail,omitempty"`
	SignedBy        string                 `json:"signed_by,omitempty"`
	Weight          float64                `json:"weight,omitempty"`
	EstDeliveryDate *DateTime              `json:"est_delivery_date,omitempty"`
	ShipmentID      string                 `json:"shipment_id,omitempty"`
	Carrier         string                 `json:"carrier,omitempty"`
	TrackingDetails []*TrackingDetail      `json:"tracking_details,omitempty"`
	CarrierDetail   *TrackingCarrierDetail `json:"carrier_detail,omitempty"`
	PublicURL       string                 `json:"public_url,omitempty"`
	Fees            []*Fee                 `json:"fees,omitempty"`
	Finalized       bool                   `json:"finalized,omitempty"`
	IsReturn        bool                   `json:"is_return,omitempty"`
}

A Tracker object contains all the tracking information for a package.

type TrackingCarrierDetail

type TrackingCarrierDetail struct {
	Object                      string            `json:"object,omitempty"`
	Service                     string            `json:"service,omitempty"`
	ContainerType               string            `json:"container_type,omitempty"`
	EstDeliveryDateLocal        string            `json:"est_delivery_date_local,omitempty"`
	EstDeliveryTimeLocal        string            `json:"est_delivery_time_local,omitempty"`
	OriginLocation              string            `json:"origin_location,omitempty"`
	OriginTrackingLocation      *TrackingLocation `json:"origin_tracking_location,omitempty"`
	DestinationLocation         string            `json:"destination_location,omitempty"`
	DestinationTrackingLocation *TrackingLocation `json:"destination_tracking_location,omitempty"`
	GuaranteedDeliveryDate      *DateTime         `json:"guaranteed_delivery_date,omitempty"`
	AlternateIdentifier         string            `json:"alternate_identifier,omitempty"`
	InitialDeliveryAttempt      *DateTime         `json:"initial_delivery_attempt,omitempty"`
}

TrackingCarrierDetail provides additional tracking information from the carrier, when available.

type TrackingDetail

type TrackingDetail struct {
	Object           string            `json:"object,omitempty"`
	Message          string            `json:"message,omitempty"`
	Description      string            `json:"description,omitempty"`
	Status           string            `json:"status,omitempty"`
	StatusDetail     string            `json:"status_detail,omitempty"`
	DateTime         string            `json:"datetime,omitempty"`
	Source           string            `json:"source,omitempty"`
	CarrierCode      string            `json:"carrier_code,omitempty"`
	TrackingLocation *TrackingLocation `json:"tracking_location,omitempty"`
}

TrackingDetail provides information about a tracking event.

type TrackingLocation

type TrackingLocation struct {
	Object  string `json:"object,omitempty"`
	City    string `json:"city,omitempty"`
	State   string `json:"state,omitempty"`
	Country string `json:"country,omitempty"`
	Zip     string `json:"zip,omitempty"`
}

TrackingLocation provides additional information about the location of a tracking event.

type UnauthorizedError

type UnauthorizedError struct {
	APIError
}

UnauthorizedError is raised when the API returns a 401 status code.

type UnknownHttpError

type UnknownHttpError struct {
	APIError
}

UnknownHttpError is raised when the API returns an unrecognized status code.

type User

type User struct {
	ID                      string    `json:"id,omitempty"`
	Object                  string    `json:"object,omitempty"`
	ParentID                string    `json:"parent_id,omitempty"`
	Name                    string    `json:"name,omitempty"`
	Email                   string    `json:"email,omitempty"`
	PhoneNumber             string    `json:"phone_number,omitempty"`
	Balance                 string    `json:"balance,omitempty"`
	RechargeAmount          string    `json:"recharge_amount,omitempty"`
	SecondaryRechargeAmount string    `json:"secondary_recharge_amount,omitempty"`
	RechargeThreshold       string    `json:"recharge_threshold,omitempty"`
	Children                []*User   `json:"children,omitempty"`
	APIKeys                 []*APIKey `json:"api_keys,omitempty"`
	Verified                bool      `json:"verified,omitempty"`
}

A User contains data about an EasyPost account and child accounts.

type UserOptions

type UserOptions struct {
	ID                      string  `json:"-"`
	Email                   *string `json:"email,omitempty"`
	Password                *string `json:"password,omitempty"`
	PasswordConfirmation    *string `json:"password_confirmation,omitempty"`
	CurrentPassword         *string `json:"current_password,omitempty"`
	Name                    *string `json:"name,omitempty"`
	Phone                   *string `json:"phone,omitempty"`
	PhoneNumber             *string `json:"phone_number,omitempty"`
	RechargeAmount          *string `json:"recharge_amount,omitempty"`
	SecondaryRechargeAmount *string `json:"secondary_recharge_amount,omitempty"`
	RechargeThreshold       *string `json:"recharge_threshold,omitempty"`
}

UserOptions specifies options for creating or updating a user.

type Webhook

type Webhook struct {
	ID            string    `json:"id,omitempty"`
	Object        string    `json:"object,omitempty"`
	Mode          string    `json:"mode,omitempty"`
	URL           string    `json:"url,omitempty"`
	DisabledAt    *DateTime `json:"disabled_at,omitempty"`
	WebhookSecret string    `json:"webhook_secret,omitempty"`
}

A Webhook represents an EasyPost webhook callback URL.

Jump to

Keyboard shortcuts

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