ozon-logistics 0.0.7 → 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 +9 -9
- 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,7 +13,7 @@ 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
|
|
16
|
+
rescue StandardError => e
|
|
17
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)
|
|
@@ -32,8 +32,8 @@ module OzonLogistics
|
|
|
32
32
|
configure_request(request: request, params: params, headers: headers, body: MultiJson.dump(body))
|
|
33
33
|
end
|
|
34
34
|
parse_response(response)
|
|
35
|
-
rescue => e
|
|
36
|
-
if e.response.dig(:status)== 401 && first_time
|
|
35
|
+
rescue StandardError => e
|
|
36
|
+
if e.response.dig(:status) == 401 && first_time
|
|
37
37
|
OzonLogistics::Request.access_token = OzonLogistics.generate_access_token.try(:dig, "access_token")
|
|
38
38
|
self.patch(params: params, headers: headers, body: body, first_time: false)
|
|
39
39
|
else
|
|
@@ -50,7 +50,7 @@ module OzonLogistics
|
|
|
50
50
|
configure_request(request: request, params: params, headers: headers, body: MultiJson.dump(body))
|
|
51
51
|
end
|
|
52
52
|
parse_response(response)
|
|
53
|
-
rescue => e
|
|
53
|
+
rescue StandardError => e
|
|
54
54
|
if e.response.dig(:status) == 401 && first_time
|
|
55
55
|
OzonLogistics::Request.access_token = OzonLogistics.generate_access_token.try(:dig, "access_token")
|
|
56
56
|
self.put(params: params, headers: headers, body: body, first_time: false)
|
|
@@ -68,7 +68,7 @@ module OzonLogistics
|
|
|
68
68
|
configure_request(request: request, params: params, headers: headers)
|
|
69
69
|
end
|
|
70
70
|
parse_response(response)
|
|
71
|
-
rescue => e
|
|
71
|
+
rescue StandardError => e
|
|
72
72
|
if e.response.dig(:status) == 401 && first_time
|
|
73
73
|
OzonLogistics::Request.access_token = OzonLogistics.generate_access_token.try(:dig, "access_token")
|
|
74
74
|
self.get(params: params, headers: headers, first_time: false)
|
|
@@ -86,7 +86,7 @@ module OzonLogistics
|
|
|
86
86
|
configure_request(request: request, params: params, headers: headers)
|
|
87
87
|
end
|
|
88
88
|
parse_response(response)
|
|
89
|
-
rescue => e
|
|
89
|
+
rescue StandardError => e
|
|
90
90
|
if e.response.dig(:status) == 401 && first_time
|
|
91
91
|
OzonLogistics::Request.access_token = OzonLogistics.generate_access_token.try(:dig, "access_token")
|
|
92
92
|
self.delete(params: params, headers: headers, first_time: false)
|
|
@@ -163,7 +163,8 @@ module OzonLogistics
|
|
|
163
163
|
if request
|
|
164
164
|
request.params.merge!(params) if params
|
|
165
165
|
request.headers['Content-Type'] = 'application/json'
|
|
166
|
-
request.headers['Authorization'] = "Bearer #{
|
|
166
|
+
request.headers['Authorization'] = "Bearer #{OzonLogistics::Request.access_token}"
|
|
167
|
+
request.headers['User-Agent'] = "OzonLogistics/#{OzonLogistics::VERSION} Ruby gem"
|
|
167
168
|
request.headers.merge!(headers) if headers
|
|
168
169
|
request.body = body if body
|
|
169
170
|
request.options.timeout = self.timeout
|
|
@@ -201,8 +202,7 @@ module OzonLogistics
|
|
|
201
202
|
end
|
|
202
203
|
|
|
203
204
|
def validate_access_token
|
|
204
|
-
|
|
205
|
-
unless access_token && (access_token["-"] || self.api_endpoint)
|
|
205
|
+
unless self.access_token
|
|
206
206
|
raise OzonLogistics::OzonLogisticsError, "You must set an access_token prior to making a call"
|
|
207
207
|
end
|
|
208
208
|
end
|
data/lib/ozon-logistics.rb
CHANGED