unfor_base_api 1.2 → 1.3
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 +13 -7
- 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: 5f4b242b66228d3981ac93061c49f0ed65e964cd
|
4
|
+
data.tar.gz: 506e97ac8af3c351dc62eb036d77ba511d7189a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96007268a4ec6e0480fb87504d47ef447f6bc4e4e66d0da2924ef966b6d85d7257cae5f2e1bab086e25aae272452edb831872e65b4506e7c83751aee7c6a1bd2
|
7
|
+
data.tar.gz: fbad208765907cdb17abaf0762ec73c5c8f6d9298819d750852614a1a06ead268b677fd68f58908fbf3984944b52945d7b0afda42f1261bd79ba5fb244c83e05
|
data/CHANGELOG.md
CHANGED
data/lib/unfor_base_api.rb
CHANGED
@@ -27,8 +27,9 @@ class UnforBaseApi
|
|
27
27
|
def get_request(action, params={}, headers={})
|
28
28
|
begin
|
29
29
|
headers.merge!({ authorization: "Token token=\"#{@access_token}\"" })
|
30
|
+
response_kind = extract_response_kind(headers)
|
30
31
|
response = RestClient.get("#{@endpoint}#{action}", {params: params}.merge(headers))
|
31
|
-
parse_response(
|
32
|
+
parse_response(response_kind, response)
|
32
33
|
rescue => e
|
33
34
|
parse_response('object', e.response)
|
34
35
|
end
|
@@ -37,8 +38,9 @@ class UnforBaseApi
|
|
37
38
|
def post_request(action, params={}, headers={})
|
38
39
|
begin
|
39
40
|
headers.merge!({ authorization: "Token token=\"#{@access_token}\"" })
|
41
|
+
response_kind = extract_response_kind(headers)
|
40
42
|
response = RestClient.post("#{@endpoint}#{action}", params, headers)
|
41
|
-
parse_response(
|
43
|
+
parse_response(response_kind, response)
|
42
44
|
rescue => e
|
43
45
|
parse_response('object', e.response)
|
44
46
|
end
|
@@ -47,8 +49,9 @@ class UnforBaseApi
|
|
47
49
|
def put_request(action, params={}, headers={})
|
48
50
|
begin
|
49
51
|
headers.merge!({ authorization: "Token token=\"#{@access_token}\"" })
|
52
|
+
response_kind = extract_response_kind(headers)
|
50
53
|
response = RestClient.put("#{@endpoint}#{action}", params, headers)
|
51
|
-
parse_response(
|
54
|
+
parse_response(response_kind, response)
|
52
55
|
rescue => e
|
53
56
|
parse_response('object', e.response)
|
54
57
|
end
|
@@ -57,8 +60,9 @@ class UnforBaseApi
|
|
57
60
|
def patch_request(action, params={}, headers={})
|
58
61
|
begin
|
59
62
|
headers.merge!({ authorization: "Token token=\"#{@access_token}\"" })
|
63
|
+
response_kind = extract_response_kind(headers)
|
60
64
|
response = RestClient.patch("#{@endpoint}#{action}", params, headers)
|
61
|
-
parse_response(
|
65
|
+
parse_response(response_kind, response)
|
62
66
|
rescue => e
|
63
67
|
parse_response('object', e.response)
|
64
68
|
end
|
@@ -67,8 +71,9 @@ class UnforBaseApi
|
|
67
71
|
def head_request(action, headers={})
|
68
72
|
begin
|
69
73
|
headers.merge!({ authorization: "Token token=\"#{@access_token}\"" })
|
74
|
+
response_kind = extract_response_kind(headers)
|
70
75
|
response = RestClient.head("#{@endpoint}#{action}", headers)
|
71
|
-
parse_response(
|
76
|
+
parse_response(response_kind, response)
|
72
77
|
rescue => e
|
73
78
|
parse_response('object', e.response)
|
74
79
|
end
|
@@ -77,14 +82,15 @@ class UnforBaseApi
|
|
77
82
|
def delete_request(action, headers={})
|
78
83
|
begin
|
79
84
|
headers.merge!({ authorization: "Token token=\"#{@access_token}\"" })
|
85
|
+
response_kind = extract_response_kind(headers)
|
80
86
|
response = RestClient.delete("#{@endpoint}#{action}", headers)
|
81
|
-
parse_response(
|
87
|
+
parse_response(response_kind, response)
|
82
88
|
rescue => e
|
83
89
|
parse_response('object', e.response)
|
84
90
|
end
|
85
91
|
end
|
86
92
|
|
87
|
-
def
|
93
|
+
def extract_response_kind(headers)
|
88
94
|
api_response_kind = headers.delete('api_response_kind')
|
89
95
|
api_response_kind = headers.delete(:api_response_kind) if api_response_kind.nil?
|
90
96
|
api_response_kind.nil? ? 'object' : api_response_kind
|