smartwaiver-sdk 4.0.0 → 4.2.0

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
- SHA1:
3
- metadata.gz: f7db8097383e5239cf525bdf325c02b7115a2154
4
- data.tar.gz: de13abd5f6f4a0a9c9ada27ebdf613433c8e0b74
2
+ SHA256:
3
+ metadata.gz: 559daaed2e60bb9bd05128bb3c9a61bf2ee9c63e862cf4add5a66444331a3d23
4
+ data.tar.gz: dc80881ed8c83fc99b5091d6c9f6d6f98847a7de06b478f5cc5c324c0c9e2eac
5
5
  SHA512:
6
- metadata.gz: 478a58a44cca53de3bc84cfd123cabb198fe17c4605018db4c963ffd1f3163984e0e79f9af168c8d22ac888ea45ca519172d8c99724058e4740c76f115fcbcdf
7
- data.tar.gz: f0e8475bbb8a6b3668447b2e0d230f5ef1e074ca1d751f5e76b20d0f4909317d46329c021a66ad19ed4c747e511de918971490c2f1983a7f513db5a3edba23cf
6
+ metadata.gz: 61e416b05563dd6c29b430198cf5083f8037b3476f1b1daab254367bf0129c813bd09a48795bd86188e6520ad963e335bd8fa8143d5274b9b48c923881c40459
7
+ data.tar.gz: 204c4d8f057947d2e8b3bf4e0137f3ddfa31c04055bc03514d73d35557f7ab54a4ef3140e2e7faf664aaf67eb34ffdcf6c3e6fa72a0dbc8c2307361a75c01c70
data/README.md CHANGED
@@ -11,6 +11,8 @@ Table of Contents
11
11
  * [Retrieve a Specific Template](#retrieve-a-specific-template)
12
12
  * [List all Signed Waivers](#list-all-signed-waivers)
13
13
  * [Retrieve a Specific Waiver](#retrieve-a-specific-waiver)
14
+ * [Retrieve Photos on a Waiver](#retrieve-photos-on-a-waiver)
15
+ * [Search For Waivers](#search-for-waivers)
14
16
  * [Retrieve/Set Webhook Config](#retrieveset-webhook-configuration)
15
17
  * [Exception Handling](#exception-handling)
16
18
  * [Status Codes](#status-codes)
@@ -246,6 +248,179 @@ result = client.get(waiver_id, pdf)
246
248
 
247
249
  The code provided here is also combined in to one example in [retrieve_single_waiver.rb](examples/waivers/retrieve_single_waiver.rb)
248
250
 
251
+ Retrieve Photos on a Waiver
252
+ ----------
253
+
254
+ We can also use the API to retrieve any photos taken when the waiver was signed or attached later with the console.
255
+ All we need is you're API key and the ID of a signed waiver, which has attached photos.
256
+
257
+
258
+ If you don't have a waiver ID to use, you can get a list of signed waivers in your account [here](#list-all-signed-waivers)
259
+
260
+ First let's set up the basic Smartwaiver object. Make sure to put in your account's API Key where it says `[INSERT API KEY]`
261
+
262
+ ```ruby
263
+ require 'smartwaiver-sdk/waiver_client'
264
+
265
+ # The API Key for your account
266
+ api_key='[INSERT API KEY]'
267
+
268
+ client = SmartwaiverWaiverClient.new(api_key)
269
+ ```
270
+
271
+ Now, we can request the photos on a specific waiver.
272
+ Make sure to put your waiver ID in where it says `[INSERT WAIVER ID]`
273
+
274
+ ```ruby
275
+ # The unique ID of the signed waiver to be retrieved
276
+ waiver_id='[INSERT WAIVER ID]'
277
+
278
+ result = client.photos(waiver_id)
279
+
280
+ photos = result[:photos]
281
+ ```
282
+
283
+ This photos object has a little meta-data we can print out:
284
+
285
+ ```ruby
286
+ # Print a little header
287
+ puts "Waiver Photos for: #{photos[:title]}"
288
+
289
+ photos[:photos].each do |photo|
290
+ puts "#{photo[:photoId]}: #{photo[:date]}"
291
+ end
292
+ ```
293
+
294
+ The code provided here is also combined in to one example in [retrieve_waiver_photos.rb](examples/waivers/retrieve_waiver_photos.rb)
295
+
296
+
297
+ Search for Waivers
298
+ ----------
299
+
300
+ First let's set up the basic Smartwaiver object. Make sure to put in your account's API Key where it says `[INSERT API KEY]`
301
+
302
+ ```ruby
303
+ require 'smartwaiver-sdk/search_client'
304
+
305
+ # The API Key for your account
306
+ api_key='[INSERT API KEY]'
307
+
308
+ client = SmartwaiverSearchClient.new(api_key)
309
+ ```
310
+
311
+ Now we can request a search for signed waivers from your account.
312
+
313
+ ```ruby
314
+ # Request all waivers signed in 2018
315
+ results = client.search('', '2018-01-01 00:00:00')
316
+ ```
317
+
318
+ **Note: The search route is a blocking search. Thus, a request to search for large amounts of data can take up to a few seconds.
319
+ As such, this route should not be used for anything where real-time performance is important. Instead use the Waivers route.**
320
+
321
+ This will return a search object containing metadata about the results of our search.
322
+ We can easily print out all that information:
323
+
324
+ ```ruby
325
+ search = results[:search]
326
+ # Print out some information about the result of the search
327
+ puts "Search Complete:"
328
+ puts " Search ID: #{search[:guid]}"
329
+ puts " Waiver Count: #{search[:count]}"
330
+ puts " #{search[:pages]} pages of size #{search[:pageSize]}"
331
+ ```
332
+
333
+ The server has stored the results of our search request under the GUID given.
334
+ We can now loop through the pages and request each page, which will be a list of up to 100 waivers.
335
+ For example, if we wanted to created a list of all first names from our search, we would do that like this:
336
+
337
+ ```ruby
338
+ # We're going to create a list of all the first names on all the waivers
339
+ name_list = [];
340
+
341
+ pages = search[:pages]
342
+ current_page = 0
343
+ search_guid = search[:guid]
344
+
345
+ while current_page < pages
346
+ puts "Requesting page: #{current_page}/#{pages} ..."
347
+
348
+ waivers = client.results(search_guid, current_page)
349
+
350
+ puts "Processing page: #{current_page}/#{pages} ..."
351
+
352
+ waivers[:search_results].each do |waiver|
353
+ name_list.push(waiver[:firstName])
354
+ end
355
+
356
+ current_page = current_page + 1
357
+ end
358
+ ```
359
+
360
+ To see all the different properties a waiver has, check out [waiver_properties.rb](examples/waivers/waiver_properties.rb)
361
+
362
+ This examples is also available in [basic_search.rb](examples/search/basic_search.rb)
363
+
364
+ ### Search Parameters
365
+
366
+ We can also restrict our search with more parameters.
367
+ For example, what if we only want to return waivers for one of the templates in our account.
368
+ Here is the code to do that:
369
+
370
+ ```ruby
371
+ # The unique ID of the template to search for
372
+
373
+ template_id='[INSERT TEMPLATE ID]'
374
+
375
+ # Request all waivers signed for this template
376
+ results = client.search(template_id)
377
+ ```
378
+
379
+ Or what if we only want any waivers that have not been verified (either by email or at the kiosk)?
380
+
381
+ ```ruby
382
+ # Request all waivers signed that not have been email verified
383
+ results = client.search(template_id, '', '', '', '', true)
384
+ ```
385
+
386
+ What other parameters can you use? Here are some more examples:
387
+
388
+ ```ruby
389
+ # Request all waivers signed for this template after the given date
390
+ results = client.search(template_id, '2017-01-01 00:00:00')
391
+
392
+ # Request all waivers signed for this template before the given date
393
+ results = client.search(template_id, '', '2017-01-01 00:00:00')
394
+
395
+ # Request all waivers signed for this template with a participant name Kyle
396
+ results = client.search(template_id, '', '', 'Kyle')
397
+
398
+ # Request all waivers signed for this template with a participant name Kyle Smith
399
+ results = client.search(template_id, '', '', 'Kyle', 'Smith')
400
+
401
+ # Request all waivers signed with a participant name Kyle that have been email verified
402
+ results = client.search(template_id, '', '', 'Kyle', '', true)
403
+
404
+ # Request all waivers signed in ascending sorted order
405
+ results = client.search(template_id, '', '', '', '', '', false)
406
+ ```
407
+
408
+ These examples are also available in [search_params.rb](examples/search/search_params.rb)
409
+
410
+ ### Parameter Options
411
+
412
+ | Parameter Name | Default Value | Accepted Values | Notes |
413
+ | -------------- | ------------- | ----------------- | --------------------------------------------------------------------------------------- |
414
+ | templateId | | Valid Template ID | Limit signed waivers to only this template |
415
+ | fromDts | | ISO 8601 Date | Limit to signed waivers between after this date |
416
+ | toDts | | ISO 8601 Date | Limit to signed waivers between before this date |
417
+ | firstName | | Alpha-numeric | Limit to signed waivers that have a participant with this first name (Case Insensitive) |
418
+ | lastName | | Alpha-numeric | Limit to signed waivers that have a participant with this last name (Case Insensitive) |
419
+ | verified | null | true/false/null | Limit selection to waiver that have been verified (true), not (false), or both (null) |
420
+ | sortDesc | true | true/false | Sort results in descending (latest signed waiver first) order |
421
+
422
+
423
+
249
424
  Retrieve/Set Webhook Configuration
250
425
  ----------
251
426
 
@@ -0,0 +1,387 @@
1
+ #
2
+ # Copyright 2018 Smartwaiver
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+ # not use this file except in compliance with the License. You may obtain
6
+ # a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations
14
+ # under the License.
15
+
16
+ require 'smartwaiver-sdk/smartwaiver_base'
17
+ require 'smartwaiver-sdk/dynamic_template_data'
18
+
19
+ class SmartwaiverDynamicTemplate
20
+
21
+ EXPIRATION_DEFAULT = 300
22
+
23
+ attr_accessor :expiration, :template_config, :data
24
+
25
+ def initialize(expiration = EXPIRATION_DEFAULT)
26
+ @expiration = expiration
27
+ @template_config = SmartwaiverDynamicTemplateConfig.new
28
+ @data = SmartwaiverDynamicTemplateData.new
29
+ end
30
+
31
+ def to_json
32
+ {:template => @template_config.for_json, :data => @data.for_json}.to_json
33
+ end
34
+ end
35
+
36
+
37
+ class SmartwaiverDynamicTemplateConfig
38
+
39
+ attr_accessor :meta, :header, :body, :participants,
40
+ :standard_questions, :guardian, :electronic_consent,
41
+ :styling, :completion, :signatures, :processing
42
+
43
+ def initialize()
44
+ @meta = SmartwaiverTemplateMeta.new
45
+ @header = SmartwaiverTemplateHeader.new
46
+ @body = SmartwaiverTemplateBody.new
47
+ @participants = SmartwaiverTemplateParticipants.new
48
+ @standard_questions = SmartwaiverTemplateStandardQuestions.new
49
+ @guardian = SmartwaiverTemplateGuardian.new
50
+ @electronic_consent = SmartwaiverTemplateElectronicConsent.new
51
+ @styling = SmartwaiverTemplateStyling.new
52
+ @completion = SmartwaiverTemplateCompletion.new
53
+ @signatures = SmartwaiverTemplateSignatures.new
54
+ @processing = SmartwaiverTemplateProcessing.new
55
+ end
56
+
57
+ def for_json
58
+ {
59
+ 'meta' => @meta.for_json,
60
+ 'header' => @header.for_json,
61
+ 'body' => @body.for_json,
62
+ 'participants' => @participants.for_json,
63
+ 'standardQuestions' => @standard_questions.for_json,
64
+ 'guardian' => @guardian.for_json,
65
+ 'electronicConsent' => @electronic_consent.for_json,
66
+ 'styling' => @styling.for_json,
67
+ 'completion' => @completion.for_json,
68
+ 'signatures' => @signatures.for_json,
69
+ 'processing' => @processing.for_json
70
+ }
71
+ end
72
+ end
73
+
74
+ class SmartwaiverTemplateMeta
75
+
76
+ attr_accessor :title, :locale
77
+
78
+ def initialize()
79
+ @title = nil
80
+ @locale = nil
81
+ end
82
+
83
+ def for_json
84
+ json = {}
85
+ json['title'] = @title if (!@title.nil?)
86
+ json['locale'] = {'locale' => @locale} if (!@locale.nil?)
87
+ json
88
+ end
89
+ end
90
+
91
+ class SmartwaiverTemplateHeader
92
+
93
+ MEDIA_TYPE_PNG = 'image/png'
94
+ MEDIA_TYPE_JPEG = 'image/jpeg'
95
+
96
+ attr_accessor :text, :image_base_64
97
+
98
+ def initialize()
99
+ @text = nil
100
+ @image_base_64 = nil
101
+ end
102
+
103
+ def format_image_inline(media_type, encoded_image)
104
+ @image_base_64 = "data:#{media_type};base64,#{encoded_image}"
105
+ end
106
+
107
+ def for_json
108
+ json = {}
109
+ json['text'] = @text if (!@text.nil?)
110
+ json['logo'] = {'image' => @image_base_64} if (!@image_base_64.nil?)
111
+ json
112
+ end
113
+ end
114
+
115
+ class SmartwaiverTemplateBody
116
+
117
+ attr_accessor :text
118
+
119
+ def initialize()
120
+ @text = nil
121
+ end
122
+
123
+ def for_json
124
+ json = {}
125
+ json['text'] = @text if (!@text.nil?)
126
+ json
127
+ end
128
+ end
129
+
130
+ class SmartwaiverTemplateParticipants
131
+
132
+ ADULTS_AND_MINORS = 'adultsAndMinors'
133
+ MINORS_WITHOUT_ADULTS = 'minorsWithoutAdults'
134
+
135
+ PHONE_ADULTS_ONLY = 'adults'
136
+ PHOHE_ADULTS_AND_MINORS = 'adultsAndMinors'
137
+
138
+ DOB_CHECKBOX = 'checkbox'
139
+ DOB_SELECT = 'select'
140
+
141
+ attr_accessor :adults, :minors_enabled, :allow_multiple_minors, :allow_without_adults,
142
+ :allows_adults_and_minors, :age_of_majority, :participant_label, :participating_text,
143
+ :show_middle_name, :show_phone, :show_gender, :dob_type
144
+
145
+ def initialize()
146
+ @adults = true
147
+ @minors_enabled = nil
148
+ @allow_multiple_minors = nil
149
+ @allow_without_adults = nil
150
+ @allows_adults_and_minors = nil
151
+ @age_of_majority = nil
152
+ @participant_label = nil
153
+ @participating_text = nil
154
+ @show_middle_name = nil
155
+ @show_phone = nil
156
+ @show_gender = nil
157
+ @dob_type = nil
158
+ end
159
+
160
+ def for_json
161
+ json = {}
162
+ json['adults'] = @adults if (!@adults.nil?)
163
+
164
+ minors = {}
165
+ minors['enabled'] = @minors_enabled if (!@minors_enabled.nil?)
166
+ minors['multipleMinors'] = @allow_multiple_minors if (!@allow_multiple_minors.nil?)
167
+ minors['minorsWithoutAdults'] = @allow_without_adults if (!@allow_without_adults.nil?)
168
+ minors['adultsAndMinors'] = @allows_adults_and_minors if (!@allows_adults_and_minors.nil?)
169
+ json['minors'] = minors if (minors != {})
170
+
171
+ json['ageOfMajority'] = @age_of_majority if (!@age_of_majority.nil?)
172
+ json['participantLabel'] = @participant_label if (!@participant_label.nil?)
173
+ json['participatingText'] = @participating_text if (!@participating_text.nil?)
174
+
175
+ config = {}
176
+ config['middleName'] = @show_middle_name if (!@show_middle_name.nil?)
177
+ config['phone'] = @show_phone if (!@show_phone.nil?)
178
+ config['gender'] = @show_gender if (!@show_gender.nil?)
179
+ config['dobType'] = @dob_type if (!@dob_type.nil?)
180
+ json['config'] = config if (config != {})
181
+
182
+ json
183
+ end
184
+ end
185
+
186
+
187
+ class SmartwaiverTemplateStandardQuestions
188
+
189
+ attr_accessor :address_enabled, :address_required, :default_country_code, :default_state_code,
190
+ :email_verification_enabled, :email_marketing_enabled, :marketing_opt_in_text,
191
+ :marketing_opt_in_checked, :emergency_contact_enabled, :insurance_enabled, :id_card_enabled
192
+ def initialize()
193
+ @address_enabled = nil
194
+ @address_required = nil
195
+ @default_country_code = nil
196
+ @default_state_code = nil
197
+ @email_verification_enabled = nil
198
+ @email_marketing_enabled = nil
199
+ @marketing_opt_in_text = nil
200
+ @marketing_opt_in_checked = nil
201
+ @emergency_contact_enabled = nil
202
+ @insurance_enabled = nil
203
+ @id_card_enabled = nil
204
+ end
205
+
206
+ def for_json
207
+ json = {}
208
+ address = {}
209
+ address['enabled'] = @address_enabled if (!@address_enabled.nil?)
210
+ address['required'] = @address_required if (!@address_required.nil?)
211
+ defaults = {}
212
+ defaults['country'] = @default_country_code if (!@default_country_code.nil?)
213
+ defaults['state'] = @default_state_code if (!@default_state_code.nil?)
214
+ address['defaults'] = defaults if (defaults != {})
215
+ json['address'] = address if (address != {})
216
+
217
+ email = {}
218
+ email['verification'] = @email_verification_enabled if (!@email_verification_enabled.nil?)
219
+ email_marketing = {}
220
+ email_marketing['enabled'] = @email_marketing_enabled if (!@email_marketing_enabled.nil?)
221
+ email_marketing['optInText'] = @marketing_opt_in_text if (!@marketing_opt_in_text.nil?)
222
+ email_marketing['defaultChecked'] = @marketing_opt_in_checked if (!@marketing_opt_in_checked.nil?)
223
+ email['marketing'] = email_marketing if (email_marketing != {})
224
+ json['email'] = email if (email != {})
225
+
226
+ emergency_contact = {}
227
+ emergency_contact['enabled'] = @emergency_contact_enabled if (!@emergency_contact_enabled.nil?)
228
+ json['emergencyContact'] = emergency_contact if (emergency_contact != {})
229
+
230
+ insurance = {}
231
+ insurance['enabled'] = @insurance_enabled if (!@insurance_enabled.nil?)
232
+ json['insurance'] = emergency_contact if (emergency_contact != {})
233
+
234
+ id_card = {}
235
+ id_card['enabled'] = @id_card_enabled if (!@id_card_enabled.nil?)
236
+ json['idCard'] = id_card if (id_card != {})
237
+ json
238
+ end
239
+ end
240
+
241
+ class SmartwaiverTemplateGuardian
242
+
243
+ attr_accessor :verbiage, :verbiage_participant_addendum, :label, :relationship, :age_verification
244
+
245
+ def initialize()
246
+ @verbiage = nil
247
+ @verbiage_participant_addendum = nil
248
+ @label = nil
249
+ @relationship = nil
250
+ @age_verification = nil
251
+ end
252
+
253
+ def for_json
254
+ json = {}
255
+ json['verbiage'] = @verbiage if (!@verbiage.nil?)
256
+ json['verbiageParticipantAddendum'] = @verbiage_participant_addendum if (!@verbiage_participant_addendum.nil?)
257
+ json['label'] = @label if (!@label.nil?)
258
+ json['relationship'] = @relationship if (!@relationship.nil?)
259
+ json['ageVerification'] = @age_verification if (!@age_verification.nil?)
260
+ json
261
+ end
262
+ end
263
+
264
+ class SmartwaiverTemplateElectronicConsent
265
+
266
+ attr_accessor :title, :verbiage
267
+
268
+ def initialize()
269
+ @title = nil
270
+ @verbiage = nil
271
+ end
272
+
273
+ def for_json
274
+ json = {}
275
+ json['title'] = @title if (!@title.nil?)
276
+ json['verbiage'] = @verbiage if (!@verbiage.nil?)
277
+ json
278
+ end
279
+ end
280
+
281
+ class SmartwaiverTemplateStyling
282
+
283
+ attr_accessor :style, :custom_background_color, :custom_border_color, :custom_shadow_color
284
+
285
+ def initialize()
286
+ @style = nil
287
+ @custom_background_color = nil
288
+ @custom_border_color = nil
289
+ @custom_shadow_color = nil
290
+ end
291
+
292
+ def for_json
293
+ json = {}
294
+ json['style'] = @style if (!@style.nil?)
295
+
296
+ custom = {}
297
+ custom['background'] = @custom_background_color if (!@custom_background_color.nil?)
298
+ custom['border'] = @custom_border_color if (!@custom_border_color.nil?)
299
+ custom['shadow'] = @custom_shadow_color if (!@custom_shadow_color.nil?)
300
+ json['custom'] = custom if (custom != {})
301
+
302
+ json
303
+ end
304
+ end
305
+
306
+ class SmartwaiverTemplateCompletion
307
+
308
+ attr_accessor :redirect_success, :redirect_cancel
309
+
310
+ def initialize()
311
+ @redirect_success = nil
312
+ @redirect_cancel = nil
313
+ end
314
+
315
+ def for_json
316
+ json = {}
317
+ redirect = {}
318
+ redirect['success'] = @redirect_success if (!@redirect_success.nil?)
319
+ redirect['cancel'] = @redirect_cancel if (!@redirect_cancel .nil?)
320
+ json['redirect'] = redirect if (redirect != {})
321
+ json
322
+ end
323
+ end
324
+
325
+ class SmartwaiverTemplateSignatures
326
+
327
+ SIGNATURE_DRAW = 'draw'
328
+ SIGNATURE_TYPE = 'type'
329
+ SIGNATURE_CHOICE = 'choice'
330
+
331
+ attr_accessor :type, :minors, :default_choice
332
+
333
+ def initialize()
334
+ @type = nil
335
+ @minors = nil
336
+ @default_choice = nil
337
+ end
338
+
339
+ def for_json
340
+ json = {}
341
+ json['type'] = @type if (!@type.nil?)
342
+ json['minors'] = @minors if (!@minors.nil?)
343
+ json['defaultChoice'] = @default_choice if (!@default_choice.nil?)
344
+ json
345
+ end
346
+ end
347
+
348
+ class SmartwaiverTemplateProcessing
349
+
350
+ attr_accessor :email_business_name, :email_reply_to, :email_custom_text_enabled,
351
+ :email_custom_text_web, :email_cc_enabled, :email_cc_web_completed,
352
+ :email_cc_addresses, :include_bar_codes
353
+
354
+ def initialize()
355
+ @email_business_name = nil
356
+ @email_reply_to = nil
357
+ @email_custom_text_enabled = nil
358
+ @email_custom_text_web = nil
359
+ @email_cc_enabled = nil
360
+ @email_cc_web_completed = nil
361
+ @email_cc_addresses = nil
362
+ @include_bar_codes = nil
363
+ end
364
+
365
+ def for_json
366
+ json = {}
367
+ emails = {}
368
+
369
+ emails['businessName'] = @email_business_name if (!@email_business_name.nil?)
370
+ emails['replyTo'] = @email_reply_to if (!@email_reply_to.nil?)
371
+
372
+ customText = {}
373
+ customText['enabled'] = @email_custom_text_enabled if (!@email_custom_text_enabled.nil?)
374
+ customText['web'] = @email_custom_text_web if (!@email_custom_text_web.nil?)
375
+ emails['customText'] = customText if (customText != {})
376
+
377
+ cc = {}
378
+ cc['enabled'] = @email_cc_enabled if (!@email_cc_enabled.nil?)
379
+ cc['web'] = @email_cc_web_completed if (!@email_cc_web_completed.nil?)
380
+ cc['emails'] = @email_cc_addresses if (!@email_cc_addresses.nil?)
381
+ emails['cc'] = cc if (cc != {})
382
+
383
+ emails['includeBarcodes'] = @include_bar_codes if (!@include_bar_codes.nil?)
384
+ json['emails'] = emails if (emails != {})
385
+ json
386
+ end
387
+ end