fedex

package module
v0.0.0-...-764a92e Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2014 License: MIT Imports: 6 Imported by: 0

README

fedex

Some Fedex API support for GoLang (ATM just for tracking)

Fedex API's are one of those WDSL SOAP monster documented in a gigantic PDF file, don't we all love those.

I did not bother dealing with all of that here and only created what I needed so far.

I might add more over time but for now it provides:

  • Retrieving Tracking info by either: Tracking number, PO number, or shipper reference number (~order ID) The data is unmarshalled from SOAP into Go structures for more practical usage.

See fedex_example.go for usage examples

Note that you will need an API key and Password as well as Accont and Meter numbers from Fedex. See: http://images.fedex.com/ca_english/businesstools/webservices/Web_Services_Guide_ENG.pdf

Documentation

Overview

fedex provides access to (some) FedEx Soap API's and unmarshall answers into Go structures

History: Nov 20 13 tcolar Creation

Index

Constants

View Source
const (
	// Convenience constants for standard Fedex API url's
	FEDEX_API_URL       = "https://ws.fedex.com:443/web-services"
	FEDEX_API_TEST_URL  = "https://wsbeta.fedex.com:443/web-services"
	FEDEX_TEST_TRACKING = "123456789012"
)
View Source
const (
	FEDEX_SOAP_HEAD = `` /* 656-byte string literal not displayed */

	FEDEX_SOAP_TAIL = `
</q0:TrackRequest>
</soapenv:Body></soapenv:Envelope>`
)

Variables

This section is empty.

Functions

func Dump

func Dump(reply TrackReply)

Dump : Dumps some of the query resuts for testing

Types

type AncillaryDetail

type AncillaryDetail struct {
	Reason            string
	ReasonDescription string
}

type CompletedTrackDetail

type CompletedTrackDetail struct {
	HighestSeverity  string
	Notifications    []Notification
	DuplicateWaybill bool
	MoreData         bool
	TrackDetails     []TrackDetail
}

type Event

type Event struct {
	Timestamp                  string
	EventType                  string
	EventDescription           string
	StatusExceptionCode        string
	StatusExceptionDescription string
	Address                    Location
	ArrivalLocation            string
}

type Fedex

type Fedex struct {
	Key, Password, Account, Meter string
	FedexUrl                      string
}

Fedex : Utility to retrieve data from Fedex API Bypassing painful proper SOAP implementation and just crafting minimal XML messages to get the data we need. Fedex WSDL docs here: http://images.fedex.com/us/developer/product/WebServices/MyWebHelp/DeveloperGuide2012.pdf

func (Fedex) ParseTrackReply

func (f Fedex) ParseTrackReply(xmlResp []byte) (reply TrackReply, err error)

Unmarshal XML SOAP response into a TrackReply

func (Fedex) PostXml

func (f Fedex) PostXml(url string, xml string) (content []byte, err error)

Post Xml to Fedex API and return response

func (Fedex) TrackByNumber

func (f Fedex) TrackByNumber(carrierCode string, trackingNo string) (reply TrackReply, err error)

TrackByNumber : Returns tracking info for a specific Fedex tracking number

func (Fedex) TrackByPo

func (f Fedex) TrackByPo(carrierCode string, po string, postalCode string,
	countryCode string) (reply TrackReply, err error)

TrackByPo : Returns tracking info for a specific Purchase Order (often the OrderId) Note that Fedex requires the Destination Postal Code & country

to match when making PO queries

func (Fedex) TrackByShipperRef

func (f Fedex) TrackByShipperRef(carrierCode string, shipperRef string,
	shipperAccountNumber string) (reply TrackReply, err error)

TrackByShipperRef : Return tracking info for a specific shipper reference ShipperRef is usually an order ID or other unique identifier ShipperAccountNumber is the Fedex account number of the shipper

type Identifier

type Identifier struct {
	Type  string
	Value string
}

type Location

type Location struct {
	StreetLines         string
	City                string
	StateOrProvinceCode string
	CountryCode         string
	CountryName         string
	Residential         bool
}

type Notification

type Notification struct {
	Severity         string
	Source           string
	Code             int
	Message          string
	LocalizedMessage string
}

type OtherIdentifier

type OtherIdentifier struct {
	PackageIdentifier Identifier
}

type Service

type Service struct {
	Type             string
	Description      string
	ShortDescription string
}

type SpecialHandling

type SpecialHandling struct {
	Type        string
	Description string
	PaymentType string
}

type StatusDetail

type StatusDetail struct {
	CreationTime     string
	Code             string
	Description      string
	Location         Location
	AncillaryDetails []AncillaryDetail
}

type TrackDetail

type TrackDetail struct {
	TrackingNumber                         string
	TrackingNumberUniqueIdentifier         string
	Notification                           Notification
	StatusDetail                           StatusDetail
	CarrierCode                            string
	OperatingCompanyOrCarrierDescription   string
	OtherIdentifiers                       []OtherIdentifier
	Service                                Service
	PackageWeight                          Weight
	ShipmentWeight                         Weight
	Packaging                              string
	PackagingType                          string
	PackageSequenceNumber                  int
	PackageCount                           int
	SpecialHandlings                       []SpecialHandling
	ShipTimestamp                          string
	ActualDeliveryTimestamp                string
	DestinationAddress                     Location
	ActualDeliveryAddress                  Location
	DeliveryLocationType                   string
	DeliveryLocationDescription            string
	DeliveryAttempts                       int
	DeliverySignatureName                  string
	TotalUniqueAddressCountInConsolidation int
	NotificationEventsAvailable            string
	RedirectToHoldEligibility              string
	Events                                 []Event
}

type TrackReply

type TrackReply struct {
	HighestSeverity       string
	Notifications         []Notification
	Version               Version
	CompletedTrackDetails []CompletedTrackDetail
}

TrackReply : Track reply root (`xml:"Body>TrackReply"`)

func (TrackReply) Failed

func (r TrackReply) Failed() bool

type Version

type Version struct {
	ServiceId    string
	Major        int
	Intermediate int
	Minor        int
}

type Weight

type Weight struct {
	Units string
	Value float64
}

Jump to

Keyboard shortcuts

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