-
Notifications
You must be signed in to change notification settings - Fork 0
/
block.go
224 lines (190 loc) · 8.42 KB
/
block.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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package onebusaway
import (
"context"
"errors"
"fmt"
"net/http"
"github.com/OneBusAway/go-sdk/internal/apijson"
"github.com/OneBusAway/go-sdk/internal/requestconfig"
"github.com/OneBusAway/go-sdk/option"
"github.com/OneBusAway/go-sdk/shared"
)
// BlockService 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 [NewBlockService] method instead.
type BlockService struct {
Options []option.RequestOption
}
// NewBlockService 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 NewBlockService(opts ...option.RequestOption) (r *BlockService) {
r = &BlockService{}
r.Options = opts
return
}
// Get details of a specific block by ID
func (r *BlockService) Get(ctx context.Context, blockID string, opts ...option.RequestOption) (res *BlockGetResponse, err error) {
opts = append(r.Options[:], opts...)
if blockID == "" {
err = errors.New("missing required blockID parameter")
return
}
path := fmt.Sprintf("api/where/block/%s.json", blockID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
type BlockGetResponse struct {
Data BlockGetResponseData `json:"data,required"`
JSON blockGetResponseJSON `json:"-"`
shared.ResponseWrapper
}
// blockGetResponseJSON contains the JSON metadata for the struct
// [BlockGetResponse]
type blockGetResponseJSON struct {
Data apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *BlockGetResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r blockGetResponseJSON) RawJSON() string {
return r.raw
}
type BlockGetResponseData struct {
Entry BlockGetResponseDataEntry `json:"entry,required"`
References shared.References `json:"references,required"`
JSON blockGetResponseDataJSON `json:"-"`
}
// blockGetResponseDataJSON contains the JSON metadata for the struct
// [BlockGetResponseData]
type blockGetResponseDataJSON struct {
Entry apijson.Field
References apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *BlockGetResponseData) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r blockGetResponseDataJSON) RawJSON() string {
return r.raw
}
type BlockGetResponseDataEntry struct {
ID string `json:"id,required"`
Configurations []BlockGetResponseDataEntryConfiguration `json:"configurations,required"`
JSON blockGetResponseDataEntryJSON `json:"-"`
}
// blockGetResponseDataEntryJSON contains the JSON metadata for the struct
// [BlockGetResponseDataEntry]
type blockGetResponseDataEntryJSON struct {
ID apijson.Field
Configurations apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *BlockGetResponseDataEntry) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r blockGetResponseDataEntryJSON) RawJSON() string {
return r.raw
}
type BlockGetResponseDataEntryConfiguration struct {
ActiveServiceIDs []string `json:"activeServiceIds,required"`
Trips []BlockGetResponseDataEntryConfigurationsTrip `json:"trips,required"`
InactiveServiceIDs []string `json:"inactiveServiceIds"`
JSON blockGetResponseDataEntryConfigurationJSON `json:"-"`
}
// blockGetResponseDataEntryConfigurationJSON contains the JSON metadata for the
// struct [BlockGetResponseDataEntryConfiguration]
type blockGetResponseDataEntryConfigurationJSON struct {
ActiveServiceIDs apijson.Field
Trips apijson.Field
InactiveServiceIDs apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *BlockGetResponseDataEntryConfiguration) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r blockGetResponseDataEntryConfigurationJSON) RawJSON() string {
return r.raw
}
type BlockGetResponseDataEntryConfigurationsTrip struct {
AccumulatedSlackTime float64 `json:"accumulatedSlackTime,required"`
BlockStopTimes []BlockGetResponseDataEntryConfigurationsTripsBlockStopTime `json:"blockStopTimes,required"`
DistanceAlongBlock float64 `json:"distanceAlongBlock,required"`
TripID string `json:"tripId,required"`
JSON blockGetResponseDataEntryConfigurationsTripJSON `json:"-"`
}
// blockGetResponseDataEntryConfigurationsTripJSON contains the JSON metadata for
// the struct [BlockGetResponseDataEntryConfigurationsTrip]
type blockGetResponseDataEntryConfigurationsTripJSON struct {
AccumulatedSlackTime apijson.Field
BlockStopTimes apijson.Field
DistanceAlongBlock apijson.Field
TripID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *BlockGetResponseDataEntryConfigurationsTrip) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r blockGetResponseDataEntryConfigurationsTripJSON) RawJSON() string {
return r.raw
}
type BlockGetResponseDataEntryConfigurationsTripsBlockStopTime struct {
AccumulatedSlackTime float64 `json:"accumulatedSlackTime,required"`
BlockSequence int64 `json:"blockSequence,required"`
DistanceAlongBlock float64 `json:"distanceAlongBlock,required"`
StopTime BlockGetResponseDataEntryConfigurationsTripsBlockStopTimesStopTime `json:"stopTime,required"`
JSON blockGetResponseDataEntryConfigurationsTripsBlockStopTimeJSON `json:"-"`
}
// blockGetResponseDataEntryConfigurationsTripsBlockStopTimeJSON contains the JSON
// metadata for the struct
// [BlockGetResponseDataEntryConfigurationsTripsBlockStopTime]
type blockGetResponseDataEntryConfigurationsTripsBlockStopTimeJSON struct {
AccumulatedSlackTime apijson.Field
BlockSequence apijson.Field
DistanceAlongBlock apijson.Field
StopTime apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *BlockGetResponseDataEntryConfigurationsTripsBlockStopTime) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r blockGetResponseDataEntryConfigurationsTripsBlockStopTimeJSON) RawJSON() string {
return r.raw
}
type BlockGetResponseDataEntryConfigurationsTripsBlockStopTimesStopTime struct {
ArrivalTime int64 `json:"arrivalTime,required"`
DepartureTime int64 `json:"departureTime,required"`
StopID string `json:"stopId,required"`
DropOffType int64 `json:"dropOffType"`
PickupType int64 `json:"pickupType"`
JSON blockGetResponseDataEntryConfigurationsTripsBlockStopTimesStopTimeJSON `json:"-"`
}
// blockGetResponseDataEntryConfigurationsTripsBlockStopTimesStopTimeJSON contains
// the JSON metadata for the struct
// [BlockGetResponseDataEntryConfigurationsTripsBlockStopTimesStopTime]
type blockGetResponseDataEntryConfigurationsTripsBlockStopTimesStopTimeJSON struct {
ArrivalTime apijson.Field
DepartureTime apijson.Field
StopID apijson.Field
DropOffType apijson.Field
PickupType apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *BlockGetResponseDataEntryConfigurationsTripsBlockStopTimesStopTime) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r blockGetResponseDataEntryConfigurationsTripsBlockStopTimesStopTimeJSON) RawJSON() string {
return r.raw
}