roadie

package
v0.0.0-...-bb8af37 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultRoadieHost is the default host address to use for calls to the roadie api
	DefaultRoadieHost = `https://connect.roadie.com`
	// DefaultRoadieVersion is the default version to use for calls to the roadie api
	DefaultRoadieVersion = `v1`
)

Variables

This section is empty.

Functions

func WithAccessToken

func WithAccessToken(ctx context.Context, accessToken string) func(*Client) error

WithAccessToken allows the user to provide an access token to use for authorization

func WithEnvVars

func WithEnvVars(c *Client) error

WithEnvVars allows retrieves host/version from environment variables

func WithHTTPClient

func WithHTTPClient(client *http.Client) func(*Client) error

WithHTTPClient allows user to provide a custom client

func WithHTTPHeaders

func WithHTTPHeaders(headers map[string]string) func(*Client) error

WithHTTPHeaders allows the user to specify custom headers to be used with all requests

func WithHost

func WithHost(host string) func(*Client) error

WithHost allows the user to use a custom roadie api host

func WithVersion

func WithVersion(version string) func(*Client) error

WithVersion allows the user to use a custom roadie api version

Types

type Address

type Address struct {
	// Name is the name of the location if applicable. This helpful for the driver if the location is a business. Max length 200 characters
	Name string
	// StoreNumber is the store identifier, if the address is a retail location. Max length 20 characters
	StoreNumber string
	// Street1 is the first line of the address. Max length 200 characters (required)
	Street1 string
	// Street2 is the first line of the address. Max length 200 characters
	Street2 string
	// City is the city. Max length 200 characters (required)
	City string
	// State is the two letter state code (required)
	State string
	// Zip is the postal code. Max length 10 characters (required)
	Zip string
	// Latitude us tge exact pickup/delivery latitude
	Latitude float32
	// Longitude is the exact pickup/delivery longitude
	Longitude float32
}

type CancelShipmentRequest

type CancelShipmentRequest struct {
	// CancellationCode is the cancellation code matching the reason for the cancellation
	CancellationCode string
	// CancellationComment is an additional comment explaining the cancellation reason
	CancellationComment string
}

CancelShipmentRequest is the request object for canceling shipments

type Client

type Client struct {

	// Estimates is the service used to create estimates
	Estimates *EstimateService
	// Shipments is the service used to interact with shipments
	Shipments *ShipmentsService
	// contains filtered or unexported fields
}

Client is used to perform all operations with the roadie api

func NewClient

func NewClient(optFns ...func(*Client) error) (*Client, error)

NewClient creates a new instance of Client with any optional functions applied

func (*Client) GetCustomHTTPHeaders

func (cli *Client) GetCustomHTTPHeaders() map[string]string

GetCustomHTTPHeaders returns custom http headers stored by the client

func (*Client) UpdateAccessToken

func (cli *Client) UpdateAccessToken(ctx context.Context, accessToken string)

UpdateAccessToken can be used to update an outdated access token

type Contact

type Contact struct {
	// Name is the name of the contact. Max length 200 characters (required)
	Name string
	// Phone is the phone number of the contact. Max length 10 characters (required)
	Phone string
}

type CreateEstimateRequest

type CreateEstimateRequest struct {
	// Items is an array of one or more item (required)
	Items []Item
	// PickupLocation is a location object (required)
	PickupLocation Location
	// DeliveryLocation is a location object (required)
	DeliveryLocation Location
	// PickupAfter is the time when the shipment is ready for pickup
	PickupAfter time.Time
	// DeliverBetween is the window within which the shipment must be complete
	DeliverBetween TimeWindow
}

type CreateEstimateResponse

type CreateEstimateResponse struct {
	// Price is the estimated price
	Price float32
	// Size is the size category
	Size string
	// Estimated distance is the estimated distance between pickup and delivery
	EstimatedDistance float32
	// Errors contains any errors returned from the API
	Errors ErrorResponse
}

