hellosign-ruby-sdk 3.5.4 → 3.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1804c9f642f169ef4a3d44abb6946ef81f484d2c
4
- data.tar.gz: a1eb0baecdcf75ecc0636634821278854da45720
3
+ metadata.gz: 624c50c86c5c3f142cbc0b183003431a912fba33
4
+ data.tar.gz: d20286ae7e98f4b8472bee8e1809d9bc7a3ccdf1
5
5
  SHA512:
6
- metadata.gz: 680e7442f10598103fa16f631fb3f8c7081e2564f765150c3947eeb6f68d2a5e81b4b9ec07590d395eef43603b10b16b773624501640301f0d5ea618367b3566
7
- data.tar.gz: adf4bff05fa09bdc31db9fd0827a1cf1eeb55a17f95d28f06d23118385f1a42368291a0ff20937fc2e02cb0ea314bea7f904f3e02dce865960cfdf011db7c445
6
+ metadata.gz: 26b234abfba696397fe1a4a30f524eba5e432fcd00d9fa4d2791c0a513bacf0d0fb4d1a215bba7be9119413e900d68bc89a9a72bf8a8f4d475ce2a16c2673ce7
7
+ data.tar.gz: 3c22e1f575ef110955ccd0a5b70d67f32435db2aafef8c553cdb6425dc4d76bbd498d673e7f92ac533507008a82f42a9fed9f3dc7d19087feb5629ce31dcca0b
data/README.md CHANGED
@@ -29,7 +29,7 @@ HelloSign.configure do |config|
29
29
  end
30
30
  ```
31
31
 
32
- ##Usage
32
+ ## Usage
33
33
  When you have configured your app like above, you can start using it:
34
34
 
35
35
  ```ruby
@@ -55,7 +55,7 @@ When using request endpoints that send files, such as a signature request, you c
55
55
  2. A Ruby File Object (File.open, then assign to a variable)
56
56
  3. A Rails ActionDispatch::Http::UploadedFile
57
57
 
58
- ##Testing
58
+ ## Testing
59
59
 
60
60
  Testing relies on built in hard-coded fixtures. You can run the tests without affecting your actual account data. To do so
61
61
  from the root of your project run <code>rake spec</code>.
Binary file
@@ -147,7 +147,7 @@ module HelloSign
147
147
  def create_embedded_unclaimed_draft(opts)
148
148
  opts[:client_id] ||= self.client_id
149
149
  prepare_files opts
150
- if opts[:type] == 'request_signature'
150
+ if opts[:type] == 'request_signature' || opts[:type] == 'send_document'
151
151
  prepare_signers opts
152
152
  end
153
153
 
@@ -205,6 +205,7 @@ module HelloSign
205
205
  def create_embedded_unclaimed_draft_with_template(opts)
206
206
  opts[:client_id] ||= self.client_id
207
207
  prepare_signers opts
208
+ prepare_custom_fields opts
208
209
  prepare_ccs opts
209
210
  prepare_templates opts
210
211
  prepare_files opts
@@ -177,7 +177,11 @@ module HelloSign
177
177
  def validate(response)
178
178
  if response.status >= 400
179
179
  error_class = ERRORS[response.status] || HelloSign::Error::UnknownError
180
- raise error_class.new error_message(response)
180
+ error = error_class.new
181
+ error.response_status = response.status
182
+ error.response_body = response.body
183
+ error.request_uri = response.to_hash[:url].to_s
184
+ raise error
181
185
  end
182
186
  end
183
187
 
@@ -193,12 +197,6 @@ module HelloSign
193
197
  end
194
198
  end
195
199
 
196
- def error_message(response)
197
- "Server responded with code #{response.status}\n" \
198
- "Request URI: #{response.to_hash[:url].to_s}\n"\
199
- "Message: #{response.body}"
200
- end
201
-
202
200
  def MIMEfromName(name)
203
201
  parts = name.split('.')
204
202
  #default to pdf if no extension
@@ -25,7 +25,22 @@
25
25
  module HelloSign
26
26
  module Error
27
27
  # Custom error class for rescuing from all HelloSign errors.
