ozon-logistics 0.0.6 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- 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 +13 -13
- data/lib/ozon-logistics/request.rb +1 -1
- data/lib/ozon-logistics/version.rb +1 -1
- data/lib/ozon-logistics.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da443e41a0808bb891ccb8a1a8597378f323c07d62ee8761cc27702ec8c9c90a
|
4
|
+
data.tar.gz: 71c6cac8d72571c314b65851b078c244eb42dfb980eed30fc97b2b3d37c91c54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8628a1dbd033f9b79e879741d15b24d2cc93b174f05667cf173edaf19ef6c5c815843ab49c4d8148da7e9b30bb6b71501f10acf1726e17d5714e3d4dce7f33f3
|
7
|
+
data.tar.gz: b07dfd2e924d0e5cb60b5b0ab4e3c32b9b7e1738a88c4ea26fbb89d3394fa0ac63f9b254fe56f68877c19e640f0b9e56c1b98321f1893d3c0adc5b55a4f9df08
|
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,8 +13,8 @@ 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.try(:
|
16
|
+
rescue StandardError => e
|
17
|
+
if e.response.try(: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
20
|
else
|
@@ -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.
|
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,8 +50,8 @@ 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
|
54
|
-
if e.response.
|
53
|
+
rescue StandardError => e
|
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)
|
57
57
|
else
|
@@ -68,8 +68,8 @@ module OzonLogistics
|
|
68
68
|
configure_request(request: request, params: params, headers: headers)
|
69
69
|
end
|
70
70
|
parse_response(response)
|
71
|
-
rescue => e
|
72
|
-
if e.response.
|
71
|
+
rescue StandardError => e
|
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)
|
75
75
|
else
|
@@ -86,8 +86,8 @@ module OzonLogistics
|
|
86
86
|
configure_request(request: request, params: params, headers: headers)
|
87
87
|
end
|
88
88
|
parse_response(response)
|
89
|
-
rescue => e
|
90
|
-
if e.response.
|
89
|
+
rescue StandardError => e
|
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)
|
93
93
|
else
|
@@ -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
@@ -1,8 +1,10 @@
|
|
1
|
+
require 'faraday'
|
1
2
|
require 'ozon-logistics/ozon_logistics_error'
|
2
3
|
require 'ozon-logistics/ozon_error'
|
3
4
|
require 'ozon-logistics/request'
|
4
5
|
require 'ozon-logistics/api_request'
|
5
6
|
require 'ozon-logistics/response'
|
7
|
+
require 'ozon-logistics/version'
|
6
8
|
|
7
9
|
module OzonLogistics
|
8
10
|
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
|
+
version: 0.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Osetrov
|
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
|
-
rubygems_version: 3.
|
79
|
+
rubygems_version: 3.2.32
|
80
80
|
signing_key:
|
81
81
|
specification_version: 4
|
82
82
|
summary: Ozon logistics
|