type CreateShipmentRequest

type CreateShipmentRequest struct {
	// ReferenceId is the user supplied ID for the shipment. Max length 100 characters (required)
	ReferenceId string
	// IdempotencyKey is a unique value generated by the user which the Roadie system will use to recognize subsequent retries of the same request.
	// Duplicate requests with the same idempotency_key value will yield a 409 conflict response after the first successful 200 response.
	// Can only be supplied when creating a shipment.
	IdempotencyKey string
	// AlternateId1 is the user-supplied alternate identifier 1
	AlternateId1 string
	// AlternateId2 is the user-supplied alternate identifier 2
	AlternateId2 string
	// Description is a general description for the shipment, often containing important information for the driver. This field is globally visible to all users on the platform.
	// Max length 600 characters
	Description string
	// Items is an array of one or more item (required)
	Items []Item
	// PickupLocation is a complete location object (required)
	PickupLocation Location
	// DeliveryLocation is a complete location object (required)
	DeliveryLocation Location
	// PickupAfter is the time when the shipment is ready for pickup (required)
	PickupAfter time.Time
	// DeliverBetween is the window within which the shipment must be completed
	DeliverBetween TimeWindow
	// Options is any delivery options for the shipment
	Options DeliveryOptions
}

CreateShipmentRequest is the request object for creating shipments

type CreateShipmentResponse

type CreateShipmentResponse struct {
	// Id is the id of the shipment, generated by roadie
	Id int64
	// ReferenceId is the user supplied ID for the shipment. Max length 100 characters (required)
	ReferenceId string
	// State is the state of the shipment
	State string
	// AlternateId1 is the user-supplied alternate identifier 1
	AlternateId1 string
	// AlternateId2 is the user-supplied alternate identifier 2
	AlternateId2 string
	// Description is a general description for the shipment, often containing important information for the driver. This field is globally visible to all users on the platform.
	// Max length 600 characters
	Description string
	// Items is an array of one or more item (required)
	Items []Item
	// PickupLocation is a complete location object (required)
	PickupLocation Location
	// DeliveryLocation is a complete location object (required)
	DeliveryLocation Location
	// PickupAfter is the time when the shipment is ready for pickup (required)
	PickupAfter time.Time
	// DeliverBetween is the window within which the shipment must be completed
	DeliverBetween TimeWindow
	// Options is any delivery options for the shipment
	Options DeliveryOptions
	// TrackingNumber is the tracking number associated with the shipment
	TrackingNumber string
	// Price is the price of the shipment
	Price float32
	// EstimatedDistance is the estimated distance of the shipment
	EstimatedDistance float32
	// Events is an array of shipment events associated with the shipment
	Events []ShipmentEvent
	// CreatedAt is the timestamp the shipment was created
	CreatedAt time.Time
	// UpdatedAt is the timestamp of the shipment's most recent update
	UpdatedAt time.Time
	// Errors contains any errors returned from the API
	Errors ErrorResponse
}

type DeliveryOptions

type DeliveryOptions struct {
	// SignatureRequired indicates whether driver must receive a signature from the recipient (required)
	SignatureRequired bool
	// NotificationsEnabled indicates whether the recipient should receive SMS updates for their delivery
	NotificationsEnables bool
	// Over21Required indicates if the driver must be over 21 to be eligible to deliver the item (typically for alcohol deliveries)
	Over21Required bool
	// ExtraCompensation is the additional compensation for the driver prior to assignment
	ExtraCompensation float32
	// TrailerRequired indicates if the driver must use a trailer to deliver the item(s)
	TrailerRequired bool
}

type Driver

type Driver struct {
	// Name is the driver's name
	Name string
	// Phone is the driver's phone number
	Phone string
}

type ErrBadRequest

type ErrBadRequest struct{}

ErrBadRequest is the error returned when the api returns a 400 status code

