stuartclient

package module
v0.0.0-...-35ba3bb Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 11 Imported by: 0

README

stuart-client-go

Stuart Go client

Documentation

Index

Constants

View Source
const (
	PickupType  RequestType = "picking"
	DropoffType RequestType = "delivering"

	TOBACCO   StuartRestrictedItem = "TOBACCO"
	LOTTERY   StuartRestrictedItem = "LOTTERY"
	KNIVES    StuartRestrictedItem = "KNIVES"
	FIREWORKS StuartRestrictedItem = "FIREWORKS"
	SOLVENTS  StuartRestrictedItem = "SOLVENTS"
	BUTANE    StuartRestrictedItem = "BUTANE"
	ALCOHOL   StuartRestrictedItem = "ALCOHOL"
	SUNBEDS   StuartRestrictedItem = "SUNBEDS"
	OTHER     StuartRestrictedItem = "OTHER"
)

Variables

This section is empty.

Functions

func StuartResponseHandler

func StuartResponseHandler(resp *http.Response) error

Types

type AccessCodeType

type AccessCodeType string
const (
	ScanQRText     AccessCodeType = "scan_qr_text"
	ScanBarcode128 AccessCodeType = "scan_barcode_128"
	QRText         AccessCodeType = "qr_text"
	Barcode128     AccessCodeType = "barcode_128"
)

type AccessCodesModel

type AccessCodesModel struct {
	Code         string         `json:"code"`
	Type         AccessCodeType `json:"type"`
	Title        string         `json:"title"`
	Instructions string         `json:"instructions"`
}

type AddressType

type AddressType struct {
	Street   string      `json:"street"`
	Postcode string      `json:"postcode"`
	City     interface{} `json:"city"`
	Zone     string      `json:"zone"`
	Country  string      `json:"country"`
}

type CancelReasonType

type CancelReasonType string
const (
	CancelAddressError                  CancelReasonType = "address_error"
	CancelCourierIssue                  CancelReasonType = "courier_issue"
	CancelCustomerCancellationRequested CancelReasonType = "customer_cancellation_requested"
	CancelDuplicateJob                  CancelReasonType = "duplicate_job"
	CancelIncorrectPackage              CancelReasonType = "incrorrect_package"
	CancelNoSupply                      CancelReasonType = "no_supply"
	CancelOther                         CancelReasonType = "other"
	CancelPackageDamaged                CancelReasonType = "package_damaged"
	CancelPackageNotReady               CancelReasonType = "package_not_ready"
	CancelPUClosed                      CancelReasonType = "pu_closed"
	CancelTechnicalIssue                CancelReasonType = "technical_issue"
	CancelWrongTransportType            CancelReasonType = "wrong_transport_type"
)

type CancelRequestModel

type CancelRequestModel struct {
	PublicReasonKey CancelReasonType `json:"public_reason_key"`
	Comment         string           `json:"comment"`
}

type CancellationResponseModel

type CancellationResponseModel struct {
	CanceledBy string `json:"canceled_by"`
	ReasonKey  string `json:"reason_key"`
	Comment    string `json:"comment"`
}

type ClientInterface

type ClientInterface interface {
	GetDriverPhoneNumber(ctx context.Context, deliveryId string) (string, error)
	CancelDelivery(ctx context.Context, deliveryId string, cancelReq *CancelRequestModel) (int, error)
	ValidateAddress(ctx context.Context, address string, addressType RequestType, phone string) (bool, error)
	GetZoneCoverage(ctx context.Context, zone string, addressType RequestType) (*geojson.FeatureCollection, error)
	GetParcelShops(ctx context.Context, address string, date string) (*ParcelShopsResponse, error)
	CreateJob(ctx context.Context, model JobRequestModel) ([]byte, error)
	GetJobPricing(ctx context.Context, model JobRequestModel) (*PricingProposalModel, error)
	ValidateJobParameters(ctx context.Context, model JobRequestModel) (bool, error)
	GetJobOriginEta(ctx context.Context, model JobRequestModel) (int, error)
	GetJobDropoffEta(ctx context.Context, model JobRequestModel) (int, error)
	GetJobs(ctx context.Context, options GetJobsOptions) ([]JobResponseModel, error)
	GetJob(ctx context.Context, jobId string) (*JobResponseModel, error)
	GetSchedulingSlots(ctx context.Context, zone string, requestType RequestType, date string) (*SchedulingSlotsResponseModel, error)
	UpdateJob(ctx context.Context, jobId string, model JobRequestModel) (*JobResponseModel, error)
	CancelJob(ctx context.Context, jobId string, cancelReq *CancelRequestModel) (int, error)
}

