rail-locator-api 0.1.1 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: edc4f957d48ba4a6a724fdc6eb30a4e98c3a870f238687df672343822e7d9e62
4
- data.tar.gz: 39793e92df61361bb59b53dc0f42eaa3e26f3af4a95ce55f76cef4989adca554
3
+ metadata.gz: da757da5a995acefce054caa13481192c75e90601232a8d91f60da72d76fbae9
4
+ data.tar.gz: 8873e45d2446b3b5704691c9fed01a38c9be37e9bfa320952840957d3c6188cd
5
5
  SHA512:
6
- metadata.gz: 59538f8648d35498520b19fdfe66d028a867f46bcfae08354cbdb3be8eae673c6375083d86228cdf21c7615e48dce38571aa97d09d493d4008432a99b8a9ddd8
7
- data.tar.gz: 919b0d37c8cb4cbcfd6f313520c5680aa928eede734052de8ea006adc24e8d9d64a0a7de011666cec9b6b694560c69b71c08774203ffa141986ccaefa1dd9d3e
6
+ metadata.gz: 2cccb68cee0ae41504f7f1e0c9fab054fd182eaebe43f86815c36c5f35b0b6f575ddccbaac0dfdff0bde1e35488bfe024edbdb7e010662352fca541fe4753da2
7
+ data.tar.gz: 99489e413ed24932c1fe7a82fac11a201abecf47474b7e8ccbad2c4a3290f7509b19c82cb6621cf640e35b5dfa776a9682740c706fad7706955057d15ed93f68
data/README.markdown CHANGED
@@ -43,9 +43,16 @@ API wrapper для RailLocator API v2
43
43
  8. [Справочники](#references)
44
44
  1. [Получение Координат Станции](#references_station_get)
45
45
  2. [Получение Списка Станций С Краткой Информацией](#references_stations_get)
46
+ 9. [Рассылки](#emailings)
47
+ 1. [Создание Рассылки](#emailings_post)
46
48
 
47
49
  # <a name="install"></a> Установка
48
50
 
51
+ Для авторизации по api key необходимо получить его [в личном кабинете локатора](https://rail-locator.com/app/api-keys)
52
+ либо использовать другие методы авторизации:
53
+
54
+ `:keycloak, :api_key, :base64`
55
+
49
56
  ## Ruby
50
57
  $ gem install rail-locator-api
51
58
  ## Rails
@@ -59,7 +66,6 @@ API wrapper для RailLocator API v2
59
66
 
60
67
  rails g rail_locator_api:install
61
68
 
62
-
63
69
  ## <a name="using_rails"></a> Использование Rails
64
70
 
65
71
  В файл `config/rail_locator_api.yml` вставьте ваши данные
@@ -69,19 +75,24 @@ API wrapper для RailLocator API v2
69
75
  Сначала создайте экземпляр объекта `RailLocatorApi::Request`:
70
76
 
71
77
  ```ruby
72
- locator = RailLocatorApi::Request.new(api_user_email: "email@ctm.ru", api_user_password: "12345678")
78
+ locator = RailLocatorApi::Request.new(api_key: "***")
79
+ # или
80
+ locator = RailLocatorApi::Request.new(api_auth_method: :base64, api_user_email: "email@ctm.ru", api_user_password: "12345678")
73
81
  ```
74
82
 
75
- Вы можете изменять `api_user_email`, `api_user_password`, `timeout`, `open_timeout`, `faraday_adapter`, `proxy`, `symbolize_keys`, `logger`, и `debug`:
83
+ Вы можете изменять `api_auth_method`, `api_key`, `api_user_email`, `api_user_password`, `timeout`, `open_timeout`, `faraday_adapter`, `proxy`, `symbolize_keys`, `logger`, и `debug`:
76
84
 
77
85
  ```ruby
78
- RailLocatorApi::Request.api_key = "your_api_key"
79
- RailLocatorApi::Request.api_user_email = "email@ctm.ru"
80
- RailLocatorApi::Request.api_user_password = "12345678"
81
86
  RailLocatorApi::Request.timeout = 15
82
87
  RailLocatorApi::Request.open_timeout = 15
83
88
  RailLocatorApi::Request.symbolize_keys = true
84
89
  RailLocatorApi::Request.debug = false
90
+
91
+ RailLocatorApi::Request.api_key = "your_api_key"
92
+ # или
93
+ RailLocatorApi::Request.api_auth_method = :base64
94
+ RailLocatorApi::Request.api_user_email = "email@ctm.ru"
95
+ RailLocatorApi::Request.api_user_password = "12345678"
85
96
  ```
86
97
 
87
98
  Либо в файле `config/initializers/rail_locator_api.rb` для Rails.
@@ -91,7 +102,7 @@ RailLocatorApi::Request.debug = false
91
102
  Измените `debug: true` чтобы включить логирование в STDOUT.
92
103
 
93
104
  ```ruby
94
- locator = RailLocatorApi::Request.new(api_key: "your_api_key", debug: true)
105
+ locator = RailLocatorApi::Request.new(api_key: "***", debug: true)
95
106
  ```
96
107
 
97
108
  ### <a name="custom_logger"></a> Custom logger
@@ -99,7 +110,7 @@ locator = RailLocatorApi::Request.new(api_key: "your_api_key", debug: true)
99
110
  `Logger.new` используется по умолчанию, но вы можете изменить на свой:
100
111
 
101
112
  ```ruby
102
- locator = RailLocatorApi::Request.new(api_user_email: "email@ctm.ru", api_user_password: "12345678", debug: true, logger: MyLogger.new)
113
+ locator = RailLocatorApi::Request.new(api_key: "***", debug: true, logger: MyLogger.new)
103
114
  ```
104
115
 
105
116
  Или:
@@ -182,14 +193,15 @@ request = {
182
193
  ],
183
194
  "operations_count": 10
184
195
  }
185
- response = RailLocatorApi::Request.tracks.dislocation.batch.retrieve(body: request)
196
+ response = RailLocatorApi::Request.tracks.dislocation.history.retrieve(body: request)
186
197
  p response.body
187
198
  ```
188
199
 
189
200
  ### <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
201
 
191
202
  ```ruby
192
- response = RailLocatorApi::Request.tracks.dislocation.route_info.retrieve(params: {track_id: 1})
203
+ track_id = 1
204
+ response = RailLocatorApi::Request.tracks.dislocation(track_id).route.retrieve
193
205
  p response.body
194
206
  ```
195
207
 
@@ -197,7 +209,7 @@ p response.body
197
209
 
198
210
  ```ruby
199
211
  track_id = 1
200
- response = RailLocatorApi::Request.tracks.dislocation(track_id).retrieve
212
+ response = RailLocatorApi::Request.tracks.dislocation(track_id).history.retrieve
201
213
  p response.body
202
214
  ```
203
215
 
@@ -298,13 +310,13 @@ request = {
298
310
  ],
299
311
  "count": 1
300
312
  }
301
- response = RailLocatorApi::Request.tracks.tech_passport.batch.retrieve(body: request)
313
+ response = RailLocatorApi::Request.tracks.dislocation.tech_passports.retrieve(body: request)
302
314
  p response.body
303
315
  ```
304
316
  ### <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)
305
317
  ```ruby
306
318
  track_id = 1
307
- response = RailLocatorApi::Request.tracks.tech_passport(track_id).retrieve
319
+ response = RailLocatorApi::Request.tracks.dislocation(track_id).tech_passports.retrieve
308
320
  p response.body
309
321
  ```
310
322
 
@@ -489,4 +501,40 @@ p response.body
489
501
  ```ruby
490
502
  response = RailLocatorApi::Request.references.stations.retrieve(params: {station_code: "111"})
491
503
  p response.body
492
- ```
504
+ ```
505
+ ## <a name="emailings"></a> Рассылки
506
+ ### <a name="emailings_post"></a> [Создание Рассылки](http://soap.ctm.ru:8112/api/v2.0/redoc#tag/Rassylki/operation/__________________emailings_post)
507
+
508
+ ```ruby
509
+ request = {
510
+ "title": "Название рассылки",
511
+ "data_source": "groups",
512
+ "data_ids": [
513
+ "1234",
514
+ "12345"
515
+ ],
516
+ "recipients": [
517
+ "example@mail.ru"
518
+ ],
519
+ "sending_days": [
520
+ "Sun",
521
+ "Mon",
522
+ "Tue",
523
+ "Wed",
524
+ "Thu",
525
+ "Fri",
526
+ "Sat"
527
+ ],
528
+ "sending_times": [
529
+ "08:00:00",
530
+ "17:00:00"
531
+ ],
532
+ "template_title": "Тема письма",
533
+ "template_content": "Текст письма",
534
+ "active_objects": true,
535
+ "language": "ru",
536
+ "user_note": "Примечание"
537
+ }
538
+ response = RailLocatorApi::Request.emailings.create(body: request)
539
+ p response.body
540
+ ```
@@ -1,8 +1,12 @@
1
1
  defaults: &defaults
2
- API_KEY: "***"
3
2
  API_ENDPOINT: "http://soap.ctm.ru:8112"
3
+
4
+ API_AUTH_METHOD: "api_key"
5
+ API_KEY: "***"
6
+
4
7
  API_USER_EMAIL: ""
5
8
  API_USER_PASSWORD: ""
9
+
6
10
  KEYCLOAK_TOKEN_URL: "https://iam.ctm.ru/auth/realms/ctm/protocol/openid-connect/token"
7
11
  KEYCLOAK_GRANT_TYPE: "password"
8
12
  KEYCLOAK_CLIENT_ID: "client_id"
@@ -127,6 +127,9 @@ module RailLocatorApi
127
127
  if [:api_key, :keycloak].include?(self.api_auth_method)
128
128
  request.headers['Authorization'] = "Bearer #{RailLocatorApi::Request.access_token}"
129
129
  end
130
+ if [:keycloak].include?(self.api_auth_method)
131
+ request.headers['X-API-KEY'] = "#{RailLocatorApi::Request.api_key}"
132
+ end
130
133
  request.headers['User-Agent'] = "RailLocatorApi/#{RailLocatorApi::VERSION} Ruby gem"
131
134
  if @request_builder.without_ratelimit
132
135
  request.headers['X-Request-Without-Ratelimit'] = "1"
@@ -5,7 +5,7 @@ module RailLocatorApi
5
5
  :without_ratelimit, :logger, :test
6
6
 
7
7
  AUTH_METHODS = [:keycloak, :api_key, :base64]
8
- DEFAULT_AUTH_METHOD = :keycloak
8
+ DEFAULT_AUTH_METHOD = :api_key
9
9
  DEFAULT_TIMEOUT = 60
10
10
  DEFAULT_OPEN_TIMEOUT = 60
11
11
 
@@ -1,3 +1,3 @@
1
1
  module RailLocatorApi
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rail-locator-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Osetrov