Documentation
¶
Overview ¶
Package myflyingbox implements a Go REST client for the MyFlyingBox API
Index ¶
- Constants
- Variables
- type API
- func (a *API) CancelOrder(ctx context.Context, o interface{}) (*Order, error)
- func (a *API) Do(ctx context.Context, req *http.Request, result interface{}) error
- func (a *API) Get(ctx context.Context, urlStr string, result interface{}) error
- func (a *API) GetOrder(ctx context.Context, o interface{}) (*Order, error)
- func (a *API) LabelPDF(ctx context.Context, o interface{}) ([]byte, error)
- func (a *API) PlaceOrder(ctx context.Context, o *Order) (*Order, error)
- func (a *API) Post(ctx context.Context, urlStr string, data, result interface{}) error
- func (a *API) Put(ctx context.Context, urlStr string, result interface{}) error
- func (a *API) RequestQuote(ctx context.Context, q *Quote) (*Quote, error)
- func (a *API) RetrieveQuote(ctx context.Context, q interface{}) (*Quote, error)
- func (a *API) SetTestMode(test bool) *API
- func (a *API) SetURL(urlStr string) *API
- func (a *API) Track(ctx context.Context, o interface{}) (list []Tracking, err error)
- type CollectionDate
- type DeliveryLocation
- type Details
- type ErrorInfo
- type Event
- type Label
- type Location
- type Offer
- type OpeningTime
- type Order
- type Parcel
- type Price
- type Product
- type Quote
- type Recipient
- type Request
- type Response
- type Shipper
- type Tracking
Constants ¶
const ( // ProductionURL is the production API base endpoint ProductionURL = "https://api.myflyingbox.com/v2" // TestURL is the production API base endpoint TestURL = "https://test.myflyingbox.com/v2" )
Variables ¶
var ( // ErrInvalidArgumentType is returns when a argument which has an interface // type does not recieve a value it can use ErrInvalidArgumentType = errors.New("invalid argument type") ErrNoOrderID = errors.New("no order id") ErrNoQuoteID = errors.New("no quote id") )
Error messages
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// Client is the http client used for requests. If nil, an appropriate default is used
Client *http.Client
// contains filtered or unexported fields
}
API is a myflyingbox.com API client for Go
func New ¶
New creates a new API client. If in Google App Engine development envirnonment, it will automatically be set to test mode
func (*API) CancelOrder ¶
CancelOrder cancels the given order.
func (*API) PlaceOrder ¶
PlaceOrder creates an order and returns the results
func (*API) Post ¶
Post sends a POST request with the JSON encoded data to the urlStr and marshals response into result
func (*API) RequestQuote ¶
RequestQuote places a quote request and returns the result
func (*API) RetrieveQuote ¶
RetrieveQuote retrieves details for an existing quote.
func (*API) SetTestMode ¶
SetTestMode toggles mode to test
type CollectionDate ¶
CollectionDate is a sub-element
type DeliveryLocation ¶
type DeliveryLocation struct {
Company string `json:"company"`
Street []string `json:"street"`
PostalCode string `json:"postal_code"`
City string `json:"city"`
OpeningHours []OpeningTime
}
DeliveryLocation is a MyFlyingBox delivery location
type ErrorInfo ¶
type ErrorInfo struct {
Type string `json:"type"`
Message string `json:"message"`
Details []string `json:"details"`
}
ErrorInfo is an upstream error
type Event ¶
type Event struct {
Code string `json:"code"`
HappendAt time.Time `json:"happened_at"`
Label Label `json:"label"`
Location Location `json:"location"`
Details Details `json:"details"`
}
Event is a tracking event
type Location ¶
type Location struct {
Name string `json:"name"`
Street []string `json:"street"`
City string `json:"city"`
PostalCode string `json:"postal_code,omitempty"`
Country string `json:"country,omitempty"`
}
Location is a location
type Offer ¶
type Offer struct {
ID string `json:"id"`
QuoteID string `json:"quote_id"`
ProductID string `json:"product_id"`
Product Product `json:"product"`
Price *Price `json:"price,omitempty"`
PriceVAT *Price `json:"price_vat,omitempty"`
TotalPrice *Price `json:"total_price,omitempty"`
InsurancePrice *Price `json:"insurance_price,omitempty"`
CollectionDates []CollectionDate `json:"collection_dates,omitempty"`
// Response data.
Insurable bool `json:"insurable"`
Orderable bool `json:"orderable"`
}
Offer is a offer struct
type OpeningTime ¶
OpeningTime provides opening time details for a location
type Order ¶
type Order struct {
// Used in placing the order.
OfferID string `json:"offer_id,omitempty"`
ThermalLabels bool `json:"thermal_labels,omitempty"`
InsureShipment bool `json:"insure_shipment,omitempty"`
Shipper Shipper `json:"shipper"`
Parcels []Parcel `json:"parcels,omitempty"`
// Used when retrieving the order\
ID string `json:"id,omitempty"`
Recipient Recipient `json:"recipient,omitempty"`
}
Order is the struct used to place an order.
type Parcel ¶
type Parcel struct {
Weight float64 `json:"weight,omitempty"`
Length float64 `json:"length,omitempty"`
Width float64 `json:"width,omitempty"`
Height float64 `json:"height,omitempty"`
Value int64 `json:"value,string,omitempty"`
Currency string `json:"currency"`
Description string `json:"description"`
ShipperReference string `json:"shipper_reference"`
RecipientReference string `json:"recipient_reference"`
CustomerReference string `json:"customer_reference"`
CountryOfOrigin string `json:"country_of_origin"`
InsuredValue float64 `json:"insured_value,omitempty"`
InsuredCurrency string `json:"insured_currency,omitempty"`
}
Parcel is a parcel
type Price ¶
type Price struct {
Formatted string `json:"formatted"`
Currency string `json:"currency"`
Amount float64 `json:"amount,string"`
AmountInCents int `json:"amount_in_cents"`
}
Price is a price struct
type Product ¶
type Product struct {
ID string `json:"id"`
Logo string `json:"logo"`
Code string `json:"code"`
Name string `json:"name"`
Delay string `json:"delay"`
Pickup bool `json:"pick_up"`
Dropoff bool `json:"drop_off"`
PresetDeliveryLocation bool `json:"preset_delivery_location"`
ExportFrom []string `json:"export_from,omitempty"`
CarrierCode string `json:"carrier_code,omitempty"`
CollectionInformations map[string]string `json:"collection_informations,omitempty"`
DeliveryInformations map[string]string `json:"delivery_informations,omitempty"`
Details map[string]string `json:"details,comitempty"`
}
Product is a MyFlyingBox product
type Quote ¶
type Quote struct {
Shipper Shipper `json:"shipper"`
Recipient Recipient `json:"recipient"`
Parcels []Parcel `json:"parcels"`
Offers []Offer `json:"offers"`
ID string `json:"id,omitempty"`
Ordered bool `json:"ordered"`
}
Quote is a MyFlyingBox quote
type Recipient ¶
type Recipient struct {
Name string `json:"name"`
Company string `json:"company"`
Street string `json:"street"`
City string `json:"city"`
State string `json:"state"`
PostalCode string `json:"postal_code"`
Country string `json:"country"`
Phone string `json:"phone"`
Email string `json:"email"`
IsACompany bool `json:"is_a_company,string"`
LocationCode string `json:"location_code,omitempty"`
}
Recipient is a recipient
type Request ¶
Request is a struct used for sending requests of all types since request elements need to be wrapped in a root element of the same name
type Response ¶
type Response struct {
Status string `json:"status"`
Self string `json:"self"`
Count int `json:"count"`
Data interface{} `json:"data"`
ErrorInfo *ErrorInfo `json:"error"`
}
Response is the base response type for all API responses.
type Shipper ¶
type Shipper struct {
City string `json:"city,omitempty"`
Country string `json:"country,omitempty"`
PostalCode string `json:"postal_code,omitempty"`
Name string `json:"name,omitempty"`
Company string `json:"company,omitempty"`
Street string `json:"street,omitempty"`
State string `json:"state,omitempty"`
Phone string `json:"phone,omitempty"`
// CollectionDate is used to request collection date from a shipper when placing an order
CollectionDate *time.Time `json:"collection_date,omitempty"`
Email string `json:"email,omitempty"`
}
Shipper is a shipper