parcel

package
v0.0.0-...-c5d5a31 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package parcel shows package status for UPS, Fedex and others

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Expected

type Expected struct {
	Delivery string    `json:"delivery"`
	Date     time.Time `json:"expected"`
}

Expected is the expected delivery date and time

type FedEx

type FedEx struct {
	HTTPClient *http.Client
	Key        string
	Password   string
	Account    string
	Meter      string
}

FedEx holds settings for the FedEx API

func (*FedEx) Fetch

func (f *FedEx) Fetch(trackingNumber string) (Response, error)

Fetch retrieves from the FedEx API

type FedExResponse

type FedExResponse struct {
	Response
	Body struct {
		TrackReply struct {
			HighestSeverity string `xml:"HighestSeverity"`
			Notifications   []struct {
				Severity         string
				Source           string
				Code             int
				Message          string
				LocalizedMessage string
			}
			Version struct {
				ServiceID    string
				Major        int
				Intermediate int
				Minor        int
			}
			CompletedTrackDetails struct {
				HighestSeverity string
				Notifications   []struct {
					Severity         string
					Source           string
					Code             int
					Message          string
					LocalizedMessage string
				}
				DuplicateWaybill bool
				MoreData         bool
				TrackDetails     struct {
					TrackingNumber                 string
					TrackingNumberUniqueIdentifier string
					Notification                   struct {
						Severity         string
						Source           string
						Code             int
						Message          string
						LocalizedMessage string
					}
					StatusDetail struct {
						CreationTime string
						Code         string
						Description  string
						Location     struct {
							StreetLines         string
							City                string
							StateOrProvinceCode string
							CountryCode         string
							CountryName         string
							Residential         bool
						}
						AncillaryDetails []struct {
							Reason            string
							ReasonDescription string
						}
					}
					CarrierCode                          string
					OperatingCompanyOrCarrierDescription string
					OtherIdentifiers                     []struct {
						PackageIdentifier struct {
							Type  string
							Value string
						}
					}
					Service struct {
						Type             string
						Description      string
						ShortDescription string
					}
					PackageWeight struct {
						Units string
						Value float64
					}
					ShipmentWeight struct {
						Units string
						Value float64
					}
					Packaging             string
					PackagingType         string
					PackageSequenceNumber int
					PackageCount          int
					SpecialHandlings      []struct {
						Type        string
						Description string
						PaymentType string
					}
					ShipTimestamp           string
					ActualDeliveryTimestamp string
					DestinationAddress      struct {
						StreetLines         string
						City                string
						StateOrProvinceCode string
						CountryCode         string
						CountryName         string
						Residential         bool
					}
					ActualDeliveryAddress struct {
						StreetLines         string
						City                string
						StateOrProvinceCode string
						CountryCode         string
						CountryName         string
						Residential         bool
					}
					DeliveryLocationType                   string
					DeliveryLocationDescription            string
					DeliveryAttempts                       int
					DeliverySignatureName                  string
					TotalUniqueAddressCountInConsolidation int
					NotificationEventsAvailable            string
					RedirectToHoldEligibility              string
					Events                                 []struct {
						Timestamp                  string
						EventType                  string
						EventDescription           string
						StatusExceptionCode        string
						StatusExceptionDescription string
						Address                    struct {
							StreetLines         string
							City                string
							StateOrProvinceCode string
							CountryCode         string
							CountryName         string
							Residential         bool
						}
						ArrivalLocation string
					}
				}
			}
		} `xml:"TrackReply"`
	} `xml:"Body"`
}

FedExResponse is FedEx's raw XML response

func (*FedExResponse) UnmarshalXML

func (r *FedExResponse) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML sets the Response fields

type Fetcher

type Fetcher interface {
	Fetch(number string) (Response, error)
}

Fetcher retrieves package info from the UPS API

type Location

type Location struct {
	City    string `json:"city"`
	State   string `json:"state"`
	Country string `json:"country"`
}

Location is a location of an Update

type Response

type Response struct {
	TrackingNumber string   `json:"tracking_number"`
	Updates        []Update `json:"updates"`
	Expected
	URL string `json:"url"`
}

Response is a standardized response for tracking packages

type UPS

type UPS struct {
	HTTPClient *http.Client
	User       string
	Password   string
	Key        string
}

UPS holds settings for the UPS API

