unfor_base_api 1.2 → 1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/lib/unfor_base_api.rb +13 -7
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99f95dd89fd89fb1050f44c216fc4a858849a876
4
- data.tar.gz: 231cf3e8078f2943dd65f61de6e9e8358106c0a5
3
+ metadata.gz: 5f4b242b66228d3981ac93061c49f0ed65e964cd
4
+ data.tar.gz: 506e97ac8af3c351dc62eb036d77ba511d7189a3
5
5
  SHA512:
6
- metadata.gz: 657031276de39d106ded31e320a1fc07a7c8efcd30f698ea2a49192c2a0d1f17d83a00250a9f6d3c6130c5cee5fe3af55bde7519690e78341225c33a7a96fb93
7
- data.tar.gz: cabb0126c581e46ba1deec1b6c22e9c1e2ce099c78bc160f672ec0390e3d43c03afd83323569c88b2286d3e2ccaf23d285b47b095f831215f0c10e924875dfed
6
+ metadata.gz: 96007268a4ec6e0480fb87504d47ef447f6bc4e4e66d0da2924ef966b6d85d7257cae5f2e1bab086e25aae272452edb831872e65b4506e7c83751aee7c6a1bd2
7
+ data.tar.gz: fbad208765907cdb17abaf0762ec73c5c8f6d9298819d750852614a1a06ead268b677fd68f58908fbf3984944b52945d7b0afda42f1261bd79ba5fb244c83e05
data/CHANGELOG.md CHANGED
@@ -25,3 +25,7 @@
25
25
  ## v1.2
26
26
 
27
27
  * Fixes on head and delete methods
28
+
29
+ ## v1.3
30
+
31
+ * Fix in response kind
@@ -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(get_response_kind(headers), 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(get_response_kind(headers), 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(get_response_kind(headers), 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(get_response_kind(headers), 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(get_response_kind(headers), 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(get_response_kind(headers), 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 get_response_kind(headers)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unfor_base_api
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.2'
4
+ version: '1.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matias Hick