ozon-logistics 0.0.4 → 0.0.14

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: 7e04197096b5e5586b65a1a9fb4fa8fc31599975fc29b837c22bb66355d8ea30
4
- data.tar.gz: 6aedfbb7e1167f6d62368666ea01e8d29c34722e36a37fd4037b7d65db2332ff
3
+ metadata.gz: e4c4f351393367ec940e0f7abd55135de1587ec44a4b26c4145b8f30143db09f
4
+ data.tar.gz: dd723292b024d65d594b4140539427fbcf6a83575137b85778b74e3ceca5fd4c
5
5
  SHA512:
6
- metadata.gz: 3ff95569e63c572e1c7fccd15b96009785498fb5eb7a4d2a1904f677f5521c0846c5f1b9d6116e9696b7a169e5fcf569392f3a4439f805c32f82a59f68e6a380
7
- data.tar.gz: 1029a14114a1e6689da6bd7cb1671070d966b2223303144f5050c5847cddb2d97e03ab417bcc5c699e8c47743e648e2b5cb7f7fddc21e4ca63e1f0129fc77093
6
+ metadata.gz: 5aef5ad14830fdaae7d65ea352b57c4244897dd51e09df1a8cd3d88f196dc6ae1cf8316a0742eec31a546c020826a4b25190ae9f4cce1eba586607455368b9d1
7
+ data.tar.gz: c82628cf9568ee9354b2bead904aad23737a6776b16f8ae8782710b14a863ff7cdcc31213e0f696c70e05cfee49c12bfdc5bbe469d351788ddb58dc0cd833af6
data/README.markdown CHANGED
@@ -160,6 +160,10 @@ amount = response.body[:amount]
160
160
  ```ruby
161
161
  body = {
162
162
  orderNumber: '1',
163
+ firstMileTransfer: {
164
+ type: 'DropOff',
165
+ fromPlaceId: OzonLogistics.from_places.to_s
166
+ },
163
167
  buyer: {
164
168
  name: 'Павел',
165
169
  phone: '+71234567890',
@@ -203,6 +207,19 @@ body = {
203
207
  response = OzonLogistics::Request.order.create(body: body)
204
208
  order = response[:data]
205
209
  ```
210
+
211
+ ### Shipment
212
+ #### Метод создания заявки на отгрузку на складе OZON
213
+ ```ruby
214
+ body = {
215
+ orderIds: [
216
+ order_id
217
+ ]
218
+ }
219
+ response = OzonLogistics::Request.shipmentRequest.create(body: body)
220
+ result = response.body
221
+ ```
222
+
206
223
  ### Tariff
207
224
  #### Получение списка тарифов
