signaturit-sdk 0.0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 037bd35cedc20fe874d582632a5bcfb831a5caa7
4
+ data.tar.gz: 971dff460cd1887b677381850f32c31372ec044f
5
+ SHA512:
6
+ metadata.gz: 072a70412f160c241773ef55bc908e8220b27c2ee8018b9d0e9fef27abc4004e79d30a8dced9f5b908cc9b0f6aa865678f7dfe1691fae82e23cf2089c7eccda2
7
+ data.tar.gz: 0744ca43f5bf0786dda15bc0e112441186f2eec47981cb11c784eebced4080498deb3eefb6abcb693bcbe3fc05fad17bfb820c58d3a932418dc084e79a1098dd
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ pkg
2
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rest_client', '~> 1.7.3'
4
+ gem 'webmock', '~> 1.18.0'
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.3.6)
5
+ crack (0.4.2)
6
+ safe_yaml (~> 1.0.0)
7
+ netrc (0.7.7)
8
+ rest_client (1.7.3)
9
+ netrc (~> 0.7.7)
10
+ safe_yaml (1.0.3)
11
+ webmock (1.18.0)
12
+ addressable (>= 2.3.6)
13
+ crack (>= 0.3.2)
14
+
15
+ PLATFORMS
16
+ ruby
17
+
18
+ DEPENDENCIES
19
+ rest_client (~> 1.7.3)
20
+ webmock (~> 1.18.0)
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013-2014 Signaturit Solutions
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,181 @@
1
+ Signaturit Ruby SDK
2
+ ===================
3
+ 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](http://docs.signaturit.com/).
4
+
5
+ You can install the package through gem.
6
+
7
+ ```
8
+ gem install signaturit-sdk
9
+ ```
10
+
11
+ Configuration
12
+ -------------
13
+
14
+ Just import the Signaturit Client this way
15
+ ```
16
+ require 'signaturit_client'
17
+ ```
18
+
19
+ Then you can authenticate yourself using your AuthToken
20
+ ```
21
+ client = SignaturitClient.new('TOKEN')
22
+ ```
23
+
24
+ Remember, the default calls are made to our Sandbox server. If you want to do in production, just set the flag when you do the call.
25
+ ```
26
+ client = SignaturitClient.new('TOKEN', true)
27
+ ```
28
+
29
+ Examples
30
+ --------
31
+
32
+ ## Signature request
33
+
34
+ ### Get all signature requests
35
+ Retrieve all data from your signature requests using different filters.
36
+
37
+ ##### All signatures
38
+ ```
39
+ response = client.get_signatures()
40
+ ```
41
+
42
+ ##### Getting the last 50 signatures
43
+ ```
44
+ response = client.get_signatures(50)
45
+ ```
46
+
47
+ ##### Getting the following last 50 signatures
48
+ ```
49
+ response = client.get_signatures(50, 50)
50
+ ```
51
+
52
+ ##### Getting only the finished signatures
53
+ ```
54
+ response = client.get_signatures(100, 0, 3)
55
+ ```
56
+
57
+ ##### Getting the finished signatures created since July 20th of 2014
58
+ ```
59
+ response = client.get_signatures(100, 0, 3, '2014-7-20')
60
+ ```
61
+
62
+ ### Count signature requests
63
+ Count your signature requests.
64
+ ```
65
+ response = client.count_signatures()
66
+ ```
67
+
68
+ ### Get signature request
69
+ Get a single signature request.
70
+ ```
71
+ response = client.get_signature('SIGNATURE_ID')
72
+ ```
73
+
74
+ ### Get signature documents
75
+ Get all documents from a signature request.
76
+ ```
77
+ response = client.get_signature_documents('SIGNATURE_ID')
78
+ ```
79
+
80
+ ### Get signature document
81
+ Get a single document from a signature request.
82
+ ```
83
+ response = client.get_signature_document('SIGNATURE_ID','DOCUMENT_ID')
84
+ ```
85
+
86
+ ### Signature request
87
+ Create a new signature request. Check all [params](http://docs.signaturit.com/api/#sign_create_sign).
88
+ ```
89
+ recipients = ['bobsoap@signatur.it']
90
+ params = {:subject: 'Receipt number 250', :body: 'Please, can you sign this document?'}
91
+ file_path = '/documents/contracts/125932_important.pdf'
92
+ response = client.create_signature_request(file_path, recipients, params)
93
+ ```
94
+
95
+ ### Get audit trail
96
+ Get the audit trail of a signature request document and save it in the submitted path.
97
+ ```
98
+ response = client.get_audit_trail('ID', 'DOCUMENT_ID', '/path/doc.pdf')
99
+ ```
100
+
101
+ ### Get signed document
102
+ Get the signed document of a signature request document and save it in the submitted path.
103
+ ```
104
+ response = client.get_signed_document('ID', 'DOCUMENT_ID', '/path/doc.pdf')
105
+ ```
106
+
107
+ ## Account
108
+
109
+ ### Get account
110
+ Retrieve the information of your account.
111
+ ```
112
+ response = client.get_account()
113
+ ```
114
+
115
+ ### Set document storage
116
+ Set your own storage credentials, to store a copy of the documents. You can get all the info of credential types [here](http://docs.signaturit.com/api/#account_set_credentials).
117
+ ```
118
+ credentials = {
119
+ :user: 'john',
120
+ :port: 22,
121
+ :dir: '/test',
122
+ :host: 'john.doe.server',
123
+ :password: 'XXX',
124
+ :auth_method: 'PASS'
125
+ }
126
+ response = client.set_document_storage('sftp', credentials)
127
+ ```
128
+
129
+ ## Branding
130
+
131
+ ### Get brandings
132
+ Get all account brandings.
133
+ ```
134
+ response = client.get_brandings()
135
+ ```
136
+
137
+ ### Get branding
138
+ Get a single branding.
139
+ ```
140
+ response = client.get_branding('BRANDING_ID')
141
+ ```
142
+
143
+ ### Create branding
144
+ Create a new branding. You can check all branding params [here](http://docs.signaturit.com/api/#set_branding).`
145
+ ```
146
+ params = {
147
+ :corporate_layout_color: '#FFBF00',
148
+ :corporate_text_color: '#2A1B0A',
149
+ :application_texts: { :sign_button: 'Sign!' }
150
+ }
151
+ response = client.create_branding(params)
152
+ ```
153
+
154
+ ### Update branding
155
+ Update a single branding.
156
+ ```
157
+ params = { :application_texts: { :send_button: 'Send!' } }
158
+ response = client.update_branding('BRANDING_ID', params)
159
+ ```
160
+
161
+ ### Update branding logo
162
+ Change the branding logo.
163
+ ```
164
+ file_path = '/path/new_logo.png'
165
+ response = client.update_branding_logo('BRANDING_ID', file_path)
166
+ ```
167
+
168
+ ### Update branding template
169
+ Change a template. Learn more about the templates [here](http://docs.signaturit.com/api/#put_template_branding).
170
+ ```
171
+ file_path = '/path/new_template.html'
172
+ response = client.update_branding_template('BRANDING_ID', 'sign_request', file_path)
173
+ ```
174
+
175
+ ## Template
176
+
177
+ ###Get all templates
178
+ Retrieve all data from your templates.
179
+ ```
180
+ response = client.get_templates()
181
+ ```
data/Rakefile ADDED
@@ -0,0 +1,35 @@
1
+ require 'rake/testtask'
2
+
3
+ gemspec_file = 'signaturit-sdk.gemspec'
4
+
5
+ spec = Gem::Specification::load(gemspec_file)
6
+
7
+ gem_file = "#{spec.name}-#{spec.version}.gem"
8
+
9
+ desc "Release signaturit-sdk-#{spec.version}"
10
+ task :release => :build do
11
+ unless `git branch` =~ /^\* master$/
12
+ puts 'You must be on the master branch to release!'
13
+ exit!
14
+ end
15
+
16
+ sh "git commit --allow-empty -m 'Release :gem: #{spec.version}'"
17
+ sh "git tag #{spec.version}"
18
+ sh 'git push origin master'
19
+ sh "git push origin #{spec.version}"
20
+ sh "gem push pkg/signaturit-sdk-#{spec.version}.gem"
21
+ end
22
+
23
+ desc "Build signaturit-sdk-#{spec.version} into pkg/"
24
+ task :build do
25
+ mkdir_p 'pkg'
26
+ sh "gem build #{gemspec_file}"
27
+ sh "mv #{gem_file} pkg"
28
+ end
29
+
30
+ Rake::TestTask.new do |t|
31
+ t.libs << 'test'
32
+ t.test_files = FileList['test/test*.rb']
33
+ end
34
+
35
+ task :default => :test
@@ -0,0 +1,285 @@
1
+ # Load rest client
2
+ require 'rest_client'
3
+
4
+ # Load json
5
+ require 'json'
6
+
7
+ # Signaturit client class
8
+ class SignaturitClient
9
+
10
+ # Initialize the object with the token and environment
11
+ def initialize(token, production = false)
12
+ @token = token
13
+ @production = production
14
+ end
15
+
16
+ # get info from your account
17
+ def get_account
18
+ request :get, '/v2/account.json'
19
+ end
20
+
21
+ # Set the credentials in account, in order to store a copy from all documents
22
+ #
23
+ # Params:
24
+ # +type+:: Type of storage, sftp or s3
25
+ # +params+:: An array with credentials data
26
+ # sftp:
27
+ # - host: Your host
28
+ # - port: Connection port
29
+ # - dir: Directory where store the files
30
+ # - user: Username
31
+ # - auth_method: KEY or PASS
32
+ # pass:
33
+ # - password: Password
34
+ # key:
35
+ # - private: Private key
36
+ # - public: Public key
37
+ # - passphrase: The passphrase
38
+ # s3:
39
+ # - bucket: Name of bucket
40
+ # - key: S3 key
41
+ # - secret: S3 secret
42
+ def set_document_storage(type, params)
43
+ params[:type] = type
44
+
45
+ request :patch, '/v2/account.json', params
46
+ end
47
+
48
+ # Get a concrete signature object
49
+ #
50
+ # Params:
51
+ # +signature_id+:: The id of the signature object
52
+ def get_signature(signature_id)
53
+ request :get, "/v2/signs/#{signature_id}.json"
54
+ end
55
+
56
+ # Get a list of signature objects
57
+ #
58
+ # Params:
59
+ # +limit+:: Maximum number of results to return
60
+ # +offset+:: Offset of results to skip
61
+ # +status+:: Status of the signature objects to filter
62
+ # +since+:: Filter signature objects created since this date
63
+ def get_signatures(limit = 100, offset = 0, status = nil, since = nil)
64
+ params = { :limit => limit, :offset => offset }
65
+
66
+ params[:status] = status unless status.nil?
67
+ params[:since] = since unless since.nil?
68
+
69
+ request :get, '/v2/signs.json', params
70
+ end
71
+
72
+ # Get the number of signature objects
73
+ #
74
+ # Params:
75
+ # +status+:: Status of the signature objects to filter
76
+ # +since+:: Filter signature objects created since this date
77
+ def count_signatures(status = nil, since = nil)
78
+ params = {}
79
+
80
+ params[:status] = status unless status.nil?
81
+ params[:since] = since unless since.nil?
82
+
83
+ request :get, '/v2/signs/count.json', params
84
+ end
85
+
86
+ # Get a concrete document from a concrete Signature
87
+ #
88
+ # Params:
89
+ # +signature_id+:: The id of the signature object
90
+ # +document_id+:: The id of the document object
91
+ def get_signature_document(signature_id, document_id)
92
+ request :get, "/v2/signs/#{signature_id}/documents/#{document_id}.json"
93
+ end
94
+
95
+ # Get all documents in the given signature object
96
+ #
97
+ # Params:
98
+ # +signature_id+:: The id of the signature object
99
+ def get_signature_documents(signature_id)
100
+ request :get, "/v2/signs/#{signature_id}/documents.json"
101
+ end
102
+
103
+ # Get the audit trail of concrete document
104
+ #
105
+ # Params:
106
+ # +signature_id++:: The id of the signature object
107
+ # +document_id++:: THe id of the document object
108
+ # +path++:: Path where the document will be stored
109
+ def get_audit_trail(signature_id, document_id, path)
110
+ response = request :get, "/v2/signs/#{signature_id}/documents/#{document_id}/download/doc_proof", {}, false
111
+
112
+ File.open(path, 'wb') do |file|
113
+ file.write(response)
114
+ end
115
+
116
+ nil
117
+ end
118
+
119
+ # Get the signed document
120
+ #
121
+ # Params:
122
+ # +signature_id++:: The id of the signature object
123
+ # +document_id++:: THe id of the document object
124
+ # +path++:: Path where the document will be stored
125
+ def get_signed_document(signature_id, document_id, path)
126
+ response = request :get, "/v2/signs/#{signature_id}/documents/#{document_id}/download/signed", {}, false
127
+
128
+ File.open(path, 'wb') do |file|
129
+ file.write(response)
130
+ end
131
+
132
+ nil
133
+ end
134
+
135
+ # Create a new Signature request
136
+ #
137
+ # Params:
138
+ # +filepath+:: The pdf file to send or an array with multiple files.
139
+ # +recipients+:: A string with an email, a hash like
140
+ # {:name => "a name", :email => "me@domain.com", :phone => "34655123456"}
141
+ # or an array of hashes.
142
+ # +params+:: An array of parameters for the signature object
143
+ # - subject: Subject of the email
144
+ # - body: Body of the email
145
+ # - in_person: If you want to do an in person sign (system will not send
146
+ # an email to the user, but return the signature url instead)
147
+ # - sequential: If you want to do a sequential sign (for multiple
148
+ # recipients, the sign goes in sequential way)
149
+ # - photo: If a photo is required in sign process
150
+ # - mandatory_pages: An array with the pages the signer must sign
151
+ # - branding_id: The id of the branding you want to use
152
+ # - templates: An array ot template ids to use.
153
+ def create_signature_request(filepath, recipients, params = {})
154
+ params[:recipients] = {}
155
+
156
+ [recipients].flatten().each_with_index do |recipient, index|
157
+ params[:recipients][index] = recipient
158
+ end
159
+
160
+ params[:files] = [filepath].flatten().map do |filepath|
161
+ File.new(filepath, 'rb')
162
+ end
163
+
164
+ params[:templates] = [params[:templates]].flatten() if params[:templates]
165
+
166
+ request :post, '/v2/signs.json', params
167
+ end
168
+
169
+ # Get a concrete branding
170
+ #
171
+ # Params
172
+ # +branding_id+:: The id of the branding object
173
+ def get_branding(branding_id)
174
+ request :get, "/v2/brandings/#{branding_id}.json"
175
+ end
176
+
177
+ # Get all account brandings
178
+ def get_brandings
179
+ request :get, '/v2/brandings.json'
180
+ end
181
+
182
+ # Create a new branding
183
+ #
184
+ # Params:
185
+ # +params+:: An array of parameters for the branding object
186
+ # - primary: If set, this new branding will be the default one
187
+ # - corporate_layout_color: Default color for all application widgets
188
+ # - corporate_text_color: Default text color for all application widgets
189
+ # - application_texts: A dict with the new text values
190
+ # - sign_button: Text for sign button
191
+ # - send_button: Text for send button
192
+ # - decline_button: Text for decline button:
193
+ # - decline_modal_title: Title for decline modal
194
+ # - decline_modal_body: Body for decline modal
195
+ # - photo: Photo message text, which tells the user that a photo is
196
+ # needed in the current process
197
+ # - multi_pages: Header of the document, which tells the user the
198
+ # number of pages to sign
199
+ # - subject_tag: This tag appears at the subject of all your messages
200
+ # - reminders: A list with reminder times (in seconds). Every reminder
201
+ # time, a email will be sent, if the signer didn't sign the document
202
+ # - expire_time: The signature time (in seconds). When the expire time is
203
+ # over, the document cannot be signed. Set 0 if you want a signature
204
+ # without expire time.
205
+ # - callback_url: A url to redirect the user, when the process is over.
206
+ # - signature_pos_x: Default position x of signature
207
+ # - signature_pos_y: Default position y of signature
208
+ # - terms_and_conditions_label: The terms text that appears when you need
209
+ # to check the button to accept.
210
+ # - terms_and_conditions_body: Custom text that appears below signature
211
+ # conditions
212
+ # - hide_legal_section: If true, legal section in email footer doesn't
213
+ # appear
214
+ # - hide_info_section: If true, info section in email footer doesn't
215
+ # appear
216
+ # - hide_contact_section: If true, contact section in email footer
217
+ # doesn't appear
218
+ def create_branding(params)
219
+ request :post, '/v2/brandings.json', params
220
+ end
221
+
222
+ # Update a existing branding
223
+ #
224
+ # Params:
225
+ # +branding_id+:: Id of the branding to update
226
+ # +params+:: Same params as method create_branding, see above
227
+ def update_branding(branding_id, params)
228
+ request :patch, "/v2/brandings/#{branding_id}.json", params
229
+ end
230
+
231
+ # Update the logo of a branding
232
+ #
233
+ # Params:
234
+ # +branding_id+:: Id of the branding to update
235
+ # +filepath+:: The path to the image file
236
+ def update_branding_logo(branding_id, filepath)
237
+ request :put, "/v2/brandings/#{branding_id}/logo.json", File.read(filepath)
238
+ end
239
+
240
+ # Update the template of a branding
241
+ #
242
+ # Params:
243
+ # +branding_id+:: Id of the branding to update
244
+ # +filepath+:: The path to the html file
245
+ # +template+:: The email template trying to update
246
+ def update_branding_template(branding_id, template, filepath)
247
+ request :put, "/v2/brandings/#{branding_id}/emails/#{template}.json", File.read(filepath)
248
+ end
249
+
250
+ # Get a list of template objects
251
+ #
252
+ # Params:
253
+ # +limit+:: Maximum number of results to return
254
+ # +offset+:: Offset of results to skip
255
+ def get_templates(limit = 100, offset = 0)
256
+ params = { :limit => limit, :offset => offset }
257
+
258
+ request :get, '/v2/templates.json', params
259
+ end
260
+
261
+ # PRIVATE METHODS FROM HERE
262
+
263
+ private
264
+
265
+ # Common request method
266
+ def request(method, path, params = {}, to_json = true)
267
+ base = @production ? 'https://api.signaturit.com' : 'http://api.sandbox.signaturit.com'
268
+
269
+ case method
270
+ when :get
271
+ encoded = URI.encode_www_form(params)
272
+ path = "#{path}?#{encoded}" if encoded.length > 0
273
+
274
+ body = RestClient.get("#{base}#{path}", :Authorization => "Bearer #{@token}")
275
+
276
+ else
277
+ body = RestClient.send(method, "#{base}#{path}", params, :Authorization => "Bearer #{@token}")
278
+ end
279
+
280
+ body = JSON.parse body if to_json
281
+
282
+ body
283
+ end
284
+
285
+ end
@@ -0,0 +1,21 @@
1
+ Gem::Specification.new do |s|
2
+ s.platform = Gem::Platform::RUBY
3
+ s.name = 'signaturit-sdk'
4
+ s.version = '0.0.1'
5
+ s.date = '2014-09-04'
6
+ s.summary = 'Signaturit Ruby SDK'
7
+ s.description = 'Sign Documents Online'
8
+
9
+ s.author = 'Signaturit'
10
+ s.email = 'api@signaturit.com'
11
+ s.homepage = 'https://signaturit.com/'
12
+
13
+ s.files = `git ls-files`.split($/)
14
+ s.test_files = s.files.grep(%r{^test})
15
+
16
+ s.license = 'MIT'
17
+
18
+ s.add_dependency 'rest_client', '~> 1.7.3'
19
+
20
+ s.add_development_dependency 'webmock', '~> 1.18.0'
21
+ end
data/test/file.html ADDED
@@ -0,0 +1 @@
1
+ <html></html>
data/test/file.pdf ADDED
Binary file
data/test/file.png ADDED
Binary file
@@ -0,0 +1,169 @@
1
+ require 'test/unit'
2
+
3
+ require 'webmock/test_unit'
4
+
5
+ require './lib/signaturit_client.rb'
6
+
7
+ class TestSignaturitClient < Test::Unit::TestCase
8
+
9
+ TOKEN = 'a_token'
10
+
11
+ def setup
12
+ @client = SignaturitClient.new TOKEN, true
13
+ end
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 :patch, 'https://api.signaturit.com/v2/account.json', :headers => { :Authorization => 'Bearer a_token' }
29
+ end
30
+
31
+ def test_get_signature
32
+ stub_request(:any, /.*/).to_return(:body => '{}')
33
+
34
+ @client.get_signature 'an_id'
35
+
36
+ assert_requested :get, 'https://api.signaturit.com/v2/signs/an_id.json', :headers => { :Authorization => 'Bearer a_token' }
37
+ end
38
+
39
+ def test_get_signatures
40
+ stub_request(:any, /.*/).to_return(:body => '[]')
41
+
42
+ @client.get_signatures(5, 10)
43
+
44
+ assert_requested :get, 'https://api.signaturit.com/v2/signs.json?limit=5&offset=10', :headers => { :Authorization => 'Bearer a_token' }
45
+ end
46
+
47
+ def test_count_signatures
48
+ stub_request(:any, /.*/).to_return(:body => '{}')
49
+
50
+ @client.count_signatures('signed', '1982-07-27')
51
+
52
+ assert_requested :get, 'https://api.signaturit.com/v2/signs/count.json?status=signed&since=1982-07-27', :headers => { :Authorization => 'Bearer a_token' }
53
+ end
54
+
55
+ def test_get_signature_document
56
+ stub_request(:any, /.*/).to_return(:body => '{}')
57
+
58
+ @client.get_signature_document('an_id', 'another_id')
59
+
60
+ assert_requested :get, 'https://api.signaturit.com/v2/signs/an_id/documents/another_id.json', :headers => { :Authorization => 'Bearer a_token' }
61
+ end
62
+
63
+ def test_get_signature_documents
64
+ stub_request(:any, /.*/).to_return(:body => '[]')
65
+
66
+ @client.get_signature_documents('an_id')
67
+
68
+ assert_requested :get, 'https://api.signaturit.com/v2/signs/an_id/documents.json', :headers => { :Authorization => 'Bearer a_token' }
69
+ end
70
+
71
+ def test_get_audit_trail
72
+ stub_request(:any, /.*/).to_return(:body => '')
73
+
74
+ @client.get_audit_trail('an_id', 'another_id', Tempfile.new('pdf').path)
75
+
76
+ assert_requested :get, 'https://api.signaturit.com/v2/signs/an_id/documents/another_id/download/doc_proof', :headers => { :Authorization => 'Bearer a_token' }
77
+ end
78
+
79
+ def test_get_signed_document
80
+ stub_request(:any, /.*/).to_return(:body => '')
81
+
82
+ @client.get_signed_document('an_id', 'another_id', Tempfile.new('pdf').path)
83
+
84
+ assert_requested :get, 'https://api.signaturit.com/v2/signs/an_id/documents/another_id/download/signed', :headers => { :Authorization => 'Bearer a_token' }
85
+ end
86
+
87
+ def test_create_signature_request
88
+ stub_request(:any, /.*/).to_return(:body => '{}')
89
+
90
+ path = File.join(File.expand_path(File.dirname(__FILE__)), 'file.pdf')
91
+
92
+ @client.create_signature_request(path, 'admin@signatur.it')
93
+
94
+ assert_requested :post, 'https://api.signaturit.com/v2/signs.json', :headers => { :Authorization => 'Bearer a_token' }
95
+ end
96
+
97
+ def test_create_signature_request_multi
98
+ stub_request(:any, /.*/).to_return(:body => '{}')
99
+
100
+ paths = [
101
+ File.join(File.expand_path(File.dirname(__FILE__)), 'file.pdf'),
102
+ File.join(File.expand_path(File.dirname(__FILE__)), 'file.pdf')
103
+ ]
104
+
105
+ @client.create_signature_request(paths, 'admin@signatur.it')
106
+
107
+ assert_requested :post, 'https://api.signaturit.com/v2/signs.json', :headers => { :Authorization => 'Bearer a_token' }
108
+ end
109
+
110
+ def test_get_branding
111
+ stub_request(:any, /.*/).to_return(:body => '{}')
112
+
113
+ @client.get_branding('an_id')
114
+
115
+ assert_requested :get, 'https://api.signaturit.com/v2/brandings/an_id.json', :headers => { :Authorization => 'Bearer a_token' }
116
+ end
117
+
118
+ def test_get_brandings
119
+ stub_request(:any, /.*/).to_return(:body => '[]')
120
+
121
+ @client.get_brandings()
122
+
123
+ assert_requested :get, 'https://api.signaturit.com/v2/brandings.json', :headers => { :Authorization => 'Bearer a_token' }
124
+ end
125
+
126
+ def test_create_branding
127
+ stub_request(:any, /.*/).to_return(:body => '{}')
128
+
129
+ @client.create_branding({})
130
+
131
+ assert_requested :post, 'https://api.signaturit.com/v2/brandings.json', :headers => { :Authorization => 'Bearer a_token' }
132
+ end
133
+
134
+ def test_update_branding
135
+ stub_request(:any, /.*/).to_return(:body => '{}')
136
+
137
+ @client.update_branding('an_id', {})
138
+
139
+ assert_requested :patch, 'https://api.signaturit.com/v2/brandings/an_id.json', :headers => { :Authorization => 'Bearer a_token' }
140
+ end
141
+
142
+ def test_update_branding_logo
143
+ stub_request(:any, /.*/).to_return(:body => '{}')
144
+
145
+ path = File.join(File.expand_path(File.dirname(__FILE__)), 'file.png')
146
+
147
+ @client.update_branding_logo('an_id', path)
148
+
149
+ assert_requested :put, 'https://api.signaturit.com/v2/brandings/an_id/logo.json', :headers => { :Authorization => 'Bearer a_token' }
150
+ end
151
+
152
+ def test_update_branding_template
153
+ stub_request(:any, /.*/).to_return(:body => '{}')
154
+
155
+ path = File.join(File.expand_path(File.dirname(__FILE__)), 'file.html')
156
+
157
+ @client.update_branding_template('an_id', 'a_template', path)
158
+
159
+ assert_requested :put, 'https://api.signaturit.com/v2/brandings/an_id/emails/a_template.json', :headers => { :Authorization => 'Bearer a_token' }
160
+ end
161
+
162
+ def test_get_templates
163
+ stub_request(:any, /.*/).to_return(:body => '[]')
164
+
165
+ @client.get_templates(5, 10)
166
+
167
+ assert_requested :get, 'https://api.signaturit.com/v2/templates.json?limit=5&offset=10', :headers => { :Authorization => 'Bearer a_token' }
168
+ end
169
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: signaturit-sdk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Signaturit
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest_client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 1.7.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 1.7.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: webmock
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.18.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.18.0
41
+ description: Sign Documents Online
42
+ email: api@signaturit.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - .gitignore
48
+ - Gemfile
49
+ - Gemfile.lock
50
+ - LICENSE
51
+ - README.md
52
+ - Rakefile
53
+ - lib/signaturit_client.rb
54
+ - signaturit-sdk.gemspec
55
+ - test/file.html
56
+ - test/file.pdf
57
+ - test/file.png
58
+ - test/test_signaturit_client.rb
59
+ homepage: https://signaturit.com/
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.0.14
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Signaturit Ruby SDK
83
+ test_files:
84
+ - test/file.html
85
+ - test/file.pdf
86
+ - test/file.png
87
+ - test/test_signaturit_client.rb