estes

package module
v0.0.0-...-05a699c Latest Latest
Warning

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

Go to latest
Published: May 22, 2018 License: MIT Imports: 7 Imported by: 0

README

estes

Golang Code to Work With the Estes (Freight Carrier) API

Documentation

Overview

Package estes provides tooling to connect to the Estes Freight API. This is for truck shipments, not small parcels. Think LTL (less than truckload) shipments. This code was created off the Estes API documentation. This uses and XML SOAP API.

You will need to have a Estes account and register for access to use this.

Currently this package can perform: - pickup requests

To create a pickup request: - Set test or production mode (SetProductionMode()). - Set shipper information. - Set shipment data. - Request the pickup. - Check for any errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetProductionMode

func SetProductionMode(yes bool)

SetProductionMode chooses the production url for use

func SetTimeout

func SetTimeout(seconds time.Duration)

SetTimeout updates the timeout value to something the user sets use this to increase the timeout if connecting to Ward is really slow

Types

type Address

type Address struct {
	//required
	AddressLine1  string `xml:"addressLine1"`
	City          string `xml:"city"`
	StateProvince string `xml:"stateProvince"`
	PostalCode    string `xml:"postalCode"`
	Country       string `xml:"countryAbbrev"`

	//optional
	AddressLine2 string `xml:"addressLine2"`
}

Address holds an address

type Contact

type Contact struct {
	Name  Name   `xml:"name"`
	Email string `xml:"email"`
	Phone Phone  `xml:"phone"`
}

Contact holds a contact

type CreatePickupRequestResponse

type CreatePickupRequestResponse struct {
	RequestNumber string `xml:"requestNumber"`
}

CreatePickupRequestResponse is the pickup request confirmation data

type ErrorPickupRequest

type ErrorPickupRequest struct {
	XMLName     xml.Name `xml:"error"`
	Code        string   `xml:"code"`
	Description string   `xml:"description"`
	BadData     string   `xml:"badData"`
}

ErrorPickupRequest is the format of an error returned when scheduling a pickup

type Name

type Name struct {
	First  string `xml:"firstName"`
	Middle string `xml:"middleName"`
	Last   string `xml:"lastName"`
}

Name holds a contact's name

type Phone

type Phone struct {
	AreaCode string `xml:"areaCode"` //first 3
	Number   string `xml:"number"`   //last 7, only numbers
}

Phone holds a contact's phone number

type PickupRequest

type PickupRequest struct {
	XMLName xml.Name `xml:"soapenv:Envelope"`

	SoapenvAttr string `xml:"xmlns:soapenv,attr"`
	EstAttr     string `xml:"xmlns:est,attr"`

	PickupRequestInput PickupRequestInput `xml:"soapenv:Body>est:createPickupRequestWS>pickupRequestInput"`
}

PickupRequest is the main body of the xml request

type PickupRequestInput

type PickupRequestInput struct {
	//required
	Shipper            Shipper `xml:"shipper"`
	PickupDate         string  `xml:"pickupDate"`      //yyyy-mm-dd
	PickupStartTime    string  `xml:"pickupStartTime"` //hhmm
	PickupEndTime      string  `xml:"pickupEndTime"`   //hhmm
	TotalPieces        uint    `xml:"totalPieces"`     //pieces
	TotalWeight        float64 `xml:"totalWeight"`
	TotalHandlingUnits uint    `xml:"totalHandlingUnits"` //skids

	//optional
	RequestNumber string `xml:"requestNumber"`
	WhoRequested  string `xml:"whoRequested"`
}

PickupRequestInput is the data on the pickup request

func (*PickupRequestInput) RequestPickup

func (p *PickupRequestInput) RequestPickup(estesUsername, estesPassword string) (responseData SuccessfulPickupRequest, err error)

RequestPickup performs the call to the estes api to schedule a pickup

type Shipper

type Shipper struct {
	//required
	ShipperName string `xml:"shipperName"`

	//optional
	ShipperAddress Address `xml:"shipperAddress>addressInfo"`
	ShipperContact Contact `xml:"shipperContacts>shipperContact"`
}

Shipper is data on where a shipment is coming from

type SuccessfulPickupRequest

type SuccessfulPickupRequest struct {
	XMLName  xml.Name                    `xml:"Envelope"` //don't need "soapenv"
	Response CreatePickupRequestResponse `xml:"Body>createPickupRequestWSResponse"`
}

SuccessfulPickupRequest is the format of a successful pickup request

Jump to

Keyboard shortcuts

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