func NewClient

func NewClient(ctx context.Context, envType EnvEndpointType, apiClientId string, apiClientSecret string) (client ClientInterface)

type ClientWrapper

type ClientWrapper struct {
	http.Client
	// contains filtered or unexported fields
}

func (ClientWrapper) CancelDelivery

func (c ClientWrapper) CancelDelivery(ctx context.Context, deliveryId string, cancelReq *CancelRequestModel) (int, error)

func (ClientWrapper) CancelJob

func (c ClientWrapper) CancelJob(ctx context.Context, jobId string, cancelReq *CancelRequestModel) (int, error)

func (ClientWrapper) CreateJob

func (c ClientWrapper) CreateJob(ctx context.Context, model JobRequestModel) ([]byte, error)

func (ClientWrapper) GetDriverPhoneNumber

func (c ClientWrapper) GetDriverPhoneNumber(ctx context.Context, deliveryId string) (string, error)

func (ClientWrapper) GetJob

func (c ClientWrapper) GetJob(ctx context.Context, jobId string) (*JobResponseModel, error)

func (ClientWrapper) GetJobDropoffEta

func (c ClientWrapper) GetJobDropoffEta(ctx context.Context, model JobRequestModel) (int, error)

func (ClientWrapper) GetJobOriginEta

func (c ClientWrapper) GetJobOriginEta(ctx context.Context, model JobRequestModel) (int, error)

func (ClientWrapper) GetJobPricing

func (c ClientWrapper) GetJobPricing(ctx context.Context, model JobRequestModel) (*PricingProposalModel, error)

func (ClientWrapper) GetJobs

func (c ClientWrapper) GetJobs(ctx context.Context, options GetJobsOptions) ([]JobResponseModel, error)

func (ClientWrapper) GetParcelShops

func (c ClientWrapper) GetParcelShops(ctx context.Context, address string, date string) (*ParcelShopsResponse, error)

func (ClientWrapper) GetSchedulingSlots

func (c ClientWrapper) GetSchedulingSlots(ctx context.Context, zone string, requestType RequestType, date string) (*SchedulingSlotsResponseModel, error)

func (ClientWrapper) GetZoneCoverage

func (c ClientWrapper) GetZoneCoverage(ctx context.Context, zone string, addressType RequestType) (*geojson.FeatureCollection, error)

func (ClientWrapper) UpdateJob

func (c ClientWrapper) UpdateJob(ctx context.Context, jobId string, model JobRequestModel) (*JobResponseModel, error)

func (ClientWrapper) ValidateAddress

func (c ClientWrapper) ValidateAddress(ctx context.Context, address string, addressType RequestType, phone string) (bool, error)

func (ClientWrapper) ValidateJobParameters

func (c ClientWrapper) ValidateJobParameters(ctx context.Context, model JobRequestModel) (bool, error)

type ContactDetails

type ContactDetails struct {
	Firstname string `json:"firstname"`
	Lastname  string `json:"lastname"`
	Phone     string `json:"phone"`
	Email     string `json:"email"`
	Company   string `json:"company"`
}

type DeliveriesResponseModel

