rail-locator-api 0.0.31 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.markdown +409 -63
- data/lib/rail-locator-api/api_request.rb +4 -0
- data/lib/rail-locator-api/request.rb +10 -6
- data/lib/rail-locator-api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edc4f957d48ba4a6a724fdc6eb30a4e98c3a870f238687df672343822e7d9e62
|
4
|
+
data.tar.gz: 39793e92df61361bb59b53dc0f42eaa3e26f3af4a95ce55f76cef4989adca554
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59538f8648d35498520b19fdfe66d028a867f46bcfae08354cbdb3be8eae673c6375083d86228cdf21c7615e48dce38571aa97d09d493d4008432a99b8a9ddd8
|
7
|
+
data.tar.gz: 919b0d37c8cb4cbcfd6f313520c5680aa928eede734052de8ea006adc24e8d9d64a0a7de011666cec9b6b694560c69b71c08774203ffa141986ccaefa1dd9d3e
|
data/README.markdown
CHANGED
@@ -9,27 +9,56 @@ API wrapper для RailLocator API v2
|
|
9
9
|
3. [Debug Logging](#debug_logging)
|
10
10
|
4. [Custom logger](#custom_logger)
|
11
11
|
1. [Треки](#tracks)
|
12
|
-
1. [Получение
|
13
|
-
2. [
|
14
|
-
3. [
|
15
|
-
4. [
|
16
|
-
5. [Получение
|
17
|
-
|
12
|
+
1. [Получение Списка Треков](#tracks_dislocation_get)
|
13
|
+
2. [Постановка На Слежение](#tracks_dislocation_post)
|
14
|
+
3. [Получение Дислокации По Нескольким Трекам](#tracks_dislocation_batch_get)
|
15
|
+
4. [Получение Информации О Маршруте](#tracks_dislocation_route_info_get)
|
16
|
+
5. [Получение Дислокации По Одному Треку](#tracks_dislocation__track_id__get)
|
17
|
+
2. [Справки](#inquiries)
|
18
|
+
1. [Получение Справок](#tracks_inquiries_get)
|
19
|
+
2. [Постановка На Слежение](#tracks_inquiries_get)
|
20
|
+
3. [Получение Справки](#tracks_inquiries__track_id__get)
|
21
|
+
3. [Подходы](#approaches)
|
22
|
+
1. [Постановка На Слежение](#tracks_approaches_post)
|
23
|
+
4. [Тех. паспорт вагона](#tech_passport)
|
24
|
+
1. [Получение Тех. Паспортов](#tracks_tech_passport_batch_get)
|
25
|
+
2. [Получение Тех. Паспорта](#tracks_tech_passport__track_id__get)
|
26
|
+
5. [Контроль тех. состояния](#tech_condition)
|
27
|
+
1. [Получение Тех. Состояния](#tracks_tech_condition_get)
|
28
|
+
2. [Постановка На Слежение](#tracks_tech_condition_post)
|
29
|
+
6. [Изменение/Снятие треков](#update_delete_tracks)
|
30
|
+
1. [Снятие Со Слежения Нескольких Треков](#tracks_batch_delete)
|
31
|
+
2. [Изменение Информации О Нескольких Треках](#tracks_batch_patch)
|
32
|
+
3. [Снятие Со Слежения Одного Трека](#tracks__track_id__delete)
|
33
|
+
4. [Изменение Информации О Треке](#tracks__track_id__patch)
|
34
|
+
7. [Группы](#groups)
|
35
|
+
1. [Получение Списка Групп](#groups_get)
|
36
|
+
2. [Создание Группы](#groups_post)
|
37
|
+
3. [Удаление Группы](#groups__group_id__delete)
|
38
|
+
4. [Изменение Группы](#groups__group_id__patch)
|
39
|
+
5. [Добавление Вагона В Группу](#groups__group_id__cargo_transport_unit_number_batch_put)
|
40
|
+
6. [Удаление Вагонов Из Группы](#groups__group_id__cargo_transport_unit_number_batch_delete)
|
41
|
+
7. [Добавление Вагона В Группу](#groups__group_id__cargo_transport_unit_number__cargo_transport_unit_number__put)
|
42
|
+
8. [Удаление Вагона Из Группы](#groups__group_id__cargo_transport_unit_number__cargo_transport_unit_number__delete)
|
43
|
+
8. [Справочники](#references)
|
44
|
+
1. [Получение Координат Станции](#references_station_get)
|
45
|
+
2. [Получение Списка Станций С Краткой Информацией](#references_stations_get)
|
46
|
+
|
18
47
|
# <a name="install"></a> Установка
|
19
48
|
|
20
49
|
## Ruby
|
21
50
|
$ gem install rail-locator-api
|
22
51
|
## Rails
|
23
52
|
добавьте в Gemfile:
|
24
|
-
|
53
|
+
|
54
|
+
gem 'rail-locator-api'
|
25
55
|
|
26
56
|
и запустите `bundle install`.
|
27
57
|
|
28
58
|
Затем:
|
59
|
+
|
29
60
|
rails g rail_locator_api:install
|
30
|
-
## Требования
|
31
61
|
|
32
|
-
Необходимо получить api key https://rail-locator.com/app/api-keys
|
33
62
|
|
34
63
|
## <a name="using_rails"></a> Использование Rails
|
35
64
|
|
@@ -40,12 +69,10 @@ API wrapper для RailLocator API v2
|
|
40
69
|
Сначала создайте экземпляр объекта `RailLocatorApi::Request`:
|
41
70
|
|
42
71
|
```ruby
|
43
|
-
locator = RailLocatorApi::Request.new(api_key: "your_api_key", api_auth_method: :api_key)
|
44
|
-
или
|
45
72
|
locator = RailLocatorApi::Request.new(api_user_email: "email@ctm.ru", api_user_password: "12345678")
|
46
73
|
```
|
47
74
|
|
48
|
-
Вы можете изменять `
|
75
|
+
Вы можете изменять `api_user_email`, `api_user_password`, `timeout`, `open_timeout`, `faraday_adapter`, `proxy`, `symbolize_keys`, `logger`, и `debug`:
|
49
76
|
|
50
77
|
```ruby
|
51
78
|
RailLocatorApi::Request.api_key = "your_api_key"
|
@@ -72,7 +99,7 @@ locator = RailLocatorApi::Request.new(api_key: "your_api_key", debug: true)
|
|
72
99
|
`Logger.new` используется по умолчанию, но вы можете изменить на свой:
|
73
100
|
|
74
101
|
```ruby
|
75
|
-
locator = RailLocatorApi::Request.new(
|
102
|
+
locator = RailLocatorApi::Request.new(api_user_email: "email@ctm.ru", api_user_password: "12345678", debug: true, logger: MyLogger.new)
|
76
103
|
```
|
77
104
|
|
78
105
|
Или:
|
@@ -82,65 +109,384 @@ RailLocatorApi::Request.logger = MyLogger.new
|
|
82
109
|
```
|
83
110
|
|
84
111
|
# <a name="examples"></a> Примеры
|
85
|
-
## <a name="tracks"></a>
|
86
|
-
### <a name="
|
112
|
+
## <a name="tracks"></a> Дислокация
|
113
|
+
### <a name="tracks_dislocation_get"></a> [Получение Списка Треков](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Dislokaciya/operation/________________________tracks_dislocation_get)
|
114
|
+
```ruby
|
115
|
+
request = {
|
116
|
+
"limit": 100,
|
117
|
+
"offset": 0,
|
118
|
+
"filters": [
|
119
|
+
{
|
120
|
+
"field": "is_broken",
|
121
|
+
"operand": "in",
|
122
|
+
"value": [
|
123
|
+
null,
|
124
|
+
true
|
125
|
+
]
|
126
|
+
},
|
127
|
+
{
|
128
|
+
"field": "track_create_time",
|
129
|
+
"operand": ">=",
|
130
|
+
"value": "2010-10-10 00:00"
|
131
|
+
},
|
132
|
+
{
|
133
|
+
"field": "track_stop_time",
|
134
|
+
"operand": "between",
|
135
|
+
"value": [
|
136
|
+
"2010-10-10 00:00",
|
137
|
+
"2021-10-10 00:00"
|
138
|
+
]
|
139
|
+
}
|
140
|
+
],
|
141
|
+
"sort": [
|
142
|
+
{
|
143
|
+
"field": "is_active",
|
144
|
+
"order": "asc"
|
145
|
+
}
|
146
|
+
],
|
147
|
+
"fulltext_filter": {
|
148
|
+
"value": "2010",
|
149
|
+
"fields": [
|
150
|
+
"track_create_time",
|
151
|
+
"track_stop_time"
|
152
|
+
],
|
153
|
+
"operation": "include"
|
154
|
+
}
|
155
|
+
}
|
156
|
+
response = RailLocatorApi::Request.tracks.dislocation.retrieve(body: request)
|
157
|
+
p response.body
|
158
|
+
```
|
159
|
+
|
160
|
+
### <a name="tracks_dislocation_post"></a> [Постановка На Слежение](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Dislokaciya/operation/_______________________tracks_dislocation_post)
|
161
|
+
|
162
|
+
```ruby
|
163
|
+
request = [
|
164
|
+
{
|
165
|
+
"is_validate_vehicle": true,
|
166
|
+
"cargo_transport_unit_number": "ASVD123",
|
167
|
+
"country_code": "01",
|
168
|
+
"tracking_type": 1,
|
169
|
+
"is_cross_country_tracking": true
|
170
|
+
}
|
171
|
+
]
|
172
|
+
response = RailLocatorApi::Request.tracks.dislocation.create(body: request)
|
173
|
+
p response.body
|
174
|
+
```
|
175
|
+
|
176
|
+
### <a name="tracks_dislocation_batch_get"></a> [Получение Дислокации По Нескольким Трекам](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Dislokaciya/operation/__________________________________________tracks_dislocation_batch_get)
|
177
|
+
|
178
|
+
```ruby
|
179
|
+
request = {
|
180
|
+
"track_ids": [
|
181
|
+
0
|
182
|
+
],
|
183
|
+
"operations_count": 10
|
184
|
+
}
|
185
|
+
response = RailLocatorApi::Request.tracks.dislocation.batch.retrieve(body: request)
|
186
|
+
p response.body
|
187
|
+
```
|
188
|
+
|
189
|
+
### <a name="tracks_dislocation_route_info_get"></a> [Получение Информации О Маршруте](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Dislokaciya/operation/________________________________tracks_dislocation_route_info_get)
|
190
|
+
|
191
|
+
```ruby
|
192
|
+
response = RailLocatorApi::Request.tracks.dislocation.route_info.retrieve(params: {track_id: 1})
|
193
|
+
p response.body
|
194
|
+
```
|
195
|
+
|
196
|
+
### <a name="tracks_dislocation__track_id__get"></a> [Получение Дислокации По Одному Треку](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Dislokaciya/operation/_____________________________________tracks_dislocation__track_id__get)
|
197
|
+
|
198
|
+
```ruby
|
199
|
+
track_id = 1
|
200
|
+
response = RailLocatorApi::Request.tracks.dislocation(track_id).retrieve
|
201
|
+
p response.body
|
202
|
+
```
|
203
|
+
|
204
|
+
## <a name="inquiries"></a> Справки
|
205
|
+
|
206
|
+
### <a name="tracks_inquiries_get"></a> [Получение Справок](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Spravki/operation/__________________tracks_inquiries_get)
|
207
|
+
```ruby
|
208
|
+
request = {
|
209
|
+
"limit": 100,
|
210
|
+
"offset": 0,
|
211
|
+
"filters": [
|
212
|
+
{
|
213
|
+
"field": "is_broken",
|
214
|
+
"operand": "in",
|
215
|
+
"value": [
|
216
|
+
null,
|
217
|
+
true
|
218
|
+
]
|
219
|
+
},
|
220
|
+
{
|
221
|
+
"field": "track_start",
|
222
|
+
"operand": ">=",
|
223
|
+
"value": "2010-10-10 00:00"
|
224
|
+
},
|
225
|
+
{
|
226
|
+
"field": "track_stop",
|
227
|
+
"operand": "between",
|
228
|
+
"value": [
|
229
|
+
"2010-10-10 00:00",
|
230
|
+
"2021-10-10 00:00"
|
231
|
+
]
|
232
|
+
}
|
233
|
+
],
|
234
|
+
"sort": [
|
235
|
+
{
|
236
|
+
"field": "is_active",
|
237
|
+
"order": "asc"
|
238
|
+
}
|
239
|
+
],
|
240
|
+
"fulltext_filter": {
|
241
|
+
"value": "2010",
|
242
|
+
"fields": [
|
243
|
+
"track_start",
|
244
|
+
"track_stop"
|
245
|
+
],
|
246
|
+
"operation": "include"
|
247
|
+
}
|
248
|
+
}
|
249
|
+
response = RailLocatorApi::Request.tracks.inquiries.retrieve(body: request)
|
250
|
+
p response.body
|
251
|
+
```
|
252
|
+
|
253
|
+
### <a name="tracks_inquiries_post"></a> [Постановка На Слежение](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Spravki/operation/_______________________tracks_inquiries_post)
|
254
|
+
```ruby
|
255
|
+
request = [
|
256
|
+
{
|
257
|
+
"inquiry_type": "2612",
|
258
|
+
"cargo_transport_unit_number": "12345678"
|
259
|
+
}
|
260
|
+
]
|
261
|
+
response = RailLocatorApi::Request.tracks.inquiries.create(body: request)
|
262
|
+
p response.body
|
263
|
+
```
|
264
|
+
|
265
|
+
### <a name="tracks_inquiries__track_id__get"></a> [Получение Справки](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Spravki/operation/__________________tracks_inquiries__track_id__get)
|
266
|
+
```ruby
|
267
|
+
track_id = 1
|
268
|
+
response = RailLocatorApi::Request.tracks.inquiries(track_id).retrieve
|
269
|
+
p response.body
|
270
|
+
```
|
271
|
+
|
272
|
+
## <a name="approaches"></a> Подходы
|
273
|
+
### <a name="tracks_approaches_post"></a> [Постановка На Слежение](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Podhody/operation/_______________________tracks_approaches_post)
|
274
|
+
```ruby
|
275
|
+
request = [
|
276
|
+
{
|
277
|
+
"cargo_transport_unit_type": 0,
|
278
|
+
"stop_tracking_condition": 0,
|
279
|
+
"cargo_transport_unit_load_state": 0,
|
280
|
+
"cargo_code": "string",
|
281
|
+
"tracking_type": 0,
|
282
|
+
"destination_station": "string",
|
283
|
+
"which_okpo_to_use": 0,
|
284
|
+
"cargo_sender_okpo": "string",
|
285
|
+
"cargo_receiver_okpo": "string"
|
286
|
+
}
|
287
|
+
]
|
288
|
+
response = RailLocatorApi::Request.tracks.approaches.create(body: request)
|
289
|
+
p response.body
|
290
|
+
```
|
291
|
+
|
292
|
+
## <a name="tech_passport"></a> Тех. паспорт вагона
|
293
|
+
### <a name="tracks_tech_passport_batch_get"></a> [Получение Тех. Паспортов](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Teh.-pasport-vagona/operation/_________________________tracks_tech_passport_batch_get)
|
294
|
+
```ruby
|
295
|
+
request = {
|
296
|
+
"track_ids": [
|
297
|
+
0
|
298
|
+
],
|
299
|
+
"count": 1
|
300
|
+
}
|
301
|
+
response = RailLocatorApi::Request.tracks.tech_passport.batch.retrieve(body: request)
|
302
|
+
p response.body
|
303
|
+
```
|
304
|
+
### <a name="tracks_tech_passport__track_id__get"></a> [Получение Тех. Паспорта](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Teh.-pasport-vagona/operation/_________________________tracks_tech_passport__track_id__get)
|
87
305
|
```ruby
|
88
306
|
track_id = 1
|
89
|
-
|
90
|
-
|
91
|
-
#КАК ЭТО ДОЛЖНО ВЫГЛЯДЕТЬ
|
92
|
-
RailLocatorApi::Request.tracks(track_id).retrieve.body
|
307
|
+
response = RailLocatorApi::Request.tracks.tech_passport(track_id).retrieve
|
308
|
+
p response.body
|
93
309
|
```
|
94
|
-
|
310
|
+
|
311
|
+
## <a name="tech_condition"></a> Контроль тех. состояния
|
312
|
+
### <a name="tracks_tech_condition_get"></a> [Получение Тех. Состояния](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Kontrol-teh.-sostoyaniya/operation/_________________________tracks_tech_condition_get)
|
95
313
|
```ruby
|
96
|
-
|
97
|
-
|
98
|
-
|
314
|
+
request = {
|
315
|
+
"limit": 100,
|
316
|
+
"offset": 0,
|
317
|
+
"filters": [
|
318
|
+
{
|
319
|
+
"field": "is_broken",
|
320
|
+
"operand": "in",
|
321
|
+
"value": [
|
322
|
+
null,
|
323
|
+
true
|
324
|
+
]
|
325
|
+
},
|
326
|
+
{
|
327
|
+
"field": "track_start",
|
328
|
+
"operand": ">=",
|
329
|
+
"value": "2010-10-10 00:00"
|
330
|
+
},
|
331
|
+
{
|
332
|
+
"field": "track_stop",
|
333
|
+
"operand": "between",
|
334
|
+
"value": [
|
335
|
+
"2010-10-10 00:00",
|
336
|
+
"2021-10-10 00:00"
|
337
|
+
]
|
338
|
+
}
|
339
|
+
],
|
340
|
+
"sort": [
|
341
|
+
{
|
342
|
+
"field": "active",
|
343
|
+
"order": "asc"
|
344
|
+
}
|
345
|
+
],
|
346
|
+
"fulltext_filter": {
|
347
|
+
"value": "2010",
|
348
|
+
"fields": [
|
349
|
+
"track_start",
|
350
|
+
"track_stop"
|
351
|
+
],
|
352
|
+
"operation": "include"
|
353
|
+
}
|
99
354
|
}
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
```ruby
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
tracking_type: 0,
|
112
|
-
country_code: "RU",
|
113
|
-
is_cross_country_tracking: true
|
114
|
-
}
|
355
|
+
response = RailLocatorApi::Request.tracks.tech_condition.retrieve(body: request)
|
356
|
+
p response.body
|
357
|
+
```
|
358
|
+
|
359
|
+
### <a name="tracks_tech_condition_post"></a> [Постановка На Слежение](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Kontrol-teh.-sostoyaniya/operation/_______________________tracks_tech_condition_post)
|
360
|
+
|
361
|
+
```ruby
|
362
|
+
request = [
|
363
|
+
{
|
364
|
+
"cargo_transport_unit_number": "12345678"
|
365
|
+
}
|
115
366
|
]
|
116
|
-
RailLocatorApi::Request.tracks.create(body:
|
367
|
+
response = RailLocatorApi::Request.tracks.tech_condition.create(body: request)
|
368
|
+
p response.body
|
117
369
|
```
|
118
|
-
|
370
|
+
|
371
|
+
## <a name="update_delete_tracks"></a> Изменение/Снятие треков
|
372
|
+
### <a name="tracks_batch_delete"></a> [Снятие Со Слежения Нескольких Треков](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/IzmenenieSnyatie-trekov/operation/_____________________________________tracks_batch_delete)
|
119
373
|
```ruby
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
374
|
+
request = {
|
375
|
+
"track_ids": [
|
376
|
+
123,
|
377
|
+
1234
|
378
|
+
]
|
125
379
|
}
|
126
|
-
RailLocatorApi::Request.tracks.delete(body:
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
380
|
+
response = RailLocatorApi::Request.tracks.batch.delete(body: request)
|
381
|
+
p response.body
|
382
|
+
```
|
383
|
+
|
384
|
+
### <a name="tracks_batch_patch"></a> [Изменение Информации О Нескольких Треках](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/IzmenenieSnyatie-trekov/operation/_________________________________________tracks_batch_patch)
|
385
|
+
```ruby
|
386
|
+
request = [
|
387
|
+
{
|
388
|
+
"track_id": 123456,
|
389
|
+
"comment": "Примечание трека"
|
390
|
+
}
|
391
|
+
]
|
392
|
+
response = RailLocatorApi::Request.tracks.batch.update(body: request)
|
393
|
+
p response.body
|
394
|
+
```
|
395
|
+
|
396
|
+
### <a name="tracks__track_id__delete"></a> [Снятие Со Слежения Одного Трека](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/IzmenenieSnyatie-trekov/operation/________________________________tracks__track_id__delete)
|
397
|
+
```ruby
|
398
|
+
track_id = 1
|
399
|
+
response = RailLocatorApi::Request.tracks(track_id).delete
|
400
|
+
p response.body
|
401
|
+
```
|
402
|
+
|
403
|
+
### <a name="tracks__track_id__patch"></a> [Изменение Информации О Треке](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/IzmenenieSnyatie-trekov/operation/_____________________________tracks__track_id__patch)
|
404
|
+
```ruby
|
405
|
+
track_id = 1
|
406
|
+
request = {
|
407
|
+
"comment": "Примечание трека"
|
140
408
|
}
|
141
|
-
RailLocatorApi::Request.tracks.
|
409
|
+
response = RailLocatorApi::Request.tracks(track_id).update(body: request)
|
410
|
+
p response.body
|
411
|
+
```
|
142
412
|
|
143
|
-
|
144
|
-
|
145
|
-
|
413
|
+
## <a name="groups"></a> Группы
|
414
|
+
### <a name="groups_get"></a> [Получение Списка Групп](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Gruppy/operation/_______________________groups_get)
|
415
|
+
```ruby
|
416
|
+
response = RailLocatorApi::Request.groups.retrieve
|
417
|
+
p response.body
|
418
|
+
```
|
419
|
+
### <a name="groups_post"></a> [Создание Группы](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Gruppy/operation/________________groups_post)
|
420
|
+
```ruby
|
421
|
+
request = {
|
422
|
+
"group_name": "Название новой группы"
|
423
|
+
}
|
424
|
+
response = RailLocatorApi::Request.groups.create(body: request)
|
425
|
+
p response.body
|
426
|
+
```
|
427
|
+
### <a name="groups__group_id__delete"></a> [Удаление Группы](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Gruppy/operation/________________groups__group_id__delete)
|
428
|
+
```ruby
|
429
|
+
group_id = 1
|
430
|
+
response = RailLocatorApi::Request.groups(group_id).delete
|
431
|
+
p response.body
|
432
|
+
```
|
433
|
+
### <a name="groups__group_id__patch"></a> [Изменение Группы](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Gruppy/operation/_________________groups__group_id__patch)
|
434
|
+
```ruby
|
435
|
+
group_id = 1
|
436
|
+
request = {
|
437
|
+
"group_name": "Переименованная группа"
|
438
|
+
}
|
439
|
+
response = RailLocatorApi::Request.groups(group_id).update(body: request)
|
440
|
+
p response.body
|
441
|
+
```
|
442
|
+
### <a name="groups__group_id__cargo_transport_unit_number_batch_put"></a> [Добавление Вагона В Группу](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Gruppy/operation/___________________________groups__group_id__cargo_transport_unit_number_batch_put)
|
443
|
+
```ruby
|
444
|
+
group_id = 1
|
445
|
+
request = {
|
446
|
+
"cargo_transport_unit_numbers": [
|
447
|
+
"ASD1234",
|
448
|
+
"F0123454D"
|
449
|
+
]
|
450
|
+
}
|
451
|
+
response = RailLocatorApi::Request.groups(group_id).cargo_transport_unit_number.batch.update(body: request)
|
452
|
+
p response.body
|
453
|
+
```
|
454
|
+
### <a name="groups__group_id__cargo_transport_unit_number_batch_delete"></a> [Удаление Вагонов Из Группы](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Gruppy/operation/___________________________groups__group_id__cargo_transport_unit_number_batch_delete)
|
455
|
+
```ruby
|
456
|
+
group_id = 1
|
457
|
+
request = {
|
458
|
+
"cargo_transport_unit_numbers": [
|
459
|
+
"ASD1234",
|
460
|
+
"F0123454D"
|
461
|
+
]
|
462
|
+
}
|
463
|
+
response = RailLocatorApi::Request.groups(group_id).cargo_transport_unit_number.batch.delete(body: request)
|
464
|
+
p response.body
|
465
|
+
```
|
466
|
+
### <a name="groups__group_id__cargo_transport_unit_number__cargo_transport_unit_number__put"></a> [Добавление Вагона В Группу](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Gruppy/operation/___________________________groups__group_id__cargo_transport_unit_number__cargo_transport_unit_number__put)
|
467
|
+
```ruby
|
468
|
+
group_id = 1
|
469
|
+
cargo_transport_unit_number = "11111"
|
470
|
+
response = RailLocatorApi::Request.groups(group_id).cargo_transport_unit_number(cargo_transport_unit_number).update
|
471
|
+
p response.body
|
472
|
+
```
|
473
|
+
### <a name="groups__group_id__cargo_transport_unit_number__cargo_transport_unit_number__delete"></a> [Удаление Вагона Из Группы](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Gruppy/operation/__________________________groups__group_id__cargo_transport_unit_number__cargo_transport_unit_number__delete)
|
474
|
+
```ruby
|
475
|
+
group_id = 1
|
476
|
+
cargo_transport_unit_number = "11111"
|
477
|
+
response = RailLocatorApi::Request.groups(group_id).cargo_transport_unit_number(cargo_transport_unit_number).delete
|
478
|
+
p response.body
|
479
|
+
```
|
480
|
+
|
481
|
+
## <a name="references"></a> Справочники
|
482
|
+
### <a name="references_station_get"></a> [Получение Координат Станции](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Spravochniki/operation/____________________________references_station_get)
|
483
|
+
```ruby
|
484
|
+
response = RailLocatorApi::Request.references.station.retrieve(params: {disloc_id: 1})
|
485
|
+
p response.body
|
486
|
+
```
|
487
|
+
|
488
|
+
### <a name="references_stations_get"></a> [Получение Списка Станций С Краткой Информацией](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Spravochniki/operation/_______________________________________________references_stations_get)
|
489
|
+
```ruby
|
490
|
+
response = RailLocatorApi::Request.references.stations.retrieve(params: {station_code: "111"})
|
491
|
+
p response.body
|
146
492
|
```
|
@@ -128,6 +128,10 @@ module RailLocatorApi
|
|
128
128
|
request.headers['Authorization'] = "Bearer #{RailLocatorApi::Request.access_token}"
|
129
129
|
end
|
130
130
|
request.headers['User-Agent'] = "RailLocatorApi/#{RailLocatorApi::VERSION} Ruby gem"
|
131
|
+
if @request_builder.without_ratelimit
|
132
|
+
request.headers['X-Request-Without-Ratelimit'] = "1"
|
133
|
+
end
|
134
|
+
|
131
135
|
request.headers.merge!(headers) if headers
|
132
136
|
request.body = MultiJson.dump(body) if body
|
133
137
|
request.options.timeout = self.timeout
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module RailLocatorApi
|
2
2
|
class Request
|
3
3
|
attr_accessor :access_token, :refresh_token, :api_key, :api_user_email, :api_user_password, :api_auth_method, :api_endpoint,
|
4
|
-
:timeout, :open_timeout, :proxy, :ssl_options, :faraday_adapter, :symbolize_keys, :debug,
|
4
|
+
:timeout, :open_timeout, :proxy, :ssl_options, :faraday_adapter, :symbolize_keys, :debug,
|
5
|
+
:without_ratelimit, :logger, :test
|
5
6
|
|
6
7
|
AUTH_METHODS = [:keycloak, :api_key, :base64]
|
7
8
|
DEFAULT_AUTH_METHOD = :keycloak
|
@@ -10,12 +11,12 @@ module RailLocatorApi
|
|
10
11
|
|
11
12
|
def initialize(access_token: nil, refresh_token: nil, api_key: nil, api_user_email: nil, api_user_password: nil,
|
12
13
|
api_endpoint: nil, api_auth_method: nil, timeout: nil, open_timeout: nil, proxy: nil, ssl_options: nil,
|
13
|
-
faraday_adapter: nil, symbolize_keys: false, debug: false,
|
14
|
+
faraday_adapter: nil, symbolize_keys: false, debug: false, without_ratelimit: false,
|
15
|
+
logger: nil, test: false)
|
14
16
|
|
15
17
|
@path_parts = []
|
16
18
|
@api_key = api_key || self.class.api_key || ENV['RAIL_LOCATOR_API_KEY']
|
17
19
|
@api_key = @api_key.strip if @api_key
|
18
|
-
@api_key = RailLocatorApi::api_key if @api_key.nil?
|
19
20
|
|
20
21
|
@access_token = access_token || self.class.access_token || RailLocatorApi.generate_access_token.try(:dig, "access_token")
|
21
22
|
@access_token = @access_token.strip if @access_token
|
@@ -35,6 +36,7 @@ module RailLocatorApi
|
|
35
36
|
@faraday_adapter = faraday_adapter || self.class.faraday_adapter || Faraday.default_adapter
|
36
37
|
@symbolize_keys = symbolize_keys || self.class.symbolize_keys || false
|
37
38
|
@debug = debug || self.class.debug || false
|
39
|
+
@without_ratelimit = without_ratelimit || self.class.without_ratelimit
|
38
40
|
@test = test || self.class.test || false
|
39
41
|
@logger = logger || self.class.logger || ::Logger.new(STDOUT)
|
40
42
|
end
|
@@ -93,15 +95,17 @@ module RailLocatorApi
|
|
93
95
|
end
|
94
96
|
|
95
97
|
class << self
|
96
|
-
attr_accessor :access_token, :refresh_token, :api_key, :api_user_email, :api_user_password, :api_auth_method,
|
97
|
-
:
|
98
|
+
attr_accessor :access_token, :refresh_token, :api_key, :api_user_email, :api_user_password, :api_auth_method,
|
99
|
+
:timeout, :open_timeout, :api_endpoint, :proxy, :ssl_options, :faraday_adapter, :symbolize_keys,
|
100
|
+
:debug, :without_ratelimit, :logger, :test
|
98
101
|
|
99
102
|
def method_missing(sym, *args, &block)
|
100
103
|
new(access_token: self.access_token, refresh_token: self.refresh_token, api_key: self.api_key,
|
101
104
|
api_user_email: self.api_user_email, api_user_password: self.api_user_email,
|
102
105
|
api_auth_method: self.api_auth_method, api_endpoint: self.api_endpoint,
|
103
106
|
timeout: self.timeout, open_timeout: self.open_timeout, faraday_adapter: self.faraday_adapter,
|
104
|
-
symbolize_keys: self.symbolize_keys, debug: self.debug,
|
107
|
+
symbolize_keys: self.symbolize_keys, debug: self.debug, without_ratelimit: self.without_ratelimit,
|
108
|
+
proxy: self.proxy, ssl_options: self.ssl_options, logger: self.logger,
|
105
109
|
test: self.test).send(sym, *args, &block)
|
106
110
|
end
|
107
111
|
|