bubbles-rest-client 0.3.1 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d85396895955c45173bf56e4f7efb61a841bceb90c0d4f3348f99fcb0271e7a0
4
- data.tar.gz: c7147c2c317a496d577a63f19f7fe4a398997b9bb6d8b3084585f7da6f93da3c
3
+ metadata.gz: aa7191e00b0fa6396be519250117e31e924c258f368cf7d1c9e02697234bcab0
4
+ data.tar.gz: e989353ef2ef2fc4cb07014fb3b2a9a0dfce0bf778b820582c98c13502c1de1d
5
5
  SHA512:
6
- metadata.gz: '076759218897e4bac3955b296fa5a0eabb58fb826c5e51c063da34f39d659f7fa2c61d85e8ae064fa5dd46c88a7d3b33baad513bff1951ea629fa30de2c9091e'
7
- data.tar.gz: b84b861758a6bd7b44ae4f4153da1467fb6cd5e69b2846450088b7946af21539efe20d9fb3b80f136aa6f0f40cd6f58e5ca5fab3e2cd6fe2f7af8a75a38e8bb4
6
+ metadata.gz: 046af961bf1da02e71a2193cfad8cd048084dc021e6786bfc1df753d54730284b4d3bd309f383b8b9456e4628a5c21a24beccbbddc25977c6b93c40485b1bfe8
7
+ data.tar.gz: 579c841ef7eb221a3d86e3e0ef13e77e77fb08a9ecacf70847f4a5c38509b7de2541507b9d45d05b26eb98c3e93dfcc61b229cbd8b8efba70c8b44336a361530
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bubbles-rest-client (0.3.1)
4
+ bubbles-rest-client (0.4.0)
5
5
  addressable (~> 2.5)
6
6
  rest-client (~> 2.0)
7
7
 
@@ -19,12 +19,13 @@ GEM
19
19
  domain_name (0.5.20190701)
20
20
  unf (>= 0.0.5, < 1.0.0)
21
21
  hashdiff (1.0.0)
22
+ http-accept (1.7.0)
22
23
  http-cookie (1.0.3)
23
24
  domain_name (~> 0.5)
24
25
  json (2.0.2)
25
- mime-types (3.2.2)
26
+ mime-types (3.3)
26
27
  mime-types-data (~> 3.2015)
27
- mime-types-data (3.2019.0331)
28
+ mime-types-data (3.2019.0904)
28
29
  minitest (5.11.3)
29
30
  minitest-reporters (1.1.19)
30
31
  ansi
@@ -34,7 +35,8 @@ GEM
34
35
  netrc (0.11.0)
35
36
  public_suffix (3.0.3)
36
37
  rake (10.5.0)
37
- rest-client (2.0.2)
38
+ rest-client (2.1.0)
39
+ http-accept (>= 1.7.0, < 2.0)
38
40
  http-cookie (>= 1.0.2, < 2.0)
39
41
  mime-types (>= 1.16, < 4.0)
40
42
  netrc (~> 0.8)
@@ -103,7 +103,7 @@ module Bubbles
103
103
  def endpoints=(endpoints)
104
104
  new_endpoints = Hash.new
105
105
  endpoints.each do |ep|
106
- endpoint_object = Endpoint.new ep[:method], ep[:location].to_s, ep[:authenticated], ep[:api_key_required], ep[:name], ep[:return_type], ep[:encode_authorization]
106
+ endpoint_object = Endpoint.new ep[:method], ep[:location].to_s, ep[:authenticated], ep[:api_key_required], ep[:name], ep[:return_type], ep[:encode_authorization], ep[:headers]
107
107
 
108
108
  new_endpoints[endpoint_object.get_key_string] = endpoint_object
109
109
  end
@@ -129,18 +129,18 @@ module Bubbles
129
129
  Bubbles::RestEnvironment.class_exec do
130
130
  if endpoint.has_uri_params?
131
131
  define_method(endpoint_name_as_sym) do |auth_token, uri_params|
132
- RestClientResources.execute_get_authenticated self, endpoint, auth_token, uri_params
132
+ RestClientResources.execute_get_authenticated self, endpoint, auth_token, uri_params, endpoint.additional_headers
133
133
  end
134
134
  else
135
135
  define_method(endpoint_name_as_sym) do |auth_token|