208
225
  ```ruby
@@ -2,12 +2,12 @@ defaults: &defaults
2
2
  GRANT_TYPE: 'client_credentials'
3
3
  CLIENT_ID: 'ApiTest_11111111-1111-1111-1111-111111111111'
4
4
  CLIENT_SECRET: 'SRYksX3PBPUYj73A6cNqbQYRSaYNpjSodIMeWoSCQ8U='
5
- URL_TOKEN: 'https://api-stg.ozonru.me/principal-auth-api/connect/token'
6
- HOST: 'https://api-stg.ozonru.me/principal-integration-api'
5
+ URL_TOKEN: 'https://xapi.ozon.ru/principal-auth-api/connect/token'
6
+ HOST: 'https://xapi.ozon.ru/principal-integration-api'
7
7
  production:
8
8
  <<: *defaults
9
- URL_TOKEN: 'https://api.ozon.ru/principal-auth-api/connect/token'
10
- HOST: 'https://api.ozon.ru/principal-integration-api'
9
+ URL_TOKEN: 'https://xapi.ozon.ru/principal-auth-api/connect/token'
10
+ HOST: 'https://xapi.ozon.ru/principal-integration-api'
11
11
  CLIENT_ID: ''
12
12
  CLIENT_SECRET: ''
13
13
  development:
@@ -13,12 +13,13 @@ module OzonLogistics
13
13
  configure_request(request: request, params: params, headers: headers, body: MultiJson.dump(body))
14
14
  end
15
15
  parse_response(response)
16
- rescue => e
17
- if e.response[:status] == 401 && first_time
16
+ rescue StandardError => e
17
+ if e.response.dig(:status) == 401 && first_time
18
18
  OzonLogistics::Request.access_token = OzonLogistics.generate_access_token.try(:dig, "access_token")
19
19
  self.post(params: params, headers: headers, body: body, first_time: false)
20
+ else
21
+ handle_error(e)
20
22
  end
21
- handle_error(e)
22
23
  end
23
24
  end
24
25
 
@@ -31,12 +32,13 @@ module OzonLogistics
31
32
  configure_request(request: request, params: params, headers: headers, body: MultiJson.dump(body))
32
33
  end
33
34
  parse_response(response)
34
- rescue => e
35
- if e.response[:status] == 401 && first_time
35
+ rescue StandardError => e
36
+ if e.response.dig(:status) == 401 && first_time
36
37
  OzonLogistics::Request.access_token = OzonLogistics.generate_access_token.try(:dig, "access_token")
37
38
  self.patch(params: params, headers: headers, body: body, first_time: false)
39
+ else
40
+ handle_error(e)
38
41
  end
39
- handle_error(e)
40
42
  end
41
43
  end
42
44
 
@@ -48,12 +50,13 @@ module OzonLogistics
48
50
  configure_request(request: request, params: params, headers: headers, body: MultiJson.dump(body))
49
51
  end
50
52
  parse_response(response)
51
- rescue => e
52
- if e.response[:status] == 401 && first_time
53
+ rescue StandardError => e
54
+ if e.response.dig(:status) == 401 && first_time
53
55
  OzonLogistics::Request.access_token = OzonLogistics.generate_access_token.try(:dig, "access_token")
54
56
  self.put(params: params, headers: headers, body: body, first_time: false)
57
+ else
58
+ handle_error(e)
55
59
  end
56
- handle_error(e)
57
60
  end
58
61
  end
59
62
 
@@ -65,12 +68,13 @@ module OzonLogistics
65
68
  configure_request(request: request, params: params, headers: headers)
66
69
  end
67
70
  parse_response(response)
68
- rescue => e
69
- if e.response[:status] == 401 && first_time
71
+ rescue StandardError => e
72
+ if e.response.dig(:status) == 401 && first_time
70
73
  OzonLogistics::Request.access_token = OzonLogistics.generate_access_token.try(:dig, "access_token")
71
74
  self.get(params: params, headers: headers, first_time: false)
75
+ else
76
+ handle_error(e)
72
77
  end
73
- handle_error(e)
74
78
  end
75
79
  end
76
80
 
@@ -82,12 +86,13 @@ module OzonLogistics
82
86
  configure_request(request: request, params: params, headers: headers)
83
87
  end
84
88
  parse_response(response)
85
- rescue => e
86
- if e.response[:status] == 401 && first_time
89
+ rescue StandardError => e
90
+ if e.response.dig(:status) == 401 && first_time
87
91
  OzonLogistics::Request.access_token = OzonLogistics.generate_access_token.try(:dig, "access_token")
88
92
  self.delete(params: params, headers: headers, first_time: false)
93
+ else
94
+ handle_error(e)
89
95
  end
90
- handle_error(e)
91
96
  end
92
97
  end
93
98
 
@@ -158,7 +163,8 @@ module OzonLogistics
158
163
  if request
159
164
  request.params.merge!(params) if params
160
165
  request.headers['Content-Type'] = 'application/json'
161
- request.headers['Authorization'] = "Bearer #{self.access_token}"
166
+ request.headers['Authorization'] = "Bearer #{OzonLogistics::Request.access_token}"
167
+ request.headers['User-Agent'] = "OzonLogistics/#{OzonLogistics::VERSION} Ruby gem"
162
168
  request.headers.merge!(headers) if headers
163
169
  request.body = body if body
164
170
  request.options.timeout = self.timeout
@@ -196,8 +202,7 @@ module OzonLogistics
196
202
  end
197
203
 
198
204
  def validate_access_token
199
- access_token = self.access_token
200
- unless access_token && (access_token["-"] || self.api_endpoint)
205
+ unless self.access_token
201
206
  raise OzonLogistics::OzonLogisticsError, "You must set an access_token prior to making a call"
202
207
  end
203
208
  end
@@ -21,7 +21,7 @@ module OzonLogistics
21
21
  end
22
22
 
23
23
  def method_missing(method, *args)
24
- @path_parts << method.to_s.downcase
24
+ @path_parts << method.to_s
25
25
  @path_parts << args if args.length > 0
26
26
  @path_parts.flatten!
27
27
  self
@@ -1,3 +1,3 @@
1
1
  module OzonLogistics
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.14"
3
3
  end
@@ -3,6 +3,7 @@ require 'ozon-logistics/ozon_error'
3
3
  require 'ozon-logistics/request'
4
4
  require 'ozon-logistics/api_request'
5
5
  require 'ozon-logistics/response'
6
+ require 'ozon-logistics/version'
6
7
 
7
8
  module OzonLogistics
8
9
  class << self
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ozon-logistics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Osetrov