routific

package
v0.0.0-...-2d3cc3e Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package routific exposes a wrapper for making calls to Routific's Engine API

Index

Examples

Constants

View Source
const VehicleRoutingAPIUrl = "https://api.routific.com/v1/vrp"

VehicleRoutingAPIUrl is a constant that holds the url for vehicle routing problem solver

Variables

This section is empty.

Functions

This section is empty.

Types

type CurrentRoute

type CurrentRoute Position

CurrentRoute represents the current location as lat+lng for a given driver

type DestinationRoute

type DestinationRoute Position

DestinationRoute represents a destination route as lat+lng

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient interface

var Client HTTPClient

Client holds the http client

type LocationResponse

type LocationResponse struct {
	LocationID   string `bson:"location_id" json:"location_id"`
	LocationName string `bson:"location_name" json:"location_name"`
}

LocationResponse struct holds each location in a given solution for a driver to go through

type MockHTTPClient

type MockHTTPClient struct {
	mock.Mock
}

MockHTTPClient is an autogenerated mock type for the HTTPClient type

func (*MockHTTPClient) Do

func (_m *MockHTTPClient) Do(req *http.Request) (*http.Response, error)

Do provides a mock function with given fields: req

type MockService

type MockService struct {
	mock.Mock
}

MockService is an autogenerated mock type for the Service type

func (*MockService) GetVehicleRoute

func (_m *MockService) GetVehicleRoute(driverID bson.ObjectId, currentRoute CurrentRoute, destinationRoute DestinationRoute) (VehicleRoutingResponse, error)

GetVehicleRoute provides a mock function with given fields: driverID, currentRoute, destinationRoute

type OrderRequest

type OrderRequest struct {
	Location Position `json:"location"`
}

OrderRequest represents the order for a given vehicle routing reequest

type Position

type Position struct {
	ID  string  `json:"id"`
	Lat float64 `json:"lat"`
	Lng float64 `json:"lng"`
}

Position represents any given position as lat+lng

type Routific

type Routific struct {
	Client HTTPClient
}

Routific struct will hold http client and implement API interface

func NewService

func NewService(client HTTPClient) *Routific

NewService will return a new value of type interface Service

Example
service := NewService(Client)
fmt.Printf("%T", service)
Output:

*routific.Routific

func (*Routific) GetVehicleRoute

func (r *Routific) GetVehicleRoute(driverID bson.ObjectId, currentRoute CurrentRoute, destinationRoute DestinationRoute) (VehicleRoutingResponse, error)

GetVehicleRoute will make a call to Routific's Engine API Vehicle routing endpoint and try to get a valid solution back

type Service

type Service interface {
	GetVehicleRoute(driverID bson.ObjectId, currentRoute CurrentRoute, destinationRoute DestinationRoute) (VehicleRoutingResponse, error)
}

Service interface has all the methods needed for communicating to Routific's Engine API

type VehicleRequest

type VehicleRequest struct {
	StartLocation Position `json:"start_location"`
}

VehicleRequest represents the vehicle for a given vehicle routing reequest

type VehicleRoutingRequest

type VehicleRoutingRequest struct {
	Visits map[string]OrderRequest   `json:"visits"`
	Fleet  map[string]VehicleRequest `json:"fleet"`
}

VehicleRoutingRequest struct holds values for a vehicle routing request

type VehicleRoutingResponse

type VehicleRoutingResponse struct {
	Status          string                        `json:"status"`
	TotalTravelTime float64                       `bson:"total_travel_time" json:"total_travel_time"`
	Solution        map[string][]LocationResponse `json:"solution"`
}

VehicleRoutingResponse holds a valid response from Vehicle routing Routific Engine API

Jump to

Keyboard shortcuts

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