-
Notifications
You must be signed in to change notification settings - Fork 0
/
scheduleforstop.go
250 lines (214 loc) · 11.3 KB
/
scheduleforstop.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
// 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"
)
// ScheduleForStopService 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 [NewScheduleForStopService] method instead.
type ScheduleForStopService struct {
Options []option.RequestOption
}
// NewScheduleForStopService 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 NewScheduleForStopService(opts ...option.RequestOption) (r *ScheduleForStopService) {
r = &ScheduleForStopService{}
r.Options = opts
return
}
// Get schedule for a specific stop
func (r *ScheduleForStopService) Get(ctx context.Context, stopID string, query ScheduleForStopGetParams, opts ...option.RequestOption) (res *ScheduleForStopGetResponse, err error) {
opts = append(r.Options[:], opts...)
if stopID == "" {
err = errors.New("missing required stopID parameter")
return
}
path := fmt.Sprintf("api/where/schedule-for-stop/%s.json", stopID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
return
}
type ScheduleForStopGetResponse struct {
Data ScheduleForStopGetResponseData `json:"data,required"`
JSON scheduleForStopGetResponseJSON `json:"-"`
shared.ResponseWrapper
}
// scheduleForStopGetResponseJSON contains the JSON metadata for the struct
// [ScheduleForStopGetResponse]
type scheduleForStopGetResponseJSON struct {
Data apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ScheduleForStopGetResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r scheduleForStopGetResponseJSON) RawJSON() string {
return r.raw
}
type ScheduleForStopGetResponseData struct {
Entry ScheduleForStopGetResponseDataEntry `json:"entry,required"`
References shared.References `json:"references,required"`
JSON scheduleForStopGetResponseDataJSON `json:"-"`
}
// scheduleForStopGetResponseDataJSON contains the JSON metadata for the struct
// [ScheduleForStopGetResponseData]
type scheduleForStopGetResponseDataJSON struct {
Entry apijson.Field
References apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ScheduleForStopGetResponseData) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r scheduleForStopGetResponseDataJSON) RawJSON() string {
return r.raw
}
type ScheduleForStopGetResponseDataEntry struct {
Date int64 `json:"date,required"`
StopID string `json:"stopId,required"`
StopRouteSchedules []ScheduleForStopGetResponseDataEntryStopRouteSchedule `json:"stopRouteSchedules,required"`
JSON scheduleForStopGetResponseDataEntryJSON `json:"-"`
}
// scheduleForStopGetResponseDataEntryJSON contains the JSON metadata for the
// struct [ScheduleForStopGetResponseDataEntry]
type scheduleForStopGetResponseDataEntryJSON struct {
Date apijson.Field
StopID apijson.Field
StopRouteSchedules apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ScheduleForStopGetResponseDataEntry) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r scheduleForStopGetResponseDataEntryJSON) RawJSON() string {
return r.raw
}
type ScheduleForStopGetResponseDataEntryStopRouteSchedule struct {
RouteID string `json:"routeId,required"`
StopRouteDirectionSchedules []ScheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionSchedule `json:"stopRouteDirectionSchedules,required"`
JSON scheduleForStopGetResponseDataEntryStopRouteScheduleJSON `json:"-"`
}
// scheduleForStopGetResponseDataEntryStopRouteScheduleJSON contains the JSON
// metadata for the struct [ScheduleForStopGetResponseDataEntryStopRouteSchedule]
type scheduleForStopGetResponseDataEntryStopRouteScheduleJSON struct {
RouteID apijson.Field
StopRouteDirectionSchedules apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ScheduleForStopGetResponseDataEntryStopRouteSchedule) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r scheduleForStopGetResponseDataEntryStopRouteScheduleJSON) RawJSON() string {
return r.raw
}
type ScheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionSchedule struct {
ScheduleStopTimes []ScheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionSchedulesScheduleStopTime `json:"scheduleStopTimes,required"`
TripHeadsign string `json:"tripHeadsign,required"`
ScheduleFrequencies []ScheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionSchedulesScheduleFrequency `json:"scheduleFrequencies"`
JSON scheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionScheduleJSON `json:"-"`
}
// scheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionScheduleJSON
// contains the JSON metadata for the struct
// [ScheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionSchedule]
type scheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionScheduleJSON struct {
ScheduleStopTimes apijson.Field
TripHeadsign apijson.Field
ScheduleFrequencies apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ScheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionSchedule) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r scheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionScheduleJSON) RawJSON() string {
return r.raw
}
type ScheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionSchedulesScheduleStopTime struct {
ArrivalEnabled bool `json:"arrivalEnabled,required"`
ArrivalTime int64 `json:"arrivalTime,required"`
DepartureEnabled bool `json:"departureEnabled,required"`
DepartureTime int64 `json:"departureTime,required"`
ServiceID string `json:"serviceId,required"`
TripID string `json:"tripId,required"`
StopHeadsign string `json:"stopHeadsign"`
JSON scheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionSchedulesScheduleStopTimeJSON `json:"-"`
}
// scheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionSchedulesScheduleStopTimeJSON
// contains the JSON metadata for the struct
// [ScheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionSchedulesScheduleStopTime]
type scheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionSchedulesScheduleStopTimeJSON struct {
ArrivalEnabled apijson.Field
ArrivalTime apijson.Field
DepartureEnabled apijson.Field
DepartureTime apijson.Field
ServiceID apijson.Field
TripID apijson.Field
StopHeadsign apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ScheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionSchedulesScheduleStopTime) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r scheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionSchedulesScheduleStopTimeJSON) RawJSON() string {
return r.raw
}
type ScheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionSchedulesScheduleFrequency struct {
EndTime int64 `json:"endTime,required"`
Headway int64 `json:"headway,required"`
ServiceDate int64 `json:"serviceDate,required"`
ServiceID string `json:"serviceId,required"`
StartTime int64 `json:"startTime,required"`
TripID string `json:"tripId,required"`
JSON scheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionSchedulesScheduleFrequencyJSON `json:"-"`
}
// scheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionSchedulesScheduleFrequencyJSON
// contains the JSON metadata for the struct
// [ScheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionSchedulesScheduleFrequency]
type scheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionSchedulesScheduleFrequencyJSON struct {
EndTime apijson.Field
Headway apijson.Field
ServiceDate apijson.Field
ServiceID apijson.Field
StartTime apijson.Field
TripID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ScheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionSchedulesScheduleFrequency) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r scheduleForStopGetResponseDataEntryStopRouteSchedulesStopRouteDirectionSchedulesScheduleFrequencyJSON) RawJSON() string {
return r.raw
}
type ScheduleForStopGetParams struct {
// The date for which you want to request a schedule in the format YYYY-MM-DD
// (optional, defaults to the current date)
Date param.Field[time.Time] `query:"date" format:"date"`
}
// URLQuery serializes [ScheduleForStopGetParams]'s query parameters as
// `url.Values`.
func (r ScheduleForStopGetParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatRepeat,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}