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 +5 -5
- data/README.md +175 -0
- data/lib/smartwaiver-sdk/dynamic_template.rb +387 -0
- data/lib/smartwaiver-sdk/dynamic_template_client.rb +45 -0
- data/lib/smartwaiver-sdk/dynamic_template_data.rb +96 -0
- data/lib/smartwaiver-sdk/keys_client.rb +43 -0
- data/lib/smartwaiver-sdk/search_client.rb +64 -0
- data/lib/smartwaiver-sdk/smartwaiver_base.rb +10 -1
- data/lib/smartwaiver-sdk/smartwaiver_errors.rb +1 -1
- data/lib/smartwaiver-sdk/smartwaiver_version.rb +2 -2
- data/lib/smartwaiver-sdk/template_client.rb +1 -1
- data/lib/smartwaiver-sdk/user_client.rb +37 -0
- data/lib/smartwaiver-sdk/waiver_client.rb +11 -1
- data/lib/smartwaiver-sdk/webhook_client.rb +14 -2
- data/lib/smartwaiver-sdk/webhook_queues_client.rb +63 -0
- data/spec/smartwaiver-sdk/base_spec.rb +37 -0
- data/spec/smartwaiver-sdk/dynamic_template_data_spec.rb +139 -0
- data/spec/smartwaiver-sdk/dynamic_template_spec.rb +450 -0
- data/spec/smartwaiver-sdk/keys_client_spec.rb +41 -0
- data/spec/smartwaiver-sdk/search_client_spec.rb +55 -0
- data/spec/smartwaiver-sdk/user_client_spec.rb +30 -0
- data/spec/smartwaiver-sdk/waiver_client_spec.rb +34 -0
- data/spec/smartwaiver-sdk/webhook_client_spec.rb +17 -0
- data/spec/smartwaiver-sdk/webhook_queues_client_spec.rb +75 -0
- data/spec/spec_helper.rb +333 -1
- metadata +25 -6
@@ -0,0 +1,45 @@
|
|
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
|
+
|
18
|
+
class SmartwaiverDynamicTemplateClient < SmartwaiverSDK::SmartwaiverBase
|
19
|
+
|
20
|
+
def initialize(api_key, api_endpoint = DEFAULT_API_ENDPOINT)
|
21
|
+
super(api_key, api_endpoint)
|
22
|
+
@rest_endpoints = define_rest_endpoints
|
23
|
+
end
|
24
|
+
|
25
|
+
def create(template)
|
26
|
+
path = @rest_endpoints[:create]
|
27
|
+
json = {:dynamic => {:expiration => template.expiration, :template => template.template_config.for_json, :data => template.data.for_json}}.to_json
|
28
|
+
make_api_request(path, HTTP_POST, json)
|
29
|
+
end
|
30
|
+
|
31
|
+
def process(transaction_id)
|
32
|
+
path = "#{@rest_endpoints[:process]}/#{transaction_id}"
|
33
|
+
json = {}.to_json
|
34
|
+
make_api_request(path, HTTP_POST, json)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def define_rest_endpoints
|
40
|
+
{
|
41
|
+
:create => "/v4/dynamic/templates",
|
42
|
+
:process => "/v4/dynamic/process"
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,96 @@
|
|
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
|
+
|
18
|
+
class SmartwaiverDynamicTemplateData
|
19
|
+
|
20
|
+
attr_accessor :adult, :participants, :guardian
|
21
|
+
|
22
|
+
def initialize(adult = true)
|
23
|
+
@adult = adult
|
24
|
+
@participants = []
|
25
|
+
@guardian = SmartwaiverGuardian.new
|
26
|
+
end
|
27
|
+
|
28
|
+
def add_participant(participant)
|
29
|
+
@participants.push(participant)
|
30
|
+
end
|
31
|
+
|
32
|
+
def for_json
|
33
|
+
participants_for_json = []
|
34
|
+
@participants.each do |participant|
|
35
|
+
participants_for_json.push(participant.for_json)
|
36
|
+
end
|
37
|
+
{'adult' => @adult, 'participants' => participants_for_json, 'guardian' => @guardian.for_json}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class SmartwaiverParticipant
|
42
|
+
|
43
|
+
attr_accessor :first_name, :middle_name, :last_name, :phone, :gender, :dob
|
44
|
+
|
45
|
+
def initialize()
|
46
|
+
@first_name = nil
|
47
|
+
@middle_name = nil
|
48
|
+
@last_name = nil
|
49
|
+
@phone = nil
|
50
|
+
@gender = nil
|
51
|
+
@dob = nil
|
52
|
+
end
|
53
|
+
|
54
|
+
def for_json
|
55
|
+
json = {}
|
56
|
+
json['firstName'] = @first_name if (!@first_name.nil?)
|
57
|
+
json['middleName'] = @middle_name if (!@middle_name.nil?)
|
58
|
+
json['lastName'] = @last_name if (!@last_name.nil?)
|
59
|
+
json['phone'] = @phone if (!@phone.nil?)
|
60
|
+
json['gender'] = @gender if (!@gender.nil?)
|
61
|
+
json['dob'] = @dob if (!@dob.nil?)
|
62
|
+
json
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
class SmartwaiverGuardian
|
67
|
+
|
68
|
+
attr_accessor :participant, :first_name, :middle_name, :last_name, :relationship, :phone, :gender, :dob
|
69
|
+
|
70
|
+
def initialize(participant = false)
|
71
|
+
@participant = participant
|
72
|
+
@first_name = nil
|
73
|
+
@middle_name = nil
|
74
|
+
@last_name = nil
|
75
|
+
@relationship = nil
|
76
|
+
@phone = nil
|
77
|
+
@gender = nil
|
78
|
+
@dob = nil
|
79
|
+
end
|
80
|
+
|
81
|
+
def for_json
|
82
|
+
json = {}
|
83
|
+
json['participant'] = @participant if (!@participant.nil?)
|
84
|
+
json['firstName'] = @first_name if (!@first_name.nil?)
|
85
|
+
json['middleName'] = @middle_name if (!@middle_name.nil?)
|
86
|
+
json['lastName'] = @last_name if (!@last_name.nil?)
|
87
|
+
json['relationship'] = @relationship if (!@relationship.nil?)
|
88
|
+
json['phone'] = @phone if (!@phone.nil?)
|
89
|
+
json['gender'] = @gender if (!@gender.nil?)
|
90
|
+
json['dob'] = @dob if (!@dob.nil?)
|
91
|
+
json
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
|
@@ -0,0 +1,43 @@
|
|
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
|
+
|
18
|
+
class SmartwaiverKeysClient < SmartwaiverSDK::SmartwaiverBase
|
19
|
+
|
20
|
+
def initialize(api_key, api_endpoint = DEFAULT_API_ENDPOINT)
|
21
|
+
super(api_key, api_endpoint)
|
22
|
+
@rest_endpoints = define_rest_endpoints
|
23
|
+
end
|
24
|
+
|
25
|
+
def create(label)
|
26
|
+
path = @rest_endpoints[:published]
|
27
|
+
json = {:label => label}.to_json
|
28
|
+
make_api_request(path, HTTP_POST, json)
|
29
|
+
end
|
30
|
+
|
31
|
+
def list
|
32
|
+
path = @rest_endpoints[:published]
|
33
|
+
make_api_request(path, HTTP_GET)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def define_rest_endpoints
|
39
|
+
{
|
40
|
+
:published => "/v4/keys/published"
|
41
|
+
}
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,64 @@
|
|
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
|
+
|
18
|
+
class SmartwaiverSearchClient < SmartwaiverSDK::SmartwaiverBase
|
19
|
+
|
20
|
+
EMPTY_SEARCH_PARAMETER = ''
|
21
|
+
SEARCH_SORT_ASC = 'asc'
|
22
|
+
SEARCH_SORT_DESC = 'desc'
|
23
|
+
|
24
|
+
def initialize(api_key, api_endpoint = DEFAULT_API_ENDPOINT)
|
25
|
+
super(api_key, api_endpoint)
|
26
|
+
@rest_endpoints = define_rest_endpoints
|
27
|
+
end
|
28
|
+
|
29
|
+
def search(template_id = EMPTY_SEARCH_PARAMETER,
|
30
|
+
from_dts = EMPTY_SEARCH_PARAMETER,
|
31
|
+
to_dts = EMPTY_SEARCH_PARAMETER,
|
32
|
+
first_name = EMPTY_SEARCH_PARAMETER,
|
33
|
+
last_name = EMPTY_SEARCH_PARAMETER,
|
34
|
+
verified = EMPTY_SEARCH_PARAMETER,
|
35
|
+
sort = EMPTY_SEARCH_PARAMETER,
|
36
|
+
tag = EMPTY_SEARCH_PARAMETER)
|
37
|
+
|
38
|
+
qs = {}
|
39
|
+
qs[:templateId] = template_id if (template_id != EMPTY_SEARCH_PARAMETER)
|
40
|
+
qs[:fromDts] = from_dts if (from_dts != EMPTY_SEARCH_PARAMETER)
|
41
|
+
qs[:toDts] = to_dts if (to_dts != EMPTY_SEARCH_PARAMETER)
|
42
|
+
qs[:firstName] = first_name if (first_name != EMPTY_SEARCH_PARAMETER)
|
43
|
+
qs[:lastName] = last_name if (last_name != EMPTY_SEARCH_PARAMETER)
|
44
|
+
qs[:verified] = verified if (verified != EMPTY_SEARCH_PARAMETER)
|
45
|
+
qs[:sort] = sort if (sort != EMPTY_SEARCH_PARAMETER)
|
46
|
+
qs[:tag] = tag if (tag != EMPTY_SEARCH_PARAMETER)
|
47
|
+
|
48
|
+
path = @rest_endpoints[:search] + (qs != {} ? ('?' + create_query_string(qs)) : '')
|
49
|
+
make_api_request(path, HTTP_GET)
|
50
|
+
end
|
51
|
+
|
52
|
+
def results(search_guid, page = 0)
|
53
|
+
path = "#{@rest_endpoints[:search]}/#{search_guid}/results?page=#{page}"
|
54
|
+
make_api_request(path, HTTP_GET)
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def define_rest_endpoints
|
60
|
+
{
|
61
|
+
:search => "/v4/search"
|
62
|
+
}
|
63
|
+
end
|
64
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright
|
2
|
+
# Copyright 2018 Smartwaiver
|
3
3
|
#
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
5
5
|
# not use this file except in compliance with the License. You may obtain
|
@@ -28,6 +28,8 @@ module SmartwaiverSDK
|
|
28
28
|
HTTP_GET = "GET"
|
29
29
|
HTTP_POST = "POST"
|
30
30
|
HTTP_PUT = "PUT"
|
31
|
+
HTTP_DELETE = "DELETE"
|
32
|
+
|
31
33
|
|
32
34
|
def initialize(api_key, api_endpoint = DEFAULT_API_ENDPOINT)
|
33
35
|
@api_endpoint = api_endpoint
|
@@ -86,6 +88,9 @@ module SmartwaiverSDK
|
|
86
88
|
when HTTP_POST
|
87
89
|
headers = common_http_headers.merge(rest_post_headers)
|
88
90
|
response = @http.request_post(path, data, headers)
|
91
|
+
when HTTP_DELETE
|
92
|
+
headers = common_http_headers.merge(rest_post_headers)
|
93
|
+
response = @http.delete(path, headers)
|
89
94
|
end
|
90
95
|
check_response(response)
|
91
96
|
end
|
@@ -121,5 +126,9 @@ module SmartwaiverSDK
|
|
121
126
|
:type => ""
|
122
127
|
}
|
123
128
|
end
|
129
|
+
|
130
|
+
def create_query_string(params)
|
131
|
+
URI.encode_www_form(params)
|
132
|
+
end
|
124
133
|
end
|
125
134
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright
|
2
|
+
# Copyright 2018 Smartwaiver
|
3
3
|
#
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
5
5
|
# not use this file except in compliance with the License. You may obtain
|
@@ -14,7 +14,7 @@
|
|
14
14
|
# under the License.
|
15
15
|
|
16
16
|
module SmartwaiverSDK
|
17
|
-
VERSION = "4.
|
17
|
+
VERSION = "4.2.0"
|
18
18
|
|
19
19
|
class Info
|
20
20
|
@@ClientVersion = SmartwaiverSDK::VERSION
|
@@ -0,0 +1,37 @@
|
|
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
|
+
|
18
|
+
class SmartwaiverUserClient < SmartwaiverSDK::SmartwaiverBase
|
19
|
+
|
20
|
+
def initialize(api_key, api_endpoint = DEFAULT_API_ENDPOINT)
|
21
|
+
super(api_key, api_endpoint)
|
22
|
+
@rest_endpoints = define_rest_endpoints
|
23
|
+
end
|
24
|
+
|
25
|
+
def settings()
|
26
|
+
path = @rest_endpoints[:settings]
|
27
|
+
make_api_request(path, HTTP_GET)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def define_rest_endpoints
|
33
|
+
{
|
34
|
+
:settings => "/v4/settings"
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright
|
2
|
+
# Copyright 2018 Smartwaiver
|
3
3
|
#
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
5
5
|
# not use this file except in compliance with the License. You may obtain
|
@@ -44,6 +44,16 @@ class SmartwaiverWaiverClient < SmartwaiverSDK::SmartwaiverBase
|
|
44
44
|
make_api_request(path, HTTP_GET)
|
45
45
|
end
|
46
46
|
|
47
|
+
def photos(waiver_id)
|
48
|
+
path = "#{@rest_endpoints[:waivers]}/#{waiver_id}/photos"
|
49
|
+
make_api_request(path, HTTP_GET)
|
50
|
+
end
|
51
|
+
|
52
|
+
def signatures(waiver_id)
|
53
|
+
path = "#{@rest_endpoints[:waivers]}/#{waiver_id}/signatures"
|
54
|
+
make_api_request(path, HTTP_GET)
|
55
|
+
end
|
56
|
+
|
47
57
|
private
|
48
58
|
|
49
59
|
def define_rest_endpoints
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright
|
2
|
+
# Copyright 2018 Smartwaiver
|
3
3
|
#
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
5
5
|
# not use this file except in compliance with the License. You may obtain
|
@@ -37,11 +37,23 @@ class SmartwaiverWebhookClient < SmartwaiverSDK::SmartwaiverBase
|
|
37
37
|
make_api_request(path, HTTP_PUT, json)
|
38
38
|
end
|
39
39
|
|
40
|
+
def delete
|
41
|
+
path = @rest_endpoints[:configure]
|
42
|
+
make_api_request(path, HTTP_DELETE)
|
43
|
+
end
|
44
|
+
|
45
|
+
def resend(waiver_id)
|
46
|
+
path = "#{@rest_endpoints[:resend]}/#{waiver_id}"
|
47
|
+
json = {}.to_json
|
48
|
+
make_api_request(path, HTTP_PUT, json)
|
49
|
+
end
|
50
|
+
|
40
51
|
private
|
41
52
|
|
42
53
|
def define_rest_endpoints
|
43
54
|
{
|
44
|
-
:configure => "/v4/webhooks/configure"
|
55
|
+
:configure => "/v4/webhooks/configure",
|
56
|
+
:resend => "/v4/webhooks/resend"
|
45
57
|
}
|
46
58
|
end
|
47
59
|
end
|
@@ -0,0 +1,63 @@
|
|
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
|
+
|
18
|
+
class SmartwaiverWebhookQueuesClient < SmartwaiverSDK::SmartwaiverBase
|
19
|
+
|
20
|
+
WEBHOOK_AFTER_EMAIL_ONLY = 'yes'
|
21
|
+
WEBHOOK_BEFORE_EMAIL_ONLY = 'no'
|
22
|
+
WEBHOOK_BEFORE_AND_AFTER_EMAIL = 'both'
|
23
|
+
|
24
|
+
def initialize(api_key, api_endpoint = DEFAULT_API_ENDPOINT)
|
25
|
+
super(api_key, api_endpoint)
|
26
|
+
@rest_endpoints = define_rest_endpoints
|
27
|
+
end
|
28
|
+
|
29
|
+
def information
|
30
|
+
path = @rest_endpoints[:queues]
|
31
|
+
make_api_request(path, HTTP_GET)
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_message
|
35
|
+
path = @rest_endpoints[:account]
|
36
|
+
make_api_request(path, HTTP_GET)
|
37
|
+
end
|
38
|
+
|
39
|
+
def delete_message(message_id)
|
40
|
+
path = "#{@rest_endpoints[:account]}/#{message_id}"
|
41
|
+
make_api_request(path, HTTP_DELETE)
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_template_message(template_id)
|
45
|
+
path = "#{@rest_endpoints[:template]}/#{template_id}"
|
46
|
+
make_api_request(path, HTTP_GET)
|
47
|
+
end
|
48
|
+
|
49
|
+
def delete_template_message(template_id, message_id)
|
50
|
+
path = "#{@rest_endpoints[:template]}/#{template_id}/#{message_id}"
|
51
|
+
make_api_request(path, HTTP_DELETE)
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def define_rest_endpoints
|
57
|
+
{
|
58
|
+
:queues => "/v4/webhooks/queues",
|
59
|
+
:account => "/v4/webhooks/queues/account",
|
60
|
+
:template => "/v4/webhooks/queues/template"
|
61
|
+
}
|
62
|
+
end
|
63
|
+
end
|