func (*ErrBadRequest) Error

func (err *ErrBadRequest) Error() string

type ErrForbidden

type ErrForbidden struct{}

ErrForbidden is the error returned when the api returns a 403 status code

func (*ErrForbidden) Error

func (err *ErrForbidden) Error() string

type ErrGone

type ErrGone struct{}

ErrGone is the error returned when the api returns a 410 status code

func (*ErrGone) Error

func (err *ErrGone) Error() string

type ErrInternalServerError

type ErrInternalServerError struct{}

ErrInternalServerError is the error returned when the api returns a 500 status code

func (*ErrInternalServerError) Error

func (err *ErrInternalServerError) Error() string

type ErrMethodNotAllowed

type ErrMethodNotAllowed struct{}

ErrMethodNotAllowed is the error returned when the api returns a 405 status code

func (*ErrMethodNotAllowed) Error

func (err *ErrMethodNotAllowed) Error() string

type ErrNotAcceptable

type ErrNotAcceptable struct{}

ErrNotAcceptable is the error returned when the api returns a 406 status code

func (*ErrNotAcceptable) Error

func (err *ErrNotAcceptable) Error() string

type ErrNotFound

type ErrNotFound struct{}

ErrNotFound is the error returned when the api returns a 404 status code

func (*ErrNotFound) Error

func (err *ErrNotFound) Error() string

type ErrServiceUnavailable

type ErrServiceUnavailable struct{}

ErrServiceUnavailable is the error returned when the api returns a 503 status code

func (*ErrServiceUnavailable) Error

func (err *ErrServiceUnavailable) Error() string

type ErrTooManyRequests

type ErrTooManyRequests struct{}

ErrTooManyRequests is the error returned when the api returns a 429 status code

func (*ErrTooManyRequests) Error

func (err *ErrTooManyRequests) Error() string

type ErrUnauthorized

type ErrUnauthorized struct{}

ErrUnauthorized is the error returned when the api returns a 401 status code

func (*ErrUnauthorized) Error

func (err *ErrUnauthorized) Error() string

type Error

type Error struct {
	// Code is the roadie error code corresponding to the specific issue
	Code int
	// Parameter is the request parameter that is problematic
	Parameter string
	// Message is a message describing the issue
	Message string
}

type ErrorResponse

type ErrorResponse struct {
	// Errors is an array of error objects
	Errors []Error
}

ErrorResponse is the response object containing errors when a 400 status code is returned

type EstimateService

type EstimateService service

EstimateService has methods for interacting with estimates in roadie

func (*EstimateService) Create

Create creates an estimate

type GetShipmentResponse

type GetShipmentResponse CreateShipmentResponse

GetShipmentResponse is identical to the response from the shipment creation endpoint

type Item

type Item struct {
	// Length is the length in inches of the item
	Length float32
	// Width is the width in inches of the item
	Width float32
	// Height is the height in inches of the item
	Height float32
	// Weight is the weight in pounds of the item
	Weight float32
	// Quantity is the number of items included in the shipment
	Quantity int
	// Value is the monetary value of the item
	Value float32
	// Description is the description of the item. Max length 200 characters
	Description string
	// ReferenceId is the user supplied ID for the item. Max length 100 characters
	ReferenceId string
}

type LeaveTipRequest

type LeaveTipRequest struct {
	// Amount is the amount of tip to leave
	Amount float32
}

LeaveTipRequest is the request object for leaving a tip

type LeaveTipResponse

type LeaveTipResponse struct {
	// Amount is the amount of tip to leave
	Amount float32
	// Errors contains any errors returned from the API
	Errors ErrorResponse
}

LeaveTipResponse is identical to LeaveTipRequest

type Location

type Location struct {
	// Address is the address information (required)
	Address Address
	// Contact is the contact information (required for shipment)
	Contact Contact
	// Notes is any additional information the drivers needs regarding the location. Max length 500 characters
	Notes string
}