28
- class Error < StandardError; end
28
+ class Error < StandardError;
29
+ attr_accessor :request_uri
30
+ attr_accessor :response_body
31
+ attr_accessor :response_status
32
+
33
+ def initialize(message = nil)
34
+ super(message || human_readable_message)
35
+ end
36
+
37
+ private
38
+ def human_readable_message
39
+ "Server responded with code #{response_status}\n" \
40
+ "Request URI: #{request_uri}\n"\
41
+ "Message: #{response_body}"
42
+ end
43
+ end
29
44
 
30
45
  # Raise when attributes are missing.
31
46
  class MissingAttributes < Error; end
@@ -23,5 +23,5 @@
23
23
  #
24
24
 
25
25
  module HelloSign
26
- VERSION = '3.5.4'
26
+ VERSION = '3.6'
27
27
  end
@@ -3,4 +3,4 @@
3
3
  "claim_url": "https:\/\/www.hellosign.com\/send\/resendDocs?root_snapshot_guids[]=7f967b7d06e154394eab693febedf61e8ebe49eb&amp;snapshot_access_guids[]=fb848631&amp;root_snapshot_guids[]=7aedaf31e12edf9f2672a0b2ddf028aca670e101&amp;snapshot_access_guids[]=f398ef87",
4
4
  "signing_redirect_url": null
5
5
  }
6
- }
6
+ }
Binary file
@@ -50,4 +50,68 @@ describe HelloSign::Api::UnclaimedDraft do
50
50
  end
51
51
  end
52
52
  end
53
+
54
+ describe '#create_embedded_unclaimed_draft' do
55
+ context 'send_document' do
56
+ before do
57
+ stub_post('/unclaimed_draft/create_embedded', 'unclaimed_draft')
58
+ @unclaimed_draft = HelloSign.create_embedded_unclaimed_draft({ :type => 'send_document' })
59
+ end
60
+
61
+ it 'should get the correct resource' do
62
+ expect(a_post('/unclaimed_draft/create_embedded')).to have_been_made
63
+ end
64
+
65
+ it 'should return a UnclaimedDraft' do
66
+ expect(@unclaimed_draft).to be_an HelloSign::Resource::UnclaimedDraft
67
+ end
68
+ end
69
+
70
+ context 'request_signature' do
71
+ before do
72
+ stub_post('/unclaimed_draft/create_embedded', 'unclaimed_draft')
73
+ @unclaimed_draft = HelloSign.create_embedded_unclaimed_draft({ :type => 'request_signature' })
74
+ end
75
+
76
+ it 'should get the correct resource' do
77
+ expect(a_post('/unclaimed_draft/create_embedded')).to have_been_made
78
+ end
79
+
80
+ it 'should return a UnclaimedDraft' do
81
+ expect(@unclaimed_draft).to be_an HelloSign::Resource::UnclaimedDraft
82
+ end
83
+ end
84
+ end
85
+
86
+ describe '#create_embedded_unclaimed_draft_with_template' do
87
+ context 'send_document' do
88
+ before do
89
+ stub_post('/unclaimed_draft/create_embedded_with_template', 'unclaimed_draft')
90
+ @unclaimed_draft = HelloSign.create_embedded_unclaimed_draft_with_template({})
91
+ end
92
+
93
+ it 'should get the correct resource' do
94
+ expect(a_post('/unclaimed_draft/create_embedded_with_template')).to have_been_made
95
+ end
96
+
97
+ it 'should return a UnclaimedDraft' do
98
+ expect(@unclaimed_draft).to be_an HelloSign::Resource::UnclaimedDraft
99
+ end
100
+ end
101
+
102
+ context 'request_signature' do
103
+ before do
104
+ stub_post('/unclaimed_draft/create_embedded_with_template', 'unclaimed_draft')
105
+ @unclaimed_draft = HelloSign.create_embedded_unclaimed_draft_with_template({})
106
+ end
107
+
108
+ it 'should get the correct resource' do
109
+ expect(a_post('/unclaimed_draft/create_embedded_with_template')).to have_been_made
110
+ end
111
+
112
+ it 'should return a UnclaimedDraft' do
113
+ expect(@unclaimed_draft).to be_an HelloSign::Resource::UnclaimedDraft
114
+ end
115
+ end
116
+ end
53
117
  end
