signaturit-sdk 0.0.5 → 1.0.0
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.
- data/CHANGELOG.md +21 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +13 -8
- data/README.md +87 -82
- data/lib/signaturit_client.rb +112 -182
- data/signaturit-sdk.gemspec +4 -4
- data/test/test_signaturit_client.rb +23 -81
- metadata +7 -6
data/CHANGELOG.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
CHANGELOG
|
2
|
+
=========
|
3
|
+
|
4
|
+
* 1.0.0 (2016-01-20)
|
5
|
+
* updated all methods to use api v3
|
6
|
+
|
7
|
+
* 0.0.5 (2015-02-10)
|
8
|
+
* added send reminder for signature request method
|
9
|
+
* fixed a bug sending params
|
10
|
+
|
11
|
+
* 0.0.4 (2014-10-20)
|
12
|
+
* added cancel signature request
|
13
|
+
|
14
|
+
* 0.0.3 (2014-10-17)
|
15
|
+
* fixed a bug with ssl
|
16
|
+
|
17
|
+
* 0.0.2 (2014-09-16)
|
18
|
+
* added a new method to revert document storage
|
19
|
+
|
20
|
+
* 0.0.1 (2014-09-04)
|
21
|
+
* initial release
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,20 +1,25 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
addressable (2.
|
5
|
-
crack (0.4.
|
4
|
+
addressable (2.4.0)
|
5
|
+
crack (0.4.3)
|
6
6
|
safe_yaml (~> 1.0.0)
|
7
|
-
|
8
|
-
|
7
|
+
hashdiff (0.2.3)
|
8
|
+
netrc (0.7.9)
|
9
|
+
rest_client (1.8.3)
|
9
10
|
netrc (~> 0.7.7)
|
10
|
-
safe_yaml (1.0.
|
11
|
-
webmock (1.
|
11
|
+
safe_yaml (1.0.4)
|
12
|
+
webmock (1.22.6)
|
12
13
|
addressable (>= 2.3.6)
|
13
14
|
crack (>= 0.3.2)
|
15
|
+
hashdiff
|
14
16
|
|
15
17
|
PLATFORMS
|
16
18
|
ruby
|
17
19
|
|
18
20
|
DEPENDENCIES
|
19
|
-
rest_client (~> 1.7
|
20
|
-
webmock (~> 1.18
|
21
|
+
rest_client (~> 1.7)
|
22
|
+
webmock (~> 1.18)
|
23
|
+
|
24
|
+
BUNDLED WITH
|
25
|
+
1.11.2
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Signaturit Ruby SDK
|
2
2
|
===================
|
3
3
|
|
4
|
-
This package is a wrapper for Signaturit Api. If you didn't read the documentation yet, maybe it's time to take a look [here](
|
4
|
+
This package is a wrapper for Signaturit Api. If you didn't read the documentation yet, maybe it's time to take a look [here](https://docs.signaturit.com/).
|
5
5
|
|
6
6
|
You can install the package through gem.
|
7
7
|
|
@@ -42,37 +42,37 @@ Retrieve all data from your signature requests using different filters.
|
|
42
42
|
##### All signatures
|
43
43
|
|
44
44
|
```
|
45
|
-
response = client.get_signatures
|
45
|
+
response = client.get_signatures
|
46
46
|
```
|
47
47
|
|
48
48
|
##### Getting the last 50 signatures
|
49
49
|
|
50
50
|
```
|
51
|
-
response = client.get_signatures
|
51
|
+
response = client.get_signatures 50
|
52
52
|
```
|
53
53
|
|
54
54
|
##### Getting the following last 50 signatures
|
55
55
|
|
56
56
|
```
|
57
|
-
response = client.get_signatures
|
57
|
+
response = client.get_signatures 50, 50
|
58
58
|
```
|
59
59
|
|
60
|
-
##### Getting only the finished signatures
|
60
|
+
##### Getting only the finished signatures
|
61
61
|
|
62
62
|
```
|
63
|
-
response = client.get_signatures
|
63
|
+
response = client.get_signatures 100, 0, {:status => 'completed'}
|
64
64
|
```
|
65
65
|
|
66
66
|
##### Getting the finished signatures created since July 20th of 2014
|
67
67
|
|
68
68
|
```
|
69
|
-
response = client.get_signatures
|
69
|
+
response = client.get_signatures 100, 0, 3, {:since => '2014-7-20'}
|
70
70
|
```
|
71
71
|
|
72
72
|
##### Getting signatures with custom field "crm_id"
|
73
73
|
|
74
74
|
```
|
75
|
-
response = client.get_signatures
|
75
|
+
response = client.get_signatures 100, 0, {:crm_id => 2445}
|
76
76
|
```
|
77
77
|
|
78
78
|
### Count signature requests
|
@@ -80,7 +80,7 @@ response = client.get_signatures(100, 0, nil, nil, :crm_id => 2445)
|
|
80
80
|
Count your signature requests.
|
81
81
|
|
82
82
|
```
|
83
|
-
response = client.count_signatures
|
83
|
+
response = client.count_signatures
|
84
84
|
```
|
85
85
|
|
86
86
|
### Get signature request
|
@@ -88,34 +88,27 @@ response = client.count_signatures()
|
|
88
88
|
Get a single signature request.
|
89
89
|
|
90
90
|
```
|
91
|
-
response = client.get_signature
|
91
|
+
response = client.get_signature 'SIGNATURE_ID'
|
92
92
|
```
|
93
93
|
|
94
|
-
###
|
95
|
-
|
96
|
-
Get all documents from a signature request.
|
97
|
-
|
98
|
-
```
|
99
|
-
response = client.get_signature_documents('SIGNATURE_ID')
|
100
|
-
```
|
101
|
-
|
102
|
-
### Get signature document
|
94
|
+
### Signature request
|
103
95
|
|
104
|
-
|
96
|
+
Create a new signature request. You can check all signature [params](https://docs.signaturit.com/api/v3#sign_create_sign).
|
105
97
|
|
106
98
|
```
|
107
|
-
|
99
|
+
recipients = ['bobsoap@signatur.it']
|
100
|
+
params = {:subject: 'Receipt number 250', :body: 'Please, can you sign this document?'}
|
101
|
+
file_path = '/documents/contracts/125932_important.pdf'
|
102
|
+
response = client.create_signature file_path, recipients, params
|
108
103
|
```
|
109
104
|
|
110
|
-
|
111
|
-
|
112
|
-
Create a new signature request. Check all [params](http://docs.signaturit.com/api/#sign_create_sign).
|
105
|
+
You can send templates with the fields filled
|
113
106
|
|
114
107
|
```
|
115
108
|
recipients = ['bobsoap@signatur.it']
|
116
|
-
params = {:subject
|
117
|
-
|
118
|
-
response = client.
|
109
|
+
params = {:subject => 'Receipt number 250', :body => 'Please, can you sign this document?', :templates => {'TEMPLATE_ID'}, :data => {:WIDGET_ID => 'DEFAULT_VALUE'}}
|
110
|
+
|
111
|
+
response = client.create_signature {}, recipients, params
|
119
112
|
```
|
120
113
|
|
121
114
|
You can add custom info in your requests
|
@@ -124,7 +117,7 @@ You can add custom info in your requests
|
|
124
117
|
recipients = ['bobsoap@signatur.it']
|
125
118
|
params = {:subject => 'Receipt number 250', :body => 'Please, can you sign this document?', :data => {:crm_id => 2445}}
|
126
119
|
file_path = '/documents/contracts/125932_important.pdf'
|
127
|
-
response = client.
|
120
|
+
response = client.create_signature file_path, recipients, params
|
128
121
|
```
|
129
122
|
|
130
123
|
### Cancel signature request
|
@@ -132,7 +125,7 @@ response = client.create_signature_request(file_path, recipients, params)
|
|
132
125
|
Cancel a signature request.
|
133
126
|
|
134
127
|
```
|
135
|
-
response = client.
|
128
|
+
response = client.cancel_signature 'SIGNATURE_ID'
|
136
129
|
```
|
137
130
|
|
138
131
|
### Send reminder
|
@@ -140,123 +133,135 @@ response = client.cancel_signature_request('SIGNATURE_ID');
|
|
140
133
|
Send a reminder for signature request job.
|
141
134
|
|
142
135
|
```
|
143
|
-
response = client.
|
136
|
+
response = client.send_signature_reminder 'SIGNATURE_ID'
|
144
137
|
```
|
145
138
|
|
146
139
|
### Get audit trail
|
147
140
|
|
148
|
-
Get the audit trail of a signature request document
|
141
|
+
Get the audit trail of a signature request document
|
149
142
|
|
150
143
|
```
|
151
|
-
response = client.
|
144
|
+
response = client.download_audit_trail 'ID', 'DOCUMENT_ID'
|
152
145
|
```
|
153
146
|
|
154
147
|
### Get signed document
|
155
148
|
|
156
|
-
Get the signed document of a signature request document
|
149
|
+
Get the signed document of a signature request document
|
157
150
|
|
158
151
|
```
|
159
|
-
response = client.
|
152
|
+
response = client.download_signed_document 'ID', 'DOCUMENT_ID'
|
160
153
|
```
|
161
154
|
|
162
|
-
##
|
155
|
+
## Branding
|
156
|
+
|
157
|
+
### Get brandings
|
158
|
+
|
159
|
+
Get all account brandings.
|
160
|
+
|
161
|
+
```
|
162
|
+
response = client.get_brandings
|
163
|
+
```
|
163
164
|
|
164
|
-
### Get
|
165
|
+
### Get branding
|
165
166
|
|
166
|
-
|
167
|
+
Get a single branding.
|
167
168
|
|
168
169
|
```
|
169
|
-
response = client.
|
170
|
+
response = client.get_branding 'BRANDING_ID'
|
170
171
|
```
|
171
172
|
|
172
|
-
###
|
173
|
+
### Create branding
|
173
174
|
|
174
|
-
|
175
|
+
Create a new branding. You can check all branding [params](https://docs.signaturit.com/api/v3#set_branding).`
|
175
176
|
|
176
177
|
```
|
177
|
-
|
178
|
-
:
|
179
|
-
:
|
180
|
-
:
|
181
|
-
:host: 'john.doe.server',
|
182
|
-
:password: 'XXX',
|
183
|
-
:auth_method: 'PASS'
|
178
|
+
params = {
|
179
|
+
:layout_color: '#FFBF00',
|
180
|
+
:text_color: '#2A1B0A',
|
181
|
+
:application_texts: { :sign_button: 'Sign!' }
|
184
182
|
}
|
185
|
-
response = client.
|
183
|
+
response = client.create_branding params
|
186
184
|
```
|
187
185
|
|
188
|
-
###
|
186
|
+
### Update branding
|
189
187
|
|
190
|
-
|
188
|
+
Update a single branding.
|
191
189
|
|
192
190
|
```
|
193
|
-
|
191
|
+
params = { :application_texts: { :send_button: 'Send!' } }
|
192
|
+
response = client.update_branding 'BRANDING_ID', params
|
194
193
|
```
|
195
194
|
|
196
|
-
##
|
195
|
+
## Template
|
197
196
|
|
198
|
-
### Get
|
197
|
+
### Get all templates
|
199
198
|
|
200
|
-
|
199
|
+
Retrieve all data from your templates.
|
201
200
|
|
202
201
|
```
|
203
|
-
response = client.
|
202
|
+
response = client.get_templates
|
204
203
|
```
|
205
204
|
|
206
|
-
|
205
|
+
## Email
|
207
206
|
|
208
|
-
Get
|
207
|
+
### Get emails
|
208
|
+
|
209
|
+
####Get all certified emails
|
209
210
|
|
210
211
|
```
|
211
|
-
response = client.
|
212
|
+
response = client.get_emails
|
212
213
|
```
|
213
214
|
|
214
|
-
|
215
|
+
####Get last 50 emails
|
216
|
+
|
217
|
+
```
|
218
|
+
response = client.get_emails 50
|
219
|
+
```
|
215
220
|
|
216
|
-
|
221
|
+
####Navigate through all emails in blocks of 50 results
|
217
222
|
|
218
223
|
```
|
219
|
-
|
220
|
-
:corporate_layout_color: '#FFBF00',
|
221
|
-
:corporate_text_color: '#2A1B0A',
|
222
|
-
:application_texts: { :sign_button: 'Sign!' }
|
223
|
-
}
|
224
|
-
response = client.create_branding(params)
|
224
|
+
response = client.get_emails 50, 50
|
225
225
|
```
|
226
226
|
|
227
|
-
###
|
227
|
+
### Count emails
|
228
228
|
|
229
|
-
|
229
|
+
Count all certified emails
|
230
230
|
|
231
231
|
```
|
232
|
-
|
233
|
-
response = client.update_branding('BRANDING_ID', params)
|
232
|
+
response = client.count_emails
|
234
233
|
```
|
235
234
|
|
236
|
-
###
|
235
|
+
### Get email
|
237
236
|
|
238
|
-
|
237
|
+
Get a single email
|
239
238
|
|
240
239
|
```
|
241
|
-
|
242
|
-
response = client.update_branding_logo('BRANDING_ID', file_path)
|
240
|
+
client.get_email 'EMAIL_ID'
|
243
241
|
```
|
244
242
|
|
245
|
-
###
|
243
|
+
### Create email
|
246
244
|
|
247
|
-
|
245
|
+
Create a new certified email.
|
248
246
|
|
249
247
|
```
|
250
|
-
file_path
|
251
|
-
|
248
|
+
file_path = '/path/document.pdf'
|
249
|
+
recipients = [{:name => 'Mr John', :email => 'john.doe@signaturit.com'}]
|
250
|
+
response = client.create_email file_path, recipients, 'ruby subject', 'ruby body', {}
|
252
251
|
```
|
253
252
|
|
254
|
-
|
253
|
+
### Get original file
|
255
254
|
|
256
|
-
|
255
|
+
Get the original document of an email request
|
257
256
|
|
258
|
-
|
257
|
+
```
|
258
|
+
response = client.download_email_original_file 'EMAIL_ID','CERTIFICATE_ID'
|
259
|
+
```
|
260
|
+
|
261
|
+
### Get audit trail document
|
262
|
+
|
263
|
+
Get the audit trail document of an email request
|
259
264
|
|
260
265
|
```
|
261
|
-
response = client.
|
266
|
+
response = client.download_email_audit_trail 'EMAIL_ID','CERTIFICATE_ID'
|
262
267
|
```
|
data/lib/signaturit_client.rb
CHANGED
@@ -9,46 +9,9 @@ class SignaturitClient
|
|
9
9
|
|
10
10
|
# Initialize the object with the token and environment
|
11
11
|
def initialize(token, production = false)
|
12
|
-
base = production ? 'https://api.signaturit.com' : '
|
12
|
+
base = production ? 'https://api.signaturit.com' : 'https://api.sandbox.signaturit.com'
|
13
13
|
|
14
|
-
@client = RestClient::Resource.new base, :headers => { :Authorization => "Bearer #{token}", :user_agent => 'signaturit-ruby-sdk 0.0
|
15
|
-
end
|
16
|
-
|
17
|
-
# get info from your account
|
18
|
-
def get_account
|
19
|
-
request :get, '/v2/account.json'
|
20
|
-
end
|
21
|
-
|
22
|
-
# Set the credentials in account, in order to store a copy from all documents
|
23
|
-
#
|
24
|
-
# Params:
|
25
|
-
# +type+:: Type of storage, sftp or s3
|
26
|
-
# +params+:: An array with credentials data
|
27
|
-
# sftp:
|
28
|
-
# - host: Your host
|
29
|
-
# - port: Connection port
|
30
|
-
# - dir: Directory where store the files
|
31
|
-
# - user: Username
|
32
|
-
# - auth_method: KEY or PASS
|
33
|
-
# pass:
|
34
|
-
# - password: Password
|
35
|
-
# key:
|
36
|
-
# - private: Private key
|
37
|
-
# - public: Public key
|
38
|
-
# - passphrase: The passphrase
|
39
|
-
# s3:
|
40
|
-
# - bucket: Name of bucket
|
41
|
-
# - key: S3 key
|
42
|
-
# - secret: S3 secret
|
43
|
-
def set_document_storage(type, params)
|
44
|
-
params[:type] = type
|
45
|
-
|
46
|
-
request :post, '/v2/account/storage.json', params
|
47
|
-
end
|
48
|
-
|
49
|
-
# Revert the document storage to the signaturit's default
|
50
|
-
def revert_to_default_document_storage
|
51
|
-
request :delete, '/v2/account/storage.json'
|
14
|
+
@client = RestClient::Resource.new base, :headers => { :Authorization => "Bearer #{token}", :user_agent => 'signaturit-ruby-sdk 1.0.0' }, :ssl_version => :TLSv1_2
|
52
15
|
end
|
53
16
|
|
54
17
|
# Get a concrete signature object
|
@@ -56,7 +19,7 @@ class SignaturitClient
|
|
56
19
|
# Params:
|
57
20
|
# +signature_id+:: The id of the signature object
|
58
21
|
def get_signature(signature_id)
|
59
|
-
request :get, "/
|
22
|
+
request :get, "/v3/signatures/#{signature_id}.json"
|
60
23
|
end
|
61
24
|
|
62
25
|
# Get a list of signature objects
|
@@ -64,64 +27,24 @@ class SignaturitClient
|
|
64
27
|
# Params:
|
65
28
|
# +limit+:: Maximum number of results to return
|
66
29
|
# +offset+:: Offset of results to skip
|
67
|
-
# +
|
68
|
-
|
69
|
-
|
70
|
-
def get_signatures(limit = 100, offset = 0, status = nil, since = nil, data = nil)
|
71
|
-
params = { :limit => limit, :offset => offset }
|
30
|
+
# +conditions+:: Filter conditions
|
31
|
+
def get_signatures(limit = 100, offset = 0, conditions = {})
|
32
|
+
params = extract_query_params conditions
|
72
33
|
|
73
|
-
params[
|
74
|
-
params[
|
34
|
+
params['limit'] = limit
|
35
|
+
params['offset'] = offset
|
75
36
|
|
76
|
-
|
77
|
-
data.each do |key, value|
|
78
|
-
new_key = "data.#{key}"
|
79
|
-
|
80
|
-
params[new_key] = value
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
request :get, '/v2/signs.json', params
|
37
|
+
request :get, "/v3/signatures.json", params
|
85
38
|
end
|
86
39
|
|
87
40
|
# Get the number of signature objects
|
88
41
|
#
|
89
42
|
# Params:
|
90
|
-
# +
|
91
|
-
|
92
|
-
|
93
|
-
def count_signatures(status = nil, since = nil, data = nil)
|
94
|
-
params = {}
|
95
|
-
|
96
|
-
params[:status] = status unless status.nil?
|
97
|
-
params[:since] = since unless since.nil?
|
98
|
-
|
99
|
-
if data
|
100
|
-
data.each do |key, value|
|
101
|
-
new_key = "data.#{key}"
|
102
|
-
|
103
|
-
params[new_key] = value
|
104
|
-
end
|
105
|
-
end
|
43
|
+
# +conditions+:: Filter conditions
|
44
|
+
def count_signatures(conditions = {})
|
45
|
+
params = extract_query_params conditions
|
106
46
|
|
107
|
-
request :get,
|
108
|
-
end
|
109
|
-
|
110
|
-
# Get a concrete document from a concrete Signature
|
111
|
-
#
|
112
|
-
# Params:
|
113
|
-
# +signature_id+:: The id of the signature object
|
114
|
-
# +document_id+:: The id of the document object
|
115
|
-
def get_signature_document(signature_id, document_id)
|
116
|
-
request :get, "/v2/signs/#{signature_id}/documents/#{document_id}.json"
|
117
|
-
end
|
118
|
-
|
119
|
-
# Get all documents in the given signature object
|
120
|
-
#
|
121
|
-
# Params:
|
122
|
-
# +signature_id+:: The id of the signature object
|
123
|
-
def get_signature_documents(signature_id)
|
124
|
-
request :get, "/v2/signs/#{signature_id}/documents.json"
|
47
|
+
request :get, "/v3/signatures/count.json", params
|
125
48
|
end
|
126
49
|
|
127
50
|
# Get the audit trail of concrete document
|
@@ -129,15 +52,8 @@ class SignaturitClient
|
|
129
52
|
# Params:
|
130
53
|
# +signature_id++:: The id of the signature object
|
131
54
|
# +document_id++:: The id of the document object
|
132
|
-
|
133
|
-
|
134
|
-
response = request :get, "/v2/signs/#{signature_id}/documents/#{document_id}/download/doc_proof", {}, false
|
135
|
-
|
136
|
-
File.open(path, 'wb') do |file|
|
137
|
-
file.write(response)
|
138
|
-
end
|
139
|
-
|
140
|
-
nil
|
55
|
+
def download_audit_trail(signature_id, document_id)
|
56
|
+
request :get, "/v3/signatures/#{signature_id}/documents/#{document_id}/download/audit_trail", {}, false
|
141
57
|
end
|
142
58
|
|
143
59
|
# Get the signed document
|
@@ -145,15 +61,8 @@ class SignaturitClient
|
|
145
61
|
# Params:
|
146
62
|
# +signature_id++:: The id of the signature object
|
147
63
|
# +document_id++:: The id of the document object
|
148
|
-
|
149
|
-
|
150
|
-
response = request :get, "/v2/signs/#{signature_id}/documents/#{document_id}/download/signed", {}, false
|
151
|
-
|
152
|
-
File.open(path, 'wb') do |file|
|
153
|
-
file.write(response)
|
154
|
-
end
|
155
|
-
|
156
|
-
nil
|
64
|
+
def download_signed_document(signature_id, document_id)
|
65
|
+
request :get, "/v3/signatures/#{signature_id}/documents/#{document_id}/download/signed", {}, false
|
157
66
|
end
|
158
67
|
|
159
68
|
# Create a new Signature request
|
@@ -164,47 +73,36 @@ class SignaturitClient
|
|
164
73
|
# {:name => "a name", :email => "me@domain.com", :phone => "34655123456"}
|
165
74
|
# or an array of hashes.
|
166
75
|
# +params+:: An array of parameters for the signature object
|
167
|
-
|
168
|
-
# - body: Body of the email
|
169
|
-
# - in_person: If you want to do an in person sign (system will not send
|
170
|
-
# an email to the user, but return the signature url instead)
|
171
|
-
# - sequential: If you want to do a sequential sign (for multiple
|
172
|
-
# recipients, the sign goes in sequential way)
|
173
|
-
# - photo: If a photo is required in sign process
|
174
|
-
# - mandatory_pages: An array with the pages the signer must sign
|
175
|
-
# - branding_id: The id of the branding you want to use
|
176
|
-
# - templates: An array ot template ids to use.
|
177
|
-
def create_signature_request(filepath, recipients, params = {})
|
76
|
+
def create_signature(filepath, recipients, params = {})
|
178
77
|
params[:recipients] = {}
|
179
78
|
|
180
|
-
[recipients].flatten
|
79
|
+
[recipients].flatten.each_with_index do |recipient, index|
|
181
80
|
params[:recipients][index] = recipient
|
182
81
|
end
|
183
82
|
|
184
|
-
params[:files] = [filepath].flatten
|
83
|
+
params[:files] = [filepath].flatten.map do |filepath|
|
185
84
|
File.new(filepath, 'rb')
|
186
85
|
end
|
187
86
|
|
188
|
-
params[:templates] = [params[:templates]].flatten
|
87
|
+
params[:templates] = [params[:templates]].flatten if params[:templates]
|
189
88
|
|
190
|
-
request :post,
|
89
|
+
request :post, "/v3/signatures.json", params
|
191
90
|
end
|
192
91
|
|
193
92
|
# Cancel a signature request
|
194
93
|
#
|
195
94
|
# Params
|
196
95
|
# +signature_id++:: The id of the signature object
|
197
|
-
def
|
198
|
-
request :patch, "/
|
96
|
+
def cancel_signature(signature_id)
|
97
|
+
request :patch, "/v3/signatures/#{signature_id}/cancel.json"
|
199
98
|
end
|
200
99
|
|
201
100
|
# Send a reminder for the given signature request document
|
202
101
|
#
|
203
102
|
# Param
|
204
103
|
# +signature_id++:: The id of the signature object
|
205
|
-
|
206
|
-
|
207
|
-
request :post, "/v2/signs/#{signature_id}/documents/#{document_id}/reminder.json"
|
104
|
+
def send_signature_reminder(signature_id)
|
105
|
+
request :post, "/v3/signatures/#{signature_id}/reminder.json"
|
208
106
|
end
|
209
107
|
|
210
108
|
# Get a concrete branding
|
@@ -212,52 +110,20 @@ class SignaturitClient
|
|
212
110
|
# Params
|
213
111
|
# +branding_id+:: The id of the branding object
|
214
112
|
def get_branding(branding_id)
|
215
|
-
request :get, "/
|
113
|
+
request :get, "/v3/brandings/#{branding_id}.json"
|
216
114
|
end
|
217
115
|
|
218
116
|
# Get all account brandings
|
219
117
|
def get_brandings
|
220
|
-
request :get,
|
118
|
+
request :get, "/v3/brandings.json"
|
221
119
|
end
|
222
120
|
|
223
121
|
# Create a new branding
|
224
122
|
#
|
225
123
|
# Params:
|
226
124
|
# +params+:: An array of parameters for the branding object
|
227
|
-
# - primary: If set, this new branding will be the default one
|
228
|
-
# - corporate_layout_color: Default color for all application widgets
|
229
|
-
# - corporate_text_color: Default text color for all application widgets
|
230
|
-
# - application_texts: A dict with the new text values
|
231
|
-
# - sign_button: Text for sign button
|
232
|
-
# - send_button: Text for send button
|
233
|
-
# - decline_button: Text for decline button:
|
234
|
-
# - decline_modal_title: Title for decline modal
|
235
|
-
# - decline_modal_body: Body for decline modal
|
236
|
-
# - photo: Photo message text, which tells the user that a photo is
|
237
|
-
# needed in the current process
|
238
|
-
# - multi_pages: Header of the document, which tells the user the
|
239
|
-
# number of pages to sign
|
240
|
-
# - subject_tag: This tag appears at the subject of all your messages
|
241
|
-
# - reminders: A list with reminder times (in seconds). Every reminder
|
242
|
-
# time, a email will be sent, if the signer didn't sign the document
|
243
|
-
# - expire_time: The signature time (in seconds). When the expire time is
|
244
|
-
# over, the document cannot be signed. Set 0 if you want a signature
|
245
|
-
# without expire time.
|
246
|
-
# - callback_url: A url to redirect the user, when the process is over.
|
247
|
-
# - signature_pos_x: Default position x of signature
|
248
|
-
# - signature_pos_y: Default position y of signature
|
249
|
-
# - terms_and_conditions_label: The terms text that appears when you need
|
250
|
-
# to check the button to accept.
|
251
|
-
# - terms_and_conditions_body: Custom text that appears below signature
|
252
|
-
# conditions
|
253
|
-
# - hide_legal_section: If true, legal section in email footer doesn't
|
254
|
-
# appear
|
255
|
-
# - hide_info_section: If true, info section in email footer doesn't
|
256
|
-
# appear
|
257
|
-
# - hide_contact_section: If true, contact section in email footer
|
258
|
-
# doesn't appear
|
259
125
|
def create_branding(params)
|
260
|
-
request :post,
|
126
|
+
request :post, "/v3/brandings.json", params
|
261
127
|
end
|
262
128
|
|
263
129
|
# Update a existing branding
|
@@ -266,48 +132,111 @@ class SignaturitClient
|
|
266
132
|
# +branding_id+:: Id of the branding to update
|
267
133
|
# +params+:: Same params as method create_branding, see above
|
268
134
|
def update_branding(branding_id, params)
|
269
|
-
request :patch, "/
|
135
|
+
request :patch, "/v3/brandings/#{branding_id}.json", params
|
270
136
|
end
|
271
137
|
|
272
|
-
#
|
138
|
+
# Get a list of template objects
|
273
139
|
#
|
274
140
|
# Params:
|
275
|
-
# +
|
276
|
-
# +
|
277
|
-
def
|
278
|
-
|
141
|
+
# +limit+:: Maximum number of results to return
|
142
|
+
# +offset+:: Offset of results to skip
|
143
|
+
def get_templates(limit = 100, offset = 0)
|
144
|
+
params = { :limit => limit, :offset => offset }
|
145
|
+
|
146
|
+
request :get, "/v3/templates.json", params
|
279
147
|
end
|
280
148
|
|
281
|
-
#
|
149
|
+
# Get all emails
|
282
150
|
#
|
283
151
|
# Params:
|
284
|
-
# +
|
285
|
-
# +
|
286
|
-
# +
|
287
|
-
def
|
288
|
-
|
152
|
+
# +limit+:: Maximum number of results to return
|
153
|
+
# +offset+:: Offset of results to skip
|
154
|
+
# +conditions+:: Query conditions
|
155
|
+
def get_emails(limit = 100, offset = 0, conditions = {})
|
156
|
+
params = extract_query_params conditions
|
157
|
+
|
158
|
+
params['limit'] = limit
|
159
|
+
params['offset'] = offset
|
160
|
+
|
161
|
+
request :get, "/v3/emails.json", params
|
289
162
|
end
|
290
163
|
|
291
|
-
#
|
164
|
+
# Count all emails
|
292
165
|
#
|
293
166
|
# Params:
|
294
|
-
# +
|
295
|
-
|
296
|
-
|
297
|
-
params = { :limit => limit, :offset => offset }
|
167
|
+
# +conditions+:: Query conditions
|
168
|
+
def count_emails(conditions = {})
|
169
|
+
params = extract_query_params conditions
|
298
170
|
|
299
|
-
request :get,
|
171
|
+
request :get, "/v3/emails/count.json", params
|
300
172
|
end
|
301
173
|
|
302
|
-
#
|
174
|
+
# Get a single email
|
175
|
+
#
|
176
|
+
# Params:
|
177
|
+
# +email_id+:: Id of email
|
178
|
+
def get_email(email_id)
|
179
|
+
request :get, "/v3/emails/#{email_id}.json"
|
180
|
+
end
|
181
|
+
|
182
|
+
# Create a new email
|
183
|
+
#
|
184
|
+
# Params:
|
185
|
+
# +files+:: File or files to send with the email
|
186
|
+
# +recipients+:: Recipients for the email
|
187
|
+
# +subject+:: Email subject
|
188
|
+
# +body+:: Email body
|
189
|
+
# +params+:: Extra params
|
190
|
+
def create_email(files, recipients, subject, body, params = {})
|
191
|
+
params[:recipients] = {}
|
192
|
+
|
193
|
+
[recipients].flatten.each_with_index do |recipient, index|
|
194
|
+
params[:recipients][index] = recipient
|
195
|
+
end
|
303
196
|
|
197
|
+
params[:files] = [files].flatten.map do |filepath|
|
198
|
+
File.new(filepath, 'rb')
|
199
|
+
end
|
200
|
+
|
201
|
+
params[:subject] = subject
|
202
|
+
params[:body] = body
|
203
|
+
|
204
|
+
request :post, "/v3/emails.json", params
|
205
|
+
end
|
206
|
+
|
207
|
+
# Get the audit trail of concrete certificate
|
208
|
+
#
|
209
|
+
# Params:
|
210
|
+
# +email_id++:: The id of the signature object
|
211
|
+
# +certificate_id++:: The id of the document object
|
212
|
+
def download_email_audit_trail(email_id, certificate_id)
|
213
|
+
request :get, "/v3/emails/#{email_id}/certificates/#{certificate_id}/download/audit_trail", {}, false
|
214
|
+
end
|
215
|
+
|
216
|
+
# PRIVATE METHODS FROM HERE
|
304
217
|
private
|
305
218
|
|
219
|
+
# Parse query parameters
|
220
|
+
def extract_query_params(conditions)
|
221
|
+
params = {}
|
222
|
+
|
223
|
+
conditions.each do |key, value|
|
224
|
+
if key == 'ids'
|
225
|
+
value = value.join(',')
|
226
|
+
end
|
227
|
+
|
228
|
+
params[key] = value
|
229
|
+
end
|
230
|
+
|
231
|
+
params
|
232
|
+
end
|
233
|
+
|
306
234
|
# Common request method
|
307
235
|
def request(method, path, params = {}, to_json = true)
|
308
236
|
case method
|
309
237
|
when :get, :delete
|
310
238
|
encoded = URI.encode_www_form(params)
|
239
|
+
|
311
240
|
path = "#{path}?#{encoded}" if encoded.length > 0
|
312
241
|
|
313
242
|
body = @client[path].send method
|
@@ -320,4 +249,5 @@ class SignaturitClient
|
|
320
249
|
|
321
250
|
body
|
322
251
|
end
|
252
|
+
|
323
253
|
end
|
data/signaturit-sdk.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.platform = Gem::Platform::RUBY
|
3
3
|
s.name = 'signaturit-sdk'
|
4
|
-
s.version = '0.0
|
5
|
-
s.date = '
|
4
|
+
s.version = '1.0.0'
|
5
|
+
s.date = '2016-01-20'
|
6
6
|
s.summary = 'Signaturit Ruby SDK'
|
7
7
|
s.description = 'Sign Documents Online'
|
8
8
|
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
|
16
16
|
s.license = 'MIT'
|
17
17
|
|
18
|
-
s.add_dependency 'rest_client', '~> 1.7
|
18
|
+
s.add_dependency 'rest_client', '~> 1.7'
|
19
19
|
|
20
|
-
s.add_development_dependency 'webmock', '~> 1.18
|
20
|
+
s.add_development_dependency 'webmock', '~> 1.18'
|
21
21
|
end
|
@@ -12,36 +12,12 @@ class TestSignaturitClient < Test::Unit::TestCase
|
|
12
12
|
@client = SignaturitClient.new TOKEN, true
|
13
13
|
end
|
14
14
|
|
15
|
-
def test_get_account
|
16
|
-
stub_request(:any, /.*/).to_return(:body => '{}')
|
17
|
-
|
18
|
-
@client.get_account()
|
19
|
-
|
20
|
-
assert_requested :get, 'https://api.signaturit.com/v2/account.json', :headers => { :Authorization => 'Bearer a_token' }
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_set_document_storage
|
24
|
-
stub_request(:any, /.*/).to_return(:body => '{}')
|
25
|
-
|
26
|
-
@client.set_document_storage('sftp', {})
|
27
|
-
|
28
|
-
assert_requested :post, 'https://api.signaturit.com/v2/account/storage.json', :headers => { :Authorization => 'Bearer a_token' }
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_revert_to_default_document_storage
|
32
|
-
stub_request(:any, /.*/).to_return(:body => '{}')
|
33
|
-
|
34
|
-
@client.revert_to_default_document_storage()
|
35
|
-
|
36
|
-
assert_requested :delete, 'https://api.signaturit.com/v2/account/storage.json', :headers => { :Authorization => 'Bearer a_token' }
|
37
|
-
end
|
38
|
-
|
39
15
|
def test_get_signature
|
40
16
|
stub_request(:any, /.*/).to_return(:body => '{}')
|
41
17
|
|
42
18
|
@client.get_signature 'an_id'
|
43
19
|
|
44
|
-
assert_requested :get, 'https://api.signaturit.com/
|
20
|
+
assert_requested :get, 'https://api.signaturit.com/v3/signatures/an_id.json', :headers => { :Authorization => 'Bearer a_token' }
|
45
21
|
end
|
46
22
|
|
47
23
|
def test_get_signatures
|
@@ -49,47 +25,32 @@ class TestSignaturitClient < Test::Unit::TestCase
|
|
49
25
|
|
50
26
|
@client.get_signatures(5, 10)
|
51
27
|
|
52
|
-
assert_requested :get, 'https://api.signaturit.com/
|
28
|
+
assert_requested :get, 'https://api.signaturit.com/v3/signatures.json?limit=5&offset=10', :headers => { :Authorization => 'Bearer a_token' }
|
53
29
|
end
|
54
30
|
|
55
31
|
def test_count_signatures
|
56
32
|
stub_request(:any, /.*/).to_return(:body => '{}')
|
57
33
|
|
58
|
-
@client.count_signatures('signed', '1982-07-27')
|
34
|
+
@client.count_signatures({:status => 'signed', :since =>'1982-07-27'})
|
59
35
|
|
60
|
-
assert_requested :get, 'https://api.signaturit.com/
|
36
|
+
assert_requested :get, 'https://api.signaturit.com/v3/signatures/count.json?status=signed&since=1982-07-27', :headers => { :Authorization => 'Bearer a_token' }
|
61
37
|
end
|
62
38
|
|
63
|
-
def test_get_signature_document
|
64
|
-
stub_request(:any, /.*/).to_return(:body => '{}')
|
65
|
-
|
66
|
-
@client.get_signature_document('an_id', 'another_id')
|
67
|
-
|
68
|
-
assert_requested :get, 'https://api.signaturit.com/v2/signs/an_id/documents/another_id.json', :headers => { :Authorization => 'Bearer a_token' }
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_get_signature_documents
|
72
|
-
stub_request(:any, /.*/).to_return(:body => '[]')
|
73
|
-
|
74
|
-
@client.get_signature_documents('an_id')
|
75
|
-
|
76
|
-
assert_requested :get, 'https://api.signaturit.com/v2/signs/an_id/documents.json', :headers => { :Authorization => 'Bearer a_token' }
|
77
|
-
end
|
78
39
|
|
79
40
|
def test_get_audit_trail
|
80
41
|
stub_request(:any, /.*/).to_return(:body => '')
|
81
42
|
|
82
|
-
@client.
|
43
|
+
@client.download_audit_trail('an_id', 'another_id')
|
83
44
|
|
84
|
-
assert_requested :get, 'https://api.signaturit.com/
|
45
|
+
assert_requested :get, 'https://api.signaturit.com/v3/signatures/an_id/documents/another_id/download/audit_trail', :headers => { :Authorization => 'Bearer a_token' }
|
85
46
|
end
|
86
47
|
|
87
48
|
def test_get_signed_document
|
88
49
|
stub_request(:any, /.*/).to_return(:body => '')
|
89
50
|
|
90
|
-
@client.
|
51
|
+
@client.download_signed_document('an_id', 'another_id')
|
91
52
|
|
92
|
-
assert_requested :get, 'https://api.signaturit.com/
|
53
|
+
assert_requested :get, 'https://api.signaturit.com/v3/signatures/an_id/documents/another_id/download/signed', :headers => { :Authorization => 'Bearer a_token' }
|
93
54
|
end
|
94
55
|
|
95
56
|
def test_create_signature_request
|
@@ -97,25 +58,25 @@ class TestSignaturitClient < Test::Unit::TestCase
|
|
97
58
|
|
98
59
|
path = File.join(File.expand_path(File.dirname(__FILE__)), 'file.pdf')
|
99
60
|
|
100
|
-
@client.
|
61
|
+
@client.create_signature path, 'admin@signatur.it'
|
101
62
|
|
102
|
-
assert_requested :post, 'https://api.signaturit.com/
|
63
|
+
assert_requested :post, 'https://api.signaturit.com/v3/signatures.json', :headers => { :Authorization => 'Bearer a_token' }
|
103
64
|
end
|
104
65
|
|
105
66
|
def test_cancel_signature_request
|
106
67
|
stub_request(:any, /.*/).to_return(:body => '{}')
|
107
68
|
|
108
|
-
@client.
|
69
|
+
@client.cancel_signature 'an_id'
|
109
70
|
|
110
|
-
assert_requested :patch, 'https://api.signaturit.com/
|
71
|
+
assert_requested :patch, 'https://api.signaturit.com/v3/signatures/an_id/cancel.json', :headers => { :Authorization => 'Bearer a_token' }
|
111
72
|
end
|
112
73
|
|
113
74
|
def test_send_reminder
|
114
75
|
stub_request(:any, /.*/).to_return(:body => '{}')
|
115
76
|
|
116
|
-
@client.
|
77
|
+
@client.send_signature_reminder 'an_id'
|
117
78
|
|
118
|
-
assert_requested :post, 'https://api.signaturit.com/
|
79
|
+
assert_requested :post, 'https://api.signaturit.com/v3/signatures/an_id/reminder.json', :headers => { :Authorization => 'Bearer a_token' }
|
119
80
|
end
|
120
81
|
|
121
82
|
def test_create_signature_request_multi
|
@@ -126,9 +87,9 @@ class TestSignaturitClient < Test::Unit::TestCase
|
|
126
87
|
File.join(File.expand_path(File.dirname(__FILE__)), 'file.pdf')
|
127
88
|
]
|
128
89
|
|
129
|
-
@client.
|
90
|
+
@client.create_signature paths, 'admin@signatur.it'
|
130
91
|
|
131
|
-
assert_requested :post, 'https://api.signaturit.com/
|
92
|
+
assert_requested :post, 'https://api.signaturit.com/v3/signatures.json', :headers => { :Authorization => 'Bearer a_token' }
|
132
93
|
end
|
133
94
|
|
134
95
|
def test_get_branding
|
@@ -136,15 +97,15 @@ class TestSignaturitClient < Test::Unit::TestCase
|
|
136
97
|
|
137
98
|
@client.get_branding('an_id')
|
138
99
|
|
139
|
-
assert_requested :get, 'https://api.signaturit.com/
|
100
|
+
assert_requested :get, 'https://api.signaturit.com/v3/brandings/an_id.json', :headers => { :Authorization => 'Bearer a_token' }
|
140
101
|
end
|
141
102
|
|
142
103
|
def test_get_brandings
|
143
104
|
stub_request(:any, /.*/).to_return(:body => '[]')
|
144
105
|
|
145
|
-
@client.get_brandings
|
106
|
+
@client.get_brandings
|
146
107
|
|
147
|
-
assert_requested :get, 'https://api.signaturit.com/
|
108
|
+
assert_requested :get, 'https://api.signaturit.com/v3/brandings.json', :headers => { :Authorization => 'Bearer a_token' }
|
148
109
|
end
|
149
110
|
|
150
111
|
def test_create_branding
|
@@ -152,7 +113,7 @@ class TestSignaturitClient < Test::Unit::TestCase
|
|
152
113
|
|
153
114
|
@client.create_branding({})
|
154
115
|
|
155
|
-
assert_requested :post, 'https://api.signaturit.com/
|
116
|
+
assert_requested :post, 'https://api.signaturit.com/v3/brandings.json', :headers => { :Authorization => 'Bearer a_token' }
|
156
117
|
end
|
157
118
|
|
158
119
|
def test_update_branding
|
@@ -160,27 +121,7 @@ class TestSignaturitClient < Test::Unit::TestCase
|
|
160
121
|
|
161
122
|
@client.update_branding('an_id', {})
|
162
123
|
|
163
|
-
assert_requested :patch, 'https://api.signaturit.com/
|
164
|
-
end
|
165
|
-
|
166
|
-
def test_update_branding_logo
|
167
|
-
stub_request(:any, /.*/).to_return(:body => '{}')
|
168
|
-
|
169
|
-
path = File.join(File.expand_path(File.dirname(__FILE__)), 'file.png')
|
170
|
-
|
171
|
-
@client.update_branding_logo('an_id', path)
|
172
|
-
|
173
|
-
assert_requested :put, 'https://api.signaturit.com/v2/brandings/an_id/logo.json', :headers => { :Authorization => 'Bearer a_token' }
|
174
|
-
end
|
175
|
-
|
176
|
-
def test_update_branding_template
|
177
|
-
stub_request(:any, /.*/).to_return(:body => '{}')
|
178
|
-
|
179
|
-
path = File.join(File.expand_path(File.dirname(__FILE__)), 'file.html')
|
180
|
-
|
181
|
-
@client.update_branding_template('an_id', 'a_template', path)
|
182
|
-
|
183
|
-
assert_requested :put, 'https://api.signaturit.com/v2/brandings/an_id/emails/a_template.json', :headers => { :Authorization => 'Bearer a_token' }
|
124
|
+
assert_requested :patch, 'https://api.signaturit.com/v3/brandings/an_id.json', :headers => { :Authorization => 'Bearer a_token' }
|
184
125
|
end
|
185
126
|
|
186
127
|
def test_get_templates
|
@@ -188,6 +129,7 @@ class TestSignaturitClient < Test::Unit::TestCase
|
|
188
129
|
|
189
130
|
@client.get_templates(5, 10)
|
190
131
|
|
191
|
-
assert_requested :get, 'https://api.signaturit.com/
|
132
|
+
assert_requested :get, 'https://api.signaturit.com/v3/templates.json?limit=5&offset=10', :headers => { :Authorization => 'Bearer a_token' }
|
192
133
|
end
|
134
|
+
|
193
135
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: signaturit-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-01-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest_client
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.7
|
21
|
+
version: '1.7'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.7
|
29
|
+
version: '1.7'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: webmock
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 1.18
|
37
|
+
version: '1.18'
|
38
38
|
type: :development
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.18
|
45
|
+
version: '1.18'
|
46
46
|
description: Sign Documents Online
|
47
47
|
email: api@signaturit.com
|
48
48
|
executables: []
|
@@ -50,6 +50,7 @@ extensions: []
|
|
50
50
|
extra_rdoc_files: []
|
51
51
|
files:
|
52
52
|
- .gitignore
|
53
|
+
- CHANGELOG.md
|
53
54
|
- Gemfile
|
54
55
|
- Gemfile.lock
|
55
56
|
- LICENSE
|