-
Notifications
You must be signed in to change notification settings - Fork 0
/
stopsforroute.go
240 lines (204 loc) · 8.53 KB
/
stopsforroute.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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package onebusaway
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
"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"
)
// StopsForRouteService 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 [NewStopsForRouteService] method instead.
type StopsForRouteService struct {
Options []option.RequestOption
}
// NewStopsForRouteService 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 NewStopsForRouteService(opts ...option.RequestOption) (r *StopsForRouteService) {
r = &StopsForRouteService{}
r.Options = opts
return
}
// Get stops for a specific route
func (r *StopsForRouteService) List(ctx context.Context, routeID string, query StopsForRouteListParams, opts ...option.RequestOption) (res *StopsForRouteListResponse, err error) {
opts = append(r.Options[:], opts...)
if routeID == "" {
err = errors.New("missing required routeID parameter")
return
}
path := fmt.Sprintf("api/where/stops-for-route/%s.json", routeID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
return
}
type StopsForRouteListResponse struct {
Data StopsForRouteListResponseData `json:"data,required"`
JSON stopsForRouteListResponseJSON `json:"-"`
shared.ResponseWrapper
}
// stopsForRouteListResponseJSON contains the JSON metadata for the struct
// [StopsForRouteListResponse]
type stopsForRouteListResponseJSON struct {
Data apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *StopsForRouteListResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r stopsForRouteListResponseJSON) RawJSON() string {
return r.raw
}
type StopsForRouteListResponseData struct {
Entry StopsForRouteListResponseDataEntry `json:"entry,required"`
References shared.References `json:"references,required"`
JSON stopsForRouteListResponseDataJSON `json:"-"`
}
// stopsForRouteListResponseDataJSON contains the JSON metadata for the struct
// [StopsForRouteListResponseData]
type stopsForRouteListResponseDataJSON struct {
Entry apijson.Field
References apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *StopsForRouteListResponseData) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r stopsForRouteListResponseDataJSON) RawJSON() string {
return r.raw
}
type StopsForRouteListResponseDataEntry struct {
Polylines []StopsForRouteListResponseDataEntryPolyline `json:"polylines"`
RouteID string `json:"routeId"`
StopGroupings []StopsForRouteListResponseDataEntryStopGrouping `json:"stopGroupings"`
StopIDs []string `json:"stopIds"`
JSON stopsForRouteListResponseDataEntryJSON `json:"-"`
}
// stopsForRouteListResponseDataEntryJSON contains the JSON metadata for the struct
// [StopsForRouteListResponseDataEntry]
type stopsForRouteListResponseDataEntryJSON struct {
Polylines apijson.Field
RouteID apijson.Field
StopGroupings apijson.Field
StopIDs apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *StopsForRouteListResponseDataEntry) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r stopsForRouteListResponseDataEntryJSON) RawJSON() string {
return r.raw
}
type StopsForRouteListResponseDataEntryPolyline struct {
Length int64 `json:"length"`
Levels string `json:"levels"`
Points string `json:"points"`
JSON stopsForRouteListResponseDataEntryPolylineJSON `json:"-"`
}
// stopsForRouteListResponseDataEntryPolylineJSON contains the JSON metadata for
// the struct [StopsForRouteListResponseDataEntryPolyline]
type stopsForRouteListResponseDataEntryPolylineJSON struct {
Length apijson.Field
Levels apijson.Field
Points apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *StopsForRouteListResponseDataEntryPolyline) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r stopsForRouteListResponseDataEntryPolylineJSON) RawJSON() string {
return r.raw
}
type StopsForRouteListResponseDataEntryStopGrouping struct {
ID string `json:"id"`
Name StopsForRouteListResponseDataEntryStopGroupingsName `json:"name"`
Polylines []StopsForRouteListResponseDataEntryStopGroupingsPolyline `json:"polylines"`
StopIDs []string `json:"stopIds"`
JSON stopsForRouteListResponseDataEntryStopGroupingJSON `json:"-"`
}
// stopsForRouteListResponseDataEntryStopGroupingJSON contains the JSON metadata
// for the struct [StopsForRouteListResponseDataEntryStopGrouping]
type stopsForRouteListResponseDataEntryStopGroupingJSON struct {
ID apijson.Field
Name apijson.Field
Polylines apijson.Field
StopIDs apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *StopsForRouteListResponseDataEntryStopGrouping) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r stopsForRouteListResponseDataEntryStopGroupingJSON) RawJSON() string {
return r.raw
}
type StopsForRouteListResponseDataEntryStopGroupingsName struct {
Name string `json:"name"`
Names []string `json:"names"`
Type string `json:"type"`
JSON stopsForRouteListResponseDataEntryStopGroupingsNameJSON `json:"-"`
}
// stopsForRouteListResponseDataEntryStopGroupingsNameJSON contains the JSON
// metadata for the struct [StopsForRouteListResponseDataEntryStopGroupingsName]
type stopsForRouteListResponseDataEntryStopGroupingsNameJSON struct {
Name apijson.Field
Names apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *StopsForRouteListResponseDataEntryStopGroupingsName) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r stopsForRouteListResponseDataEntryStopGroupingsNameJSON) RawJSON() string {
return r.raw
}
type StopsForRouteListResponseDataEntryStopGroupingsPolyline struct {
Length int64 `json:"length"`
Levels string `json:"levels"`
Points string `json:"points"`
JSON stopsForRouteListResponseDataEntryStopGroupingsPolylineJSON `json:"-"`
}
// stopsForRouteListResponseDataEntryStopGroupingsPolylineJSON contains the JSON
// metadata for the struct
// [StopsForRouteListResponseDataEntryStopGroupingsPolyline]
type stopsForRouteListResponseDataEntryStopGroupingsPolylineJSON struct {
Length apijson.Field
Levels apijson.Field
Points apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *StopsForRouteListResponseDataEntryStopGroupingsPolyline) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r stopsForRouteListResponseDataEntryStopGroupingsPolylineJSON) RawJSON() string {
return r.raw
}
type StopsForRouteListParams struct {
// Include polyline elements in the response (default true)
IncludePolylines param.Field[bool] `query:"includePolylines"`
// Specify service date (YYYY-MM-DD or epoch) (default today)
Time param.Field[string] `query:"time"`
}
// URLQuery serializes [StopsForRouteListParams]'s query parameters as
// `url.Values`.
func (r StopsForRouteListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatRepeat,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}