-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathworker.go
194 lines (167 loc) · 7.31 KB
/
worker.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
package onfleet
type Worker struct {
AccountStatus WorkerAccountStatus `json:"accountStatus"`
ActiveTask *string `json:"activeTask"`
AdditionalCapacities WorkerAdditionalCapacities `json:"additionalCapacities"`
Addresses *WorkerAddresses `json:"addresses,omitempty"`
Analytics *WorkerAnalytics `json:"analytics,omitempty"`
Capacity float64 `json:"capacity"`
DelayTime *float64 `json:"delayTime"`
DisplayName *string `json:"displayName"`
HasRecentlyUsedSpoofedLocations bool `json:"hasRecentlyUsedSpoofedLocations"`
ID string `json:"id"`
ImageUrl *string `json:"imageUrl"`
Location DestinationLocation `json:"location"`
Metadata []Metadata `json:"metadata"`
Name string `json:"name"`
OnDuty bool `json:"onDuty"`
Organization string `json:"organization"`
Phone string `json:"phone"`
Tasks []string `json:"tasks"`
Teams []string `json:"teams"`
TimeCreated int64 `json:"timeCreated"`
TimeLastModified int64 `json:"timeLastModified"`
TimeLastSeen int64 `json:"timeLastSeen"`
UserData WorkerUserData `json:"userData"`
Timezone *string `json:"timezone"`
Vehicle *WorkerVehicle `json:"vehicle"`
}
type WorkerUserData struct {
AppVersion string `json:"appVersion,omitempty"`
BatteryLevel float32 `json:"batteryLevel,omitempty"`
DeviceDescription string `json:"deviceDescription,omitempty"`
Platform string `json:"platform,omitempty"`
}
type WorkerAdditionalCapacities struct {
CapacityA float64 `json:"capacityA"`
CapacityB float64 `json:"capacityB"`
CapacityC float64 `json:"capacityC"`
}
type WorkerVehicleType string
const (
WorkerVehicleTypeCar WorkerVehicleType = "CAR"
WorkerVehicleTypeBicycle WorkerVehicleType = "BICYCLE"
WorkerVehicleTypeMotorcycle WorkerVehicleType = "MOTORCYCLE"
WorkerVehicleTypeTruck WorkerVehicleType = "TRUCK"
)
type WorkerVehicle struct {
Color *string `json:"color"`
Description *string `json:"description"`
ID string `json:"id"`
LicensePlate *string `json:"licensePlate"`
TimeLastModified int64 `json:"timeLastModified"`
Type WorkerVehicleType `json:"type"`
}
type WorkerAccountStatus string
const (
WorkerAccountStatusAccepted WorkerAccountStatus = "ACCEPTED"
WorkerAccountStatusInvited WorkerAccountStatus = "INVITED"
)
type WorkerSchedule struct {
Date string `json:"date"`
Shifts [][]int64 `json:"shifts"`
Timezone string `json:"timezone"`
}
type WorkerScheduleEntries struct {
Entries []WorkerSchedule `json:"entries"`
}
type WorkerAddresses struct {
Routing *WorkerAddressesRouting `json:"routing"`
}
type WorkerAddressesRouting struct {
Address DestinationAddress `json:"address"`
CreatedByLocation bool `json:"createdByLocation"`
GooglePlaceId string `json:"googlePlaceId"`
ID string `json:"id"`
Location DestinationLocation `json:"location"`
Notes string `json:"notes"`
Organization string `json:"organization"`
TimeCreated int64 `json:"timeCreated"`
TimeLastModified int64 `json:"timeLastModified"`
WasGeocoded bool `json:"wasGeocoded"`
}
type WorkerAnalytics struct {
Distances WorkerAnalyticsDistances `json:"distances"`
Events []WorkerAnalyticsEvent `json:"events"`
TaskCounts WorkerAnalyticsTaskCounts `json:"taskCounts"`
Times WorkerAnalyticsTimes `json:"times"`
}
type WorkerAnalyticsEvent struct {
Action string `json:"action"`
Time int64 `json:"time"`
}
type WorkerAnalyticsDistances struct {
Enroute float64 `json:"enroute"`
Idle float64 `json:"idle"`
}
type WorkerAnalyticsTimes struct {
Enroute float64 `json:"enroute"`
Idle float64 `json:"idle"`
}
type WorkerAnalyticsTaskCounts struct {
Failed int `json:"failed"`
Succeeded int `json:"succeeded"`
}
type WorkerGetQueryParams struct {
Analytics bool `json:"analytics,omitempty"`
Filter string `json:"filter,omitempty"`
From int64 `json:"from,omitempty,string"`
To int64 `json:"to,omitempty,string"`
}
type WorkerListQueryParams struct {
Filter string `json:"filter,omitempty"`
Phones string `json:"phones,omitempty"`
States string `json:"states,omitempty"`
Teams string `json:"teams,omitempty"`
}
type WorkersByLocation struct {
Workers []Worker `json:"workers"`
}
type WorkersByLocationListQueryParams struct {
Longitude float64 `json:"longitude,string"`
Latitude float64 `json:"latitude,string"`
Radius float64 `json:"radius,omitempty,string"`
}
type WorkerTasks struct {
LastId string `json:"lastId,omitempty"`
Tasks []Task `json:"tasks"`
}
type WorkerTasksListQueryParams struct {
From int64 `json:"from,omitempty,string"`
// IsPickupTask is a boolean represented as a string.
//
// E.g. "true" or "false".
//
// Set to empty string "" if both dropoff and pickup tasks should be returned.
IsPickupTask string `json:"isPickupTask,omitempty"`
LastId string `json:"lastId,omitempty"`
To int64 `json:"to,omitempty,string"`
}
type WorkerCreateParams struct {
Addresses *WorkerAddressRoutingParam `json:"addresses,omitempty"`
Capacity float64 `json:"capacity,omitempty"`
DisplayName string `json:"displayName,omitempty"`
Metadata []Metadata `json:"metadata,omitempty"`
Name string `json:"name"`
Phone string `json:"phone"`
Teams []string `json:"teams"`
Vehicle *WorkerVehicleParam `json:"vehicle,omitempty"`
}
type WorkerAddressRoutingParam struct {
Routing string `json:"routing"`
}
type WorkerVehicleParam struct {
Color string `json:"color,omitempty"`
Description string `json:"description,omitempty"`
LicensePlate string `json:"licensePlate,omitempty"`
Type WorkerVehicleType `json:"type,omitempty"`
}
type WorkerUpdateParams struct {
Addresses *WorkerAddressRoutingParam `json:"addresses,omitempty"`
Capacity float64 `json:"capacity,omitempty"`
DisplayName string `json:"displayName,omitempty"`
Metadata []Metadata `json:"metadata,omitempty"`
Name string `json:"name,omitempty"`
Teams []string `json:"teams,omitempty"`
Vehicle *WorkerVehicleParam `json:"vehicle,omitempty"`
}