postmord

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 7 Imported by: 0

README

postmord

A Go API wrapper for the PostNord track and trace API

Example

$ go get -u github.com/antonjah/postmord
package main

import (
	"fmt"
	"github.com/antonjah/postmord"
)

func main() {
	client := postmord.NewClient("MyConsumerAPIKey", nil, postmord.DefaultOptions)
	response, err := client.FindByIdentifier("MyShipmentID")
	if err != nil {
		// handle error
	}

	for _, shipment := range response.TrackingInformation.Shipments {
		fmt.Println(shipment.ShipmentID, shipment.StatusText)
	}

	// JSON
	j, _ := response.JSON()

	// YAML
	y, _ := response.YAML()

	// XML
	x, _ := response.XML()
}

Author

@antonjah

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = &Options{Locale: LocaleDefault}

Functions

This section is empty.

Types

type Acceptor

type Acceptor struct {
	SignatureReference string `json:"signatureReference"`
	Name               string `json:"name"`
}

type AdditionalServices

type AdditionalServices struct {
	Code      string `json:"code"`
	GroupCode string `json:"groupCode"`
	Name      string `json:"name"`
}

type Address

type Address struct {
	Street1     string `json:"street1"`
	Street2     string `json:"street2"`
	City        string `json:"city"`
	CountryCode string `json:"countryCode"`
	Country     string `json:"country"`
	PostCode    string `json:"postCode"`
}

type AssessedMeasurement

type AssessedMeasurement struct {
	Weight Weight `json:"weight"`
	Length Length `json:"length"`
	Height Height `json:"height"`
	Width  Width  `json:"width"`
	Volume Volume `json:"volume"`
}

type AssessedVolume

type AssessedVolume struct {
	Value string `json:"value"`
	Unit  string `json:"unit"`
}

type AssessedWeight

type AssessedWeight struct {
	Value string `json:"value"`
	Unit  string `json:"unit"`
}

type Client

type Client struct {
	APIKey string
	Opts   *Options
	// contains filtered or unexported fields
}

Client is used to retrieve information about shipments.

func NewClient

func NewClient(apiKey string, httpClient *http.Client, opts *Options) Client

func (*Client) FindByIdentifier

func (c *Client) FindByIdentifier(id string) (*Response, error)

func (*Client) FindByReference

func (c *Client) FindByReference(customerNumber, reference string) (*Response, error)

type CollectionParty

type CollectionParty struct {
	Name    string  `json:"name"`
	Address Address `json:"address"`
	Contact Contact `json:"contact"`
}

type CompositeFault

type CompositeFault struct {
	Faults []Faults `json:"faults"`
}

type Consignee

type Consignee struct {
	Name    string  `json:"name"`
	Address Address `json:"address"`
}

type Consignor

type Consignor struct {
	Name       string  `json:"name"`
	Issuercode string  `json:"issuercode"`
	Address    Address `json:"address"`
}

type Contact

type Contact struct {
	ContactName string `json:"contactName"`
	Phone       string `json:"phone"`
	MobilePhone string `json:"mobilePhone"`
	Email       string `json:"email"`
}

type Coordinate

type Coordinate struct {
	SrID     string `json:"srId"`
	Northing string `json:"northing"`
	Easting  string `json:"easting"`
}

type DeliveryPoint

type DeliveryPoint struct {
	Name             string        `json:"name"`
	LocationDetail   string        `json:"locationDetail"`
	Address          Address       `json:"address"`
	Contact          Contact       `json:"contact"`
	Coordinate       []Coordinate  `json:"coordinate"`
	OpeningHour      []OpeningHour `json:"openingHour"`
	DisplayName      string        `json:"displayName"`
	LocationID       string        `json:"locationId"`
	ServicePointType string        `json:"servicePointType"`
}

type DestinationDeliveryPoint

type DestinationDeliveryPoint struct {
	Name             string        `json:"name"`
	LocationDetail   string        `json:"locationDetail"`
	Address          Address       `json:"address"`
	Contact          Contact       `json:"contact"`
	Coordinate       []Coordinate  `json:"coordinate"`
	OpeningHour      []OpeningHour `json:"openingHour"`
	DisplayName      string        `json:"displayName"`
	LocationID       string        `json:"locationId"`
	ServicePointType string        `json:"servicePointType"`
}

type Events

