me_api 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/me_api/client.rb +10 -3
- data/lib/me_api/version.rb +1 -1
- 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: e746281011a0287a4789c9e84156710883e3d9a2c8959b4b66efd0b4d0b0c26c
|
4
|
+
data.tar.gz: b6601ef3f21c03db8b4b21856715a640fd3b0253024c6bb70738c55a0e2dbf09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b632c7dc5e2b54c0a9b06fbeb6385d65989bc33c72bd0bbbe5037e82c9522cb3c9e957a17735e0c5d024606a8dff0558b3bd91cde8c4e416beb45a7ac2a2ed95
|
7
|
+
data.tar.gz: 3c0ad7affbf4bfdbd032607687df954b94f8059cc44cb97bc0488e86baf37fc19e1ac3a881821b9305c3cc88f239fb3610610510a6106a02e14c029ff74af504
|
data/lib/me_api/client.rb
CHANGED
@@ -33,7 +33,7 @@ module MeApi
|
|
33
33
|
},
|
34
34
|
"services" => "1,2,3,4,17,33"
|
35
35
|
}
|
36
|
-
response = post
|
36
|
+
response = post("api/v2/me/shipment/calculate", body: JSON.dump(body)) { |response| validate_response(response, [0, "id"]) }
|
37
37
|
response.json.map do |rate|
|
38
38
|
Rate.new(
|
39
39
|
id: rate["id"],
|
@@ -56,7 +56,7 @@ module MeApi
|
|
56
56
|
client_secret: client_secret,
|
57
57
|
refresh_token: refresh_token
|
58
58
|
}
|
59
|
-
post
|
59
|
+
post("/oauth/token", body: JSON.dump(body), headers: {"Content-Type": "application/json"}) { |response| validate_response(response, "access_token") }
|
60
60
|
end
|
61
61
|
|
62
62
|
def authorize client_id:, client_secret:, code:, redirect_url:
|
@@ -67,7 +67,14 @@ module MeApi
|
|
67
67
|
code: code,
|
68
68
|
redirect_uri: redirect_url
|
69
69
|
}
|
70
|
-
post
|
70
|
+
post("/oauth/token", body: JSON.dump(body), headers: {"Content-Type": "application/json"}) { |response| validate_response(response, "access_token") }
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def validate_response(response, required_response_key)
|
76
|
+
puts response.json unless response.success?
|
77
|
+
![500, 429].include?(response.code) || response.json.dig(*required_response_key)
|
71
78
|
end
|
72
79
|
end
|
73
80
|
end
|
data/lib/me_api/version.rb
CHANGED