orders

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrOrderReferenceNotSpecified no order_id specified
	ErrOrderReferenceNotSpecified = errors.New("Order reference not specified")
	// ErrCancelCodeNotSpecified no cancel code provided
	ErrCancelCodeNotSpecified = errors.New("Order cancel code not specified")
)
View Source
var (
	// CancelCodes are all valid iFood API cancellation codes
	CancelCodes = map[string]string{
		"501": "PROBLEMAS DE SISTEMA",
		"502": "PEDIDO EM DUPLICIDADE",
		"503": "ITEM INDISPONÍVEL",
		"504": "RESTAURANTE SEM MOTOBOY",
		"505": "CARDÁPIO DESATUALIZADO",
		"506": "PEDIDO FORA DA ÁREA DE ENTREGA",
		"507": "CLIENTE GOLPISTA / TROTE",
		"508": "FORA DO HORÁRIO DO DELIVERY",
		"509": "DIFICULDADES INTERNAS DO RESTAURANTE",
		"511": "ÁREA DE RISCO",
		"512": "RESTAURANTE ABRIRÁ MAIS TARDE",
		"513": "RESTAURANTE FECHOU MAIS CEDO",
		"803": "ITEM INDISPONÍVEL",
		"805": "RESTAURANTE SEM MOTOBOY",
		"801": "PROBLEMAS DE SISTEMA",
		"804": "CADASTRO DO CLIENTE INCOMPLETO - CLIENTE NÃO ATENDE",
		"807": "PEDIDO FORA DA ÁREA DE ENTREGA",
		"808": "CLIENTE GOLPISTA / TROTE",
		"809": "FORA DO HORÁRIO DO DELIVERY",
		"815": "DIFICULDADES INTERNAS DO RESTAURANTE",
		"818": "TAXA DE ENTREGA INCONSISTENTE",
		"820": "ÁREA DE RISCO",
	}
)

Functions

func New

func New(adapter adapters.Http, authService auth.Service) *ordersService

New returns a new order service

Types

type Coordinates

type Coordinates struct {
	Latitude  string `json:"latitude"`
	Longitude string `json:"longitude"`
}

Coordinates of a delivery

type Customer

type Customer struct {
	ID                           string `json:"id"`
	UUID                         string `json:"uuid"`
	Name                         string `json:"name"`
	Taxpayeridentificationnumber string `json:"taxPayerIdentificationNumber"`
	Phone                        string `json:"phone"`
	Orderscountonrestaurant      string `json:"ordersCountOnRestaurant"`
}

Customer details

type DeliveryAddress

type DeliveryAddress struct {
	Formattedaddress string      `json:"formattedAddress"`
	Country          string      `json:"country"`
	State            string      `json:"state"`
	City             string      `json:"city"`
	Coordinates      Coordinates `json:"coordinates"`
	Neighborhood     string      `json:"neighborhood"`
	Streetname       string      `json:"streetName"`
	Streetnumber     string      `json:"streetNumber"`
	Postalcode       string      `json:"postalCode"`
	Reference        string      `json:"reference"`
	Complement       string      `json:"complement"`
}

DeliveryAddress from customer

type DeliveryInformationResponse

type DeliveryInformationResponse struct {
	ExternalID         string      `json:"externalId"`
	OrderStatus        string      `json:"orderStatus"`
	WorkerName         string      `json:"workerName"`
	WorkerPhone        string      `json:"workerPhone"`
	WorkerPhoto        string      `json:"workerPhoto"`
	VehicleType        string      `json:"vehicleType"`
	VehiclePlateNumber interface{} `json:"vehiclePlateNumber"`
	LogisticCompany    string      `json:"logisticCompany"`
	Latitude           float64     `json:"latitude"`
	Longitude          float64     `json:"longitude"`
	Eta                int         `json:"eta"`
}

DeliveryInformationResponse API response of the delivery

type Item

type Item struct {
	Name          string    `json:"name"`
	Quantity      string    `json:"quantity"`
	Price         string    `json:"price"`
	Subitemsprice string    `json:"subItemsPrice"`
	Totalprice    string    `json:"totalPrice"`
	Discount      string    `json:"discount"`
	Addition      string    `json:"addition"`
	Externalcode  string    `json:"externalCode,omitempty"`
	Subitems      []Subitem `json:"subItems,omitempty"`
	Observations  string    `json:"observations,omitempty"`
}

Item of the order

type OrderDetails

type OrderDetails struct {
	ID                       string            `json:"id"`
	Reference                string            `json:"reference"`
	Shortreference           string            `json:"shortReference"`
	Createdat                string            `json:"createdAt"`
	Type                     string            `json:"type"`
	Merchant                 merchant.Merchant `json:"merchant"`
	Payments                 []Payment         `json:"payments"`
	Customer                 Customer          `json:"customer"`
	Items                    []Item            `json:"items"`
	Subtotal                 string            `json:"subTotal"`
	Totalprice               string            `json:"totalPrice"`
	Deliveryfee              string            `json:"deliveryFee"`
	Deliveryaddress          DeliveryAddress   `json:"deliveryAddress"`
	Deliverydatetime         string            `json:"deliveryDateTime"`
	Preparationtimeinseconds string            `json:"preparationTimeInSeconds"`
}

OrderDetails endpoint return

type Payment

type Payment struct {
	Name      string `json:"name"`
	Code      string `json:"code"`
	Value     string `json:"value"`
	Prepaid   string `json:"prepaid"`
	Issuer    string `json:"issuer"`
	Collector string `json:"collector,omitempty"`
}

Payment details

type Service

type Service interface {
	GetDetails(reference string) (OrderDetails, error)
	SetIntegrateStatus(reference string) error
	SetConfirmStatus(reference string) error
	SetDispatchStatus(reference string) error
	SetReadyToDeliverStatus(reference string) error
	SetCancelStatus(reference, code string) error
	ClientCancellationStatus(reference string, accepted bool) error
	Tracking(orderUUID string) (TrackingResponse, error)
	DeliveryInformation(orderUUID string) (DeliveryInformationResponse, error)
}

Service determinates the order's interface

type Subitem

type Subitem struct {
	Name         string `json:"name"`
	Quantity     string `json:"quantity"`
	Price        string `json:"price"`
	Totalprice   string `json:"totalPrice"`
	Discount     string `json:"discount"`
	Addition     string `json:"addition"`
	Externalcode string `json:"externalCode"`
}

Subitem of the order

type TrackingResponse

type TrackingResponse struct {
	Date             interface{} `json:"date"`
	DeliveryTime     time.Time   `json:"deliveryTime"`
	Eta              int         `json:"eta"`
	EtaToDestination int         `json:"etaToDestination"`
	EtaToOrigin      int         `json:"etaToOrigin"`
	Latitude         float64     `json:"latitude"`
	Longitude        float64     `json:"longitude"`
	OrderID          string      `json:"orderId"`
	TrackDate        time.Time   `json:"trackDate"`
}

TrackingResponse API response of tracking

Jump to

Keyboard shortcuts

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