-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathvehiclesforagency.go
More file actions
336 lines (300 loc) · 14.2 KB
/
Copy pathvehiclesforagency.go
File metadata and controls
336 lines (300 loc) · 14.2 KB
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package onebusaway
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
"slices"
"github.com/OneBusAway/go-sdk/internal/apijson"
"github.com/OneBusAway/go-sdk/internal/apiquery"
"github.com/OneBusAway/go-sdk/internal/param"
"github.com/OneBusAway/go-sdk/internal/requestconfig"
"github.com/OneBusAway/go-sdk/option"
"github.com/OneBusAway/go-sdk/shared"
)
// VehiclesForAgencyService contains methods and other services that help with
// interacting with the onebusaway-sdk API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewVehiclesForAgencyService] method instead.
type VehiclesForAgencyService struct {
Options []option.RequestOption
}
// NewVehiclesForAgencyService generates a new service that applies the given
// options to each request. These options are applied after the parent client's
// options (if there is one), and before any request-specific options.
func NewVehiclesForAgencyService(opts ...option.RequestOption) (r *VehiclesForAgencyService) {
r = &VehiclesForAgencyService{}
r.Options = opts
return
}
// Get vehicles for a specific agency
func (r *VehiclesForAgencyService) List(ctx context.Context, agencyID string, query VehiclesForAgencyListParams, opts ...option.RequestOption) (res *VehiclesForAgencyListResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agencyID == "" {
err = errors.New("missing required agencyID parameter")
return nil, err
}
path := fmt.Sprintf("api/where/vehicles-for-agency/%s.json", agencyID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
return res, err
}
type VehiclesForAgencyListResponse struct {
Data VehiclesForAgencyListResponseData `json:"data" api:"required"`
JSON vehiclesForAgencyListResponseJSON `json:"-"`
shared.ResponseWrapper
}
// vehiclesForAgencyListResponseJSON contains the JSON metadata for the struct
// [VehiclesForAgencyListResponse]
type vehiclesForAgencyListResponseJSON struct {
Data apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *VehiclesForAgencyListResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r vehiclesForAgencyListResponseJSON) RawJSON() string {
return r.raw
}
type VehiclesForAgencyListResponseData struct {
List []VehiclesForAgencyListResponseDataList `json:"list" api:"required"`
References shared.References `json:"references" api:"required"`
LimitExceeded bool `json:"limitExceeded"`
JSON vehiclesForAgencyListResponseDataJSON `json:"-"`
}
// vehiclesForAgencyListResponseDataJSON contains the JSON metadata for the struct
// [VehiclesForAgencyListResponseData]
type vehiclesForAgencyListResponseDataJSON struct {
List apijson.Field
References apijson.Field
LimitExceeded apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *VehiclesForAgencyListResponseData) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r vehiclesForAgencyListResponseDataJSON) RawJSON() string {
return r.raw
}
type VehiclesForAgencyListResponseDataList struct {
LastLocationUpdateTime int64 `json:"lastLocationUpdateTime" api:"required"`
LastUpdateTime int64 `json:"lastUpdateTime" api:"required"`
VehicleID string `json:"vehicleId" api:"required"`
Location VehiclesForAgencyListResponseDataListLocation `json:"location"`
OccupancyCapacity int64 `json:"occupancyCapacity"`
OccupancyCount int64 `json:"occupancyCount"`
OccupancyStatus string `json:"occupancyStatus"`
Phase string `json:"phase"`
Status string `json:"status"`
TripID string `json:"tripId"`
// Trip-specific status for the arriving transit vehicle.
TripStatus VehiclesForAgencyListResponseDataListTripStatus `json:"tripStatus"`
JSON vehiclesForAgencyListResponseDataListJSON `json:"-"`
}
// vehiclesForAgencyListResponseDataListJSON contains the JSON metadata for the
// struct [VehiclesForAgencyListResponseDataList]
type vehiclesForAgencyListResponseDataListJSON struct {
LastLocationUpdateTime apijson.Field
LastUpdateTime apijson.Field
VehicleID apijson.Field
Location apijson.Field
OccupancyCapacity apijson.Field
OccupancyCount apijson.Field
OccupancyStatus apijson.Field
Phase apijson.Field
Status apijson.Field
TripID apijson.Field
TripStatus apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *VehiclesForAgencyListResponseDataList) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r vehiclesForAgencyListResponseDataListJSON) RawJSON() string {
return r.raw
}
type VehiclesForAgencyListResponseDataListLocation struct {
Lat float64 `json:"lat"`
Lon float64 `json:"lon"`
JSON vehiclesForAgencyListResponseDataListLocationJSON `json:"-"`
}
// vehiclesForAgencyListResponseDataListLocationJSON contains the JSON metadata for
// the struct [VehiclesForAgencyListResponseDataListLocation]
type vehiclesForAgencyListResponseDataListLocationJSON struct {
Lat apijson.Field
Lon apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *VehiclesForAgencyListResponseDataListLocation) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r vehiclesForAgencyListResponseDataListLocationJSON) RawJSON() string {
return r.raw
}
// Trip-specific status for the arriving transit vehicle.
type VehiclesForAgencyListResponseDataListTripStatus struct {
// Trip ID of the trip the vehicle is actively serving.
ActiveTripID string `json:"activeTripId" api:"required"`
// Index of the active trip into the sequence of trips for the active block.
BlockTripSequence int64 `json:"blockTripSequence" api:"required"`
// ID of the closest stop to the current location of the transit vehicle.
ClosestStop string `json:"closestStop" api:"required"`
// Distance, in meters, the transit vehicle has progressed along the active trip.
DistanceAlongTrip float64 `json:"distanceAlongTrip" api:"required"`
// Last known distance along the trip received in real-time from the transit
// vehicle.
LastKnownDistanceAlongTrip float64 `json:"lastKnownDistanceAlongTrip" api:"required"`
// Timestamp of the last known real-time location update from the transit vehicle.
LastLocationUpdateTime int64 `json:"lastLocationUpdateTime" api:"required"`
// Timestamp of the last known real-time update from the transit vehicle.
LastUpdateTime int64 `json:"lastUpdateTime" api:"required"`
// Capacity of the transit vehicle in terms of occupancy.
OccupancyCapacity int64 `json:"occupancyCapacity" api:"required"`
// Current count of occupants in the transit vehicle.
OccupancyCount int64 `json:"occupancyCount" api:"required"`
// Current occupancy status of the transit vehicle.
OccupancyStatus string `json:"occupancyStatus" api:"required"`
// Current journey phase of the trip.
Phase string `json:"phase" api:"required"`
// Indicates if real-time arrival info is available for this trip.
Predicted bool `json:"predicted" api:"required"`
// Deviation from the schedule in seconds (positive for late, negative for early).
ScheduleDeviation int64 `json:"scheduleDeviation" api:"required"`
// Time, in milliseconds since the Unix epoch, of midnight for the start of the
// service date for the trip.
ServiceDate int64 `json:"serviceDate" api:"required"`
// Current status modifiers for the trip.
Status string `json:"status" api:"required"`
// Total length of the trip, in meters.
TotalDistanceAlongTrip float64 `json:"totalDistanceAlongTrip" api:"required"`
// Time offset from the closest stop to the current position of the transit vehicle
// (in seconds).
ClosestStopTimeOffset int64 `json:"closestStopTimeOffset"`
// Information about frequency-based scheduling, if applicable to the trip.
Frequency string `json:"frequency" api:"nullable"`
// Last known location of the transit vehicle (optional).
LastKnownLocation VehiclesForAgencyListResponseDataListTripStatusLastKnownLocation `json:"lastKnownLocation" api:"nullable"`
// Last known orientation value received in real-time from the transit vehicle.
LastKnownOrientation float64 `json:"lastKnownOrientation"`
// ID of the next stop the transit vehicle is scheduled to arrive at.
NextStop string `json:"nextStop"`
// Time offset from the next stop to the current position of the transit vehicle
// (in seconds).
NextStopTimeOffset int64 `json:"nextStopTimeOffset"`
// Orientation of the transit vehicle, represented as an angle in degrees.
Orientation float64 `json:"orientation"`
// Current position of the transit vehicle.
Position VehiclesForAgencyListResponseDataListTripStatusPosition `json:"position"`
// Distance, in meters, the transit vehicle is scheduled to have progressed along
// the active trip.
ScheduledDistanceAlongTrip float64 `json:"scheduledDistanceAlongTrip"`
// References to situation elements (if any) applicable to this trip.
SituationIDs []string `json:"situationIds"`
// ID of the transit vehicle currently serving the trip.
VehicleID string `json:"vehicleId"`
JSON vehiclesForAgencyListResponseDataListTripStatusJSON `json:"-"`
}
// vehiclesForAgencyListResponseDataListTripStatusJSON contains the JSON metadata
// for the struct [VehiclesForAgencyListResponseDataListTripStatus]
type vehiclesForAgencyListResponseDataListTripStatusJSON struct {
ActiveTripID apijson.Field
BlockTripSequence apijson.Field
ClosestStop apijson.Field
DistanceAlongTrip apijson.Field
LastKnownDistanceAlongTrip apijson.Field
LastLocationUpdateTime apijson.Field
LastUpdateTime apijson.Field
OccupancyCapacity apijson.Field
OccupancyCount apijson.Field
OccupancyStatus apijson.Field
Phase apijson.Field
Predicted apijson.Field
ScheduleDeviation apijson.Field
ServiceDate apijson.Field
Status apijson.Field
TotalDistanceAlongTrip apijson.Field
ClosestStopTimeOffset apijson.Field
Frequency apijson.Field
LastKnownLocation apijson.Field
LastKnownOrientation apijson.Field
NextStop apijson.Field
NextStopTimeOffset apijson.Field
Orientation apijson.Field
Position apijson.Field
ScheduledDistanceAlongTrip apijson.Field
SituationIDs apijson.Field
VehicleID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *VehiclesForAgencyListResponseDataListTripStatus) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r vehiclesForAgencyListResponseDataListTripStatusJSON) RawJSON() string {
return r.raw
}
// Last known location of the transit vehicle (optional).
type VehiclesForAgencyListResponseDataListTripStatusLastKnownLocation struct {
// Latitude of the last known location of the transit vehicle.
Lat float64 `json:"lat"`
// Longitude of the last known location of the transit vehicle.
Lon float64 `json:"lon"`
JSON vehiclesForAgencyListResponseDataListTripStatusLastKnownLocationJSON `json:"-"`
}
// vehiclesForAgencyListResponseDataListTripStatusLastKnownLocationJSON contains
// the JSON metadata for the struct
// [VehiclesForAgencyListResponseDataListTripStatusLastKnownLocation]
type vehiclesForAgencyListResponseDataListTripStatusLastKnownLocationJSON struct {
Lat apijson.Field
Lon apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *VehiclesForAgencyListResponseDataListTripStatusLastKnownLocation) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r vehiclesForAgencyListResponseDataListTripStatusLastKnownLocationJSON) RawJSON() string {
return r.raw
}
// Current position of the transit vehicle.
type VehiclesForAgencyListResponseDataListTripStatusPosition struct {
// Latitude of the current position of the transit vehicle.
Lat float64 `json:"lat"`
// Longitude of the current position of the transit vehicle.
Lon float64 `json:"lon"`
JSON vehiclesForAgencyListResponseDataListTripStatusPositionJSON `json:"-"`
}
// vehiclesForAgencyListResponseDataListTripStatusPositionJSON contains the JSON
// metadata for the struct
// [VehiclesForAgencyListResponseDataListTripStatusPosition]
type vehiclesForAgencyListResponseDataListTripStatusPositionJSON struct {
Lat apijson.Field
Lon apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *VehiclesForAgencyListResponseDataListTripStatusPosition) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r vehiclesForAgencyListResponseDataListTripStatusPositionJSON) RawJSON() string {
return r.raw
}
type VehiclesForAgencyListParams struct {
// Specific time for querying the status (timestamp format)
Time param.Field[string] `query:"time"`
}
// URLQuery serializes [VehiclesForAgencyListParams]'s query parameters as
// `url.Values`.
func (r VehiclesForAgencyListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatRepeat,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}