Last active
September 28, 2023 12:57
-
-
Save ferologics/b8193d0db02e753c82d48e889d82cf0f to your computer and use it in GitHub Desktop.
Orders App API types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ISO 8601 timestamp | |
* */ | |
export type Timestamp = string; | |
export enum RouteStatus { | |
assigned = 'assigned', | |
completed = 'completed', | |
planned = 'planned', | |
tracking = 'tracking', | |
summarizing = 'summarizing', | |
} | |
export enum OrderStatus { | |
assigned = 'assigned', | |
cancelled = 'cancelled', | |
completed = 'completed', | |
disabled = 'disabled', // AKA 'Snoozed' | |
ongoing = 'ongoing', | |
planned = 'planned', | |
summarizing = 'summarizing', | |
unplanned = 'unplanned', | |
// these are not used by the API, but are used by the app | |
upcoming = 'upcoming', | |
up_next = 'up next', | |
} | |
export type RoutesList = { | |
routes: ListedRoute[]; | |
pagination_token: string; | |
}; | |
type ListedRouteFields = { | |
route_handle: string; | |
ops_group_handle: string; | |
intent: RouteIntent; | |
status: RouteStatus; | |
created_at: Timestamp; | |
version: number; | |
region: object; | |
}; | |
type ListedRouteOptionalFields = { | |
estimate?: Estimate; | |
assigned_at?: Timestamp; | |
started_at?: Timestamp; | |
completed_at?: Timestamp; | |
device_id?: string; | |
metadata?: Dictionary<string | object>; | |
start_location?: Point; | |
end_location?: Point; | |
}; | |
export type Dictionary<T> = { [key: string]: T }; | |
export type ListedRoute = ListedRouteFields & | |
ListedRouteOptionalFields & { orders: RouteListedOrder[] }; | |
export type RouteListedOrder = { | |
order_handle: string; | |
fulfillment_attempt: number; | |
status: OrderStatus; | |
}; | |
export type Route = ListedRouteFields & | |
ListedRouteOptionalFields & { | |
orders: OrderListedOrder[]; | |
// optional fields | |
embed_url?: string; | |
markers?: object[]; | |
distance?: number; | |
duration?: number; | |
polyline?: Polyline; | |
tracking_rate?: number; | |
}; | |
export type OrdersList = { | |
orders: OrderListedOrder[]; | |
pagination_token: string; | |
}; | |
type OrderListedOrderFields = { | |
order_handle: string; | |
type: OrderType; | |
fulfillment_attempt: number; | |
region: Region; | |
status: OrderStatus; | |
intent: RouteIntent; | |
ops_group_handle: string; | |
destination: Destination; | |
risk_status: boolean; | |
expected_service_time: number; | |
created_at: Timestamp; | |
scheduled_at: Timestamp; | |
capacity_used: number; | |
}; | |
type OrderListedOrderOptionalFields = { | |
device_id?: string; | |
started_at?: Timestamp; | |
assigned_at?: Timestamp; | |
scheduled_after?: Timestamp; | |
scheduled_before?: Timestamp; | |
completed_at?: Timestamp; | |
cancelled_at?: Timestamp; | |
disabled_at?: Timestamp; | |
enabled_at?: Timestamp; | |
arrived_at?: Timestamp; | |
share_url?: string; | |
metadata?: Dictionary<string | object>; | |
risks?: object; | |
product_type?: string[]; | |
}; | |
export type OrderListedOrder = OrderListedOrderFields & OrderListedOrderOptionalFields; | |
type OptionalOrderFields = { | |
start_location?: Point; | |
end_location?: Point; | |
completed_at_destination?: boolean; | |
cancelled_at_destination?: boolean; | |
order_score?: number; | |
estimate?: Estimate; | |
distance?: number; | |
duration?: number; | |
polyline?: Polyline; | |
tracking_rate?: number; | |
deviation_from_destination?: number; | |
actual_service_time?: number; | |
markers?: object[]; | |
events?: object[]; | |
previous_fulfillments?: object[]; | |
}; | |
export type Order = OrderListedOrder & OptionalOrderFields; | |
export enum RouteIntent { | |
self_improving = 'self_improving', | |
on_time = 'on_time', | |
flex = 'flex', | |
} | |
export type Estimate = { | |
start_by: Timestamp; | |
distance: number; | |
duration: number; | |
// optional fields | |
arrive_at?: Timestamp; | |
start_location?: Point; | |
end_location?: Point; | |
polyline?: Polyline; | |
}; | |
export type Region = { | |
city?: string; | |
state?: string; | |
country: string; | |
geohash?: string; | |
road?: string; | |
building_number?: string; | |
postcode?: string; | |
}; | |
export enum OrderType { | |
drop = 'drop', | |
pick = 'pick', | |
} | |
export type Destination = { | |
geometry: Point; | |
radius: number; | |
address: string; | |
}; | |
/** | |
* The longitude in degrees. | |
*/ | |
type Longitude = number; | |
/** | |
* The latitude in degrees. | |
*/ | |
type Latitude = number; | |
/** | |
* Coordinates of the point | |
* [longitude, latitude] | |
*/ | |
export type Coordinates = [Longitude, Latitude]; | |
export type Point = { | |
type: 'Point'; | |
/** | |
* Coordinates of the point | |
* [longitude, latitude] | |
*/ | |
coordinates: Coordinates; | |
}; | |
export type Polyline = { | |
type: 'LineString'; | |
coordinates: Coordinates[]; | |
}; | |
export type DeviceHistory = { | |
locations: Polyline; | |
active_duration: number; | |
inactive_duration: number; | |
drive_duration: number; | |
walk_duration: number; | |
steps: number; | |
stop_duration: number; | |
// non - optional fields | |
device_id?: string; | |
name?: string; | |
markers?: object[]; // TODO: define this type | |
started_at?: Timestamp; | |
completed_at?: Timestamp; | |
distance?: number; | |
duration?: number; | |
tracking_rate?: number; | |
inactive_reasons?: string[]; | |
geotags?: number; | |
geofences_visited?: number; | |
}; | |
export type DeviceDayHistory = { | |
name?: string; | |
device_id?: string; | |
tracking_rate?: number; | |
geotags?: number; | |
geotags_route_to_duration?: number; | |
geofences_visited?: number; | |
geofences_visited_duration?: number; | |
geofences_route_to_duration?: number; | |
geofences_route_to_idle_time?: number; | |
active_duration?: number; | |
inactive_duration?: number; | |
stop_duration?: number; | |
walk_duration?: number; | |
drive_duration?: number; | |
steps?: number; | |
distance?: number; | |
duration?: number; | |
locations?: Polyline; | |
markers?: object[]; // TODO: define this type | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should this be
pick
orpickup
? In your docs it'spick
: source.