type Events struct {
	EventTime          civil.DateTime `json:"eventTime"`
	EventCode          string         `json:"eventCode"`
	Location           Location       `json:"location"`
	GeoLocation        GeoLocation    `json:"geoLocation"`
	Status             string         `json:"status"`
	EventDescription   string         `json:"eventDescription"`
	LocalDeviationDode string         `json:"localDeviationDode"`
}

type Faults

type Faults struct {
	FaultCode       string        `json:"faultCode"`
	ExplanationText string        `json:"explanationText"`
	ParamValues     []ParamValues `json:"paramValues"`
}

type FreeText

type FreeText struct {
	Text string `json:"text"`
	Type string `json:"type"`
}

type GeoLocation

type GeoLocation struct {
	GeoNorthing        int    `json:"geoNorthing"`
	GeoEasting         int    `json:"geoEasting"`
	GeoReferenceSystem string `json:"geoReferenceSystem"`
	GeoPostalCode      string `json:"geoPostalCode"`
	GeoCity            string `json:"geoCity"`
	GeoCountryCode     string `json:"geoCountryCode"`
}

type Height

type Height struct {
	Value string `json:"value"`
	Unit  string `json:"unit"`
}

type Items

type Items struct {
	ItemID                 string              `json:"itemId"`
	EstimatedTimeOfArrival civil.DateTime      `json:"estimatedTimeOfArrival"`
	DropOffDate            civil.DateTime      `json:"dropOffDate"`
	DeliveryDate           civil.DateTime      `json:"deliveryDate"`
	ReturnDate             civil.DateTime      `json:"returnDate"`
	TypeOfItem             string              `json:"typeOfItem"`
	TypeOfItemName         string              `json:"typeOfItemName"`
	TypeOfItemActual       string              `json:"typeOfItemActual"`
	TypeOfItemActualName   string              `json:"typeOfItemActualName"`
	AdditionalInformation  string              `json:"additionalInformation"`
	NoItems                int                 `json:"noItems"`
	NumberOfPallets        string              `json:"numberOfPallets"`
	Status                 string              `json:"status"`
	StatusText             StatusText          `json:"statusText"`
	Acceptor               Acceptor            `json:"acceptor"`
	StatedMeasurement      StatedMeasurement   `json:"statedMeasurement"`
	AssessedMeasurement    AssessedMeasurement `json:"assessedMeasurement"`
	Events                 []Events            `json:"events"`
	References             []References        `json:"references"`
	PreviousItemStates     []string            `json:"previousItemStates"`
	FreeText               []FreeText          `json:"freeText"`
}

type Length

type Length struct {
	Value string `json:"value"`
	Unit  string `json:"unit"`
}

type Locale

type Locale string
const (
	LocaleEnglish   Locale = "en"
	LocaleSwedish   Locale = "sv"
	LocaleDanish    Locale = "dk"
	LocaleNorwegian Locale = "no"
	LocaleFinnish   Locale = "fi"

	LocaleDefault = LocaleEnglish
)

func (Locale) String

func (l Locale) String() string

type Location

type Location struct {
	Name         string `json:"name"`
	CountryCode  string `json:"countryCode"`
	Country      string `json:"country"`
	LocationID   string `json:"locationId"`
	DisplayName  string `json:"displayName"`
	Postcode     string `json:"postcode"`
	City         string `json:"city"`
	LocationType string `json:"locationType"`
}

type OpeningHour

type OpeningHour struct {
	OpenFrom  string `json:"openFrom"`
	OpenTo    string `json:"openTo"`
	OpenFrom2 string `json:"openFrom2"`
	OpenTo2   string `json:"openTo2"`
	Monday    bool   `json:"monday"`
	Tuesday   bool   `json:"tuesday"`
	Wednesday bool   `json:"wednesday"`
	Thursday  bool   `json:"thursday"`
	Friday    bool   `json:"friday"`
	Saturday  bool   `json:"saturday"`
	Sunday    bool   `json:"sunday"`
}

type Options

type Options struct {
	Locale Locale
}

Options is used to set the options used to retrieve information about shipments.

type ParamValues

type ParamValues struct {
	Param string `json:"param"`
	Value string `json:"value"`
}

type PickupParty

type PickupParty struct {
	Name    string  `json:"name"`
	Address Address `json:"address"`
	Contact Contact `json:"contact"`
}

