ozon-logistics 0.0.4 → 0.0.14
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 +17 -0
- data/lib/generators/ozon_logistics/install/templates/ozon_logistics.yml +4 -4
- data/lib/ozon-logistics/api_request.rb +23 -18
- data/lib/ozon-logistics/request.rb +1 -1
- data/lib/ozon-logistics/version.rb +1 -1
- data/lib/ozon-logistics.rb +1 -0
- 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: e4c4f351393367ec940e0f7abd55135de1587ec44a4b26c4145b8f30143db09f
|
|
4
|
+
data.tar.gz: dd723292b024d65d594b4140539427fbcf6a83575137b85778b74e3ceca5fd4c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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://
|
|
6
|
-
HOST: 'https://
|
|
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://
|
|
10
|
-
HOST: 'https://
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 #{
|
|
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
|
-
|
|
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
|
data/lib/ozon-logistics.rb
CHANGED