Documentation ¶
Index ¶
Constants ¶
View Source
const ( // Carriers CarrierPostnl = 1 // (PostNL) CarrierBpost = 2 // (bpost. Only available on Sendmyparcel.be) CarrierCheapCargo = 3 // (CheapCargo/pallets) CarrierDpd = 4 // (DPD. Only available on Sendmyparcel.be) CarrierInstabox = 5 // (Instabox. Only available on MyParcel.nl) CarrierUps = 8 // (UPS. Only available on MyParcel.nl) // Package types ParcelPackage = 1 // This is the standard package type used for NL, EU and Global shipments. It supports a variety of additional options such as insurance, xl format etc. We will look at these options in more detail later. This package is most commonly used when creating shipments. ParcelMailbox = 2 // This package type is only available on MyParcel.nl and Flespakket for NL shipment that fit into a mailbox. It does not support additional options. Note: If you still make the request with additional options, bear in mind that you need to pay more than is necessary! ParcelLetter = 3 // This package type is available on MyParcel.nl for NL, EU and Global shipments. The label for this shipment is unpaid meaning that you will need to pay the postal office/courier to sent this letter/package. Therefore, it does not support additional options. ParcelStamp = 4 // This package type is only available on MyParcel.nl for NL shipments and does not support any additional options. Its price is calculated using the package weight. Note: This shipment will appear on your invoice on shipment_status 2 (pending - registered) as opposed to all other package types, which won't appear on your invoice until shipment status 3 (enroute - handed to carrier). // Delivery types DeliveryMorning = 1 // Morning delivery DeliveryStandard = 2 // Standard delivery DeliveryEvening = 3 // Evening delivery DeliveryPickup = 4 // Pickup point delivery )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is the MyParcel client.
func NewClient ¶
NewClient returns a new MyParcel client. The API key is required to use the MyParcel API.
func (*Client) CreateShipment ¶
func (c *Client) CreateShipment(shipment ShipmentCreateStruct) (int, error)
CreateShipment creates a new shipment.
func (*Client) GetShipment ¶
func (c *Client) GetShipment(id int) (ShipmentResponseStruct, error)
GetShipment returns a shipment by ID.
type InsuranceStruct ¶
type InsuranceStruct struct { Amount int `json:"amount"` // Required: yes. The amount is without decimal separators (in cents). Currency string `json:"currency"` // Required: yes. The insurance currency code. Must be one of the following: EUR. }
Insurance struct
type JSONTime ¶
JSONTime is a custom time type that can be marshalled to JSON.
func (JSONTime) MarshalJSON ¶
MarshalJSON returns the JSON encoding of time specified in the format
type OptionsStruct ¶
type OptionsStruct struct { PackageType int `json:"package_type"` // Required: yes. The package type. For international shipment only package type 1 (package) is allowed. OnlyRecipient int `json:"only_recipient,omitempty"` // Required: No. Deliver the package to the recipient only. DeliveryType int `json:"delivery_type,omitempty"` // Required: Yes if delivery_date has been specified. The delivery type for the package. DeliveryDate JSONTime `json:"delivery_date,omitempty"` // Required: Yes if delivery type has been specified. The delivery date time for this shipment. Signature int `json:"signature,omitempty"` // Required: No. Package must be signed for. Return int `json:"return,omitempty"` // Required: No. Return the package if the recipient is not home. Insurance InsuranceStruct `json:"insurance"` // Required: No. Insurance price for the package. LargeFormat int `json:"large_format"` // Required: No. Large format package. LabelDescription string `json:"label_description"` // Required: No. This description will appear on the shipment label. Note: This will be overridden for return shipment by the following: Retour – 3SMYPAMYPAXXXXXX AgeCheck int `json:"age_check"` // Required: No. The recipient must sign for the package and must be at least 18 years old. }
Options struct
type RecipientStruct ¶
type RecipientStruct struct { Cc string `json:"cc"` // Required: yes. The address country code. Region string `json:"region,omitempty"` // Required: no. The region, department, state or province of the address. City string `json:"city"` // Required: yes. The address city. Street string `json:"street"` // Required: yes. The address street name. When shipping to an international destination, you may include street number in this field. Number string `json:"number"` // Required: yes for domestic shipments in NL and BE. Street number. PostalCode string `json:"postal_code"` // Required: yes for NL and EU destinations except for IE. The address postal code. Person string `json:"person"` // Required: yes. The person at this address. Up to 40 characters long. Phone string `json:"phone,omitempty"` // Required: no. The address phone. Email string `json:"email,omitempty"` // Required: no The address email. }
Insurance struct
type SenderStruct ¶
type SenderStruct struct { Cc string `json:"cc,omitempty"` // Required: yes. The address country code. Region string `json:"region,omitempty"` // Required: no. The region, department, state or province of the address. City string `json:"city,omitempty"` // Required: yes. The address city. Street string `json:"street,omitempty"` // Required: yes. The address street name. When shipping to an international destination, you may include street number in this field. Number string `json:"number,omitempty"` // Required: yes for domestic shipments in NL and BE. Street number. PostalCode string `json:"postal_code,omitempty"` // Required: yes for NL and EU destinations except for IE. The address postal code. Person string `json:"person,omitempty"` // Required: yes. The person at this address. Up to 40 characters long. Phone string `json:"phone,omitempty"` // Required: no. The address phone. Email string `json:"email,omitempty"` // Required: no The address email. }
Sender struct
type ShipmentCreateStruct ¶
type ShipmentCreateStruct struct { Recipient RecipientStruct `json:"recipient"` // Required: Yes. The recipient address. ReferenceIdentifier string `json:"reference_identifier"` // Required: No. Arbitrary reference indentifier to identify this shipment. Options OptionsStruct `json:"options"` // Required: Yes. The shipment options. Carrier int `json:"carrier"` // Required: Yes. The carrier that will deliver the package. Barcode string `json:"barcode,omitempty"` // Required: n/a. Shipment barcode. SecondaryShipments interface{} `json:"secondary_shipments,omitempty"` // Required: no. You can specify secondary shipments for the shipment with this object. This property is used to create a multi collo shipment: multiple packages to be delivered to the same address at the same time. Secondary shipment can be passed as empty json objects as all required data will be copied from the main shipment. When data is passed with the secondary shipment this data will be used in favor of the main shipment data. MultiColloMainShipmentID interface{} `json:"multi_collo_main_shipment_id,omitempty"` // Required: n/a. In case of a multi collo shipment this field contains the id of the main shipment. Created string `json:"created,omitempty"` // Required: n/a. Date of creaton. Modified string `json:"modified,omitempty"` // Required: n/a. Date of modification. }
Shipment struct
type ShipmentRequest ¶
type ShipmentRequest struct { Data struct { Shipments []ShipmentCreateStruct `json:"shipments"` } `json:"data"` }
ShipmentRequest struct with data and with multiple shipments
type ShipmentRequestStruct ¶
type ShipmentRequestStruct struct { Recipient RecipientStruct `json:"recipient"` // Required: Yes. The recipient address. Sender SenderStruct `json:"sender,omitempty"` // Required: n/a. The sender of the package. This field is never set. ReferenceIdentifier string `json:"reference_identifier"` // Required: No. Arbitrary reference indentifier to identify this shipment. Options OptionsStruct `json:"options"` // Required: Yes. The shipment options. Carrier int `json:"carrier"` // Required: Yes. The carrier that will deliver the package. Barcode string `json:"barcode,omitempty"` // Required: n/a. Shipment barcode. SecondaryShipments interface{} `json:"secondary_shipments,omitempty"` // Required: no. You can specify secondary shipments for the shipment with this object. This property is used to create a multi collo shipment: multiple packages to be delivered to the same address at the same time. Secondary shipment can be passed as empty json objects as all required data will be copied from the main shipment. When data is passed with the secondary shipment this data will be used in favor of the main shipment data. MultiColloMainShipmentID interface{} `json:"multi_collo_main_shipment_id,omitempty"` // Required: n/a. In case of a multi collo shipment this field contains the id of the main shipment. Created string `json:"created,omitempty"` // Required: n/a. Date of creaton. Modified string `json:"modified,omitempty"` // Required: n/a. Date of modification. }
type ShipmentResponseStruct ¶
type ShipmentResponseStruct struct { Data struct { Shipments []ShipmentRequestStruct `json:"shipments"` Results int `json:"results"` } `json:"data"` }
Click to show internal directories.
Click to hide internal directories.