type RateDriverRequest

type RateDriverRequest struct {
	Value int
}

RateDriverRequest is the request object for leaving a tip

type RateDriverResponse

type RateDriverResponse struct {
	// Value is the value of the rating to give the driver
	Value int
	// Errors contains any errors returned from the API
	Errors ErrorResponse
}

RateDriverResponse is identical to RateDriverRequest

type ShipmentEvent

type ShipmentEvent struct {
	// Name is the name of the event type
	Name string
	// OccurredAt is the time when the event occurred
	OccurredAt time.Time
	// Location is the location of the event
	Location Location
}

type ShipmentsService

type ShipmentsService service

ShipmentsService has methods for interacting with estimates in roadie

func (*ShipmentsService) Cancel

func (shp *ShipmentsService) Cancel(ctx context.Context, shipmentId int64, cancelRequest CancelShipmentRequest) (*UpdateShipmentResponse, error)

Cancel cancels a shipment

func (*ShipmentsService) Create

Create creates a shipment

func (*ShipmentsService) Get

func (shp *ShipmentsService) Get(ctx context.Context, shipmentId int64) (*GetShipmentResponse, error)

Get retrieves a shipment

func (*ShipmentsService) GetByIds

func (shp *ShipmentsService) GetByIds(ctx context.Context, ids []int64) ([]*GetShipmentResponse, error)

GetByIds retrieves a list of shipments by Ids

func (*ShipmentsService) GetByReferenceIds

func (shp *ShipmentsService) GetByReferenceIds(ctx context.Context, referenceIds []string) ([]*GetShipmentResponse, error)

GetByReferenceIds retrieves a list of shipments by reference ids

func (*ShipmentsService) RateDriver

func (shp *ShipmentsService) RateDriver(ctx context.Context, shipmentId int64, rating int) (*RateDriverResponse, error)

RateDriver is used to leave a rating for the driver

func (*ShipmentsService) TipDriver

func (shp *ShipmentsService) TipDriver(ctx context.Context, shipmentId int64, amount float32) (*LeaveTipResponse, error)

TipDriver is used to leave a tip for the driver

func (*ShipmentsService) Update

func (shp *ShipmentsService) Update(ctx context.Context, shipmentId int64, shipment UpdateShipmentRequest) (*UpdateShipmentResponse, error)

Update updates a shipment

type TimeWindow

type TimeWindow struct {
	// Start is the start of the window in RFC 3339 format (required)
	Start time.Time
	// End is the end of the window in RFC 3339 format (required)
	End time.Time
}

type UpdateShipmentRequest

type UpdateShipmentRequest struct {
	// ReferenceId is the reference id of the shipment to update
	ReferenceId string
	// AlternateId1 is the user-supplied alternate identifier 1
	AlternateId1 string
	// AlternateId2 is the user-supplied alternate identifier 2
	AlternateId2 string
	// Description is a general description for the shipment, often containing important information for the driver. This field is globally visible to all users on the platform.
	// Max length 600 characters
	Description string
	// Items is an array of one or more item (required)
	Items []Item
	// PickupLocation is a complete location object (required)
	PickupLocation Location
	// DeliveryLocation is a complete location object (required)
	DeliveryLocation Location
	// PickupAfter is the time when the shipment is ready for pickup (required)
	PickupAfter time.Time
	// DeliverBetween is the window within which the shipment must be completed
	DeliverBetween TimeWindow
	// Options is any delivery options for the shipment
	Options DeliveryOptions
	// TrackingNumber is the tracking number associated with the shipment
	Events []ShipmentEvent
}

UpdateShipmentRequest is the request object for updating shipments

type UpdateShipmentResponse

type UpdateShipmentResponse CreateShipmentResponse

UpdateShipmentResponse is identical to the response from the shipment creation endpoint

Jump to

Keyboard shortcuts

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