type DeliveriesResponseModel struct {
	Id                 int                        `json:"id"`
	Status             string                     `json:"status"`
	PickedAt           string                     `json:"picked_at"`
	DeliveredAt        string                     `json:"delivered_at"`
	TrackingUrl        string                     `json:"tracking_url"`
	ClientReference    string                     `json:"client_reference"`
	PackageDescription string                     `json:"package_description"`
	PackageType        string                     `json:"package_type"`
	Pickup             PickupDropoffResponseModel `json:"pickup"`
	Dropoff            PickupDropoffResponseModel `json:"dropoff"`
	Cancellation       CancellationResponseModel  `json:"cancellation"`
	Eta                EtaModel                   `json:"eta"`
	Proof              ProofModel                 `json:"proof"`
	ProofOfDeliveryUrl string                     `json:"proof_of_delivery_url"`
}

type DriverModel

type DriverModel struct {
	Id            int     `json:"id"`
	DisplayName   string  `json:"display_name"`
	Phone         string  `json:"phone"`
	PictureUrl    string  `json:"picture_url"`
	TransportType string  `json:"transport_type"`
	Latitude      float64 `json:"latitude"`
	Longitude     float64 `json:"longitude"`
}

type DropoffRequestModel

type DropoffRequestModel struct {
	PackageType                PackageType             `json:"package_type"`
	PackageDescription         string                  `json:"package_description"`
	ClientReference            string                  `json:"client_reference"`
	Address                    string                  `json:"address"`
	Comment                    string                  `json:"comment,omitempty"`
	Contact                    ContactDetails          `json:"contact"`
	AccessCodes                []AccessCodesModel      `json:"access_codes"`
	EndCustomerTimeWindowStart *time.Time              `json:"end_customer_time_window_start,omitempty"`
	EndCustomerTimeWindowEnd   *time.Time              `json:"end_customer_time_window_end,omitempty"`
	RestrictedItems            *[]StuartRestrictedItem `json:"restricted_items,omitempty"`
}

type EnvEndpointType

type EnvEndpointType string
const (
	SandboxEnv     EnvEndpointType = "https://api.sandbox.stuart.com"
	ProdEnv        EnvEndpointType = "https://api.stuart.com"
	TokenURLSuffix                 = "/oauth/token"
)

func (EnvEndpointType) GetBaseURL

func (endpoint EnvEndpointType) GetBaseURL() string

func (EnvEndpointType) GetOAuthURL

func (endpoint EnvEndpointType) GetOAuthURL() string

func (EnvEndpointType) GetURL

func (endpoint EnvEndpointType) GetURL(suffix string) string

type EtaModel

type EtaModel struct {
	Pickup  string `json:"pickup"`
	Dropoff string `json:"dropoff"`
}

type GetJobsOptions

type GetJobsOptions struct {
	Status          StatusType
	Page            int
	PerPage         int
	ClientReference string
	Active          bool
	Order           OrderValuesType
}

type JobModel

type JobModel struct {
	PickupAt        *time.Time            `json:"pickup_at"`
	AssignmentCode  string                `json:"assignment_code"`
	ClientReference string                `json:"client_reference"`
	Pickups         []PickupRequestModel  `json:"pickups"`
	Dropoffs        []DropoffRequestModel `json:"dropoffs"`
}

type JobRequestModel

type JobRequestModel struct {
	Job JobModel `json:"job"`
}

type JobResponseModel

type JobResponseModel struct {
	Id             int                       `json:"id"`
	CreatedAt      time.Time                 `json:"created_at"`
	Status         string                    `json:"status"`
	PackageType    string                    `json:"package_type"`
	TransportType  string                    `json:"transport_type"`
	AssignmentCode string                    `json:"assignment_code"`
	DropoffAt      string                    `json:"dropoff_at"`
	PickupAt       string                    `json:"pickup_at"`
	EndedAt        string                    `json:"ended_at"`
	Comment        string                    `json:"comment"`
	Distance       float64                   `json:"distance"`
	Duration       int                       `json:"duration"`
	Deliveries     []DeliveriesResponseModel `json:"deliveries"`
	Driver         DriverModel               `json:"driver"`
	Pricing        PricingModel              `json:"pricing"`
	Cancellation   CancellationResponseModel `json:"cancelation"`
	Eta            EtaModel                  `json:"eta"`
	Rating         string                    `json:"rating"`
}

