hello_sign 0.5.0 → 0.6.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/lib/hello_sign/client.rb +9 -3
- data/lib/hello_sign/error.rb +13 -0
- data/lib/hello_sign/middleware/raise_error.rb +29 -0
- data/lib/hello_sign/parameters/reusable_form_signature_request.rb +17 -13
- data/lib/hello_sign/parameters/unclaimed_draft.rb +6 -6
- data/lib/hello_sign/version.rb +1 -1
- data/lib/hello_sign.rb +10 -4
- data/spec/helper.rb +8 -0
- data/spec/integration/error_spec.rb +50 -0
- data/spec/integration/helper.rb +4 -0
- data/spec/unit/client_spec.rb +50 -3
- data/spec/unit/error_spec.rb +15 -0
- data/spec/unit/hello_sign_spec.rb +69 -17
- data/spec/unit/middleware/raise_error_spec.rb +28 -0
- data/spec/unit/parameters/reusable_form_signature_request_spec.rb +19 -20
- data/spec/unit/parameters/unclaimed_draft_spec.rb +11 -6
- data/spec/unit/proxy/unclaimed_draft_spec.rb +2 -6
- metadata +27 -9
data/lib/hello_sign/client.rb
CHANGED
@@ -12,9 +12,14 @@ module HelloSign
|
|
12
12
|
|
13
13
|
attr_reader :email_address, :password
|
14
14
|
|
15
|
-
def initialize(
|
16
|
-
|
17
|
-
|
15
|
+
def initialize(email_address_or_hash, password = nil)
|
16
|
+
if email_address_or_hash.is_a? Hash
|
17
|
+
@email_address = email_address_or_hash.fetch(:email_address) { raise ArgumentError }
|
18
|
+
@password = email_address_or_hash.fetch(:password) { raise ArgumentError }
|
19
|
+
else
|
20
|
+
@email_address = email_address_or_hash
|
21
|
+
@password = password
|
22
|
+
end
|
18
23
|
end
|
19
24
|
|
20
25
|
def get(path, options = {})
|
@@ -42,6 +47,7 @@ module HelloSign
|
|
42
47
|
|
43
48
|
connection.request :multipart
|
44
49
|
connection.request :url_encoded
|
50
|
+
connection.response :raise_error
|
45
51
|
connection.response :multi_json, :symbolize_keys => true
|
46
52
|
connection.adapter :net_http
|
47
53
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module HelloSign
|
2
|
+
class Error < StandardError
|
3
|
+
class BadRequest < HelloSign::Error; end
|
4
|
+
class Unauthorized < HelloSign::Error; end
|
5
|
+
class Forbidden < HelloSign::Error; end
|
6
|
+
class NotFound < HelloSign::Error; end
|
7
|
+
class Unknown < HelloSign::Error; end
|
8
|
+
class TeamInviteFailed < HelloSign::Error; end
|
9
|
+
class InvalidRecipient < HelloSign::Error; end
|
10
|
+
class ConvertFailed < HelloSign::Error; end
|
11
|
+
class SignatureRequestCancelFailed < HelloSign::Error; end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'hello_sign/error'
|
2
|
+
|
3
|
+
require 'faraday'
|
4
|
+
|
5
|
+
module HelloSign
|
6
|
+
module Middleware
|
7
|
+
class RaiseError < Faraday::Response::Middleware
|
8
|
+
|
9
|
+
def on_complete(env)
|
10
|
+
body = env[:body] or return
|
11
|
+
|
12
|
+
if error = body[:error]
|
13
|
+
case error[:error_name]
|
14
|
+
when 'bad_request' then raise HelloSign::Error::BadRequest
|
15
|
+
when 'unauthorized' then raise HelloSign::Error::Unauthorized
|
16
|
+
when 'forbidden' then raise HelloSign::Error::Forbidden
|
17
|
+
when 'not_found' then raise HelloSign::Error::NotFound
|
18
|
+
when 'unknown' then raise HelloSign::Error::Unknown
|
19
|
+
when 'team_invite_failed' then raise HelloSign::Error::TeamInviteFailed
|
20
|
+
when 'invalid_recipient' then raise HelloSign::Error::InvalidRecipient
|
21
|
+
when 'convert_failed' then raise HelloSign::Error::ConvertFailed
|
22
|
+
when 'signature_request_cancel_failed' then raise HelloSign::Error::SignatureRequestCancelFailed
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,8 +1,23 @@
|
|
1
1
|
module HelloSign
|
2
2
|
module Parameters
|
3
3
|
class ReusableFormSignatureRequest
|
4
|
-
|
5
|
-
|
4
|
+
attr_writer :reusable_form_id, :title, :subject, :message, :ccs, :signers, :custom_fields
|
5
|
+
|
6
|
+
def formatted
|
7
|
+
{
|
8
|
+
:reusable_form_id => reusable_form_id,
|
9
|
+
:title => title,
|
10
|
+
:subject => subject,
|
11
|
+
:message => message,
|
12
|
+
:ccs => ccs,
|
13
|
+
:signers => signers,
|
14
|
+
:custom_fields => custom_fields
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
attr_reader :reusable_form_id, :title, :subject, :message
|
6
21
|
|
7
22
|
def ccs
|
8
23
|
@ccs.inject({}) do |parameter, cc|
|
@@ -25,17 +40,6 @@ module HelloSign
|
|
25
40
|
end
|
26
41
|
end
|
27
42
|
|
28
|
-
def formatted
|
29
|
-
{
|
30
|
-
:reusable_form_id => reusable_form_id,
|
31
|
-
:title => title,
|
32
|
-
:subject => subject,
|
33
|
-
:message => message,
|
34
|
-
:ccs => ccs,
|
35
|
-
:signers => signers,
|
36
|
-
:custom_fields => custom_fields
|
37
|
-
}
|
38
|
-
end
|
39
43
|
end
|
40
44
|
end
|
41
45
|
end
|
@@ -5,6 +5,12 @@ module HelloSign
|
|
5
5
|
class UnclaimedDraft
|
6
6
|
attr_writer :files
|
7
7
|
|
8
|
+
def formatted
|
9
|
+
{:file => files}
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
8
14
|
def files
|
9
15
|
@files.each_with_index.inject({}) do |parameter, (file, index)|
|
10
16
|
parameter[index] = upload_io.new(file[:io], file[:mime], file[:name])
|
@@ -12,12 +18,6 @@ module HelloSign
|
|
12
18
|
end
|
13
19
|
end
|
14
20
|
|
15
|
-
def formatted
|
16
|
-
{:file => files}
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
21
|
def upload_io
|
22
22
|
Faraday::UploadIO
|
23
23
|
end
|
data/lib/hello_sign/version.rb
CHANGED
data/lib/hello_sign.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'hello_sign/middleware/raise_error'
|
1
2
|
require 'hello_sign/client'
|
2
3
|
require 'hello_sign/version'
|
3
4
|
|
@@ -9,16 +10,15 @@ module HelloSign
|
|
9
10
|
|
10
11
|
attr_accessor :email_address, :password
|
11
12
|
|
12
|
-
delegate [:account, :signature_request, :reusable_form, :team,
|
13
|
-
:unclaimed_draft] => :client
|
13
|
+
delegate [:account, :signature_request, :reusable_form, :team, :unclaimed_draft] => :client
|
14
14
|
|
15
15
|
def client
|
16
|
-
@client =
|
16
|
+
@client = client_source.new(email_address, password) unless credentials_match?
|
17
17
|
@client
|
18
18
|
end
|
19
19
|
|
20
20
|
def configure
|
21
|
-
yield
|
21
|
+
yield self
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
@@ -27,5 +27,11 @@ module HelloSign
|
|
27
27
|
@client && [@client.email_address, @client.password].hash == [email_address, password].hash
|
28
28
|
end
|
29
29
|
|
30
|
+
def client_source
|
31
|
+
@client_source || HelloSign::Client
|
32
|
+
end
|
33
|
+
|
34
|
+
Faraday.register_middleware :response, :raise_error => HelloSign::Middleware::RaiseError
|
35
|
+
|
30
36
|
end
|
31
37
|
end
|
data/spec/helper.rb
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'integration/helper'
|
2
|
+
|
3
|
+
describe HelloSign do
|
4
|
+
let(:any_call) { HelloSign.team.show }
|
5
|
+
|
6
|
+
specify do
|
7
|
+
stub_request_with_error('bad_request')
|
8
|
+
expect { any_call }.to raise_error HelloSign::Error::BadRequest
|
9
|
+
end
|
10
|
+
|
11
|
+
specify do
|
12
|
+
stub_request_with_error('unauthorized')
|
13
|
+
expect { any_call }.to raise_error HelloSign::Error::Unauthorized
|
14
|
+
end
|
15
|
+
|
16
|
+
specify do
|
17
|
+
stub_request_with_error('forbidden')
|
18
|
+
expect { any_call }.to raise_error HelloSign::Error::Forbidden
|
19
|
+
end
|
20
|
+
|
21
|
+
specify do
|
22
|
+
stub_request_with_error('not_found')
|
23
|
+
expect { any_call }.to raise_error HelloSign::Error::NotFound
|
24
|
+
end
|
25
|
+
|
26
|
+
specify do
|
27
|
+
stub_request_with_error('unknown')
|
28
|
+
expect { any_call }.to raise_error HelloSign::Error::Unknown
|
29
|
+
end
|
30
|
+
|
31
|
+
specify do
|
32
|
+
stub_request_with_error('team_invite_failed')
|
33
|
+
expect { any_call }.to raise_error HelloSign::Error::TeamInviteFailed
|
34
|
+
end
|
35
|
+
|
36
|
+
specify do
|
37
|
+
stub_request_with_error('invalid_recipient')
|
38
|
+
expect { any_call }.to raise_error HelloSign::Error::InvalidRecipient
|
39
|
+
end
|
40
|
+
|
41
|
+
specify do
|
42
|
+
stub_request_with_error('convert_failed')
|
43
|
+
expect { any_call }.to raise_error HelloSign::Error::ConvertFailed
|
44
|
+
end
|
45
|
+
|
46
|
+
specify do
|
47
|
+
stub_request_with_error('signature_request_cancel_failed')
|
48
|
+
expect { any_call }.to raise_error HelloSign::Error::SignatureRequestCancelFailed
|
49
|
+
end
|
50
|
+
end
|
data/spec/integration/helper.rb
CHANGED
@@ -24,6 +24,10 @@ def stub_post_with_auth(path)
|
|
24
24
|
stub_request(:post, "https://david@bowman.com:foobar@api.hellosign.com/v3#{path}")
|
25
25
|
end
|
26
26
|
|
27
|
+
def stub_request_with_error(error)
|
28
|
+
stub_request(:any, /api\.hellosign\.com/).to_return(:body => {:error => {:error_name => error}})
|
29
|
+
end
|
30
|
+
|
27
31
|
def a_get(path)
|
28
32
|
a_request(:get, "https://api.hellosign.com/v3#{path}")
|
29
33
|
end
|
data/spec/unit/client_spec.rb
CHANGED
@@ -3,12 +3,59 @@ require 'hello_sign/client'
|
|
3
3
|
require 'shared_examples/proxy'
|
4
4
|
|
5
5
|
describe HelloSign::Client do
|
6
|
-
|
6
|
+
let(:email_address) { double('email_address') }
|
7
|
+
let(:password) { double('password') }
|
8
|
+
subject(:hs_client) { HelloSign::Client.new(email_address, password) }
|
7
9
|
|
8
|
-
its(:email_address) { should eq
|
9
|
-
its(:password) { should eq
|
10
|
+
its(:email_address) { should eq email_address }
|
11
|
+
its(:password) { should eq password }
|
10
12
|
|
11
13
|
it_behaves_like 'a proxy' do
|
12
14
|
let(:client) { hs_client }
|
13
15
|
end
|
16
|
+
|
17
|
+
describe "request methods" do
|
18
|
+
let(:path) { double('path') }
|
19
|
+
let(:options) { double('options') }
|
20
|
+
let(:response) { double('response') }
|
21
|
+
|
22
|
+
before { hs_client.stub(:request).and_return(response) }
|
23
|
+
|
24
|
+
describe "#get" do
|
25
|
+
it "sends a request" do
|
26
|
+
hs_client.should_receive(:request).with(:get, path, options)
|
27
|
+
hs_client.get(path, options)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns the response" do
|
31
|
+
expect(hs_client.get(path, options)).to eq response
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#post" do
|
36
|
+
it "sends a request" do
|
37
|
+
hs_client.should_receive(:request).with(:post, path, options)
|
38
|
+
hs_client.post(path, options)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns the response" do
|
42
|
+
expect(hs_client.post(path, options)).to eq response
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "when a hash is passed to the constructor" do
|
48
|
+
subject(:hs_client) { HelloSign::Client.new(:email_address => email_address, :password => password) }
|
49
|
+
|
50
|
+
its(:email_address) { should eq email_address }
|
51
|
+
its(:password) { should eq password }
|
52
|
+
|
53
|
+
it "raises an exception if an email address is not provided" do
|
54
|
+
expect { HelloSign::Client.new(:password => 'space') }.to raise_error ArgumentError
|
55
|
+
end
|
56
|
+
|
57
|
+
it "raises an exception if a password is not provided" do
|
58
|
+
expect { HelloSign::Client.new(:email_address => 'david@bowman.com') }.to raise_error ArgumentError
|
59
|
+
end
|
60
|
+
end
|
14
61
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'hello_sign/error'
|
3
|
+
|
4
|
+
describe HelloSign::Error do
|
5
|
+
specify { expect { raise HelloSign::Error }.to raise_error StandardError }
|
6
|
+
specify { expect { raise HelloSign::Error::BadRequest }.to raise_error HelloSign::Error }
|
7
|
+
specify { expect { raise HelloSign::Error::Unauthorized }.to raise_error HelloSign::Error }
|
8
|
+
specify { expect { raise HelloSign::Error::Forbidden }.to raise_error HelloSign::Error }
|
9
|
+
specify { expect { raise HelloSign::Error::NotFound }.to raise_error HelloSign::Error }
|
10
|
+
specify { expect { raise HelloSign::Error::Unknown }.to raise_error HelloSign::Error }
|
11
|
+
specify { expect { raise HelloSign::Error::TeamInviteFailed }.to raise_error HelloSign::Error }
|
12
|
+
specify { expect { raise HelloSign::Error::InvalidRecipient }.to raise_error HelloSign::Error }
|
13
|
+
specify { expect { raise HelloSign::Error::ConvertFailed }.to raise_error HelloSign::Error }
|
14
|
+
specify { expect { raise HelloSign::Error::SignatureRequestCancelFailed }.to raise_error HelloSign::Error }
|
15
|
+
end
|
@@ -2,43 +2,95 @@ require 'helper'
|
|
2
2
|
require 'hello_sign'
|
3
3
|
|
4
4
|
describe HelloSign do
|
5
|
+
let(:email_address) { double('email address') }
|
6
|
+
let(:password) { double('password') }
|
7
|
+
|
5
8
|
before do
|
6
|
-
HelloSign.email_address =
|
7
|
-
HelloSign.password =
|
9
|
+
HelloSign.email_address = email_address
|
10
|
+
HelloSign.password = password
|
8
11
|
end
|
9
12
|
|
10
|
-
its(:email_address) { should eq
|
11
|
-
its(:password) { should eq
|
13
|
+
its(:email_address) { should eq email_address }
|
14
|
+
its(:password) { should eq password }
|
12
15
|
|
13
16
|
describe "::client" do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
17
|
+
let(:client_source) { double('client_source') }
|
18
|
+
let(:client) { double('client') }
|
19
|
+
|
20
|
+
before do
|
21
|
+
HelloSign._set_internal_collaborator(:client_source, client_source)
|
22
|
+
client_source.stub(:new).and_return(client)
|
23
|
+
end
|
24
|
+
|
25
|
+
after { HelloSign.instance_variable_set(:@client, nil) }
|
26
|
+
|
27
|
+
its(:client) { should be client }
|
28
|
+
|
29
|
+
it "passes the credentials when creating the client" do
|
30
|
+
client_source.should_receive(:new).with(email_address, password)
|
31
|
+
HelloSign.client
|
18
32
|
end
|
19
33
|
|
20
34
|
context "when it has previously been called" do
|
21
|
-
|
35
|
+
let(:new_client) { double('new client') }
|
22
36
|
|
23
|
-
|
24
|
-
|
37
|
+
before do
|
38
|
+
client_source.stub(:new).and_return(client, new_client)
|
39
|
+
client.stub(:email_address).and_return(email_address)
|
40
|
+
client.stub(:password).and_return(password)
|
41
|
+
HelloSign.client
|
25
42
|
end
|
26
43
|
|
27
|
-
|
44
|
+
its(:client) { should be client }
|
45
|
+
|
46
|
+
context "and the credentials change" do
|
28
47
|
before do
|
29
48
|
HelloSign.email_address = 'bob@earth.com'
|
30
49
|
HelloSign.password = 'being_human'
|
31
50
|
end
|
32
51
|
|
33
|
-
|
34
|
-
expect(HelloSign.client).to_not be @client
|
35
|
-
expect(HelloSign.client.email_address).to eq 'bob@earth.com'
|
36
|
-
expect(HelloSign.client.password).to eq 'being_human'
|
37
|
-
end
|
52
|
+
its(:client) { should be new_client }
|
38
53
|
end
|
39
54
|
end
|
40
55
|
end
|
41
56
|
|
57
|
+
context "when calling delegated methods" do
|
58
|
+
let(:client_source) { double('client_source') }
|
59
|
+
let(:client) { double('client') }
|
60
|
+
|
61
|
+
before do
|
62
|
+
HelloSign._set_internal_collaborator(:client_source, client_source)
|
63
|
+
client_source.stub(:new).and_return(client)
|
64
|
+
end
|
65
|
+
|
66
|
+
after { HelloSign.instance_variable_set(:@client, nil) }
|
67
|
+
|
68
|
+
it "delegates ::account to the client" do
|
69
|
+
client.should_receive(:account)
|
70
|
+
HelloSign.account
|
71
|
+
end
|
72
|
+
|
73
|
+
it "delegates ::signature_request to the client" do
|
74
|
+
client.should_receive(:signature_request)
|
75
|
+
HelloSign.signature_request
|
76
|
+
end
|
77
|
+
|
78
|
+
it "delegates ::reusable_form to the client" do
|
79
|
+
client.should_receive(:reusable_form)
|
80
|
+
HelloSign.reusable_form
|
81
|
+
end
|
82
|
+
|
83
|
+
it "delegates ::team to the client" do
|
84
|
+
client.should_receive(:team)
|
85
|
+
HelloSign.team
|
86
|
+
end
|
87
|
+
|
88
|
+
it "delegates ::unclaimed_draft to the client" do
|
89
|
+
client.should_receive(:unclaimed_draft)
|
90
|
+
HelloSign.unclaimed_draft
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
42
94
|
describe "::configure" do
|
43
95
|
it "yields itself to the block" do
|
44
96
|
HelloSign.configure do |hs|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'hello_sign/middleware/raise_error'
|
3
|
+
|
4
|
+
describe HelloSign::Middleware::RaiseError do
|
5
|
+
let(:middleware) { HelloSign::Middleware::RaiseError.new(lambda { |env| Faraday::Response.new(env) }) }
|
6
|
+
|
7
|
+
specify { expect { call_with_error('bad_request') }.to raise_error HelloSign::Error::BadRequest }
|
8
|
+
specify { expect { call_with_error('unauthorized') }.to raise_error HelloSign::Error::Unauthorized }
|
9
|
+
specify { expect { call_with_error('forbidden') }.to raise_error HelloSign::Error::Forbidden }
|
10
|
+
specify { expect { call_with_error('not_found') }.to raise_error HelloSign::Error::NotFound }
|
11
|
+
specify { expect { call_with_error('unknown') }.to raise_error HelloSign::Error::Unknown }
|
12
|
+
specify { expect { call_with_error('team_invite_failed') }.to raise_error HelloSign::Error::TeamInviteFailed }
|
13
|
+
specify { expect { call_with_error('invalid_recipient') }.to raise_error HelloSign::Error::InvalidRecipient }
|
14
|
+
specify { expect { call_with_error('convert_failed') }.to raise_error HelloSign::Error::ConvertFailed }
|
15
|
+
specify { expect { call_with_error('signature_request_cancel_failed') }.to raise_error HelloSign::Error::SignatureRequestCancelFailed }
|
16
|
+
|
17
|
+
it 'does not blow up if there is not a body' do
|
18
|
+
expect { middleware.call({}) }.to_not raise_error
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def call_with_error(error)
|
24
|
+
env = {:body => {:error => {:error_name => error}}}
|
25
|
+
middleware.call(env)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -4,26 +4,6 @@ require 'hello_sign/parameters/reusable_form_signature_request'
|
|
4
4
|
describe HelloSign::Parameters::ReusableFormSignatureRequest do
|
5
5
|
describe "#formatted" do
|
6
6
|
let(:request_parameters) { HelloSign::Parameters::ReusableFormSignatureRequest.new }
|
7
|
-
let(:expected) do
|
8
|
-
{
|
9
|
-
:reusable_form_id => 'form_id',
|
10
|
-
:title => 'Lease',
|
11
|
-
:subject => 'Sign this',
|
12
|
-
:message => 'You must sign this.',
|
13
|
-
:ccs => {
|
14
|
-
'lawyer' => {:email_address => 'lawyer@lawfirm.com'},
|
15
|
-
'accountant' => {:email_address => 'accountant@llc.com'}
|
16
|
-
},
|
17
|
-
:signers => {
|
18
|
-
'consultant' => {:name => 'Jack', :email_address => 'jack@hill.com'},
|
19
|
-
'client' => {:name => 'Jill', :email_address => 'jill@hill.com'}
|
20
|
-
},
|
21
|
-
:custom_fields => {
|
22
|
-
'cost' => '$20,000',
|
23
|
-
'time' => 'two weeks'
|
24
|
-
}
|
25
|
-
}
|
26
|
-
end
|
27
7
|
|
28
8
|
before do
|
29
9
|
request_parameters.reusable_form_id = 'form_id'
|
@@ -45,6 +25,25 @@ describe HelloSign::Parameters::ReusableFormSignatureRequest do
|
|
45
25
|
end
|
46
26
|
|
47
27
|
it "returns formatted parameters" do
|
28
|
+
expected = {
|
29
|
+
:reusable_form_id => 'form_id',
|
30
|
+
:title => 'Lease',
|
31
|
+
:subject => 'Sign this',
|
32
|
+
:message => 'You must sign this.',
|
33
|
+
:ccs => {
|
34
|
+
'lawyer' => {:email_address => 'lawyer@lawfirm.com'},
|
35
|
+
'accountant' => {:email_address => 'accountant@llc.com'}
|
36
|
+
},
|
37
|
+
:signers => {
|
38
|
+
'consultant' => {:name => 'Jack', :email_address => 'jack@hill.com'},
|
39
|
+
'client' => {:name => 'Jill', :email_address => 'jill@hill.com'}
|
40
|
+
},
|
41
|
+
:custom_fields => {
|
42
|
+
'cost' => '$20,000',
|
43
|
+
'time' => 'two weeks'
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
48
47
|
expect(request_parameters.formatted).to eq expected
|
49
48
|
end
|
50
49
|
end
|
@@ -1,17 +1,21 @@
|
|
1
1
|
require 'helper'
|
2
2
|
require 'hello_sign/parameters/unclaimed_draft'
|
3
3
|
|
4
|
+
require 'stringio'
|
5
|
+
|
4
6
|
describe HelloSign::Parameters::UnclaimedDraft do
|
7
|
+
let(:draft_parameters) { HelloSign::Parameters::UnclaimedDraft.new }
|
8
|
+
|
9
|
+
it "interfaces with Faraday::UploadIO properly" do
|
10
|
+
draft_parameters.files = [{:name => 'test.txt', :io => StringIO.new('foobar'), :mime => 'text/plain'}]
|
11
|
+
expect(draft_parameters.formatted).to be_a Hash
|
12
|
+
end
|
13
|
+
|
5
14
|
describe "#formatted" do
|
6
|
-
let(:draft_parameters) { HelloSign::Parameters::UnclaimedDraft.new }
|
7
15
|
let(:text_file) { double('text file') }
|
8
16
|
let(:image_file) { double('image file') }
|
9
|
-
let(:expected) { {:file => {0 => text_file, 1 => image_file}} }
|
10
17
|
|
11
18
|
before do
|
12
|
-
Faraday::UploadIO.should_receive(:new).with('text file IO object', 'text/plain', 'test.txt').and_return(text_file)
|
13
|
-
Faraday::UploadIO.should_receive(:new).with('image file IO object', 'image/jpeg', 'test.jpg').and_return(image_file)
|
14
|
-
|
15
19
|
draft_parameters.files = [
|
16
20
|
{:name => 'test.txt', :io => 'text file IO object', :mime => 'text/plain'},
|
17
21
|
{:name => 'test.jpg', :io => 'image file IO object', :mime => 'image/jpeg'}
|
@@ -19,7 +23,8 @@ describe HelloSign::Parameters::UnclaimedDraft do
|
|
19
23
|
end
|
20
24
|
|
21
25
|
it "returns formatted parameters" do
|
22
|
-
|
26
|
+
Faraday::UploadIO.stub(:new).and_return(text_file, image_file)
|
27
|
+
expect(draft_parameters.formatted).to eq({:file => {0 => text_file, 1 => image_file}})
|
23
28
|
end
|
24
29
|
end
|
25
30
|
end
|
@@ -6,15 +6,11 @@ describe HelloSign::Proxy::UnclaimedDraft do
|
|
6
6
|
let(:api_response) { double('API response') }
|
7
7
|
subject(:ud_proxy) { HelloSign::Proxy::UnclaimedDraft.new(client) }
|
8
8
|
|
9
|
-
|
10
|
-
it "returns the client" do
|
11
|
-
expect(ud_proxy.client).to be client
|
12
|
-
end
|
13
|
-
end
|
9
|
+
its(:client) { should eq client }
|
14
10
|
|
15
11
|
describe "#create" do
|
16
12
|
let(:formatted_request_body) { double('formatted request body') }
|
17
|
-
let(:draft_parameters)
|
13
|
+
let(:draft_parameters) { double('draft parameters') }
|
18
14
|
|
19
15
|
before do
|
20
16
|
ud_proxy.draft_parameters = draft_parameters
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hello_sign
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.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: 2013-02-
|
12
|
+
date: 2013-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -91,6 +91,22 @@ dependencies:
|
|
91
91
|
- - ~>
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: 10.0.3
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: vcr
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 2.4.0
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 2.4.0
|
94
110
|
description: A Ruby interface to the HelloSign API.
|
95
111
|
email:
|
96
112
|
- craiglttl@gmail.com
|
@@ -99,6 +115,8 @@ extensions: []
|
|
99
115
|
extra_rdoc_files: []
|
100
116
|
files:
|
101
117
|
- lib/hello_sign/client.rb
|
118
|
+
- lib/hello_sign/error.rb
|
119
|
+
- lib/hello_sign/middleware/raise_error.rb
|
102
120
|
- lib/hello_sign/parameters/reusable_form_signature_request.rb
|
103
121
|
- lib/hello_sign/parameters/signature_request.rb
|
104
122
|
- lib/hello_sign/parameters/unclaimed_draft.rb
|
@@ -116,6 +134,7 @@ files:
|
|
116
134
|
- spec/fixtures/test.txt
|
117
135
|
- spec/helper.rb
|
118
136
|
- spec/integration/account_spec.rb
|
137
|
+
- spec/integration/error_spec.rb
|
119
138
|
- spec/integration/hello_sign_spec.rb
|
120
139
|
- spec/integration/helper.rb
|
121
140
|
- spec/integration/reusable_form_spec.rb
|
@@ -124,7 +143,9 @@ files:
|
|
124
143
|
- spec/integration/unclaimed_draft_spec.rb
|
125
144
|
- spec/shared_examples/proxy.rb
|
126
145
|
- spec/unit/client_spec.rb
|
146
|
+
- spec/unit/error_spec.rb
|
127
147
|
- spec/unit/hello_sign_spec.rb
|
148
|
+
- spec/unit/middleware/raise_error_spec.rb
|
128
149
|
- spec/unit/parameters/reusable_form_signature_request_spec.rb
|
129
150
|
- spec/unit/parameters/signature_request_spec.rb
|
130
151
|
- spec/unit/parameters/unclaimed_draft_spec.rb
|
@@ -146,21 +167,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
146
167
|
- - ! '>='
|
147
168
|
- !ruby/object:Gem::Version
|
148
169
|
version: '0'
|
149
|
-
segments:
|
150
|
-
- 0
|
151
|
-
hash: -3035616681847644249
|
152
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
171
|
none: false
|
154
172
|
requirements:
|
155
173
|
- - ! '>='
|
156
174
|
- !ruby/object:Gem::Version
|
157
175
|
version: '0'
|
158
|
-
segments:
|
159
|
-
- 0
|
160
|
-
hash: -3035616681847644249
|
161
176
|
requirements: []
|
162
177
|
rubyforge_project:
|
163
|
-
rubygems_version: 1.8.
|
178
|
+
rubygems_version: 1.8.24
|
164
179
|
signing_key:
|
165
180
|
specification_version: 3
|
166
181
|
summary: A Ruby interface to the HelloSign API.
|
@@ -170,6 +185,7 @@ test_files:
|
|
170
185
|
- spec/fixtures/test.txt
|
171
186
|
- spec/helper.rb
|
172
187
|
- spec/integration/account_spec.rb
|
188
|
+
- spec/integration/error_spec.rb
|
173
189
|
- spec/integration/hello_sign_spec.rb
|
174
190
|
- spec/integration/helper.rb
|
175
191
|
- spec/integration/reusable_form_spec.rb
|
@@ -178,7 +194,9 @@ test_files:
|
|
178
194
|
- spec/integration/unclaimed_draft_spec.rb
|
179
195
|
- spec/shared_examples/proxy.rb
|
180
196
|
- spec/unit/client_spec.rb
|
197
|
+
- spec/unit/error_spec.rb
|
181
198
|
- spec/unit/hello_sign_spec.rb
|
199
|
+
- spec/unit/middleware/raise_error_spec.rb
|
182
200
|
- spec/unit/parameters/reusable_form_signature_request_spec.rb
|
183
201
|
- spec/unit/parameters/signature_request_spec.rb
|
184
202
|
- spec/unit/parameters/unclaimed_draft_spec.rb
|