Documentation ¶
Overview ¶
apiV4 exposes all API level functions and objects of AfterShip API version 4 for go code
Index ¶
- Constants
- type AfterShipApiError
- type CheckPoint
- type Courier
- type CourierDetectParam
- type CourierDetectParamReqBody
- type CourierEnvelope
- type CourierHandler
- type CourierResponseData
- type DeleteTrackingEnvelope
- type DeleteTrackingResponseData
- type DeletedTracking
- type GetTrackingsParams
- type LastCheckPoint
- type LastCheckPointEnvelope
- type NewTracking
- type NewTrackingReqBody
- type NotificationSetting
- type NotificationSettingEnvelope
- type NotificationSettingWrapper
- type NotificationsHandler
- type Response
- type ResponseMeta
- type RetryPolicy
- type Tracking
- type TrackingEnvelope
- type TrackingId
- type TrackingResponseData
- type TrackingUpdate
- type TrackingUpdateReqBody
- type TrackingsData
- type TrackingsEnvelope
- type TrackingsHandler
Constants ¶
const API_KEY_HEADER_FIELD = "aftership-api-key"
const COURIERS_ALL_ENDPOINT = "/couriers/all"
const COURIERS_DETECT_ENDPOINT = "/couriers/detect"
const COURIERS_ENDPOINT = "/couriers"
const LAST_CHECKPOINT_ENDPOINT = "/last_checkpoint"
const NOTIFICATIONS = "/notifications"
const SDK_ERROR_CODE = 10000
const TRACKINGS_ENDPOINT = "/trackings"
const TRACKINGS_EXPORTS_ENDPOINT = "/trackings/exports"
const URL = "https://api.aftership.com/v4"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AfterShipApiError ¶
type AfterShipApiError struct {
ResponseMeta
}
type CheckPoint ¶
type CheckPoint struct { Slug string `json:"slug,omitempty"` CreatedAt string `json:"created_at,omitempty"` CheckPointTime string `json:"checkpoint_time,omitempty"` City string `json:"city,omitempty"` Coordinates []string `json:"coordinates,omitempty"` CountryIso3 string `json:"country_iso3,omitempty"` CountryName string `json:"country_name,omitempty"` Message string `json:"message,omitempty"` State string `json:"state,omitempty"` Location string `json:"location,omitempty"` Tag string `json:"tag,omitempty"` Zip string `json:"zip,omitempty"` }
CheckPoint represents a CheckPoint returned by the Aftership API
type Courier ¶
type Courier struct { Slug string `json:"slug"` Name string `json:"name"` Phone string `json:"phone"` OtherName string `json:"other_name"` WebUrl string `json:"web_url"` RequiredFields []string `json:"required_fields"` DefaultLanguage string `json:"default_language"` SupportedLanguages []string `json:"supported_languages"` ServiceFromCountryISO3 []string `json:"service_from_country_iso3"` }
Courier is the model describing an AfterShip courier
type CourierDetectParam ¶
type CourierDetectParam struct { // TrackingNumber of a shipment. Mandatory field. TrackingNumber string `json:"tracking_number"` // TrackingPostalCode is the postal code of receiver's address. // Required by some couriers, such as postnl TrackingPostalCode string `json:"tracking_postal_code,omitempty"` // TrackingShipDate in YYYYMMDD format. Required by some couriers, such as deutsch-post TrackingShipDate string `json:"tracking_ship_date,omitempty"` // TrackingAccountNumber of the shipper for a specific courier. Required by some couriers, such as dynamic-logistics TrackingAccountNumber string `json:"tracking_account_number,omitempty"` // TrackingKey of the shipment for a specific courier. Required by some couriers, such as sic-teliway TrackingKey string `json:"tracking_key,omitempty"` // TrackingDestinationCountry of the shipment for a specific courier. Required by some couriers, such as postnl-3s TrackingDestinationCountry string `json:"tracking_destination_country,omitempty"` // Slug If not specified, Aftership will automatically detect the courier based on the tracking number format and // your selected couriers. // Use comma separated to input a list of couriers for auto detect. Slug []string `json:"slug,omitempty"` }
CourierDetectParam contains fields required and optional fields for courier detection
type CourierDetectParamReqBody ¶
type CourierDetectParamReqBody struct {
Tracking CourierDetectParam `json:"tracking"`
}
type CourierEnvelope ¶
type CourierEnvelope struct { Meta ResponseMeta `json:"meta"` Data CourierResponseData `json:"data"` }
CourierEnvelope is the message envelope for the courier API responses
func (*CourierEnvelope) ResponseCode ¶
func (envelope *CourierEnvelope) ResponseCode() ResponseMeta
ResponseCode provides implementation of Response.ResponseCode() for CourierEnvelope struct
type CourierHandler ¶
type CourierHandler interface { // GetCouriers returns a list of couriers activated at your AfterShip account. GetCouriers() ([]Courier, AfterShipApiError) // GetAllCouriers returns a list of all couriers. GetAllCouriers() ([]Courier, AfterShipApiError) // DetectCouriers returns a list of matched couriers based on tracking number format // and selected couriers or a list of couriers. DetectCouriers(params CourierDetectParam) ([]Courier, AfterShipApiError) }
CourierHandler provides the interface for all courier handling API calls in AfterShip APIV4
type CourierResponseData ¶
type CourierResponseData struct {
Couriers []Courier `json:"couriers"`
}
CourierResponseData is a model for data part of the courier API responses
type DeleteTrackingEnvelope ¶
type DeleteTrackingEnvelope struct { Meta ResponseMeta `json:"meta"` Data DeleteTrackingResponseData `json:"data"` }
DeleteTrackingEnvelope is the message envelope for the tracking API responses
func (*DeleteTrackingEnvelope) ResponseCode ¶
func (envelope *DeleteTrackingEnvelope) ResponseCode() ResponseMeta
ResponseCode provides implementation of Response.ResponseCode() for TrackingEnvelope struct
type DeleteTrackingResponseData ¶
type DeleteTrackingResponseData struct {
Tracking DeletedTracking `json:"tracking"`
}
DeleteTrackingResponseData is a model for data part of the tracking API responses
type DeletedTracking ¶
type DeletedTracking struct { Id string `json:"id,omitempty"` Slug string `json:"slug,omitempty"` TrackingNumber string `json:"tracking_number"` TrackingPostalCode string `json:"tracking_postal_code,omitempty"` TrackingShipDate string `json:"tracking_ship_date,omitempty"` TrackingAccountNumber string `json:"tracking_account_number,omitempty"` TrackingKey string `json:"tracking_key,omitempty"` }
DeletedTracking is a deleted tracking object returned by API
type GetTrackingsParams ¶
type GetTrackingsParams struct { // Page to show. (Default: 1) Page int `url:"page,omitempty" json:"page,omitempty"` // Number of trackings each page contain. (Default: 100, Max: 200) Limit int `url:"limit,omitempty" json:"limit,omitempty"` // Search the content of the tracking record fields:tracking_number, // title, order_id, customer_name, custom_fields, order_id, emails, smses Keyword string `url:"keyword,omitempty" json:"keyword,omitempty"` // Unique courier code Use comma for multiple values. (Example: dhl,ups,usps) Slug string `url:"slug,omitempty" json:"slug,omitempty"` // "Total delivery time in days. // - Difference of 1st checkpoint time and delivered time for delivered shipments // - Difference of 1st checkpoint time and current time for non-delivered shipments // Value as 0 for pending shipments or delivered shipment with only one checkpoint." DeliveryTime int `url:"delivery_time,omitempty" json:"delivery_time,omitempty"` // Origin country of trackings. Use ISO Alpha-3 (three letters). Use comma for multiple values. (Example: USA,HKG) Origin string `url:"origin,omitempty" json:"origin,omitempty"` // Destination country of trackings. Use ISO Alpha-3 (three letters). Use comma for multiple values. (Example: USA,HKG) Destination string `url:"destination,omitempty" json:"destination,omitempty"` // Current status of tracking. Values include Pending, InfoReceived, InTransit, OutForDelivery, AttemptFail, // Delivered, Exception, Expired(See status definition) Tag string `url:"tag,omitempty" json:"tag,omitempty"` // "Start date and time of trackings created. AfterShip only stores data of 90 days. // (Defaults: 30 days ago, Example: 2013-03-15T16:41:56+08:00)" CreatedAtMin string `url:"created_at_min,omitempty" json:"created_at_min,omitempty"` // "End date and time of trackings created. // (Defaults: now, Example: 2013-04-15T16:41:56+08:00)" CreatedAtMax string `url:"created_at_max,omitempty" json:"created_at_max,omitempty"` // "List of fields to include in the response. Use comma for multiple values. // Fields to include: title, order_id, tag, checkpoints, checkpoint_time, message, country_name // Defaults: none, Example: title,order_id" Fields string `url:"fields,omitempty" json:"fields,omitempty"` // "Default: ” / Example: 'en' // Support Chinese to English translation for china-ems and china-post only" Lang string `url:"lang,omitempty" json:"lang,omitempty"` // For GetTrackingsExport pass the cursor returned in the previous response for retrieve next page. // When the browsing reaches the end of the index, the returned cursor will be an empty string. Cursor string `url:"cursor,omitempty" json:"cursor,omitempty"` }
GetTrackingsParams represents the set of params for get Trackings API
type LastCheckPoint ¶
type LastCheckPoint struct { Id string `json:"id,omitempty"` Slug string `json:"slug,omitempty"` TrackingNumber string `json:"tracking_number"` Tag string `json:"tag"` CheckPoint CheckPoint `json:"checkpoint"` }
LastCheckPoint is the last checkpoint API response
type LastCheckPointEnvelope ¶
type LastCheckPointEnvelope struct { Meta ResponseMeta `json:"meta"` Data LastCheckPoint `json:"data"` }
LastCheckPointEnvelope is the message envelope for the last checkpoint API responses
func (*LastCheckPointEnvelope) ResponseCode ¶
func (envelope *LastCheckPointEnvelope) ResponseCode() ResponseMeta
ResponseCode provides implementation of Response.ResponseCode() for LastCheckPointEnvelope struct
type NewTracking ¶
type NewTracking struct { TrackingNumber string `json:"tracking_number"` Slug []string `json:"slug,omitempty"` TrackingPostalCode string `json:"tracking_postal_code,omitempty"` TrackingShipDate string `json:"tracking_ship_date,omitempty"` TrackingAccountNumber string `json:"tracking_account_number,omitempty"` TrackingKey string `json:"tracking_key,omitempty"` TrackingDestinationCountry string `json:"tracking_destination_country,omitempty"` Android []string `json:"android,omitempty"` Ios []string `json:"ios,omitempty"` Emails []string `json:"emails,omitempty"` Smses []string `json:"smses,omitempty"` Title string `json:"title,omitempty"` CustomerName string `json:"customer_name,omitempty"` DestinationCountryIso3 string `json:"destination_country_iso3,omitempty"` OrderId string `json:"order_id,omitempty"` OrderIdPath string `json:"order_id_path,omitempty"` CustomFields map[string]string `json:"custom_fields,omitempty"` }
NewTracking provides parameters for new Tracking API request
type NewTrackingReqBody ¶
type NewTrackingReqBody struct {
Tracking NewTracking `json:"tracking"`
}
type NotificationSetting ¶
type NotificationSetting struct { Android []string `json:"android"` Emails []string `json:"emails"` Ios []string `json:"ios"` Smses []string `json:"smses"` }
NotificationSetting a notification setting
type NotificationSettingEnvelope ¶
type NotificationSettingEnvelope struct { Meta ResponseMeta `json:"meta"` Data NotificationSettingWrapper `json:"data"` }
NotificationSettingEnvelope is the message envelope for the notification API responses
func (*NotificationSettingEnvelope) ResponseCode ¶
func (envelope *NotificationSettingEnvelope) ResponseCode() ResponseMeta
ResponseCode provides implementation of Response.ResponseCode() for NotificationSettingEnvelope struct
type NotificationSettingWrapper ¶
type NotificationSettingWrapper struct {
Notification NotificationSetting `json:"notification"`
}
type NotificationsHandler ¶
type NotificationsHandler interface { // AddNotification Adds notifications to a tracking number. AddNotification(id TrackingId, notification NotificationSetting) (NotificationSetting, AfterShipApiError) // RemoveNotification Removes notifications from a tracking number. RemoveNotification(id TrackingId, notification NotificationSetting) (NotificationSetting, AfterShipApiError) // GetNotificationSetting Gets notifications value from a tracking number. GetNotificationSetting(id TrackingId, fields string) (NotificationSetting, AfterShipApiError) }
NotificationsHandler provides the interface for all notifications handling API calls in AfterShip APIV4
type Response ¶
type Response interface {
ResponseCode() ResponseMeta
}
type ResponseMeta ¶
type RetryPolicy ¶
RetryPolicy configures retry policy
type Tracking ¶
type Tracking struct { NewTracking // TODO write a function on this type to convert slug field with a switch Slug interface{} `json:"slug"` Id string `json:"id"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` Active bool `json:"active"` ExpectedDelivery string `json:"expected_delivery"` Note string `json:"note"` OriginCountryIso3 string `json:"origin_country_iso3"` ShipmentPackageCount int `json:"shipment_package_count"` ShipmentType string `json:"shipment_type"` SignedBy string `json:"signed_by"` Source string `json:"source"` Tag string `json:"tag"` TrackCount int `json:"tracked_count"` UniqueToken string `json:"unique_token"` CheckPoints []CheckPoint `json:"checkpoints"` }
Tracking represents a Tracking returned by the Aftership API
type TrackingEnvelope ¶
type TrackingEnvelope struct { Meta ResponseMeta `json:"meta"` Data TrackingResponseData `json:"data"` }
TrackingEnvelope is the message envelope for the tracking API responses
func (*TrackingEnvelope) ResponseCode ¶
func (envelope *TrackingEnvelope) ResponseCode() ResponseMeta
ResponseCode provides implementation of Response.ResponseCode() for TrackingEnvelope struct
type TrackingId ¶
TrackingId identifies a Tracking to be deleted its mandatory to provide either Id or Slug and TrackingNumber both
type TrackingResponseData ¶
type TrackingResponseData struct {
Tracking Tracking `json:"tracking"`
}
TrackingResponseData is a model for data part of the tracking API responses
type TrackingUpdate ¶
type TrackingUpdate struct { Emails []string `json:"emails,omitempty"` Smses []string `json:"smses,omitempty"` Title string `json:"title,omitempty"` CustomerName string `json:"customer_name,omitempty"` DestinationCountryIso3 string `json:"destination_country_iso3,omitempty"` OrderId string `json:"order_id,omitempty"` OrderIdPath string `json:"order_id_path,omitempty"` CustomFields map[string]string `json:"custom_fields,omitempty"` }
TrackingUpdate represents an update to Tracking details
type TrackingUpdateReqBody ¶
type TrackingUpdateReqBody struct {
Tracking TrackingUpdate `json:"tracking"`
}
type TrackingsData ¶
type TrackingsData struct { GetTrackingsParams Origin []string `json:"origin"` Destination []string `json:"destination"` Cursor string `json:"cursor"` Trackings []Tracking `json:"trackings"` }
type TrackingsEnvelope ¶
type TrackingsEnvelope struct { Meta ResponseMeta `json:"meta"` Data TrackingsData `json:"data"` }
TrackingsEnvelope is the message envelope for the trackings API responses
func (*TrackingsEnvelope) ResponseCode ¶
func (envelope *TrackingsEnvelope) ResponseCode() ResponseMeta
ResponseCode provides implementation of Response.ResponseCode() for TrackingEnvelope struct
type TrackingsHandler ¶
type TrackingsHandler interface { // CreateTracking Creates a tracking. CreateTracking(newTracking NewTracking) (Tracking, AfterShipApiError) // DeleteTracking Deletes a tracking. DeleteTracking(id TrackingId) (DeletedTracking, AfterShipApiError) // GetTrackings Gets tracking results of multiple trackings. GetTrackings(params GetTrackingsParams) (TrackingsData, AfterShipApiError) // GetTrackingsExport Gets all trackings results (for backup or analytics purpose) GetTrackingsExport(params GetTrackingsParams) (TrackingsData, AfterShipApiError) // GetTracking Gets tracking results of a single tracking. // fields : List of fields to include in the response. Use comma for multiple values. // Fields to include: tracking_postal_code,tracking_ship_date,tracking_account_number, // tracking_key,tracking_destination_country, title,order_id,tag,checkpoints, // checkpoint_time, message, country_name GetTracking(id TrackingId, fields string, lang string) (Tracking, AfterShipApiError) // UpdateTracking Updates a tracking. UpdateTracking(id TrackingId, update TrackingUpdate) (Tracking, AfterShipApiError) // ReTrack an expired tracking once. Max. 3 times per tracking. ReTrack(id TrackingId) (Tracking, AfterShipApiError) // LastCheckPoint Return the tracking information of the last checkpoint of a single tracking. GetLastCheckPoint(id TrackingId, fields string, lang string) (LastCheckPoint, AfterShipApiError) }
TrackingsHandler provides the interface for all trackings handling API calls in AfterShip APIV4