136
- RestClientResources.execute_get_authenticated self, endpoint, auth_token, {}
136
+ RestClientResources.execute_get_authenticated self, endpoint, auth_token,{}, endpoint.additional_headers
137
137
  end
138
138
  end
139
139
  end
140
140
  else
141
141
  Bubbles::RestEnvironment.class_exec do
142
142
  define_method(endpoint_name_as_sym) do
143
- RestClientResources.execute_get_unauthenticated self, endpoint
143
+ RestClientResources.execute_get_unauthenticated self, endpoint, endpoint.additional_headers
144
144
  end
145
145
  end
146
146
  end
@@ -148,14 +148,14 @@ module Bubbles
148
148
  if endpoint.authenticated?
149
149
  Bubbles::RestEnvironment.class_exec do
150
150
  define_method(endpoint_name_as_sym) do |auth_token, data|
151
- RestClientResources.execute_post_authenticated self, endpoint, auth_token, data
151
+ RestClientResources.execute_post_authenticated self, endpoint, auth_token, data, endpoint.additional_headers
152
152
  end
153
153
  end
154
154
  else
155
155
  if endpoint.api_key_required?
156
156
  Bubbles::RestEnvironment.class_exec do
157
157
  define_method(endpoint_name_as_sym) do |data|
158
- additional_headers = {}
158
+ additional_headers = endpoint.additional_headers
159
159
  if endpoint.encode_authorization_header?
160
160
  count = 0
161
161
  auth_value = ''
@@ -188,7 +188,7 @@ module Bubbles
188
188
  Bubbles::RestEnvironment.class_exec do
189
189
  if endpoint.has_uri_params?
190
190
  define_method(endpoint_name_as_sym) do |auth_token, uri_params|
191
- RestClientResources.execute_delete_authenticated self, endpoint, auth_token, uri_params
191
+ RestClientResources.execute_delete_authenticated self, endpoint, auth_token, uri_params, endpoint.additional_headers
192
192
  end
193
193
  else
194
194
  # NOTE: While MDN states that DELETE requests with a body are allowed, it seems that a number of
@@ -214,13 +214,13 @@ module Bubbles
214
214
  Bubbles::RestEnvironment.class_exec do
215
215
  if endpoint.has_uri_params?
216
216
  define_method(endpoint_name_as_sym) do |auth_token, uri_params, data|
217
- RestClientResources.execute_patch_authenticated self, endpoint, auth_token, uri_params, data
217
+ RestClientResources.execute_patch_authenticated self, endpoint, auth_token, uri_params, data, endpoint.additional_headers
218
218
  end
219
219
  else
220
220
  define_method(endpoint_name_as_sym) do |auth_token, data|
221
221
  # TODO: Nothing tests this case. We need something to test this case or we run the risk of
222
222
  # it having bugs (uri_params was nil previously!)
223
- RestClientResources.execute_patch_authenticated self, endpoint, auth_token, {}, data
223
+ RestClientResources.execute_patch_authenticated self, endpoint, auth_token, {}, data, endpoint.additional_headers
224
224
  end
225
225
  end
226
226
  end
@@ -228,11 +228,11 @@ module Bubbles
228
228
  Bubbles::RestEnvironment.class_exec do
229
229
  if endpoint.has_uri_params?
230
230
  define_method(endpoint_name_as_sym) do |uri_params, data|
231
- RestClientResources.execute_patch_unauthenticated self, endpoint, uri_params, data
231
+ RestClientResources.execute_patch_unauthenticated self, endpoint, uri_params, data, endpoint.additional_headers
232
232
  end
233
233
  else
234
234
  define_method(endpoint_name_as_sym) do |data|
235
- RestClientResources.execute_patch_unauthenticated self, endpoint, {}, data
235
+ RestClientResources.execute_patch_unauthenticated self, endpoint, {}, data, endpoint.additional_headers
236
236
  end
237
237
  end
238
238
  end
@@ -242,13 +242,13 @@ module Bubbles
242
242
  Bubbles::RestEnvironment.class_exec do
243
243
  if endpoint.has_uri_params?
244
244
  define_method(endpoint_name_as_sym) do |auth_token, uri_params, data|
