bubbles-rest-client 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/bubbles.rb +0 -618
- data/lib/bubbles/version.rb +1 -1
- 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: 0f8bdd1fabbb4307f261d1d1a0964d3e6e1cd0ab
|
4
|
+
data.tar.gz: 91aafd3870051c1960a1a3038a0625b2383f48ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c47bd2636eb96aff3ffd058ea682e22547099f96c8f2f683d8b2b8b2a371cd5be29ed63d39651723eef283ef4f4620d638cc99d8e9f2b87c85ea6e93e176d7c6
|
7
|
+
data.tar.gz: 90572682aa9b7f686b21e96758f0ee50af6adc20d902f5894996e42457fb3ed496305bb18c8f52cd1f1e0a07cfdca5d04eb22ad18d4a4dbaa8be8dd9f9349c41
|
data/Gemfile.lock
CHANGED
data/lib/bubbles.rb
CHANGED
@@ -27,624 +27,6 @@ module Bubbles
|
|
27
27
|
:versionCode => @versionCode
|
28
28
|
}
|
29
29
|
end
|
30
|
-
|
31
|
-
# def local_environment
|
32
|
-
# LOCAL_ENVIRONMENT
|
33
|
-
# end
|
34
|
-
|
35
|
-
###### BEGIN API METHODS ######
|
36
|
-
|
37
|
-
def version
|
38
|
-
execute_get_unauthenticated(@environment.version_endpoint)
|
39
|
-
end
|
40
|
-
|
41
|
-
# def login(username, password)
|
42
|
-
# encoded_auth = Base64.strict_encode64(username + ':' + password)
|
43
|
-
#
|
44
|
-
# response = execute_post_unauthenticated(@environment.login_endpoint, nil,
|
45
|
-
# {
|
46
|
-
# :authorization => 'Basic ' + encoded_auth
|
47
|
-
# })
|
48
|
-
#
|
49
|
-
# @auth_token = JSON.parse(response, object_class: OpenStruct).auth_token
|
50
|
-
#
|
51
|
-
# response
|
52
|
-
# end
|
53
30
|
end
|
54
31
|
end
|
55
32
|
|
56
|
-
# module SinkingMoonRestClient
|
57
|
-
# class Resources
|
58
|
-
# attr_accessor :environment, :api_key
|
59
|
-
#
|
60
|
-
# def check_for_expired_token
|
61
|
-
# begin
|
62
|
-
# yield
|
63
|
-
# rescue RestClient::Forbidden => e
|
64
|
-
# response_json = JSON.parse(e.response.to_s, object_class: OpenStruct)
|
65
|
-
# if response_json.error == 'Auth token is expired; You will need to login again'
|
66
|
-
# raise SinkingMoonRestClient::AuthTokenExpiredException.new
|
67
|
-
# end
|
68
|
-
#
|
69
|
-
# raise e
|
70
|
-
# end
|
71
|
-
# end
|
72
|
-
#
|
73
|
-
#
|
74
|
-
# ###### BEGIN API METHODS ######
|
75
|
-
#
|
76
|
-
# def version
|
77
|
-
# execute_get_unauthenticated(@environment.version_endpoint)
|
78
|
-
# end
|
79
|
-
#
|
80
|
-
# def login(username, password)
|
81
|
-
# encoded_auth = Base64.strict_encode64(username + ':' + password)
|
82
|
-
#
|
83
|
-
# response = execute_post_unauthenticated(@environment.login_endpoint, nil,
|
84
|
-
# {
|
85
|
-
# :authorization => 'Basic ' + encoded_auth
|
86
|
-
# })
|
87
|
-
#
|
88
|
-
# @auth_token = JSON.parse(response, object_class: OpenStruct).auth_token
|
89
|
-
#
|
90
|
-
# response
|
91
|
-
# end
|
92
|
-
#
|
93
|
-
# def list_students(auth_token=nil)
|
94
|
-
# check_for_expired_token do
|
95
|
-
# response = execute_get_authenticated(@environment.students_endpoint, auth_token)
|
96
|
-
# return response
|
97
|
-
# end
|
98
|
-
# end
|
99
|
-
#
|
100
|
-
# def get_student(id, auth_token=nil)
|
101
|
-
# check_for_expired_token do
|
102
|
-
# url_components = [@environment.students_endpoint, id]
|
103
|
-
# url = url_components.join('/')
|
104
|
-
# execute_get_authenticated(url, auth_token)
|
105
|
-
# end
|
106
|
-
# end
|
107
|
-
#
|
108
|
-
# def forgot_password(email=nil)
|
109
|
-
# unless email
|
110
|
-
# raise 'Method requires a valid email address to be passed in'
|
111
|
-
# end
|
112
|
-
#
|
113
|
-
# response = execute_post_unauthenticated(@environment.forgot_password_endpoint,
|
114
|
-
# {
|
115
|
-
# :email => email
|
116
|
-
# })
|
117
|
-
# response
|
118
|
-
# end
|
119
|
-
#
|
120
|
-
# def change_password(login_hash, password, password_confirm)
|
121
|
-
# unless login_hash and password and password_confirm
|
122
|
-
# raise 'Method requires a valid login hash, password, and password confirmation to be passed in'
|
123
|
-
# end
|
124
|
-
#
|
125
|
-
# unless password == password_confirm
|
126
|
-
# raise 'Password and password confirmation do not match'
|
127
|
-
# end
|
128
|
-
#
|
129
|
-
# response = execute_put_unauthenticated(@environment.change_password_endpoint,
|
130
|
-
# {
|
131
|
-
# :one_time_login_hash => login_hash,
|
132
|
-
# :new_password => password,
|
133
|
-
# :password_confirmation => password_confirm
|
134
|
-
# })
|
135
|
-
# response
|
136
|
-
# end
|
137
|
-
#
|
138
|
-
# def create_student(student, auth_token = nil)
|
139
|
-
# check_for_expired_token do
|
140
|
-
# token = get_auth_token(auth_token)
|
141
|
-
#
|
142
|
-
# unless student
|
143
|
-
# raise 'Unable to create student with empty body'
|
144
|
-
# end
|
145
|
-
#
|
146
|
-
# response = execute_post_authenticated(@environment.students_endpoint, token,
|
147
|
-
# {
|
148
|
-
# :name => student[:name],
|
149
|
-
# :address => student[:address],
|
150
|
-
# :city => student[:city],
|
151
|
-
# :state => student[:state],
|
152
|
-
# :zip => student[:zip],
|
153
|
-
# :phone => student[:phone],
|
154
|
-
# :email => student[:email],
|
155
|
-
# :preferredContact => student[:preferredContact].downcase,
|
156
|
-
# :emergencyContactName => student[:emergencyContactName],
|
157
|
-
# :emergencyContactPhone => student[:emergencyContactPhone],
|
158
|
-
# :rank => student[:rank].downcase,
|
159
|
-
# :joinDate => student[:joinDate],
|
160
|
-
# :lastAdvancementDate => student[:lastAdvancementDate],
|
161
|
-
# :waiverSigned => student[:waiverSigned]
|
162
|
-
# })
|
163
|
-
#
|
164
|
-
# response
|
165
|
-
# end
|
166
|
-
# end
|
167
|
-
#
|
168
|
-
# def delete_student(id, auth_token = nil)
|
169
|
-
# check_for_expired_token do
|
170
|
-
# token = get_auth_token(auth_token)
|
171
|
-
#
|
172
|
-
# unless id
|
173
|
-
# raise 'Unable to delete a student without an id'
|
174
|
-
# end
|
175
|
-
#
|
176
|
-
# url_components = [@environment.students_endpoint, id]
|
177
|
-
# execute_delete_authenticated(url_components.join('/'), token)
|
178
|
-
# end
|
179
|
-
# end
|
180
|
-
#
|
181
|
-
# def update_student(id, new_record, auth_token = nil)
|
182
|
-
# check_for_expired_token do
|
183
|
-
# token = get_auth_token(auth_token)
|
184
|
-
#
|
185
|
-
# unless id
|
186
|
-
# raise 'Unable to update a student without the student id'
|
187
|
-
# end
|
188
|
-
#
|
189
|
-
# unless new_record
|
190
|
-
# raise 'Unable to update a student record without the record body'
|
191
|
-
# end
|
192
|
-
#
|
193
|
-
# url_components = [@environment.students_endpoint, id]
|
194
|
-
# execute_put_authenticated(url_components.join('/'), token, new_record)
|
195
|
-
# end
|
196
|
-
# end
|
197
|
-
#
|
198
|
-
# ##
|
199
|
-
# # :method: activate_student
|
200
|
-
# #
|
201
|
-
# # Activate a student by his/her student id. This method requires administrative privileges to call.
|
202
|
-
# #
|
203
|
-
# # :param: [Integer] id The identifier of the student to activate
|
204
|
-
# # :param: [String] auth_token The authentication token to use to identify yourself as an admin to the server.
|
205
|
-
# def activate_student(id, auth_token = nil)
|
206
|
-
# check_for_expired_token do
|
207
|
-
# token = get_auth_token(auth_token)
|
208
|
-
#
|
209
|
-
# unless id
|
210
|
-
# raise 'Unable to activate a student without an id'
|
211
|
-
# end
|
212
|
-
#
|
213
|
-
# url_components = [@environment.students_endpoint, 'activate', id]
|
214
|
-
# execute_patch_authenticated(url_components.join('/'), token)
|
215
|
-
# end
|
216
|
-
# end
|
217
|
-
#
|
218
|
-
# ##
|
219
|
-
# # :method: deactivate_student
|
220
|
-
# #
|
221
|
-
# # Deactivate a student by his/her student id. This method requires administrative privileges to call.
|
222
|
-
# #
|
223
|
-
# # :param: [Integer] id The identifier of the student to deactivate
|
224
|
-
# # :param: [String] auth_token The authentication token to use to identify yourself as an admin to the server.
|
225
|
-
# def deactivate_student(id, auth_token = nil)
|
226
|
-
# check_for_expired_token do
|
227
|
-
# token = get_auth_token(auth_token)
|
228
|
-
#
|
229
|
-
# unless id
|
230
|
-
# raise 'Unable to deactivate a student without an id'
|
231
|
-
# end
|
232
|
-
#
|
233
|
-
# url_components = [@environment.students_endpoint, 'deactivate', id]
|
234
|
-
# execute_patch_authenticated(url_components.join('/'), token)
|
235
|
-
# end
|
236
|
-
# end
|
237
|
-
#
|
238
|
-
# def get_user(id, auth_token = nil)
|
239
|
-
# check_for_expired_token do
|
240
|
-
# token = get_auth_token(auth_token);
|
241
|
-
# url_components = [@environment.users_endpoint, id]
|
242
|
-
# url = url_components.join('/')
|
243
|
-
# execute_get_authenticated(url, token)
|
244
|
-
# end
|
245
|
-
# end
|
246
|
-
#
|
247
|
-
# def create_user(user, auth_token = nil)
|
248
|
-
# check_for_expired_token do
|
249
|
-
# token = get_auth_token(auth_token)
|
250
|
-
#
|
251
|
-
# unless user
|
252
|
-
# raise SinkingMoonRestClient::InvalidBodyException.new
|
253
|
-
# end
|
254
|
-
#
|
255
|
-
# response = execute_post_authenticated(@environment.users_endpoint, token,
|
256
|
-
# {
|
257
|
-
# :name => user[:name],
|
258
|
-
# :email => user[:email],
|
259
|
-
# :username => user[:username],
|
260
|
-
# :role => user[:role]
|
261
|
-
# })
|
262
|
-
#
|
263
|
-
# response
|
264
|
-
# end
|
265
|
-
# end
|
266
|
-
#
|
267
|
-
# def update_user(id, new_record, auth_token = nil)
|
268
|
-
# check_for_expired_token do
|
269
|
-
# token = get_auth_token(auth_token)
|
270
|
-
#
|
271
|
-
# unless id
|
272
|
-
# raise 'Unable to update a user record without the user id'
|
273
|
-
# end
|
274
|
-
#
|
275
|
-
# unless new_record
|
276
|
-
# raise 'Unable to update a user record without the record body'
|
277
|
-
# end
|
278
|
-
#
|
279
|
-
# url_components = [@environment.users_endpoint, id]
|
280
|
-
# execute_put_authenticated(url_components.join('/'), token, new_record)
|
281
|
-
# end
|
282
|
-
# end
|
283
|
-
#
|
284
|
-
# def list_advancements(auth_token = nil)
|
285
|
-
# check_for_expired_token do
|
286
|
-
# token = get_auth_token(auth_token)
|
287
|
-
# response = execute_get_authenticated(@environment.advancements_endpoint, token)
|
288
|
-
# return response
|
289
|
-
# end
|
290
|
-
# end
|
291
|
-
#
|
292
|
-
# def create_advancement (advancement, auth_token = nil)
|
293
|
-
# check_for_expired_token do
|
294
|
-
# token = get_auth_token(auth_token)
|
295
|
-
#
|
296
|
-
# unless advancement
|
297
|
-
# raise 'Unable to create advancement with empty body'
|
298
|
-
# end
|
299
|
-
#
|
300
|
-
# response = execute_post_authenticated(@environment.advancements_endpoint, token,
|
301
|
-
# {
|
302
|
-
# :date => advancement[:date],
|
303
|
-
# :student_id => advancement[:student_id],
|
304
|
-
# :rank => advancement[:rank]
|
305
|
-
# })
|
306
|
-
#
|
307
|
-
# response
|
308
|
-
# end
|
309
|
-
# end
|
310
|
-
#
|
311
|
-
# def delete_advancement(id, auth_token = nil)
|
312
|
-
# check_for_expired_token do
|
313
|
-
# token = get_auth_token(auth_token)
|
314
|
-
#
|
315
|
-
# unless id
|
316
|
-
# raise 'Unable to delete an advancement without an id'
|
317
|
-
# end
|
318
|
-
#
|
319
|
-
# url_components = [@environment.advancements_endpoint, id]
|
320
|
-
# execute_delete_authenticated(url_components.join('/'), token)
|
321
|
-
# end
|
322
|
-
# end
|
323
|
-
#
|
324
|
-
# def update_advancement(id, new_record, auth_token = nil)
|
325
|
-
# check_for_expired_token do
|
326
|
-
# token = get_auth_token(auth_token)
|
327
|
-
#
|
328
|
-
# unless id
|
329
|
-
# raise 'Unable to update an advancement record without the advancement id'
|
330
|
-
# end
|
331
|
-
#
|
332
|
-
# unless new_record
|
333
|
-
# raise 'Unable to update an advancement record without the record body'
|
334
|
-
# end
|
335
|
-
#
|
336
|
-
# url_components = [@environment.advancements_endpoint, id]
|
337
|
-
# execute_put_authenticated(url_components.join('/'), token, new_record)
|
338
|
-
# end
|
339
|
-
# end
|
340
|
-
#
|
341
|
-
# def get_advancement(id, auth_token = nil)
|
342
|
-
# check_for_expired_token do
|
343
|
-
# token = get_auth_token(auth_token)
|
344
|
-
#
|
345
|
-
# unless id
|
346
|
-
# raise 'Unable to retrieve an advancement record without the advancement id'
|
347
|
-
# end
|
348
|
-
#
|
349
|
-
# url_components = [@environment.advancements_endpoint, id]
|
350
|
-
# execute_get_authenticated(url_components.join('/'), token)
|
351
|
-
# end
|
352
|
-
# end
|
353
|
-
#
|
354
|
-
# def list_tournament_registrations(auth_token = nil)
|
355
|
-
# check_for_expired_token do
|
356
|
-
# token = get_auth_token(auth_token)
|
357
|
-
#
|
358
|
-
# url_components = [@environment.tournament_registrations_endpoint]
|
359
|
-
# execute_get_authenticated(url_components.join('/'), token)
|
360
|
-
# end
|
361
|
-
# end
|
362
|
-
#
|
363
|
-
# def delete_tournament_registration(id, auth_token = nil)
|
364
|
-
# check_for_expired_token do
|
365
|
-
# token = get_auth_token(auth_token)
|
366
|
-
#
|
367
|
-
# unless id
|
368
|
-
# raise 'Unable to delete a tournament registration without an id'
|
369
|
-
# end
|
370
|
-
#
|
371
|
-
# url_components = [@environment.tournament_registrations_endpoint, id]
|
372
|
-
# execute_delete_authenticated(url_components.join('/'), token)
|
373
|
-
# end
|
374
|
-
# end
|
375
|
-
#
|
376
|
-
# def create_tournament_registration(registration)
|
377
|
-
# check_for_expired_token do
|
378
|
-
#
|
379
|
-
# unless registration
|
380
|
-
# raise 'Unable to create tournament registration with empty body'
|
381
|
-
# end
|
382
|
-
#
|
383
|
-
# begin
|
384
|
-
# data =
|
385
|
-
# {
|
386
|
-
# :name => registration[:name],
|
387
|
-
# :address => registration[:address],
|
388
|
-
# :city => registration[:city],
|
389
|
-
# :state => registration[:state],
|
390
|
-
# :zip => registration[:zip],
|
391
|
-
# :email => registration[:email],
|
392
|
-
# :birthDate => registration[:birthDate],
|
393
|
-
# :tShirtSize => registration[:tShirtSize],
|
394
|
-
# :registrationType => registration[:registrationType],
|
395
|
-
# :studentsExpected => registration[:studentsExpected],
|
396
|
-
# :noPrivateLessons => registration[:noPrivateLessons],
|
397
|
-
# :rank => registration[:rank],
|
398
|
-
# :permissionToSpar => registration[:permissionToSpar],
|
399
|
-
# :school => registration[:school],
|
400
|
-
# :formsCompetitionParticipant => registration[:formsCompetitionParticipant],
|
401
|
-
# :skillsCombineParticipant => registration[:skillsCombineParticipant],
|
402
|
-
# :sparringParticipant => registration[:sparringParticipant],
|
403
|
-
# :liabilityWaiverNeeded => registration[:liabilityWaiverNeeded],
|
404
|
-
# :privateLessonDesired => registration[:privateLessonDesired],
|
405
|
-
# :spectatorConfirmation => registration[:spectatorConfirmation],
|
406
|
-
# :donationAmount => registration[:donationAmount],
|
407
|
-
# :paymentToken => registration[:paymentToken]
|
408
|
-
# }
|
409
|
-
#
|
410
|
-
# response = execute_post_unauthenticated(@environment.tournament_registrations_endpoint, data)
|
411
|
-
# rescue RestClient::Exception => e
|
412
|
-
# responseObj = JSON.parse(e.response, object_class: OpenStruct)
|
413
|
-
# raise InsufficientDataException.new(responseObj.error)
|
414
|
-
# end
|
415
|
-
#
|
416
|
-
# response
|
417
|
-
# end
|
418
|
-
# end
|
419
|
-
#
|
420
|
-
# ###### End API Methods ######
|
421
|
-
#
|
422
|
-
# def get_auth_token(auth_token = nil)
|
423
|
-
# if @auth_token.nil? and auth_token.nil?
|
424
|
-
# raise 'Method requires authentication. Use login() first or pass in an authorization token.'
|
425
|
-
# end
|
426
|
-
#
|
427
|
-
# token = auth_token
|
428
|
-
# token = @auth_token if auth_token == nil
|
429
|
-
#
|
430
|
-
# token
|
431
|
-
# end
|
432
|
-
#
|
433
|
-
# private
|
434
|
-
#
|
435
|
-
# def execute_post_unauthenticated(endpoint, data, headers=nil)
|
436
|
-
# additionalHeaders = {
|
437
|
-
# 'X-Api-Key' => @api_key,
|
438
|
-
# :content_type => :json,
|
439
|
-
# :accept => :json
|
440
|
-
# }
|
441
|
-
#
|
442
|
-
# unless headers.nil?
|
443
|
-
# headers.each { |nextHeader|
|
444
|
-
# additionalHeaders[nextHeader[0]] = nextHeader[1]
|
445
|
-
# }
|
446
|
-
# end
|
447
|
-
#
|
448
|
-
# begin
|
449
|
-
# if @environment.scheme == 'https'
|
450
|
-
# response = RestClient::Resource.new(endpoint, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
|
451
|
-
# .post(data.to_json, additionalHeaders)
|
452
|
-
# else
|
453
|
-
# response = RestClient.post endpoint, data.to_json, additionalHeaders
|
454
|
-
# end
|
455
|
-
# rescue Errno::ECONNREFUSED
|
456
|
-
# return { :error => 'Unable to connect to host ' + @environment.host.to_s + ":" + @environment.port.to_s }.to_json
|
457
|
-
# end
|
458
|
-
#
|
459
|
-
# response
|
460
|
-
# end
|
461
|
-
#
|
462
|
-
# def execute_post_authenticated(endpoint, token, data)
|
463
|
-
# if token.nil?
|
464
|
-
# raise 'Cannot execute an authenticated POST request with no auth_token'
|
465
|
-
# end
|
466
|
-
#
|
467
|
-
# if data.nil?
|
468
|
-
# raise 'Cannot execute POST command with an empty data set'
|
469
|
-
# end
|
470
|
-
#
|
471
|
-
# begin
|
472
|
-
# if @environment.scheme == 'https'
|
473
|
-
# response = RestClient::Resource.new(endpoint, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
|
474
|
-
# .post(data.to_json,
|
475
|
-
# {
|
476
|
-
# :content_type => :json,
|
477
|
-
# :accept => :json,
|
478
|
-
# :authorization => 'Bearer ' + token
|
479
|
-
# })
|
480
|
-
#
|
481
|
-
# else
|
482
|
-
# response = RestClient.post(endpoint,
|
483
|
-
# data.to_json,
|
484
|
-
# {
|
485
|
-
# :content_type => :json,
|
486
|
-
# :accept => :json,
|
487
|
-
# :authorization => 'Bearer ' + token
|
488
|
-
# })
|
489
|
-
# end
|
490
|
-
# rescue Errno::ECONNREFUSED
|
491
|
-
# return { :error => 'Unable to connect to host ' + @environment.host.to_s + ':' + @environment.port.to_s }.to_json
|
492
|
-
# end
|
493
|
-
#
|
494
|
-
# response
|
495
|
-
# end
|
496
|
-
#
|
497
|
-
#
|
498
|
-
# def execute_get_authenticated(endpoint, auth_token)
|
499
|
-
# token = get_auth_token(auth_token)
|
500
|
-
#
|
501
|
-
# begin
|
502
|
-
# if @environment.scheme == 'https'
|
503
|
-
# response = RestClient::Resource.new(endpoint, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
|
504
|
-
# .get({
|
505
|
-
# :authorization => 'Bearer ' + token,
|
506
|
-
# :content_type => :json,
|
507
|
-
# :accept => :json
|
508
|
-
# })
|
509
|
-
# else
|
510
|
-
# response = RestClient.get(endpoint,
|
511
|
-
# {
|
512
|
-
# :authorization => 'Bearer ' + token,
|
513
|
-
# :content_type => :json
|
514
|
-
# })
|
515
|
-
# end
|
516
|
-
# rescue Errno::ECONNREFUSED
|
517
|
-
# return {:error => 'Unable to connect to host ' + @environment.host.to_s + ':' + @environment.port.to_s}.to_json
|
518
|
-
# end
|
519
|
-
#
|
520
|
-
# response
|
521
|
-
# end
|
522
|
-
#
|
523
|
-
# def execute_put_unauthenticated(endpoint, data)
|
524
|
-
# begin
|
525
|
-
# if @environment.scheme == 'https'
|
526
|
-
# response = RestClient::Resource.new(endpoint, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
|
527
|
-
# .put(data.to_json,
|
528
|
-
# {
|
529
|
-
# :content_type => :json,
|
530
|
-
# :accept => :json
|
531
|
-
# })
|
532
|
-
#
|
533
|
-
# else
|
534
|
-
# response = RestClient.put(endpoint,
|
535
|
-
# data.to_json,
|
536
|
-
# {
|
537
|
-
# :content_type => :json,
|
538
|
-
# :accept => :json
|
539
|
-
# })
|
540
|
-
# end
|
541
|
-
# rescue Errno::ECONNREFUSED
|
542
|
-
# return {:error => 'Unable to connect to host ' + @environment.host.to_s + ':' + @environment.port.to_s}.to_json
|
543
|
-
# end
|
544
|
-
#
|
545
|
-
# response
|
546
|
-
# end
|
547
|
-
#
|
548
|
-
# def execute_put_authenticated(endpoint, token, data)
|
549
|
-
# if token.nil?
|
550
|
-
# raise 'Cannot execute an authenticated PUT request with no auth_token'
|
551
|
-
# end
|
552
|
-
#
|
553
|
-
# if data.nil?
|
554
|
-
# raise 'Cannot execute PUT command with an empty data set'
|
555
|
-
# end
|
556
|
-
#
|
557
|
-
# begin
|
558
|
-
# if @environment.scheme == 'https'
|
559
|
-
# response = RestClient::Resource.new(endpoint, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
|
560
|
-
# .put(data.to_json,
|
561
|
-
# {
|
562
|
-
# :content_type => :json,
|
563
|
-
# :accept => :json,
|
564
|
-
# :authorization => 'Bearer ' + token
|
565
|
-
# })
|
566
|
-
#
|
567
|
-
# else
|
568
|
-
# response = RestClient.put(endpoint,
|
569
|
-
# data.to_json,
|
570
|
-
# {
|
571
|
-
# :content_type => :json,
|
572
|
-
# :accept => :json,
|
573
|
-
# :authorization => 'Bearer ' + token
|
574
|
-
# })
|
575
|
-
# end
|
576
|
-
# rescue Errno::ECONNREFUSED
|
577
|
-
# return { :error => 'Unable to connect to host ' + @environment.host.to_s + ':' + @environment.port.to_s }.to_json
|
578
|
-
# end
|
579
|
-
#
|
580
|
-
# response
|
581
|
-
# end
|
582
|
-
#
|
583
|
-
# def execute_patch_authenticated(endpoint, token)
|
584
|
-
# if token.nil?
|
585
|
-
# raise 'Cannot execute an authenticated PATCH request with no auth_token'
|
586
|
-
# end
|
587
|
-
#
|
588
|
-
# begin
|
589
|
-
# if @environment.scheme == 'https'
|
590
|
-
# response = RestClient::Resource.new(endpoint, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
|
591
|
-
# .patch(nil,
|
592
|
-
# {
|
593
|
-
# :content_type => :json,
|
594
|
-
# :accept => :json,
|
595
|
-
# :authorization => 'Bearer ' + token
|
596
|
-
# })
|
597
|
-
#
|
598
|
-
# else
|
599
|
-
# response = RestClient.patch(endpoint, nil,
|
600
|
-
# {
|
601
|
-
# :content_type => :json,
|
602
|
-
# :accept => :json,
|
603
|
-
# :authorization => 'Bearer ' + token
|
604
|
-
# })
|
605
|
-
# end
|
606
|
-
# rescue Errno::ECONNREFUSED
|
607
|
-
# return { :error => 'Unable to connect to host ' + @environment.host.to_s + ':' + @environment.port.to_s }.to_json
|
608
|
-
# end
|
609
|
-
#
|
610
|
-
# response
|
611
|
-
# end
|
612
|
-
#
|
613
|
-
# def execute_delete_authenticated(endpoint, auth_token)
|
614
|
-
# token = get_auth_token(auth_token)
|
615
|
-
#
|
616
|
-
# begin
|
617
|
-
# if @environment.scheme == 'https'
|
618
|
-
# response = RestClient::Resource.new(endpoint, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
|
619
|
-
# .delete({
|
620
|
-
# :authorization => 'Bearer ' + token,
|
621
|
-
# :content_type => :json,
|
622
|
-
# :accept => :json
|
623
|
-
# })
|
624
|
-
# else
|
625
|
-
# response = RestClient.delete(endpoint,
|
626
|
-
# {
|
627
|
-
# :authorization => 'Bearer ' + token,
|
628
|
-
# :content_type => :json
|
629
|
-
# })
|
630
|
-
# end
|
631
|
-
# rescue Errno::ECONNREFUSED
|
632
|
-
# return {:error => 'Unable to connect to host ' + @environment.host.to_s + ':' + @environment.port.to_s}.to_json
|
633
|
-
# end
|
634
|
-
#
|
635
|
-
# response
|
636
|
-
# end
|
637
|
-
#
|
638
|
-
# def get_environment(environment)
|
639
|
-
# if !environment || environment == 'production'
|
640
|
-
# return PRODUCTION_ENVIRONMENT
|
641
|
-
# elsif environment == 'staging'
|
642
|
-
# return STAGING_ENVIRONMENT
|
643
|
-
# end
|
644
|
-
#
|
645
|
-
#
|
646
|
-
# LOCAL_ENVIRONMENT
|
647
|
-
# end
|
648
|
-
# end # Class Resources
|
649
|
-
# end # Module SinkingMoonRestClient
|
650
|
-
|
data/lib/bubbles/version.rb
CHANGED