unfor_base_api 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/unfor_base_api.rb +10 -6
- 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: 31e95a3550011bad45552f23bae6e3e2a1ecebb4
|
4
|
+
data.tar.gz: 9ae5c94097cacf519729ad91efc9ad93fb728c00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0aa10abd265c413f387989b6bba19112963f0ceb0e211df2298d20eb76e5d9d76577382870d524b72fad241f36ff761ea3a3b3f7f15aa4d8d381db463843741
|
7
|
+
data.tar.gz: 9fc69ff3dae8fab46853cf4b421502a610eb1a496ea407cb9fef6323c5839f1c7deabd0036d15084e8022ac6032afdfa9f5e3ffed83e6430ad2e46f35a2e5ae8
|
data/CHANGELOG.md
CHANGED
data/lib/unfor_base_api.rb
CHANGED
@@ -8,6 +8,10 @@ class UnforBaseApi
|
|
8
8
|
def initialize(args={})
|
9
9
|
@endpoint = args[:endpoint]
|
10
10
|
@access_token = args[:access_token]
|
11
|
+
|
12
|
+
if @endpoint.blank?
|
13
|
+
raise 'endpoint is required!'
|
14
|
+
end
|
11
15
|
end
|
12
16
|
|
13
17
|
def last_response
|
@@ -23,7 +27,7 @@ class UnforBaseApi
|
|
23
27
|
def get_request(action, params={}, headers={})
|
24
28
|
begin
|
25
29
|
headers.merge!({ authorization: "Token token=\"#{@access_token}\"" })
|
26
|
-
response = RestClient.get("#{@
|
30
|
+
response = RestClient.get("#{@endpoint}#{action}", {params: params}.merge(headers))
|
27
31
|
parse_response(get_response_kind(headers), response)
|
28
32
|
rescue => e
|
29
33
|
parse_response('object', e.response)
|
@@ -33,7 +37,7 @@ class UnforBaseApi
|
|
33
37
|
def post_request(action, params={}, headers={})
|
34
38
|
begin
|
35
39
|
headers.merge!({ authorization: "Token token=\"#{@access_token}\"" })
|
36
|
-
response = RestClient.post("#{@
|
40
|
+
response = RestClient.post("#{@endpoint}#{action}", params, headers)
|
37
41
|
parse_response(get_response_kind(headers), response)
|
38
42
|
rescue => e
|
39
43
|
parse_response('object', e.response)
|
@@ -43,7 +47,7 @@ class UnforBaseApi
|
|
43
47
|
def put_request(action, params={}, headers={})
|
44
48
|
begin
|
45
49
|
headers.merge!({ authorization: "Token token=\"#{@access_token}\"" })
|
46
|
-
response = RestClient.put("#{@
|
50
|
+
response = RestClient.put("#{@endpoint}#{action}", params, headers)
|
47
51
|
parse_response(get_response_kind(headers), response)
|
48
52
|
rescue => e
|
49
53
|
parse_response('object', e.response)
|
@@ -53,7 +57,7 @@ class UnforBaseApi
|
|
53
57
|
def patch_request(action, params={}, headers={})
|
54
58
|
begin
|
55
59
|
headers.merge!({ authorization: "Token token=\"#{@access_token}\"" })
|
56
|
-
response = RestClient.patch("#{@
|
60
|
+
response = RestClient.patch("#{@endpoint}#{action}", params, headers)
|
57
61
|
parse_response(get_response_kind(headers), response)
|
58
62
|
rescue => e
|
59
63
|
parse_response('object', e.response)
|
@@ -63,7 +67,7 @@ class UnforBaseApi
|
|
63
67
|
def head_request(action, params={}, headers={})
|
64
68
|
begin
|
65
69
|
headers.merge!({ authorization: "Token token=\"#{@access_token}\"" })
|
66
|
-
response = RestClient.head("#{@
|
70
|
+
response = RestClient.head("#{@endpoint}#{action}", params)
|
67
71
|
parse_response(get_response_kind(headers), response)
|
68
72
|
rescue => e
|
69
73
|
parse_response('object', e.response)
|
@@ -73,7 +77,7 @@ class UnforBaseApi
|
|
73
77
|
def delete_request(action, params={}, headers={})
|
74
78
|
begin
|
75
79
|
headers.merge!({ authorization: "Token token=\"#{@access_token}\"" })
|
76
|
-
response = RestClient.delete("#{@
|
80
|
+
response = RestClient.delete("#{@endpoint}#{action}", params)
|
77
81
|
parse_response(get_response_kind(headers), response)
|
78
82
|
rescue => e
|
79
83
|
parse_response('object', e.response)
|