func (*UPS) Fetch

func (u *UPS) Fetch(trackingNumber string) (Response, error)

Fetch retrieves from the UPS API

type UPSResponse

type UPSResponse struct {
	Response
	TrackResponse struct {
		Response struct {
			ResponseStatus struct {
				Code        string `json:"Code"`
				Description string `json:"Description"`
			} `json:"ResponseStatus"`
			TransactionReference struct {
				CustomerContext string `json:"CustomerContext"`
			} `json:"TransactionReference"`
		} `json:"Response"`
		Shipment struct {
			InquiryNumber struct {
				Code        string `json:"Code"`
				Description string `json:"Description"`
				Value       string `json:"Value"`
			} `json:"InquiryNumber"`
			ShipperNumber   string `json:"ShipperNumber"`
			ShipmentAddress []struct {
				Type struct {
					Code        string `json:"Code"`
					Description string `json:"Description"`
				} `json:"Type"`
				Address struct {
					AddressLine       interface{} `json:"AddressLine"`
					City              string      `json:"City"`
					StateProvinceCode string      `json:"StateProvinceCode"`
					PostalCode        string      `json:"PostalCode"`
					CountryCode       string      `json:"CountryCode"`
				} `json:"Address"`
			} `json:"ShipmentAddress"`
			ShipmentWeight struct {
				UnitOfMeasurement struct {
					Code string `json:"Code"`
				} `json:"UnitOfMeasurement"`
				Weight string `json:"Weight"`
			} `json:"ShipmentWeight"`
			Service struct {
				Code        string `json:"Code"`
				Description string `json:"Description"`
			} `json:"Service"`
			ReferenceNumber interface{} `json:"ReferenceNumber"`
			DeliveryDetail  struct {
				Type struct {
					Code        string `json:"Code"`
					Description string `json:"Description"`
				} `json:"Type"`
				Date string `json:"Date"`
			} `json:"DeliveryDetail"`
			Package struct {
				TrackingNumber       string `json:"TrackingNumber"`
				PackageServiceOption struct {
					Type struct {
						Code        string `json:"Code"`
						Description string `json:"Description"`
					} `json:"Type"`
				} `json:"PackageServiceOption"`
				Activity []struct {
					ActivityLocation struct {
						Address struct {
							City              string `json:"City"`
							StateProvinceCode string `json:"StateProvinceCode"`
							CountryCode       string `json:"CountryCode"`
						} `json:"Address"`
					} `json:"ActivityLocation"`
					Status struct {
						Type        string `json:"Type"`
						Description string `json:"Description"`
						Code        string `json:"Code"`
					} `json:"Status"`
					Date string `json:"Date"`
					Time string `json:"Time"`
				} `json:"Activity"`
				Message struct {
					Code        string `json:"Code"`
					Description string `json:"Description"`
				} `json:"Message"`
				PackageWeight struct {
					UnitOfMeasurement struct {
						Code string `json:"Code"`
					} `json:"UnitOfMeasurement"`
					Weight string `json:"Weight"`
				} `json:"PackageWeight"`
				ReferenceNumber []struct {
					Code  string `json:"Code"`
					Value string `json:"Value"`
				} `json:"ReferenceNumber"`
			} `json:"Package"`
		} `json:"Shipment"`
		Disclaimer string `json:"Disclaimer"`
	} `json:"TrackResponse"`
}

UPSResponse is UPS's raw JSON response

func (*UPSResponse) UnmarshalJSON

func (r *UPSResponse) UnmarshalJSON(b []byte) error

UnmarshalJSON sets the Response fields

type USPS

type USPS struct {
	HTTPClient *http.Client
	User       string
	Password   string
}

USPS holds settings for the USPS API

func (*USPS) Fetch

func (u *USPS) Fetch(trackingNumber string) (Response, error)

Fetch retrieves from the USPS API

type USPSResponse

type USPSResponse struct {
	Response
	// contains filtered or unexported fields
}

USPSResponse is USPS's raw XML response

func (*USPSResponse) UnmarshalXML

func (r *USPSResponse) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML sets the Response fields

type Update

type Update struct {
	DateTime time.Time `json:"date_time"`
	Location `json:"location"`
	Status   string `json:"status"`
}

Update is a single delivery event for a package

Jump to

Keyboard shortcuts

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