retentiongrid 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/retentiongrid/api.rb +10 -6
- data/lib/retentiongrid/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d14ccffa70898ca564247f1dc473f7d0700656df
|
|
4
|
+
data.tar.gz: 863ca026f21076dbfdc2160e2013a59368069111
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a227260d2f69698102936877599a643e3353a3c2e8463ea1ffa66a4c33fad96592f7488089e44a7cb6828f1abe83c352b3df50267977edd794035e386671f2f1
|
|
7
|
+
data.tar.gz: ae9218373d08d1e344b8896b29e973d252e3540770b7d4368bb7d825c1bf56e88b4952bfc89fb50128a347d6a409a36d9da6d340ef0654f591560b84862922c4
|
data/lib/retentiongrid/api.rb
CHANGED
|
@@ -11,8 +11,12 @@ module Retentiongrid
|
|
|
11
11
|
class Api
|
|
12
12
|
include HTTParty
|
|
13
13
|
|
|
14
|
+
# Test
|
|
15
|
+
# base_uri 'http://retentiongrid.apiary-mock.com'
|
|
16
|
+
|
|
17
|
+
# Production
|
|
14
18
|
base_uri 'https://app.retentiongrid.com/api'
|
|
15
|
-
headers '
|
|
19
|
+
headers 'Content-type' => 'application/json'
|
|
16
20
|
logger ::Logger.new("log/httparty.log"), :debug, :curl
|
|
17
21
|
|
|
18
22
|
|
|
@@ -22,13 +26,13 @@ module Retentiongrid
|
|
|
22
26
|
default_params token: api_key
|
|
23
27
|
end
|
|
24
28
|
|
|
25
|
-
def get_with_response_check(
|
|
26
|
-
check_response_codes(
|
|
29
|
+
def get_with_response_check(*args)
|
|
30
|
+
check_response_codes(*args))
|
|
27
31
|
end
|
|
28
32
|
alias_method_chain :get, :response_check
|
|
29
33
|
|
|
30
|
-
def post_with_response_check(
|
|
31
|
-
check_response_codes(post_without_response_check(
|
|
34
|
+
def post_with_response_check(*args)
|
|
35
|
+
check_response_codes(post_without_response_check(*args))
|
|
32
36
|
end
|
|
33
37
|
alias_method_chain :post, :response_check
|
|
34
38
|
|
|
@@ -39,7 +43,7 @@ module Retentiongrid
|
|
|
39
43
|
def self.check_response_codes(response)
|
|
40
44
|
body = response.body
|
|
41
45
|
case response.code.to_i
|
|
42
|
-
when 200 then return response
|
|
46
|
+
when 200..299 then return response
|
|
43
47
|
when 400 then raise BadRequest.new(body)
|
|
44
48
|
when 401 then raise Unauthorized.new(body)
|
|
45
49
|
when 403 then raise Forbidden.new(body)
|