easy_meli 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/easy_meli/api_client.rb +16 -22
- data/lib/easy_meli/version.rb +1 -1
- 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: bc240e7ae7a827cff6460162be1a9460f5e860676f3800a50d18ae3558f2976e
|
4
|
+
data.tar.gz: 714503d3e3886b1d491d1ea579d72f1d74e2408d476b9ada5ee6446f0efbb467
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7004c03b3ec4be44170bb4ea92c5ac2595ddd5d244a7e680a88e67d5bdc9eec0197ae7a7bd0970ac78d0912e42f04b9b44a65ee907e5333db479f569753853b2
|
7
|
+
data.tar.gz: 139f426a07c7782b73ea52959283b70e068f8565d9c5e646790cd7f3373b51eed3f3e179d418a72ddf746012c13f4ea735a133c023b59da4c6d8d24aed38ab91
|
data/CHANGELOG.md
CHANGED
data/lib/easy_meli/api_client.rb
CHANGED
@@ -6,14 +6,11 @@ class EasyMeli::ApiClient
|
|
6
6
|
API_ROOT_URL = 'https://api.mercadolibre.com'
|
7
7
|
|
8
8
|
ERROR_LIST = {
|
9
|
-
'
|
9
|
+
'Error validating grant' => EasyMeli::InvalidGrantError,
|
10
10
|
'forbidden' => EasyMeli::ForbiddenError,
|
11
11
|
'invalid_token' => EasyMeli::InvalidTokenError,
|
12
|
-
'Malformed access_token' => EasyMeli::MalformedTokenError
|
13
|
-
|
14
|
-
|
15
|
-
STATUS_ERRORS = {
|
16
|
-
429 => EasyMeli::TooManyRequestsError
|
12
|
+
'Malformed access_token' => EasyMeli::MalformedTokenError,
|
13
|
+
'too_many_requests' => EasyMeli::TooManyRequestsError
|
17
14
|
}
|
18
15
|
|
19
16
|
base_uri API_ROOT_URL
|
@@ -51,30 +48,27 @@ class EasyMeli::ApiClient
|
|
51
48
|
|
52
49
|
self.class.send(verb, path, params.merge(query)).tap do |response|
|
53
50
|
logger&.log response
|
54
|
-
|
55
|
-
check_status(response)
|
51
|
+
check_for_errors(response)
|
56
52
|
end
|
57
53
|
end
|
58
54
|
|
59
|
-
def
|
60
|
-
|
61
|
-
return if response_message.to_s.empty?
|
55
|
+
def check_for_errors(response)
|
56
|
+
return unless response.parsed_response.is_a? Hash
|
62
57
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
58
|
+
exception = error_class(response)
|
59
|
+
|
60
|
+
if exception
|
61
|
+
raise exception.new(response)
|
68
62
|
end
|
69
63
|
end
|
70
64
|
|
71
|
-
def
|
72
|
-
|
73
|
-
body['error'].to_s.empty? ? body['message'] : body['error']
|
65
|
+
def error_class(body)
|
66
|
+
ERROR_LIST.find { |key, _| error_message_from_body(body).include?(key) }&.last
|
74
67
|
end
|
75
68
|
|
76
|
-
def
|
77
|
-
|
78
|
-
|
69
|
+
def error_message_from_body(response)
|
70
|
+
return if response.body.nil?
|
71
|
+
|
72
|
+
response['message'].to_s.empty? ? response['error'] : response['message']
|
79
73
|
end
|
80
74
|
end
|
data/lib/easy_meli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_meli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Northam
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|