activeclient_api 0.2.0 → 0.2.1
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/active_client/base.rb +19 -4
- data/lib/active_client/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0383744281275c59cc6b3b2cbfcf5a93a53d12716c3da0070a7e356c90b39cd8'
|
4
|
+
data.tar.gz: 2e92ed82dd57e3ff08dde1ece25270dd45080173c5bc74d1a4322783252e9255
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a0336a347464edfb857d5a8c07980a637ad826f672cc735d5ee5edbaa73ab756847debc38a9e47507e8c3850d606e059e4c3511caa8e7ebcf725a0073fa4891
|
7
|
+
data.tar.gz: 81e22b56f9f6280a33b71f30b016c24e77c05686e8eb28892f679a85efc29b867bf267d22b87bb34ec974c3258ac20ea65e8631852640c6a2ae47713628d2f33
|
data/lib/active_client/base.rb
CHANGED
@@ -29,7 +29,9 @@ class ActiveClient::Base
|
|
29
29
|
|
30
30
|
def instrument(klass:, path:, query:, body:)
|
31
31
|
uri, http, request = construct_request(klass:, path:, query:)
|
32
|
-
|
32
|
+
|
33
|
+
set_body(request, body)
|
34
|
+
|
33
35
|
loggable = loggable_uri(uri)
|
34
36
|
args = { name: self.class.name.demodulize, uri: loggable }
|
35
37
|
|
@@ -61,7 +63,7 @@ class ActiveClient::Base
|
|
61
63
|
http.use_ssl = uri.instance_of?(URI::HTTPS)
|
62
64
|
http.read_timeout = 1200
|
63
65
|
|
64
|
-
[uri, http, klass.new(uri.request_uri, default_headers)]
|
66
|
+
[uri, http, klass.new(uri.request_uri, default_headers(klass))]
|
65
67
|
end
|
66
68
|
|
67
69
|
def construct_uri(path:, query:)
|
@@ -78,7 +80,7 @@ class ActiveClient::Base
|
|
78
80
|
uri.query = URI.encode_www_form(default_query.merge(query))
|
79
81
|
end
|
80
82
|
|
81
|
-
def default_headers
|
83
|
+
def default_headers(_klass)
|
82
84
|
{ "Accept" => "application/json",
|
83
85
|
"Content-Type" => "application/json" }
|
84
86
|
end
|
@@ -116,7 +118,7 @@ class ActiveClient::Base
|
|
116
118
|
end
|
117
119
|
end
|
118
120
|
|
119
|
-
def deep_inheritable_options(obj)
|
121
|
+
def deep_inheritable_options(obj) # rubocop:disable Metrics/MethodLength
|
120
122
|
case obj
|
121
123
|
when Hash
|
122
124
|
inherited = ActiveSupport::InheritableOptions.new
|
@@ -130,4 +132,17 @@ class ActiveClient::Base
|
|
130
132
|
obj
|
131
133
|
end
|
132
134
|
end
|
135
|
+
|
136
|
+
def set_body(request, body)
|
137
|
+
if body.present? &&
|
138
|
+
request["Content-Type"] == "application/x-www-form-urlencoded"
|
139
|
+
set_form_data(request, body)
|
140
|
+
elsif body.present?
|
141
|
+
request.body = default_body.merge(body).to_json
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def set_form_data(request, body)
|
146
|
+
request.set_form_data(default_body.merge(body))
|
147
|
+
end
|
133
148
|
end
|