type OrderValuesType

type OrderValuesType string
const (
	ORDER_START_INVITING_AT_DESC OrderValuesType = "start_inviting_at:desc"
	ORDER_PICKUP_AT_DESC         OrderValuesType = "pickup_at:desc"
	ORDER_PICKUP_AT_ASC          OrderValuesType = "pickup_at:asc"
)

type PackageType

type PackageType string
const (
	XSmall PackageType = "xsmall"
	Small  PackageType = "small"
	Medium PackageType = "medium"
	Large  PackageType = "large"
	Xlarge PackageType = "xlarge"
)

func CalculateParcelSize

func CalculateParcelSize(heightCM float32, lengthCm float32, widthCm float32, weightKg float32) PackageType

type ParcelContactType

type ParcelContactType struct {
	Company string `json:"company"`
	Phone   string `json:"phone"`
	Email   string `json:"email"`
}

type ParcelShopType

type ParcelShopType struct {
	Address string            `json:"address"`
	Contact ParcelContactType `json:"contact"`
}

type ParcelShopsResponse

type ParcelShopsResponse struct {
	Date     string         `json:"date"`
	Schedule []ScheduleType `json:"schedule"`
}

type PickupDropoffResponseModel

type PickupDropoffResponseModel struct {
	Id        int            `json:"id"`
	Latitude  float64        `json:"latitude"`
	Longitude float64        `json:"longitude"`
	Comment   string         `json:"comment"`
	Address   AddressType    `json:"address"`
	Contact   ContactDetails `json:"contact"`
}

type PickupRequestModel

type PickupRequestModel struct {
	Address     string             `json:"address"`
	Comment     string             `json:"comment"`
	Contact     ContactDetails     `json:"contact"`
	AccessCodes []AccessCodesModel `json:"access_codes"`
}

type PricingModel

type PricingModel struct {
	Currency         string  `json:"currency"`
	TaxPercentage    float64 `json:"tax_percentage"`
	PriceTaxIncluded float64 `json:"price_tax_included"`
	PriceTaxExcluded float64 `json:"price_tax_excluded"`
	TaxAmount        float64 `json:"tax_amount"`
	InvoiceUrl       string  `json:"invoice_url"`
}

type PricingProposalModel

type PricingProposalModel struct {
	Amount   float64 `json:"amount"`
	Currency string  `json:"currency"`
}

type ProofModel

type ProofModel struct {
	SignatureUrl string `json:"signature_url"`
}

type RequestType

type RequestType string

type ScheduleType

type ScheduleType struct {
	ParcelShop ParcelShopType `json:"parcel_shop"`
	From       time.Time      `json:"from"`
	To         time.Time      `json:"to"`
}

type SchedulingSlotsResponseModel

type SchedulingSlotsResponseModel struct {
	Date  time.Time       `json:"date"`
	Type  string          `json:"type"`
	Slots []TimeSlotModel `json:"slots"`
}

type StatusType

type StatusType string
const (
	STATUS_NEW         StatusType = "new"
	STATUS_SCHEDULED   StatusType = "scheduled"
	STATUS_SEARCHING   StatusType = "searching"
	STATUS_IN_PROGRESS StatusType = "in_progress"
	STATUS_FINISHED    StatusType = "finished"
	STATUS_CANCELLED   StatusType = "cancelled"
	STATUS_EXPIRED     StatusType = "expired"
)

type StuartPackageDimensions

type StuartPackageDimensions struct {
	// contains filtered or unexported fields
}

type StuartRestrictedItem

type StuartRestrictedItem string

type TimeSlotModel

type TimeSlotModel struct {
	StartTime time.Time `json:"start_time"`
	EndTime   time.Time `json:"end_time"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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