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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 435947ecbb9b47558a5610a41123d5b075a2120d6b68bf869ab3b53117685def
4
- data.tar.gz: fc432a84ae37d456622f62e9e7095834ad07a1fb7719a9ea16b62365cf99d076
3
+ metadata.gz: da443e41a0808bb891ccb8a1a8597378f323c07d62ee8761cc27702ec8c9c90a
4
+ data.tar.gz: 71c6cac8d72571c314b65851b078c244eb42dfb980eed30fc97b2b3d37c91c54
5
5
  SHA512:
6
- metadata.gz: 64f7a27b9ab6e5ecccbb9c3047b01d95ddaf2896a75898f19dc08b602cf46b92f22b54c2c33519eca364ea2b8ac298dc6aad1f6735a39dd82ed295ebb68f2ed7
7
- data.tar.gz: 6935d1def31c667bc04d999e55c6811ed7fd3b00a5ca2c4cefddd4908455bd9cbf5c63d4bb7d6abf237d89952abc271a64a12b2e5af92a9e69b17bdffa0a0894
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://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,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(:code) == 401 && first_time
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.try(:code) == 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,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.try(:code) == 401 && first_time
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.try(:code) == 401 && first_time
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.try(:code) == 401 && first_time
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 #{self.access_token}"
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
- access_token = self.access_token
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
@@ -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.15"
3
3
  end
@@ -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.6
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.1.4
79
+ rubygems_version: 3.2.32
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: Ozon logistics