-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscheduleforroute.go
310 lines (270 loc) · 13.3 KB
/
scheduleforroute.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
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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package onebusaway
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
"time"
"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"
)
// ScheduleForRouteService 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 [NewScheduleForRouteService] method instead.
type ScheduleForRouteService struct {
Options []option.RequestOption
}
// NewScheduleForRouteService 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 NewScheduleForRouteService(opts ...option.RequestOption) (r *ScheduleForRouteService) {
r = &ScheduleForRouteService{}
r.Options = opts
return
}
// Retrieve the full schedule for a route on a particular day
func (r *ScheduleForRouteService) Get(ctx context.Context, routeID string, query ScheduleForRouteGetParams, opts ...option.RequestOption) (res *ScheduleForRouteGetResponse, err error) {
opts = append(r.Options[:], opts...)
if routeID == "" {
err = errors.New("missing required routeID parameter")
return
}
path := fmt.Sprintf("api/where/schedule-for-route/%s.json", routeID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
return
}
type ScheduleForRouteGetResponse struct {
Data ScheduleForRouteGetResponseData `json:"data,required"`
JSON scheduleForRouteGetResponseJSON `json:"-"`
shared.ResponseWrapper
}
// scheduleForRouteGetResponseJSON contains the JSON metadata for the struct
// [ScheduleForRouteGetResponse]
type scheduleForRouteGetResponseJSON struct {
Data apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ScheduleForRouteGetResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r scheduleForRouteGetResponseJSON) RawJSON() string {
return r.raw
}
type ScheduleForRouteGetResponseData struct {
Entry ScheduleForRouteGetResponseDataEntry `json:"entry,required"`
JSON scheduleForRouteGetResponseDataJSON `json:"-"`
}
// scheduleForRouteGetResponseDataJSON contains the JSON metadata for the struct
// [ScheduleForRouteGetResponseData]
type scheduleForRouteGetResponseDataJSON struct {
Entry apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ScheduleForRouteGetResponseData) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r scheduleForRouteGetResponseDataJSON) RawJSON() string {
return r.raw
}
type ScheduleForRouteGetResponseDataEntry struct {
RouteID string `json:"routeId,required"`
ScheduleDate int64 `json:"scheduleDate,required"`
ServiceIDs []string `json:"serviceIds,required"`
Stops []ScheduleForRouteGetResponseDataEntryStop `json:"stops,required"`
StopTripGroupings []ScheduleForRouteGetResponseDataEntryStopTripGrouping `json:"stopTripGroupings,required"`
Trips []ScheduleForRouteGetResponseDataEntryTrip `json:"trips,required"`
JSON scheduleForRouteGetResponseDataEntryJSON `json:"-"`
}
// scheduleForRouteGetResponseDataEntryJSON contains the JSON metadata for the
// struct [ScheduleForRouteGetResponseDataEntry]
type scheduleForRouteGetResponseDataEntryJSON struct {
RouteID apijson.Field
ScheduleDate apijson.Field
ServiceIDs apijson.Field
Stops apijson.Field
StopTripGroupings apijson.Field
Trips apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ScheduleForRouteGetResponseDataEntry) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r scheduleForRouteGetResponseDataEntryJSON) RawJSON() string {
return r.raw
}
type ScheduleForRouteGetResponseDataEntryStop struct {
ID string `json:"id,required"`
Lat float64 `json:"lat,required"`
Lon float64 `json:"lon,required"`
Name string `json:"name,required"`
Parent string `json:"parent,required"`
RouteIDs []string `json:"routeIds,required"`
StaticRouteIDs []string `json:"staticRouteIds,required"`
Code string `json:"code"`
Direction string `json:"direction"`
LocationType int64 `json:"locationType"`
WheelchairBoarding string `json:"wheelchairBoarding"`
JSON scheduleForRouteGetResponseDataEntryStopJSON `json:"-"`
}
// scheduleForRouteGetResponseDataEntryStopJSON contains the JSON metadata for the
// struct [ScheduleForRouteGetResponseDataEntryStop]
type scheduleForRouteGetResponseDataEntryStopJSON struct {
ID apijson.Field
Lat apijson.Field
Lon apijson.Field
Name apijson.Field
Parent apijson.Field
RouteIDs apijson.Field
StaticRouteIDs apijson.Field
Code apijson.Field
Direction apijson.Field
LocationType apijson.Field
WheelchairBoarding apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ScheduleForRouteGetResponseDataEntryStop) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r scheduleForRouteGetResponseDataEntryStopJSON) RawJSON() string {
return r.raw
}
type ScheduleForRouteGetResponseDataEntryStopTripGrouping struct {
DirectionID string `json:"directionId,required"`
StopIDs []string `json:"stopIds,required"`
TripHeadsigns []string `json:"tripHeadsigns,required"`
TripIDs []string `json:"tripIds,required"`
TripsWithStopTimes []ScheduleForRouteGetResponseDataEntryStopTripGroupingsTripsWithStopTime `json:"tripsWithStopTimes"`
JSON scheduleForRouteGetResponseDataEntryStopTripGroupingJSON `json:"-"`
}
// scheduleForRouteGetResponseDataEntryStopTripGroupingJSON contains the JSON
// metadata for the struct [ScheduleForRouteGetResponseDataEntryStopTripGrouping]
type scheduleForRouteGetResponseDataEntryStopTripGroupingJSON struct {
DirectionID apijson.Field
StopIDs apijson.Field
TripHeadsigns apijson.Field
TripIDs apijson.Field
TripsWithStopTimes apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ScheduleForRouteGetResponseDataEntryStopTripGrouping) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r scheduleForRouteGetResponseDataEntryStopTripGroupingJSON) RawJSON() string {
return r.raw
}
type ScheduleForRouteGetResponseDataEntryStopTripGroupingsTripsWithStopTime struct {
StopTimes []ScheduleForRouteGetResponseDataEntryStopTripGroupingsTripsWithStopTimesStopTime `json:"stopTimes,required"`
TripID string `json:"tripId,required"`
JSON scheduleForRouteGetResponseDataEntryStopTripGroupingsTripsWithStopTimeJSON `json:"-"`
}
// scheduleForRouteGetResponseDataEntryStopTripGroupingsTripsWithStopTimeJSON
// contains the JSON metadata for the struct
// [ScheduleForRouteGetResponseDataEntryStopTripGroupingsTripsWithStopTime]
type scheduleForRouteGetResponseDataEntryStopTripGroupingsTripsWithStopTimeJSON struct {
StopTimes apijson.Field
TripID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ScheduleForRouteGetResponseDataEntryStopTripGroupingsTripsWithStopTime) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r scheduleForRouteGetResponseDataEntryStopTripGroupingsTripsWithStopTimeJSON) RawJSON() string {
return r.raw
}
type ScheduleForRouteGetResponseDataEntryStopTripGroupingsTripsWithStopTimesStopTime struct {
ArrivalEnabled bool `json:"arrivalEnabled,required"`
ArrivalTime int64 `json:"arrivalTime,required"`
DepartureEnabled bool `json:"departureEnabled,required"`
DepartureTime int64 `json:"departureTime,required"`
StopID string `json:"stopId,required"`
TripID string `json:"tripId,required"`
ServiceID string `json:"serviceId"`
StopHeadsign string `json:"stopHeadsign"`
JSON scheduleForRouteGetResponseDataEntryStopTripGroupingsTripsWithStopTimesStopTimeJSON `json:"-"`
}
// scheduleForRouteGetResponseDataEntryStopTripGroupingsTripsWithStopTimesStopTimeJSON
// contains the JSON metadata for the struct
// [ScheduleForRouteGetResponseDataEntryStopTripGroupingsTripsWithStopTimesStopTime]
type scheduleForRouteGetResponseDataEntryStopTripGroupingsTripsWithStopTimesStopTimeJSON struct {
ArrivalEnabled apijson.Field
ArrivalTime apijson.Field
DepartureEnabled apijson.Field
DepartureTime apijson.Field
StopID apijson.Field
TripID apijson.Field
ServiceID apijson.Field
StopHeadsign apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ScheduleForRouteGetResponseDataEntryStopTripGroupingsTripsWithStopTimesStopTime) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r scheduleForRouteGetResponseDataEntryStopTripGroupingsTripsWithStopTimesStopTimeJSON) RawJSON() string {
return r.raw
}
type ScheduleForRouteGetResponseDataEntryTrip struct {
ID string `json:"id,required"`
RouteID string `json:"routeId,required"`
ServiceID string `json:"serviceId,required"`
BlockID string `json:"blockId"`
DirectionID string `json:"directionId"`
PeakOffpeak int64 `json:"peakOffpeak"`
RouteShortName string `json:"routeShortName"`
ShapeID string `json:"shapeId"`
TimeZone string `json:"timeZone"`
TripHeadsign string `json:"tripHeadsign"`
TripShortName string `json:"tripShortName"`
JSON scheduleForRouteGetResponseDataEntryTripJSON `json:"-"`
}
// scheduleForRouteGetResponseDataEntryTripJSON contains the JSON metadata for the
// struct [ScheduleForRouteGetResponseDataEntryTrip]
type scheduleForRouteGetResponseDataEntryTripJSON struct {
ID apijson.Field
RouteID apijson.Field
ServiceID apijson.Field
BlockID apijson.Field
DirectionID apijson.Field
PeakOffpeak apijson.Field
RouteShortName apijson.Field
ShapeID apijson.Field
TimeZone apijson.Field
TripHeadsign apijson.Field
TripShortName apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ScheduleForRouteGetResponseDataEntryTrip) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r scheduleForRouteGetResponseDataEntryTripJSON) RawJSON() string {
return r.raw
}
type ScheduleForRouteGetParams struct {
// The date for which you want to request a schedule in the format YYYY-MM-DD
// (optional, defaults to current date)
Date param.Field[time.Time] `query:"date" format:"date"`
}
// URLQuery serializes [ScheduleForRouteGetParams]'s query parameters as
// `url.Values`.
func (r ScheduleForRouteGetParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatRepeat,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}