245
- RestClientResources.execute_put_authenticated self, endpoint, auth_token, uri_params, data
245
+ RestClientResources.execute_put_authenticated self, endpoint, auth_token, uri_params, data, endpoint.additional_headers
246
246
  end
247
247
  else
248
248
  define_method(endpoint_name_as_sym) do |auth_token, data|
249
249
  # TODO: Nothing tests this case. We need something to test this case or we run the risk of
250
250
  # it having bugs (uri_params was nil previously!)
251
- RestClientResources.execute_put_authenticated self, endpoint, auth_token, {}, data
251
+ RestClientResources.execute_put_authenticated self, endpoint, auth_token, {}, data, endpoint.additional_headers
252
252
  end
253
253
  end
254
254
  end
@@ -257,11 +257,11 @@ module Bubbles
257
257
  Bubbles::RestEnvironment.class_exec do
258
258
  if endpoint.has_uri_params?
259
259
  define_method(endpoint_name_as_sym) do |uri_params, data|
260
- RestClientResources.execute_put_unauthenticated self, endpoint, uri_params, data
260
+ RestClientResources.execute_put_unauthenticated self, endpoint, uri_params, data, endpoint.additional_headers
261
261
  end
262
262
  else
263
263
  define_method(endpoint_name_as_sym) do |data|
264
- RestClientResources.execute_put_unauthenticated self, endpoint, {}, data
264
+ RestClientResources.execute_put_unauthenticated self, endpoint, {}, data, endpoint.additional_headers
265
265
  end
266
266
  end
267
267
  end
@@ -271,11 +271,11 @@ module Bubbles
271
271
  Bubbles::RestEnvironment.class_exec do
272
272
  if endpoint.has_uri_params?
273
273
  define_method(endpoint_name_as_sym) do |auth_token, uri_params|
274
- RestClientResources.execute_head_authenticated self, endpoint, auth_token, uri_params
274
+ RestClientResources.execute_head_authenticated self, endpoint, auth_token, uri_params, endpoint.additional_headers
275
275
  end
276
276
  else
277
277
  define_method(endpoint_name_as_sym) do |auth_token|
278
- RestClientResources.execute_head_authenticated self, endpoint, auth_token, {}
278
+ RestClientResources.execute_head_authenticated self, endpoint, auth_token, {}, endpoint.additional_headers
279
279
  end
280
280
  end
281
281
  end
@@ -283,11 +283,11 @@ module Bubbles
283
283
  Bubbles::RestEnvironment.class_exec do
284
284
  if endpoint.has_uri_params?
285
285
  define_method(endpoint_name_as_sym) do |uri_params|
286
- RestClientResources.execute_head_unauthenticated_with_uri_params self, endpoint, self.api_key, uri_params
286
+ RestClientResources.execute_head_unauthenticated_with_uri_params self, endpoint, self.api_key, uri_params, endpoint.additional_headers
287
287
  end
288
288
  else
289
289
  define_method(endpoint_name_as_sym) do
290
- RestClientResources.execute_head_unauthenticated self, endpoint, self.api_key, nil
290
+ RestClientResources.execute_head_unauthenticated self, endpoint, self.api_key, endpoint.additional_headers
291
291
  end
292
292
  end
293
293
  end
@@ -295,11 +295,11 @@ module Bubbles
295
295
  Bubbles::RestEnvironment.class_exec do
296
296
  if endpoint.has_uri_params?
297
297
  define_method(endpoint_name_as_sym) do |uri_params|
298
- RestClientResources.execute_head_unauthenticated self, endpoint, uri_params, {}
298
+ RestClientResources.execute_head_unauthenticated self, endpoint, uri_params, endpoint.additional_headers
299
299
  end
300
300
  else
301
301
  define_method(endpoint_name_as_sym) do
302
- RestClientResources.execute_head_unauthenticated self, endpoint, {}, {}
302
+ RestClientResources.execute_head_unauthenticated self, endpoint, {}, endpoint.additional_headers
303
303
  end
304
304
  end
305
305
  end
@@ -74,13 +74,14 @@ module Bubbles
74
74
  # @param [Array<Symbol>] encode_authorization Parameters that should be treated as authorization parameters and
75
75
  # encoded using a Base64 encoding.
76
76
  #
