arkaan 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/arkaan/decorators/gateway.rb +30 -12
- data/lib/arkaan/utils/controller_without_filter.rb +1 -0
- 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: c150ea52265ab4b70de42580ce3ed8697b945ae5
|
4
|
+
data.tar.gz: be079d94632022d6d9aafec43a6b74661a6d786c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20920dafe21f8e8f0cce76e0b2f0a1dc7c0671a8296bbbde3bd026adfa0b77c40004e3804076c9d2e3b05b3a47f1df6a96fbb3fb6a7a99a70626e8b65b7c7209
|
7
|
+
data.tar.gz: 9f3874ce2d0b9f932449efbfb2c8b3c7ba8ff655d4a1b6877720174d26f1fd1c5ff9656cf16dac805624cf85d59acf051ccc447558ccfb5b36dfb6cf2d57e8ae
|
@@ -19,7 +19,7 @@ module Arkaan
|
|
19
19
|
# @param url [String] the URL you want to reach on the service.
|
20
20
|
# @param params [Hash] the additional parameters to pass in the JSON body.
|
21
21
|
def delete(session:, url:, params:)
|
22
|
-
return
|
22
|
+
return make_request_without_body(verb: 'delete', session: session, url: url, params: params)
|
23
23
|
end
|
24
24
|
|
25
25
|
# Shortcut to make a GET request on the API.
|
@@ -27,7 +27,7 @@ module Arkaan
|
|
27
27
|
# @param url [String] the URL you want to reach on the service.
|
28
28
|
# @param params [Hash] the additional parameters to pass in the JSON body.
|
29
29
|
def get(session:, url:, params:)
|
30
|
-
return
|
30
|
+
return make_request_without_body(verb: 'get', session: session, url: url, params: params)
|
31
31
|
end
|
32
32
|
|
33
33
|
# Shortcut to make a POST request on the API.
|
@@ -61,16 +61,8 @@ module Arkaan
|
|
61
61
|
# @return [Hash, Boolean] FALSE if no instance are found, or an object with :status and :body keys correspding
|
62
62
|
# to the status and body of the response to the request
|
63
63
|
def make_request(verb:, session:, url:, params:)
|
64
|
-
|
65
|
-
|
66
|
-
end
|
67
|
-
params[:app_key] = ENV['APP_KEY']
|
68
|
-
params[:session_id] = session.token
|
69
|
-
connection = Faraday.new(object.url) do |faraday|
|
70
|
-
faraday.request :url_encoded
|
71
|
-
faraday.response :logger
|
72
|
-
faraday.adapter Faraday.default_adapter
|
73
|
-
end
|
64
|
+
params = before_requests(params)
|
65
|
+
connection = get_connection
|
74
66
|
response = connection.send(verb) do |req|
|
75
67
|
req.url url
|
76
68
|
req.headers['Content-Type'] = 'application/json'
|
@@ -82,6 +74,32 @@ module Arkaan
|
|
82
74
|
body: JSON.parse(response.body)
|
83
75
|
}
|
84
76
|
end
|
77
|
+
|
78
|
+
def make_request_without_body(verb:, session:, url:, params:)
|
79
|
+
params = before_requests(params)
|
80
|
+
connection = get_connection
|
81
|
+
response = connection.send(verb) do |req|
|
82
|
+
req.url url, params
|
83
|
+
req.headers['Content-Type'] = 'application/json'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def before_requests(params)
|
88
|
+
if ENV['APP_KEY'].nil?
|
89
|
+
raise Arkaan::Decorators::Errors::EnvVariableMissing.new(action: action)
|
90
|
+
end
|
91
|
+
params[:app_key] = ENV['APP_KEY']
|
92
|
+
params[:session_id] = session.token
|
93
|
+
return params
|
94
|
+
end
|
95
|
+
|
96
|
+
def get_connection
|
97
|
+
Faraday.new(object.url) do |faraday|
|
98
|
+
faraday.request :url_encoded
|
99
|
+
faraday.response :logger
|
100
|
+
faraday.adapter Faraday.default_adapter
|
101
|
+
end
|
102
|
+
end
|
85
103
|
end
|
86
104
|
end
|
87
105
|
end
|