type References

type References struct {
	Value string `json:"value"`
	Type  string `json:"type"`
	Name  string `json:"name"`
}

type Response

type Response struct {
	TrackingInformation TrackingInformation `json:"TrackingInformationResponse"`
}

func (*Response) JSON

func (r *Response) JSON() ([]byte, error)

func (*Response) XML

func (r *Response) XML() ([]byte, error)

func (*Response) YAML

func (r *Response) YAML() ([]byte, error)

type ReturnParty

type ReturnParty struct {
	Name    string  `json:"name"`
	Address Address `json:"address"`
	Contact Contact `json:"contact"`
}

type Service

type Service struct {
	Code string `json:"code"`
	Name string `json:"name"`
}

type ShipmentReferences

type ShipmentReferences struct {
	Value string `json:"value"`
	Type  string `json:"type"`
	Name  string `json:"name"`
}

type Shipments

type Shipments struct {
	ShipmentID               string                   `json:"shipmentId"`
	URI                      string                   `json:"uri"`
	AssessedNumberOfItems    int                      `json:"assessedNumberOfItems"`
	CashOnDeliveryText       string                   `json:"cashOnDeliveryText"`
	DeliveryDate             civil.DateTime           `json:"deliveryDate"`
	ReturnDate               civil.DateTime           `json:"returnDate"`
	EstimatedTimeOfArrival   civil.DateTime           `json:"estimatedTimeOfArrival"`
	NumberOfPallets          string                   `json:"numberOfPallets"`
	FlexChangePossible       bool                     `json:"flexChangePossible"`
	Service                  Service                  `json:"service"`
	Consignor                Consignor                `json:"consignor"`
	Consignee                Consignee                `json:"consignee"`
	ReturnParty              ReturnParty              `json:"returnParty"`
	PickupParty              PickupParty              `json:"pickupParty"`
	CollectionParty          CollectionParty          `json:"collectionParty"`
	StatusText               StatusText               `json:"statusText"`
	Status                   string                   `json:"status"`
	DeliveryPoint            DeliveryPoint            `json:"deliveryPoint"`
	DestinationDeliveryPoint DestinationDeliveryPoint `json:"destinationDeliveryPoint"`
	TotalWeight              TotalWeight              `json:"totalWeight"`
	TotalVolume              TotalVolume              `json:"totalVolume"`
	AssessedWeight           AssessedWeight           `json:"assessedWeight"`
	AssessedVolume           AssessedVolume           `json:"assessedVolume"`
	SplitStatuses            []SplitStatuses          `json:"splitStatuses"`
	ShipmentReferences       []ShipmentReferences     `json:"shipmentReferences"`
	AdditionalServices       []AdditionalServices     `json:"additionalServices"`
	HarmonizedVersion        int                      `json:"harmonizedVersion"`
	Items                    []Items                  `json:"items"`
}

type SplitStatuses

type SplitStatuses struct {
	NoItemsWithStatus int    `json:"noItemsWithStatus"`
	NoItems           int    `json:"noItems"`
	StatusDescription string `json:"statusDescription"`
	Status            string `json:"status"`
}

type StatedMeasurement

type StatedMeasurement struct {
	Weight Weight `json:"weight"`
	Length Length `json:"length"`
	Height Height `json:"height"`
	Width  Width  `json:"width"`
	Volume Volume `json:"volume"`
}

type StatusText

type StatusText struct {
	Header                 string `json:"header"`
	Body                   string `json:"body"`
	EstimatedTimeOfArrival string `json:"estimatedTimeOfArrival"`
}

type TotalVolume

type TotalVolume struct {
	Value string `json:"value"`
	Unit  string `json:"unit"`
}

type TotalWeight

type TotalWeight struct {
	Value string `json:"value"`
	Unit  string `json:"unit"`
}

type TrackingInformation

type TrackingInformation struct {
	CompositeFault CompositeFault `json:"compositeFault"`
	Shipments      []Shipments    `json:"shipments"`
}

type Volume

type Volume struct {
	Value string `json:"value"`
	Unit  string `json:"unit"`
}

type Weight

type Weight struct {
	Value string `json:"value"`
	Unit  string `json:"unit"`
}

type Width

type Width struct {
	Value string `json:"value"`
	Unit  string `json:"unit"`
}

Jump to

Keyboard shortcuts

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