77
- def initialize(method, location, auth_required = false, api_key_required = false, name = nil, return_type = :body_as_string, encode_authorization = {})
77
+ def initialize(method, location, auth_required = false, api_key_required = false, name = nil, return_type = :body_as_string, encode_authorization = {}, headers = {})
78
78
  @method = method
79
79
  @location = location
80
80
  @auth_required = auth_required
81
81
  @api_key_required = api_key_required
82
82
  @name = name
83
83
  @encode_authorization = encode_authorization
84
+ @additional_headers = headers
84
85
 
85
86
  unless Endpoint::RETURN_TYPES.include? return_type.to_s
86
87
  return_type = :body_as_string
@@ -272,5 +273,17 @@ module Bubbles
272
273
  def has_uri_params?
273
274
  !@uri_params.empty?
274
275
  end
276
+
277
+ def additional_headers
278
+ unless @additional_headers
279
+ @additional_headers = {}
280
+ end
281
+
282
+ @additional_headers
283
+ end
284
+
285
+ def has_additional_headers?
286
+ not additional_headers.empty?
287
+ end
275
288
  end
276
289
  end
@@ -32,11 +32,13 @@ module Bubbles
32
32
  #
33
33
  # @param [RestEnvironment] env The +RestEnvironment+ to use to execute the request
34
34
  # @param [Endpoint] endpoint The +Endpoint+ which should be requested
35
+ # @param [Hash] additional_headers A +Hash+ of key-value pairs that will be sent as additional headers in the API
36
+ # call. Defaults to an empty +Hash+.
35
37
  #
36
38
  # @return [RestClient::Response] The +Response+ resulting from the execution of the GET call.
37
39
  #
38
- def self.execute_get_unauthenticated(env, endpoint)
39
- execute_rest_call(env, endpoint, nil, nil, nil) do |env, url, data, headers|
40
+ def self.execute_get_unauthenticated(env, endpoint, additional_headers = {})
41
+ execute_rest_call(env, endpoint, nil, nil, additional_headers) do |env, url, data, headers|
40
42
  if env.scheme == 'https'
