ozon-logistics 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ozon-logistics/api_request.rb +25 -5
- 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: 7e04197096b5e5586b65a1a9fb4fa8fc31599975fc29b837c22bb66355d8ea30
|
4
|
+
data.tar.gz: 6aedfbb7e1167f6d62368666ea01e8d29c34722e36a37fd4037b7d65db2332ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ff95569e63c572e1c7fccd15b96009785498fb5eb7a4d2a1904f677f5521c0846c5f1b9d6116e9696b7a169e5fcf569392f3a4439f805c32f82a59f68e6a380
|
7
|
+
data.tar.gz: 1029a14114a1e6689da6bd7cb1671070d966b2223303144f5050c5847cddb2d97e03ab417bcc5c699e8c47743e648e2b5cb7f7fddc21e4ca63e1f0129fc77093
|
@@ -5,7 +5,7 @@ module OzonLogistics
|
|
5
5
|
@request_builder = builder
|
6
6
|
end
|
7
7
|
|
8
|
-
def post(params: nil, headers: nil, body: {})
|
8
|
+
def post(params: nil, headers: nil, body: {}, first_time: true)
|
9
9
|
validate_access_token
|
10
10
|
|
11
11
|
begin
|
@@ -14,11 +14,15 @@ module OzonLogistics
|
|
14
14
|
end
|
15
15
|
parse_response(response)
|
16
16
|
rescue => e
|
17
|
+
if e.response[:status] == 401 && first_time
|
18
|
+
OzonLogistics::Request.access_token = OzonLogistics.generate_access_token.try(:dig, "access_token")
|
19
|
+
self.post(params: params, headers: headers, body: body, first_time: false)
|
20
|
+
end
|
17
21
|
handle_error(e)
|
18
22
|
end
|
19
23
|
end
|
20
24
|
|
21
|
-
def patch(params: nil, headers: nil, body: {})
|
25
|
+
def patch(params: nil, headers: nil, body: {}, first_time: true)
|
22
26
|
validate_access_token
|
23
27
|
|
24
28
|
begin
|
@@ -28,11 +32,15 @@ module OzonLogistics
|
|
28
32
|
end
|
29
33
|
parse_response(response)
|
30
34
|
rescue => e
|
35
|
+
if e.response[:status] == 401 && first_time
|
36
|
+
OzonLogistics::Request.access_token = OzonLogistics.generate_access_token.try(:dig, "access_token")
|
37
|
+
self.patch(params: params, headers: headers, body: body, first_time: false)
|
38
|
+
end
|
31
39
|
handle_error(e)
|
32
40
|
end
|
33
41
|
end
|
34
42
|
|
35
|
-
def put(params: nil, headers: nil, body: {})
|
43
|
+
def put(params: nil, headers: nil, body: {}, first_time: true)
|
36
44
|
validate_access_token
|
37
45
|
|
38
46
|
begin
|
@@ -41,11 +49,15 @@ module OzonLogistics
|
|
41
49
|
end
|
42
50
|
parse_response(response)
|
43
51
|
rescue => e
|
52
|
+
if e.response[:status] == 401 && first_time
|
53
|
+
OzonLogistics::Request.access_token = OzonLogistics.generate_access_token.try(:dig, "access_token")
|
54
|
+
self.put(params: params, headers: headers, body: body, first_time: false)
|
55
|
+
end
|
44
56
|
handle_error(e)
|
45
57
|
end
|
46
58
|
end
|
47
59
|
|
48
|
-
def get(params: nil, headers: nil)
|
60
|
+
def get(params: nil, headers: nil, first_time: true)
|
49
61
|
validate_access_token
|
50
62
|
|
51
63
|
begin
|
@@ -54,11 +66,15 @@ module OzonLogistics
|
|
54
66
|
end
|
55
67
|
parse_response(response)
|
56
68
|
rescue => e
|
69
|
+
if e.response[:status] == 401 && first_time
|
70
|
+
OzonLogistics::Request.access_token = OzonLogistics.generate_access_token.try(:dig, "access_token")
|
71
|
+
self.get(params: params, headers: headers, first_time: false)
|
72
|
+
end
|
57
73
|
handle_error(e)
|
58
74
|
end
|
59
75
|
end
|
60
76
|
|
61
|
-
def delete(params: nil, headers: nil)
|
77
|
+
def delete(params: nil, headers: nil, first_time: true)
|
62
78
|
validate_access_token
|
63
79
|
|
64
80
|
begin
|
@@ -67,6 +83,10 @@ module OzonLogistics
|
|
67
83
|
end
|
68
84
|
parse_response(response)
|
69
85
|
rescue => e
|
86
|
+
if e.response[:status] == 401 && first_time
|
87
|
+
OzonLogistics::Request.access_token = OzonLogistics.generate_access_token.try(:dig, "access_token")
|
88
|
+
self.delete(params: params, headers: headers, first_time: false)
|
89
|
+
end
|
70
90
|
handle_error(e)
|
71
91
|
end
|
72
92
|
end
|