@@ -72,6 +72,40 @@ describe HelloSign::Client do
72
72
  expect { get_request(504) }.to raise_error(HelloSign::Error::UnknownError)
73
73
  end
74
74
  end
75
+
76
+ describe 'error keys are set' do
77
+ let(:error) do
78
+ begin
79
+ get_request(400)
80
+ rescue => e
81
+ e
82
+ else
83
+ # Defense exception:
84
+ raise 'Expected stub to throw exception'
85
+ end
86
+ end
87
+
88
+ describe 'message' do
89
+ subject { error.message }
90
+ # Following test proves backwards compatibility
91
+ it { is_expected.to match(/Server responded.*/) }
92
+ end
93
+
94
+ describe 'response_body' do
95
+ subject { error.response_body }
96
+ it { is_expected.to eql(load_fixture('error').read) }
97
+ end
98
+
99
+ describe 'response_status' do
100
+ subject { error.response_status }
101
+ it { is_expected.to eql(400) }
102
+ end
103
+
104
+ describe 'request_uri' do
105
+ subject { error.request_uri }
106
+ it { is_expected.to eql('https://api.hellosign.com/v3/account') }
107
+ end
108
+ end
75
109
  end
76
110
 
77
111
  describe 'prepare' do
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe HelloSign::Error do
4
+ # another test to prove backwards compatibility
5
+ describe 'custom error message' do
6
+ subject { HelloSign::Error::Error.new('Foo').message }
7
+ it { is_expected.to eql('Foo') }
8
+ end
9
+ end
10
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hellosign-ruby-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.4
4
+ version: '3.6'
5
5
  platform: ruby
6
6
  authors:
7
7
  - HelloSign
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-08 00:00:00.000000000 Z
11
+ date: 2018-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -125,6 +125,7 @@ files:
125
125
  - Rakefile
126
126
  - hellosign-ruby-sdk.gemspec
127
127
  - lib/hello_sign.rb
128
+ - lib/hello_sign/.error.rb.swp
128
129
  - lib/hello_sign/api.rb
129
130
  - lib/hello_sign/api/account.rb
130
131
  - lib/hello_sign/api/api_app.rb
@@ -165,6 +166,7 @@ files:
165
166
  - spec/fixtures/templates.json
166
167
  - spec/fixtures/token.json
167
168
  - spec/fixtures/unclaimed_draft.json
169
+ - spec/hello_sign/.error_spec.rb.swp
168
170
  - spec/hello_sign/api/account_spec.rb
169
171
  - spec/hello_sign/api/api_app_spec.rb
170
172
  - spec/hello_sign/api/embedded_spec.rb
@@ -174,6 +176,7 @@ files:
174
176
  - spec/hello_sign/api/template_spec.rb
175
177
  - spec/hello_sign/api/unclaimed_draft_spec.rb
176
178
  - spec/hello_sign/client_spec.rb
179
+ - spec/hello_sign/error_spec.rb
177
180
  - spec/hello_sign/resource/base_resource_spec.rb
178
181
  - spec/hello_sign_spec.rb
179
182
  - spec/scenarios/uploads_spec.rb
@@ -218,6 +221,7 @@ test_files:
218
221
  - spec/fixtures/templates.json
219
222
  - spec/fixtures/token.json
220
223
  - spec/fixtures/unclaimed_draft.json
224
+ - spec/hello_sign/.error_spec.rb.swp
221
225
  - spec/hello_sign/api/account_spec.rb
222
226
  - spec/hello_sign/api/api_app_spec.rb
223
227
  - spec/hello_sign/api/embedded_spec.rb
@@ -227,6 +231,7 @@ test_files:
227
231
  - spec/hello_sign/api/template_spec.rb
228
232
  - spec/hello_sign/api/unclaimed_draft_spec.rb
229
233
  - spec/hello_sign/client_spec.rb
234
+ - spec/hello_sign/error_spec.rb
230
235
  - spec/hello_sign/resource/base_resource_spec.rb
231
236
  - spec/hello_sign_spec.rb
232
237
  - spec/scenarios/uploads_spec.rb