41
43
  next RestClient::Resource.new(url.to_s, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
42
44
  .get(headers)
@@ -55,11 +57,13 @@ module Bubbles
55
57
  # @param [Endpoint] endpoint The +Endpoint+ which should be requested
56
58
  # @param [String] auth_token The authorization token to use for authentication.
57
59
  # @param [Hash] uri_params A +Hash+ of identifiers to values to replace in the URI string.
60
+ # @param [Hash] additional_headers A +Hash+ of key-value pairs that will be sent as additional headers in the API
61
+ # call. Defaults to an empty +Hash+.
58
62
  #
59
63
  # @return [RestClient::Response] The +Response+ resulting from the execution of the GET call.
60
64
  #
61
- def self.execute_get_authenticated(env, endpoint, auth_token, uri_params)
62
- execute_rest_call(env, endpoint, nil, auth_token, nil, uri_params) do |env, url, data, headers|
65
+ def self.execute_get_authenticated(env, endpoint, auth_token, uri_params, additional_headers = {})
66
+ execute_rest_call(env, endpoint, nil, auth_token, additional_headers, uri_params) do |env, url, data, headers|
63
67
  if env.scheme == 'https'
64
68
  next RestClient::Resource.new(url.to_s, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
65
69
  .get(headers)
@@ -76,10 +80,13 @@ module Bubbles
76
80
  #
77
81
  # @param [RestEnvironment] env The +RestEnvironment+ to use to execute the request
78
82
  # @param [Endpoint] endpoint The +Endpoint+ which should be requested
83
+ # @param [Hash] uri_params A +Hash+ of identifiers to values to replace in the URI string.
84
+ # @param [Hash] additional_headers A +Hash+ of key-value pairs that will be sent as additional headers in the API
85
+ # call. Defaults to an empty +Hash+.
79
86
  #
80
87
  # @return [RestClient::Response] The +Response+ resulting from the execution of the GET call.
81
88
  #
82
- def self.execute_head_unauthenticated(env, endpoint, uri_params, additional_headers)
89
+ def self.execute_head_unauthenticated(env, endpoint, uri_params, additional_headers = {})
83
90
  execute_rest_call(env, endpoint, nil, nil, additional_headers, uri_params) do |env, url, data, headers|
84
91
  if env.scheme == 'https'
85
92
  next RestClient::Resource.new(url.to_s, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
@@ -100,11 +107,13 @@ module Bubbles
100
107
  # @param [Endpoint] endpoint The +Endpoint+ which should be requested
101
108
  # @param [String] auth_token The authorization token to use for authentication.
102
109
  # @param [Hash] uri_params A +Hash+ of identifiers to values to replace in the URI string.
110
+ # @param [Hash] additional_headers A +Hash+ of key-value pairs that will be sent as additional headers in the API
111
+ # call. Defaults to an empty +Hash+.
103
112
  #
104
113
  # @return [RestClient::Response] The +Response+ resulting from the execution of the HEAD call.
105
114
  #
106
- def self.execute_head_authenticated(env, endpoint, auth_token, uri_params)
107
- execute_rest_call(env, endpoint, nil, auth_token, nil, uri_params) do |env, url, data, headers|
115
+ def self.execute_head_authenticated(env, endpoint, auth_token, uri_params, additional_headers = {})
116
+ execute_rest_call(env, endpoint, nil, auth_token, additional_headers, uri_params) do |env, url, data, headers|
108
117
  if env.scheme == 'https'
109
118
  next RestClient::Resource.new(url.to_s, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
110
119
  .head(headers)
@@ -121,22 +130,23 @@ module Bubbles
121
130
  # @param [Endpoint] endpoint The +Endpoint+ which should be requested
122
131
  # @param [String] api_key The API key to use to validate the client.
123
132
  # @param [Hash] uri_params A +Hash+ of identifiers to values to replace in the URI string.
124
- # @param [Hash] headers An optional +Hash+ of additional headers to pass with the request.
133
+ # @param [Hash] additional_headers A +Hash+ of key-value pairs that will be sent as additional headers in the API
134
+ # call. Defaults to an empty +Hash+.
125
135
  #
126
136
  # @return [RestClient::Response] The +Response+ resulting from the execution of the HEAD call.
127
137
  #
128
- def self.execute_head_unauthenticated_with_uri_params(env, endpoint, api_key, uri_params, headers=nil)
129
- additional_headers = {
138
+ def self.execute_head_unauthenticated_with_uri_params(env, endpoint, api_key, uri_params, additional_headers = {})
139
+ composite_headers = {
130
140
  'X-Api-Key' => api_key
131
141
  }
132
142
 
133
- unless headers.nil?
134
- headers.each { |nextHeader|
135
- additional_headers[nextHeader[0]] = nextHeader[1]
143
+ unless additional_headers.empty?
144
+ additional_headers.each { |nextHeader|
145
+ composite_headers[nextHeader[0]] = nextHeader[1]
136
146
  }
137
147
  end
138
148
 
139
- execute_rest_call(env, endpoint, nil, nil, additional_headers, uri_params) do |env, url, data, headers|
149
+ execute_rest_call(env, endpoint, nil, nil, composite_headers, uri_params) do |env, url, data, headers|
140
150
  if env.scheme == 'https'
141
151
  next RestClient::Resource.new(url.to_s, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
142
152
  .head(headers)
@@ -153,28 +163,28 @@ module Bubbles
153
163
  # @param [Endpoint] endpoint The +Endpoint+ which should be requested
154
164
  # @param [String] api_key The API key to use to process the request. Will be placed in an 'X-API-KEY' header.
155
165
  # @param [Hash] data A +Hash+ of key-value pairs that will be sent in the body of the http request.
156
- # @param [Hash] headers (Optional) A +Hash+ of key-value pairs that will be sent as HTTP headers as part of the
157
- # request. Defaults to +nil+.
166
+ # @param [Hash] additional_headers A +Hash+ of key-value pairs that will be sent as additional headers in the API
167
+ # call. Defaults to an empty +Hash+.
158
168
  #
159
169
  # @return [RestClient::Response] The +Response+ resulting from the execution of the POST call.
160
170
  #
161
- def self.execute_post_with_api_key(env, endpoint, api_key, data, headers=nil)
162
- additional_headers = {
171
+ def self.execute_post_with_api_key(env, endpoint, api_key, data, additional_headers = {})
172
+ composite_headers = {
163
173
  'X-Api-Key' => api_key
164
174
  }
165
175
 
166
- unless headers.nil?
167
- headers.each { |nextHeader|
168
- additional_headers[nextHeader[0]] = nextHeader[1]
176
+ unless additional_headers.nil?
177
+ additional_headers.each { |nextHeader|
178
+ composite_headers[nextHeader[0]] = nextHeader[1]
169
179
  }
170
180
  end
171
181
 
172
- execute_rest_call(env, endpoint, data, nil, additional_headers) do |env, url, data, headers|
182
+ execute_rest_call(env, endpoint, data, nil, composite_headers) do |env, url, data, headers|
173
183
  if env.scheme == 'https'
174
184
  next RestClient::Resource.new(url.to_s, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
175
- .post(data.to_json, additional_headers)
185
+ .post(data.to_json, headers)
176
186
  else
177
- next RestClient.post url.to_s, data.to_json, additional_headers
187
+ next RestClient.post url.to_s, data.to_json, headers
178
188
  end
179
189
  end
180
190
  end
@@ -187,11 +197,13 @@ module Bubbles
187
197
  # @param [String] auth_token The authorization token retrieved during some former authentication call. Will be
188
198
  # placed into a Authorization header.
189
199
  # @param [Hash] data A +Hash+ of key-value pairs that will be sent in the body of the http request.
200
+ # @param [Hash] additional_headers A +Hash+ of key-value pairs that will be sent as additional headers in the API
201
+ # call. Defaults to an empty +Hash+.
190
202
  #
191
203
  # @return [RestClient::Response] The +Response+ resulting from the execution of the POST call.
192
204
  #
193
- def self.execute_post_authenticated(env, endpoint, auth_token, data)
194
- return execute_rest_call(env, endpoint, data, auth_token, nil) do |env, url, data, headers|
205
+ def self.execute_post_authenticated(env, endpoint, auth_token, data, additional_headers = {})
206
+ return execute_rest_call(env, endpoint, data, auth_token, additional_headers) do |env, url, data, headers|
195
207
  if env.scheme == 'https'
196
208
  next RestClient::Resource.new(url.to_s, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
197
209
  .post(data.to_json, headers)
@@ -211,11 +223,13 @@ module Bubbles
211
223
  # placed into a Authorization header.
212
224
  # @param [Hash] uri_params A +Hash+ of identifiers to values to replace in the URI string.
213
225
  # @param [Hash] data A +Hash+ of key-value pairs that will be sent in the body of the http request.
226
+ # @param [Hash] additional_headers A +Hash+ of key-value pairs that will be sent as additional headers in the API
227
+ # call. Defaults to an empty +Hash+.
214
228
  #
215
229
  # @return [RestClient::Response] The +Response+ resulting from the execution of the PATCH call.
216
230
  #
217
- def self.execute_patch_authenticated(env, endpoint, auth_token, uri_params, data)
218
- return execute_rest_call(env, endpoint, data, auth_token, nil, uri_params) do |env, url, data, headers|
231
+ def self.execute_patch_authenticated(env, endpoint, auth_token, uri_params, data, additional_headers = {})
232
+ return execute_rest_call(env, endpoint, data, auth_token, additional_headers, uri_params) do |env, url, data, headers|
219
233
  if env.scheme == 'https'
220
234
  next RestClient::Resource.new(url.to_s, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
221
235
  .patch(data.to_json, headers)
@@ -233,11 +247,13 @@ module Bubbles
233
247
  # @param [Endpoint] endpoint The +Endpoint+ which should be requested
234
248
  # @param [Hash] uri_params A +Hash+ of identifiers to values to replace in the URI string.
235
249
  # @param [Hash] data A +Hash+ of key-value pairs that will be sent in the body of the http request.
250
+ # @param [Hash] additional_headers A +Hash+ of key-value pairs that will be sent as additional headers in the API
251
+ # call. Defaults to an empty +Hash+.
236
252
  #
237
253
  # @return [RestClient::Response] The +Response+ resulting from the execution of the PATCH call.
238
254
  #
239
- def self.execute_patch_unauthenticated(env, endpoint, uri_params, data)
240
- return execute_rest_call(env, endpoint, data, nil, nil, uri_params) do |env, url, data, headers|
255
+ def self.execute_patch_unauthenticated(env, endpoint, uri_params, data, additional_headers = {})
256
+ return execute_rest_call(env, endpoint, data, nil, additional_headers, uri_params) do |env, url, data, headers|
241
257
  if env.scheme == 'https'
242
258
  next RestClient::Resource.new(url.to_s, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
243
259
  .patch(data.to_json, headers)
@@ -256,11 +272,13 @@ module Bubbles
256
272
  # placed into a Authorization header.
257
273
  # @param [Hash] uri_params A +Hash+ of identifiers to values to replace in the URI string.
258
274
  # @param [Hash] data A +Hash+ of key-value pairs that will be sent in the body of the http request.
275
+ # @param [Hash] additional_headers A +Hash+ of key-value pairs that will be sent as additional headers in the API
276
+ # call. Defaults to an empty +Hash+.
259
277
  #
260
278
  # @return [RestClient::Response] The +Response+ resulting from the execution of the PUT call.
261
279
  #
262
- def self.execute_put_authenticated(env, endpoint, auth_token, uri_params, data)
263
- return execute_rest_call(env, endpoint, data, auth_token, nil, uri_params) do |env, url, data, headers|
280
+ def self.execute_put_authenticated(env, endpoint, auth_token, uri_params, data, additional_headers = {})
281
+ return execute_rest_call(env, endpoint, data, auth_token, additional_headers, uri_params) do |env, url, data, headers|
264
282
  if env.scheme == 'https'
265
283
  next RestClient::Resource.new(url.to_s, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
266
284
  .put(data.to_json, headers)
@@ -278,11 +296,13 @@ module Bubbles
278
296
  # @param [Endpoint] endpoint The +Endpoint+ which should be requested
279
297
  # @param [Hash] uri_params A +Hash+ of identifiers to values to replace in the URI string.
280
298
  # @param [Hash] data A +Hash+ of key-value pairs that will be sent in the body of the http request.
299
+ # @param [Hash] additional_headers A +Hash+ of key-value pairs that will be sent as additional headers in the API
300
+ # call. Defaults to an empty +Hash+.
281
301
  #
282
302
  # @return [RestClient::Response] The +Response+ resulting from the execution of the PUT call.
283
303
  #
284
- def self.execute_put_unauthenticated(env, endpoint, uri_params, data)
285
- return execute_rest_call(env, endpoint, data, nil, nil, uri_params) do |env, url, data, headers|
304
+ def self.execute_put_unauthenticated(env, endpoint, uri_params, data, additional_headers = {})
305
+ return execute_rest_call(env, endpoint, data, nil, additional_headers, uri_params) do |env, url, data, headers|
286
306
  if env.scheme == 'https'
287
307
  next RestClient::Resource.new(url.to_s, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
288
308
  .put(data.to_json, headers)
@@ -300,11 +320,13 @@ module Bubbles
300
320
  # @param [String] auth_token The authorization token retrieved during some former authentication call. Will be
301
321
  # placed into a Authorization header.
302
322
  # @param [Hash] uri_params A +Hash+ of identifiers to values to replace in the URI string.
323
+ # @param [Hash] additional_headers A +Hash+ of key-value pairs that will be sent as additional headers in the API
324
+ # call. Defaults to an empty +Hash+.
303
325
  #
304
326
  # @return [RestClient::Response] The +Response+ resulting from the execution of the DELETE call.
305
327
  #
306
- def self.execute_delete_authenticated(env, endpoint, auth_token, uri_params)
307
- execute_rest_call(env, endpoint, nil, auth_token, nil, uri_params) do |env, url, data, headers|
328
+ def self.execute_delete_authenticated(env, endpoint, auth_token, uri_params, additional_headers = {})
329
+ execute_rest_call(env, endpoint, nil, auth_token, additional_headers, uri_params) do |env, url, data, headers|
308
330
  if env.scheme == 'https'
309
331
  next RestClient::Resource.new(url.to_s, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
310
332
  .delete(headers)
@@ -7,7 +7,7 @@ module Bubbles
7
7
  end
8
8
 
9
9
  def self.version_name
10
- '0.3.1'
10
+ '0.4.1'
11
11
  end
12
12
 
13
13
  def self.version_code
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bubbles-rest-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Johnson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-22 00:00:00.000000000 Z
11
+ date: 2019-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler