-
Notifications
You must be signed in to change notification settings - Fork 2
Orders Service
Orders service let's you manage Orders on your route4me account.
import (
"github.com/route4me/route4me-go-sdk"
"github.com/route4me/route4me-go-sdk/orders"
)
func main() {
client := route4me.NewClient("your-api-key")
service := &orders.Service{Client: client}
}
order := &orders.Order{
Address1: "Some address",
CachedLatitude: 48.335991,
CachedLongitude: 31.18287,
}
newOrder, err := service.Add(order]
if err != nil {
//handle errors
return
}
To add an order to optimization you have to first get the optimization and specify the OrderID parameter for the address in the received optimization. And execute UpdateOptimization afterwards.
To add an order to optimization you have to first get the route and specify the OrderID parameter for the Address in the received optimization. And execute UpdateOptimization afterwards.
By specifying DeviceID
member in Query
struct you can filter orders returned.
orders, err := service.GetAll(&Query{})
if err != nil {
//Handle error
return
}
//do something with orders, it's a []Order
To get a specific order you have to obtain its orderid
first.
order, err := service.Get(&Query{ID: orderid})
if err != nil {
//handle error
return
}
//do something with the order
orders, err := service.GetAll(&Query{DateInserted:"sdate=2016-06-10"}) //DD-MM-YYYY
if err != nil {
//handle error
return
}
//do something with the orders it's []Order
orders, err := service.GetAll(&Query{DateScheduled:"sdate=2016-06-10"}) //DD-MM-YYYY
if err != nil {
//handle error
return
}
//do something with the orders it's []Order
orders, err := service.GetAll(&Query{Fields:"order_id,member_id"})
if err != nil {
//handle error
return
}
//do something with the orders it's []Order
orders, err := service.GetAll(&Query{Query:"Address here"})
//handle error
return
}
//do something with the orders it's []Order
To remove a specific order you have to obtain its orderid
first.
success, err := service.Delete([]uint64{orderid})
if err != nil || !success {
//handle issues
return
}
To update a specific order you have to obtain its orderid
first.
Update overrides the previous entry based on the aforementioned orderid
.
order := //get order using Get, GetAll or constructing yourself.
contact, err := service.Update(order)
if err != nil {
t.Error(err)
return
}
You can look at service's test file for more implementation details.
- Activity
- Addressbook
- Routing
- Single Driver Route 10 Stops
- Single Driver Round Trip
- Single Depot Multiple Driver No Time Windows
- Single Depot Multiple Driver Time Windows
- Multiple Depot Multiple Driver
- Multiple Depot Multiple Driver With Time Windows
- Multiple Depot Multiple Driver With Time Windows (24 Stops)
- Tracking
- Geocoding
- Users
- Territories
- Orders
- Vehicles
- Telematics