hello_sign 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hello_sign/client.rb +5 -5
- data/lib/hello_sign/parameters/reusable_form_signature_request.rb +2 -2
- data/lib/hello_sign/parameters/signature_request.rb +3 -3
- data/lib/hello_sign/proxy/account.rb +2 -8
- data/lib/hello_sign/proxy/reusable_form.rb +2 -15
- data/lib/hello_sign/proxy/settings.rb +2 -2
- data/lib/hello_sign/proxy/signature_request.rb +3 -9
- data/lib/hello_sign/proxy/team.rb +8 -21
- data/lib/hello_sign/version.rb +1 -1
- data/lib/hello_sign.rb +3 -3
- data/spec/integration/account_spec.rb +9 -12
- data/spec/integration/helper.rb +2 -2
- data/spec/integration/reusable_form_spec.rb +4 -4
- data/spec/integration/signature_request_spec.rb +6 -6
- data/spec/unit/client_spec.rb +2 -2
- data/spec/unit/hello_sign_spec.rb +7 -7
- data/spec/unit/parameters/reusable_form_signature_request_spec.rb +4 -4
- data/spec/unit/parameters/signature_request_spec.rb +49 -30
- data/spec/unit/proxy/account_spec.rb +30 -23
- data/spec/unit/proxy/reusable_form_spec.rb +31 -81
- data/spec/unit/proxy/signature_request_spec.rb +0 -6
- data/spec/unit/proxy/team_spec.rb +31 -71
- metadata +24 -2
data/lib/hello_sign/client.rb
CHANGED
@@ -10,11 +10,11 @@ module HelloSign
|
|
10
10
|
API_ENDPOINT = 'https://api.hellosign.com'
|
11
11
|
API_VERSION = '/v3'
|
12
12
|
|
13
|
-
attr_reader :
|
13
|
+
attr_reader :email_address, :password
|
14
14
|
|
15
|
-
def initialize(
|
16
|
-
@
|
17
|
-
@password
|
15
|
+
def initialize(email_address, password)
|
16
|
+
@email_address = email_address
|
17
|
+
@password = password
|
18
18
|
end
|
19
19
|
|
20
20
|
def get(path, options = {})
|
@@ -29,7 +29,7 @@ module HelloSign
|
|
29
29
|
|
30
30
|
def request(method, path, options)
|
31
31
|
base_connection do |connection|
|
32
|
-
connection.request :basic_auth,
|
32
|
+
connection.request :basic_auth, email_address, password unless options[:auth_not_required]
|
33
33
|
end.send(method) do |request|
|
34
34
|
request.url "#{API_VERSION}#{path}", options[:params]
|
35
35
|
request.body = options[:body]
|
@@ -6,14 +6,14 @@ module HelloSign
|
|
6
6
|
|
7
7
|
def ccs
|
8
8
|
@ccs.inject({}) do |parameter, cc|
|
9
|
-
parameter[cc[:role]] = {:email_address => cc[:
|
9
|
+
parameter[cc[:role]] = {:email_address => cc[:email_address]}
|
10
10
|
parameter
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
def signers
|
15
15
|
@signers.inject({}) do |parameter, signer|
|
16
|
-
parameter[signer[:role]] = {:name => signer[:name], :email_address => signer[:
|
16
|
+
parameter[signer[:role]] = {:name => signer[:name], :email_address => signer[:email_address]}
|
17
17
|
parameter
|
18
18
|
end
|
19
19
|
end
|
@@ -7,10 +7,10 @@ module HelloSign
|
|
7
7
|
attr_writer :signers, :files
|
8
8
|
|
9
9
|
def signers
|
10
|
-
@signers.each_with_index.inject({}) do |parameter, (signer, index)|
|
10
|
+
(@signers || {}).each_with_index.inject({}) do |parameter, (signer, index)|
|
11
11
|
signer = {
|
12
12
|
:name => signer[:name],
|
13
|
-
:email_address => signer[:
|
13
|
+
:email_address => signer[:email_address],
|
14
14
|
:order => index
|
15
15
|
}
|
16
16
|
parameter[index] = signer
|
@@ -19,7 +19,7 @@ module HelloSign
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def files
|
22
|
-
@files.each_with_index.inject({}) do |parameter, (file, index)|
|
22
|
+
(@files || {}).each_with_index.inject({}) do |parameter, (file, index)|
|
23
23
|
parameter[index + 1] = upload_io.new(file[:io], file[:mime], file[:name])
|
24
24
|
parameter
|
25
25
|
end
|
@@ -10,14 +10,8 @@ module HelloSign
|
|
10
10
|
@client = client
|
11
11
|
end
|
12
12
|
|
13
|
-
def create(
|
14
|
-
|
15
|
-
password = credentials.fetch(:password)
|
16
|
-
|
17
|
-
client.post('/account/create',
|
18
|
-
:body => {:email_address => email, :password => password},
|
19
|
-
:auth_not_required => true
|
20
|
-
)
|
13
|
+
def create(params = {})
|
14
|
+
client.post('/account/create', :body => params, :auth_not_required => true)
|
21
15
|
end
|
22
16
|
|
23
17
|
def settings
|
@@ -8,7 +8,6 @@ module HelloSign
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def list(params = {})
|
11
|
-
params = {:page => 1}.merge(params)
|
12
11
|
client.get('/reusable_form/list', :params => params)
|
13
12
|
end
|
14
13
|
|
@@ -17,23 +16,11 @@ module HelloSign
|
|
17
16
|
end
|
18
17
|
|
19
18
|
def grant_access(form_id, params = {})
|
20
|
-
client.post("/reusable_form/add_user/#{form_id}", :body =>
|
19
|
+
client.post("/reusable_form/add_user/#{form_id}", :body => params)
|
21
20
|
end
|
22
21
|
|
23
22
|
def revoke_access(form_id, params = {})
|
24
|
-
client.post("/reusable_form/remove_user/#{form_id}", :body =>
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def body(params)
|
30
|
-
if email = params[:email]
|
31
|
-
{:email_address => email}
|
32
|
-
elsif account_id = params[:account_id]
|
33
|
-
{:account_id => account_id}
|
34
|
-
else
|
35
|
-
raise ArgumentError, 'An email address or account ID must be provided.'
|
36
|
-
end
|
23
|
+
client.post("/reusable_form/remove_user/#{form_id}", :body => params)
|
37
24
|
end
|
38
25
|
|
39
26
|
end
|
@@ -23,10 +23,7 @@ module HelloSign
|
|
23
23
|
else
|
24
24
|
yield request_parameters
|
25
25
|
|
26
|
-
client.post(
|
27
|
-
'/signature_request/send',
|
28
|
-
:body => request_parameters.formatted
|
29
|
-
)
|
26
|
+
client.post('/signature_request/send', :body => request_parameters.formatted)
|
30
27
|
end
|
31
28
|
end
|
32
29
|
|
@@ -41,12 +38,9 @@ module HelloSign
|
|
41
38
|
end
|
42
39
|
|
43
40
|
def remind(request_id, params = {})
|
44
|
-
|
41
|
+
params = {:email_address => params.delete(:email)}.merge(params)
|
45
42
|
|
46
|
-
client.post(
|
47
|
-
"/signature_request/remind/#{request_id}",
|
48
|
-
:body => {:email_address => email}
|
49
|
-
)
|
43
|
+
client.post("/signature_request/remind/#{request_id}", :body => params)
|
50
44
|
end
|
51
45
|
|
52
46
|
def cancel(request_id)
|
@@ -7,41 +7,28 @@ module HelloSign
|
|
7
7
|
@client = client
|
8
8
|
end
|
9
9
|
|
10
|
-
def create(params)
|
11
|
-
|
12
|
-
client.post('/team/create', :body => {:name => name})
|
10
|
+
def create(params = {})
|
11
|
+
client.post('/team/create', :body => params)
|
13
12
|
end
|
14
13
|
|
15
14
|
def show
|
16
15
|
client.get('/team')
|
17
16
|
end
|
18
17
|
|
19
|
-
def update(
|
20
|
-
client.post('/team', :body =>
|
18
|
+
def update(params = {})
|
19
|
+
client.post('/team', :body => params)
|
21
20
|
end
|
22
21
|
|
23
22
|
def destroy
|
24
23
|
client.post('/team/destroy')
|
25
24
|
end
|
26
25
|
|
27
|
-
def add_member(params)
|
28
|
-
client.post("/team/add_member", :body =>
|
26
|
+
def add_member(params = {})
|
27
|
+
client.post("/team/add_member", :body => params)
|
29
28
|
end
|
30
29
|
|
31
|
-
def remove_member(params)
|
32
|
-
client.post("/team/remove_member", :body =>
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def body_by_identifier(params)
|
38
|
-
if email = params[:email]
|
39
|
-
{:email_address => email}
|
40
|
-
elsif account_id = params[:account_id]
|
41
|
-
{:account_id => account_id}
|
42
|
-
else
|
43
|
-
raise ArgumentError, 'An email address or account ID must be provided.'
|
44
|
-
end
|
30
|
+
def remove_member(params = {})
|
31
|
+
client.post("/team/remove_member", :body => params)
|
45
32
|
end
|
46
33
|
|
47
34
|
end
|
data/lib/hello_sign/version.rb
CHANGED
data/lib/hello_sign.rb
CHANGED
@@ -7,13 +7,13 @@ module HelloSign
|
|
7
7
|
class << self
|
8
8
|
extend Forwardable
|
9
9
|
|
10
|
-
attr_accessor :
|
10
|
+
attr_accessor :email_address, :password
|
11
11
|
|
12
12
|
delegate [:account, :signature_request, :reusable_form, :team,
|
13
13
|
:unclaimed_draft] => :client
|
14
14
|
|
15
15
|
def client
|
16
|
-
@client = Client.new(
|
16
|
+
@client = Client.new(email_address, password) unless credentials_match?
|
17
17
|
@client
|
18
18
|
end
|
19
19
|
|
@@ -24,7 +24,7 @@ module HelloSign
|
|
24
24
|
private
|
25
25
|
|
26
26
|
def credentials_match?
|
27
|
-
@client && [@client.
|
27
|
+
@client && [@client.email_address, @client.password].hash == [email_address, password].hash
|
28
28
|
end
|
29
29
|
|
30
30
|
end
|
@@ -2,12 +2,11 @@ require 'integration/helper'
|
|
2
2
|
|
3
3
|
describe HelloSign do
|
4
4
|
context "when creating an account" do
|
5
|
-
before
|
6
|
-
stub_post('/account/create')
|
7
|
-
HelloSign.account.create(:email => 'david@bowman.com', :password => 'foobar')
|
8
|
-
end
|
5
|
+
before { stub_post('/account/create') }
|
9
6
|
|
10
7
|
it "sends an account creation request to the HelloSign API" do
|
8
|
+
HelloSign.account.create(:email_address => 'david@bowman.com', :password => 'foobar')
|
9
|
+
|
11
10
|
expect(a_post('/account/create')
|
12
11
|
.with(:body => {:email_address => 'david@bowman.com', :password => 'foobar'}))
|
13
12
|
.to have_been_made
|
@@ -15,23 +14,21 @@ describe HelloSign do
|
|
15
14
|
end
|
16
15
|
|
17
16
|
context "when accessing an account's settings" do
|
18
|
-
before
|
19
|
-
stub_get_with_auth('/account')
|
20
|
-
HelloSign.account.settings.show
|
21
|
-
end
|
17
|
+
before { stub_get_with_auth('/account') }
|
22
18
|
|
23
19
|
it "fetches the account's settings from the HelloSign API" do
|
20
|
+
HelloSign.account.settings.show
|
21
|
+
|
24
22
|
expect(a_get_with_auth('/account')).to have_been_made
|
25
23
|
end
|
26
24
|
end
|
27
25
|
|
28
26
|
context "when updating an account's settings" do
|
29
|
-
before
|
30
|
-
stub_post_with_auth('/account')
|
31
|
-
HelloSign.account.settings.update(:callback_url => 'http://callmemaybe.com')
|
32
|
-
end
|
27
|
+
before { stub_post_with_auth('/account') }
|
33
28
|
|
34
29
|
it "sends an update account request to the HelloSign API" do
|
30
|
+
HelloSign.account.settings.update(:callback_url => 'http://callmemaybe.com')
|
31
|
+
|
35
32
|
expect(a_post_with_auth('/account')
|
36
33
|
.with(:body => {:callback_url => 'http://callmemaybe.com'}))
|
37
34
|
.to have_been_made
|
data/spec/integration/helper.rb
CHANGED
@@ -3,12 +3,12 @@ require 'integration/helper'
|
|
3
3
|
describe HelloSign do
|
4
4
|
context "when getting a list of reusable forms" do
|
5
5
|
before do
|
6
|
-
stub_get_with_auth('/reusable_form/list
|
6
|
+
stub_get_with_auth('/reusable_form/list')
|
7
7
|
HelloSign.reusable_form.list
|
8
8
|
end
|
9
9
|
|
10
10
|
it "fetches a list of reusable forms from the HelloSign API" do
|
11
|
-
expect(a_get_with_auth('/reusable_form/list
|
11
|
+
expect(a_get_with_auth('/reusable_form/list')).to have_been_made
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -26,7 +26,7 @@ describe HelloSign do
|
|
26
26
|
context "when giving a user access to a reusable form" do
|
27
27
|
before do
|
28
28
|
stub_post_with_auth('/reusable_form/add_user/form_id')
|
29
|
-
HelloSign.reusable_form.grant_access('form_id', :
|
29
|
+
HelloSign.reusable_form.grant_access('form_id', :email_address => 'john@johnson.com')
|
30
30
|
end
|
31
31
|
|
32
32
|
it "sends a request to grant form access to the HelloSign API" do
|
@@ -39,7 +39,7 @@ describe HelloSign do
|
|
39
39
|
context "when taking away a user's access to a reusable form" do
|
40
40
|
before do
|
41
41
|
stub_post_with_auth('/reusable_form/remove_user/form_id')
|
42
|
-
HelloSign.reusable_form.revoke_access('form_id', :
|
42
|
+
HelloSign.reusable_form.revoke_access('form_id', :email_address => 'john@johnson.com')
|
43
43
|
end
|
44
44
|
|
45
45
|
it "sends a request to grant form access to the HelloSign API" do
|
@@ -14,8 +14,8 @@ describe HelloSign do
|
|
14
14
|
request.message = 'You must sign this.'
|
15
15
|
request.ccs = ['lawyer@lawfirm.com', 'spouse@family.com']
|
16
16
|
request.signers = [
|
17
|
-
{:name => 'Jack', :
|
18
|
-
{:name => 'Jill', :
|
17
|
+
{:name => 'Jack', :email_address => 'jack@hill.com'},
|
18
|
+
{:name => 'Jill', :email_address => 'jill@hill.com'}
|
19
19
|
]
|
20
20
|
request.files = [
|
21
21
|
{:name => 'test.txt', :io => text_file_io, :mime => 'text/plain'},
|
@@ -39,12 +39,12 @@ describe HelloSign do
|
|
39
39
|
request.subject = 'Sign this'
|
40
40
|
request.message = 'You must sign this.'
|
41
41
|
request.ccs = [
|
42
|
-
{:
|
43
|
-
{:
|
42
|
+
{:email_address => 'lawyer@lawfirm.com', :role => 'lawyer'},
|
43
|
+
{:email_address => 'accountant@llc.com', :role => 'accountant'}
|
44
44
|
]
|
45
45
|
request.signers = [
|
46
|
-
{:name => 'Jack', :
|
47
|
-
{:name => 'Jill', :
|
46
|
+
{:name => 'Jack', :email_address => 'jack@hill.com', :role => 'consultant'},
|
47
|
+
{:name => 'Jill', :email_address => 'jill@hill.com', :role => 'client'}
|
48
48
|
]
|
49
49
|
request.custom_fields = [
|
50
50
|
{:name => 'cost', :value => '$20,000'},
|
data/spec/unit/client_spec.rb
CHANGED
@@ -5,8 +5,8 @@ require 'shared_examples/proxy'
|
|
5
5
|
describe HelloSign::Client do
|
6
6
|
subject(:hs_client) { HelloSign::Client.new('david@bowman.com', 'space') }
|
7
7
|
|
8
|
-
its(:
|
9
|
-
its(:password)
|
8
|
+
its(:email_address) { should eq 'david@bowman.com' }
|
9
|
+
its(:password) { should eq 'space' }
|
10
10
|
|
11
11
|
it_behaves_like 'a proxy' do
|
12
12
|
let(:client) { hs_client }
|
@@ -3,12 +3,12 @@ require 'hello_sign'
|
|
3
3
|
|
4
4
|
describe HelloSign do
|
5
5
|
before do
|
6
|
-
HelloSign.
|
7
|
-
HelloSign.password
|
6
|
+
HelloSign.email_address = 'hal@jupiter.com'
|
7
|
+
HelloSign.password = 'human_domination'
|
8
8
|
end
|
9
9
|
|
10
|
-
its(:
|
11
|
-
its(:password)
|
10
|
+
its(:email_address) { should eq 'hal@jupiter.com' }
|
11
|
+
its(:password) { should eq 'human_domination' }
|
12
12
|
|
13
13
|
describe "::client" do
|
14
14
|
context "when it has not previously been called" do
|
@@ -26,13 +26,13 @@ describe HelloSign do
|
|
26
26
|
|
27
27
|
context "and the email and password changes" do
|
28
28
|
before do
|
29
|
-
HelloSign.
|
30
|
-
HelloSign.password
|
29
|
+
HelloSign.email_address = 'bob@earth.com'
|
30
|
+
HelloSign.password = 'being_human'
|
31
31
|
end
|
32
32
|
|
33
33
|
it "creates a new client with the new credentials" do
|
34
34
|
expect(HelloSign.client).to_not be @client
|
35
|
-
expect(HelloSign.client.
|
35
|
+
expect(HelloSign.client.email_address).to eq 'bob@earth.com'
|
36
36
|
expect(HelloSign.client.password).to eq 'being_human'
|
37
37
|
end
|
38
38
|
end
|
@@ -31,12 +31,12 @@ describe HelloSign::Parameters::ReusableFormSignatureRequest do
|
|
31
31
|
request_parameters.subject = 'Sign this'
|
32
32
|
request_parameters.message = 'You must sign this.'
|
33
33
|
request_parameters.ccs = [
|
34
|
-
{:
|
35
|
-
{:
|
34
|
+
{:email_address => 'lawyer@lawfirm.com', :role => 'lawyer'},
|
35
|
+
{:email_address => 'accountant@llc.com', :role => 'accountant'}
|
36
36
|
]
|
37
37
|
request_parameters.signers = [
|
38
|
-
{:name => 'Jack', :
|
39
|
-
{:name => 'Jill', :
|
38
|
+
{:name => 'Jack', :email_address => 'jack@hill.com', :role => 'consultant'},
|
39
|
+
{:name => 'Jill', :email_address => 'jill@hill.com', :role => 'client'}
|
40
40
|
]
|
41
41
|
request_parameters.custom_fields = [
|
42
42
|
{:name => 'cost', :value => '$20,000'},
|
@@ -6,40 +6,59 @@ describe HelloSign::Parameters::SignatureRequest do
|
|
6
6
|
let(:request_parameters) { HelloSign::Parameters::SignatureRequest.new }
|
7
7
|
let(:text_file) { double('text file') }
|
8
8
|
let(:image_file) { double('image file') }
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
9
|
+
context "when all required arguments are set" do
|
10
|
+
let(:expected) do
|
11
|
+
{
|
12
|
+
:title => 'Lease',
|
13
|
+
:subject => 'Sign this',
|
14
|
+
:message => 'You must sign this.',
|
15
|
+
:cc_email_addresses => ['lawyer@lawfirm.com', 'spouse@family.com'], # BUGBUG: should have explicit indexes
|
16
|
+
:signers => {
|
17
|
+
0 => {:name => 'Jack', :email_address => 'jack@hill.com', :order => 0},
|
18
|
+
1 => {:name => 'Jill', :email_address => 'jill@hill.com', :order => 1}
|
19
|
+
},
|
20
|
+
:file => {1 => text_file, 2 => image_file}
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
before do
|
25
|
+
request_parameters.title = 'Lease'
|
26
|
+
request_parameters.subject = 'Sign this'
|
27
|
+
request_parameters.message = 'You must sign this.'
|
28
|
+
request_parameters.ccs = ['lawyer@lawfirm.com', 'spouse@family.com']
|
29
|
+
request_parameters.signers = [
|
30
|
+
{:name => 'Jack', :email_address => 'jack@hill.com'},
|
31
|
+
{:name => 'Jill', :email_address => 'jill@hill.com'}
|
32
|
+
]
|
33
|
+
request_parameters.files = [
|
34
|
+
{:name => 'test.txt', :io => 'text file IO object', :mime => 'text/plain'},
|
35
|
+
{:name => 'test.jpg', :io => 'image file IO object', :mime => 'image/jpeg'}
|
36
|
+
]
|
37
|
+
end
|
22
38
|
|
23
|
-
|
24
|
-
|
25
|
-
|
39
|
+
it "returns formatted parameters" do
|
40
|
+
Faraday::UploadIO.should_receive(:new).with('text file IO object', 'text/plain', 'test.txt').and_return(text_file)
|
41
|
+
Faraday::UploadIO.should_receive(:new).with('image file IO object', 'image/jpeg', 'test.jpg').and_return(image_file)
|
26
42
|
|
27
|
-
|
28
|
-
|
29
|
-
request_parameters.message = 'You must sign this.'
|
30
|
-
request_parameters.ccs = ['lawyer@lawfirm.com', 'spouse@family.com']
|
31
|
-
request_parameters.signers = [
|
32
|
-
{:name => 'Jack', :email => 'jack@hill.com'},
|
33
|
-
{:name => 'Jill', :email => 'jill@hill.com'}
|
34
|
-
]
|
35
|
-
request_parameters.files = [
|
36
|
-
{:name => 'test.txt', :io => 'text file IO object', :mime => 'text/plain'},
|
37
|
-
{:name => 'test.jpg', :io => 'image file IO object', :mime => 'image/jpeg'}
|
38
|
-
]
|
43
|
+
expect(request_parameters.formatted).to eq expected
|
44
|
+
end
|
39
45
|
end
|
40
46
|
|
41
|
-
|
42
|
-
|
47
|
+
context "when required parameters are omitted" do
|
48
|
+
let(:expected) do
|
49
|
+
{
|
50
|
+
:title => nil,
|
51
|
+
:subject => nil,
|
52
|
+
:message => nil,
|
53
|
+
:cc_email_addresses => nil,
|
54
|
+
:signers => {},
|
55
|
+
:file => {}
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
it "sets default parameters" do
|
60
|
+
expect(request_parameters.formatted).to eq expected
|
61
|
+
end
|
43
62
|
end
|
44
63
|
end
|
45
64
|
end
|
@@ -3,49 +3,56 @@ require 'hello_sign/proxy/account'
|
|
3
3
|
|
4
4
|
describe HelloSign::Proxy::Account do
|
5
5
|
let(:client) { double('client') }
|
6
|
+
let(:api_response) { double('API response') }
|
6
7
|
subject(:account_proxy) { HelloSign::Proxy::Account.new(client) }
|
7
8
|
|
8
9
|
its(:client) { should eq client }
|
9
10
|
|
10
11
|
describe "#create" do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
expect(account_proxy.create(:email => 'david@bowman.com', :password => 'space')). to eq api_response
|
28
|
-
end
|
12
|
+
|
13
|
+
let(:email_address) { 'david@bowman.com' }
|
14
|
+
let(:password) { 'password' }
|
15
|
+
|
16
|
+
before { client.stub(:post).and_return(api_response) }
|
17
|
+
|
18
|
+
it "sends a request to create an account" do
|
19
|
+
client.should_receive(:post).with(
|
20
|
+
'/account/create',
|
21
|
+
:body => {:email_address => 'david@bowman.com', :password => 'space'},
|
22
|
+
:auth_not_required => true
|
23
|
+
)
|
24
|
+
account_proxy.create(
|
25
|
+
:email_address => 'david@bowman.com',
|
26
|
+
:password => 'space'
|
27
|
+
)
|
29
28
|
end
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
it "returns the API response" do
|
31
|
+
expect(
|
32
|
+
account_proxy.create(
|
33
|
+
:email_address => 'david@bowman.com',
|
34
|
+
:password => 'space'
|
35
|
+
)
|
36
|
+
). to eq api_response
|
35
37
|
end
|
38
|
+
|
36
39
|
end
|
37
40
|
|
38
41
|
describe "#settings" do
|
42
|
+
|
39
43
|
let(:settings_proxy_source) { double('settings proxy source') }
|
40
44
|
let(:settings_proxy) { double('settings proxy') }
|
41
45
|
|
42
46
|
before do
|
43
47
|
account_proxy.settings_proxy_source = settings_proxy_source
|
44
|
-
settings_proxy_source.should_receive(:new).with(client).and_return(settings_proxy)
|
45
48
|
end
|
46
49
|
|
47
50
|
it "returns a signature request proxy" do
|
51
|
+
settings_proxy_source.should_receive(:new)
|
52
|
+
.with(client)
|
53
|
+
.and_return(settings_proxy)
|
48
54
|
expect(account_proxy.settings).to be settings_proxy
|
49
55
|
end
|
56
|
+
|
50
57
|
end
|
51
58
|
end
|
@@ -2,110 +2,60 @@ require 'helper'
|
|
2
2
|
require 'hello_sign/proxy/reusable_form'
|
3
3
|
|
4
4
|
describe HelloSign::Proxy::ReusableForm do
|
5
|
-
let(:client)
|
6
|
-
let(:api_response)
|
7
|
-
let(:form_id)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
let(:client) { double('client') }
|
6
|
+
let(:api_response) { double('API response') }
|
7
|
+
let(:form_id) { 'form_id' }
|
8
|
+
let(:email_address) { 'bob@example.com' }
|
9
|
+
subject(:rf_proxy) { HelloSign::Proxy::ReusableForm.new(client) }
|
10
|
+
|
11
|
+
before do
|
12
|
+
client.stub(:get).and_return(api_response)
|
13
|
+
client.stub(:post).and_return(api_response)
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
context "when called without options" do
|
18
|
-
before { client.should_receive(:get).with('/reusable_form/list', :params => {:page => 1}).and_return(api_response) }
|
16
|
+
its(:client) { should eq client }
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
describe "#list" do
|
19
|
+
it "sends a request to fetch the list of reusable forms" do
|
20
|
+
client.should_receive(:get).with('/reusable_form/list', :params => {:page => 10})
|
21
|
+
rf_proxy.list(:page => 10)
|
23
22
|
end
|
24
23
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
it "fetches a list of reusable forms for the passed page number and returns the result" do
|
29
|
-
expect(rf_proxy.list(:page => 10)).to eq api_response
|
30
|
-
end
|
24
|
+
it "returns the API response" do
|
25
|
+
expect(rf_proxy.list).to eq api_response
|
31
26
|
end
|
32
27
|
end
|
33
28
|
|
34
29
|
describe "#show" do
|
35
|
-
|
30
|
+
it "sends a request to fetch the details of a reusable form" do
|
31
|
+
client.should_receive(:get).with("/reusable_form/#{form_id}")
|
32
|
+
rf_proxy.show(form_id)
|
33
|
+
end
|
36
34
|
|
37
|
-
it "
|
35
|
+
it "returns the API response" do
|
38
36
|
expect(rf_proxy.show(form_id)).to eq api_response
|
39
37
|
end
|
40
38
|
end
|
41
39
|
|
42
40
|
describe "#grant_access" do
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
before { client.stub(:post).and_return(api_response) }
|
47
|
-
|
48
|
-
context "when called with an email address" do
|
49
|
-
it "grants access to account tied to the email address" do
|
50
|
-
client.should_receive(:post).with('/reusable_form/add_user/form_id', :body => {:email_address => email})
|
51
|
-
rf_proxy.grant_access(form_id, :email => email)
|
52
|
-
end
|
53
|
-
|
54
|
-
it "returns the API response" do
|
55
|
-
expect(rf_proxy.grant_access(form_id, :email => email)).to eq api_response
|
56
|
-
end
|
41
|
+
it "sends a request to grant access" do
|
42
|
+
client.should_receive(:post).with("/reusable_form/add_user/#{form_id}", :body => {:email_address => email_address})
|
43
|
+
rf_proxy.grant_access(form_id, :email_address => email_address)
|
57
44
|
end
|
58
45
|
|
59
|
-
|
60
|
-
|
61
|
-
client.should_receive(:post).with('/reusable_form/add_user/form_id', :body => {:account_id => account_id})
|
62
|
-
rf_proxy.grant_access(form_id, :account_id => account_id)
|
63
|
-
end
|
64
|
-
|
65
|
-
it "returns the API response" do
|
66
|
-
expect(rf_proxy.grant_access(form_id, :account_id => account_id)).to eq api_response
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context "when called without proper parameters" do
|
71
|
-
it "raises an argument error exception" do
|
72
|
-
expect { rf_proxy.grant_access(form_id) }.to raise_error ArgumentError
|
73
|
-
end
|
46
|
+
it "returns the API response" do
|
47
|
+
expect(rf_proxy.grant_access(form_id, :email => email_address)).to eq api_response
|
74
48
|
end
|
75
49
|
end
|
76
50
|
|
77
51
|
describe "#revoke_access" do
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
before { client.stub(:post).and_return(api_response) }
|
82
|
-
|
83
|
-
context "when called with an email address" do
|
84
|
-
it "revokes access to account tied to the email address" do
|
85
|
-
client.should_receive(:post).with('/reusable_form/remove_user/form_id', :body => {:email_address => email})
|
86
|
-
rf_proxy.revoke_access(form_id, :email => email)
|
87
|
-
end
|
88
|
-
|
89
|
-
it "returns the API response" do
|
90
|
-
expect(rf_proxy.revoke_access(form_id, :email => email)).to eq api_response
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
context "when called with an account ID" do
|
95
|
-
it "revokes access to account tied to the account ID" do
|
96
|
-
client.should_receive(:post).with('/reusable_form/remove_user/form_id', :body => {:account_id => account_id})
|
97
|
-
rf_proxy.revoke_access(form_id, :account_id => account_id)
|
98
|
-
end
|
99
|
-
|
100
|
-
it "returns the API response" do
|
101
|
-
expect(rf_proxy.revoke_access(form_id, :account_id => account_id)).to eq api_response
|
102
|
-
end
|
52
|
+
it "sends a request to revoke access" do
|
53
|
+
client.should_receive(:post).with("/reusable_form/remove_user/#{form_id}", :body => {:email_address => email_address})
|
54
|
+
rf_proxy.revoke_access(form_id, :email_address => email_address)
|
103
55
|
end
|
104
56
|
|
105
|
-
|
106
|
-
|
107
|
-
expect { rf_proxy.revoke_access(form_id) }.to raise_error ArgumentError
|
108
|
-
end
|
57
|
+
it "returns the API response" do
|
58
|
+
expect(rf_proxy.revoke_access(form_id, :email_address => email_address)).to eq api_response
|
109
59
|
end
|
110
60
|
end
|
111
61
|
end
|
@@ -113,12 +113,6 @@ describe HelloSign::Proxy::SignatureRequest do
|
|
113
113
|
client.stub(:post).and_return(api_response)
|
114
114
|
expect(sr_proxy.remind(request_id, :email => email)).to eq api_response
|
115
115
|
end
|
116
|
-
|
117
|
-
context "when called without an email address" do
|
118
|
-
it "raises an exception" do
|
119
|
-
expect { sr_proxy.remind(request_id) }.to raise_error ArgumentError
|
120
|
-
end
|
121
|
-
end
|
122
116
|
end
|
123
117
|
|
124
118
|
describe "#cancel" do
|
@@ -11,35 +11,26 @@ describe HelloSign::Proxy::Team do
|
|
11
11
|
client.stub(:post).and_return(api_response)
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
it "returns the client" do
|
16
|
-
expect(team_proxy.client).to be client
|
17
|
-
end
|
18
|
-
end
|
14
|
+
its(:client) { should eq client }
|
19
15
|
|
20
16
|
describe "#create" do
|
21
|
-
let(:name) { 'The Browncoats' }
|
22
17
|
|
23
|
-
|
24
|
-
it "sends a team creation request" do
|
25
|
-
client.should_receive(:post).with('/team/create', :body => {:name => name})
|
26
|
-
team_proxy.create(:name => name)
|
27
|
-
end
|
18
|
+
let(:name) { 'The Browncoats' }
|
28
19
|
|
29
|
-
|
30
|
-
|
31
|
-
|
20
|
+
it "sends a request to create a team" do
|
21
|
+
client.should_receive(:post).with('/team/create', :body => {:name => name})
|
22
|
+
team_proxy.create(:name => name)
|
32
23
|
end
|
33
24
|
|
34
|
-
|
35
|
-
|
36
|
-
expect { team_proxy.create }.to raise_error
|
37
|
-
end
|
25
|
+
it "returns the API response" do
|
26
|
+
expect(team_proxy.create(:name => name)).to eq api_response
|
38
27
|
end
|
28
|
+
|
39
29
|
end
|
40
30
|
|
41
31
|
describe "#show" do
|
42
|
-
|
32
|
+
|
33
|
+
it "sends a request to fetch the team information" do
|
43
34
|
client.should_receive(:get).with('/team')
|
44
35
|
team_proxy.show
|
45
36
|
end
|
@@ -47,12 +38,14 @@ describe HelloSign::Proxy::Team do
|
|
47
38
|
it "returns the API response" do
|
48
39
|
expect(team_proxy.show).to eq api_response
|
49
40
|
end
|
41
|
+
|
50
42
|
end
|
51
43
|
|
52
44
|
describe "#update" do
|
45
|
+
|
53
46
|
let(:new_name) { 'The Bluecoats' }
|
54
47
|
|
55
|
-
it "sends a
|
48
|
+
it "sends a request to update the team information" do
|
56
49
|
client.should_receive(:post).with('/team', :body => {:name => new_name})
|
57
50
|
team_proxy.update(:name => new_name)
|
58
51
|
end
|
@@ -60,10 +53,12 @@ describe HelloSign::Proxy::Team do
|
|
60
53
|
it "returns the API response" do
|
61
54
|
expect(team_proxy.update(:name => new_name)).to eq api_response
|
62
55
|
end
|
56
|
+
|
63
57
|
end
|
64
58
|
|
65
59
|
describe "#destroy" do
|
66
|
-
|
60
|
+
|
61
|
+
it "sends a request to destroy the team" do
|
67
62
|
client.should_receive(:post).with('/team/destroy')
|
68
63
|
team_proxy.destroy
|
69
64
|
end
|
@@ -71,71 +66,36 @@ describe HelloSign::Proxy::Team do
|
|
71
66
|
it "returns the API response" do
|
72
67
|
expect(team_proxy.destroy).to eq api_response
|
73
68
|
end
|
69
|
+
|
74
70
|
end
|
75
71
|
|
76
72
|
describe "#add_member" do
|
77
|
-
let(:email) { 'john@johnson.com' }
|
78
|
-
let(:account_id) { '15' }
|
79
|
-
|
80
|
-
context "when called with an email address" do
|
81
|
-
it "adds the user with the email address to the team" do
|
82
|
-
client.should_receive(:post).with('/team/add_member', :body => {:email_address => email})
|
83
|
-
team_proxy.add_member(:email => email)
|
84
|
-
end
|
85
|
-
|
86
|
-
it "returns the API response" do
|
87
|
-
expect(team_proxy.add_member(:email => email)).to eq api_response
|
88
|
-
end
|
89
|
-
end
|
90
73
|
|
91
|
-
|
92
|
-
it "adds the user with the account ID to the team" do
|
93
|
-
client.should_receive(:post).with('/team/add_member', :body => {:account_id => account_id})
|
94
|
-
team_proxy.add_member(:account_id => account_id)
|
95
|
-
end
|
74
|
+
let(:email_address) { 'john@johnson.com' }
|
96
75
|
|
97
|
-
|
98
|
-
|
99
|
-
|
76
|
+
it "sends a request to add the member to the team" do
|
77
|
+
client.should_receive(:post).with('/team/add_member', :body => {:email_address => email_address})
|
78
|
+
team_proxy.add_member(:email_address => email_address)
|
100
79
|
end
|
101
80
|
|
102
|
-
|
103
|
-
|
104
|
-
expect { team_proxy.add_member }.to raise_error ArgumentError
|
105
|
-
end
|
81
|
+
it "returns the API response" do
|
82
|
+
expect(team_proxy.add_member(:email_address => email_address)).to eq api_response
|
106
83
|
end
|
84
|
+
|
107
85
|
end
|
108
86
|
|
109
87
|
describe "#remove_member" do
|
110
|
-
let(:email) { 'john@johnson.com' }
|
111
|
-
let(:account_id) { '15' }
|
112
|
-
|
113
|
-
context "when called with an email address" do
|
114
|
-
it "removes the user with the email address from the team" do
|
115
|
-
client.should_receive(:post).with('/team/remove_member', :body => {:email_address => email})
|
116
|
-
team_proxy.remove_member(:email => email)
|
117
|
-
end
|
118
|
-
|
119
|
-
it "returns the API response" do
|
120
|
-
expect(team_proxy.remove_member(:email => email)).to eq api_response
|
121
|
-
end
|
122
|
-
end
|
123
88
|
|
124
|
-
|
125
|
-
it "removes the user with the account ID from the team" do
|
126
|
-
client.should_receive(:post).with('/team/remove_member', :body => {:account_id => account_id})
|
127
|
-
team_proxy.remove_member(:account_id => account_id)
|
128
|
-
end
|
89
|
+
let(:email_address) { 'john@johnson.com' }
|
129
90
|
|
130
|
-
|
131
|
-
|
132
|
-
|
91
|
+
it "sends a request to remove the member from the team" do
|
92
|
+
client.should_receive(:post).with('/team/remove_member', :body => {:email_address => email_address})
|
93
|
+
team_proxy.remove_member(:email_address => email_address)
|
133
94
|
end
|
134
95
|
|
135
|
-
|
136
|
-
|
137
|
-
expect { team_proxy.remove_member }.to raise_error ArgumentError
|
138
|
-
end
|
96
|
+
it "returns the API response" do
|
97
|
+
expect(team_proxy.remove_member(:email_address => email_address)).to eq api_response
|
139
98
|
end
|
99
|
+
|
140
100
|
end
|
141
101
|
end
|
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.5.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-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -75,6 +75,22 @@ dependencies:
|
|
75
75
|
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 1.9.0
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rake
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 10.0.3
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 10.0.3
|
78
94
|
description: A Ruby interface to the HelloSign API.
|
79
95
|
email:
|
80
96
|
- craiglttl@gmail.com
|
@@ -130,12 +146,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
130
146
|
- - ! '>='
|
131
147
|
- !ruby/object:Gem::Version
|
132
148
|
version: '0'
|
149
|
+
segments:
|
150
|
+
- 0
|
151
|
+
hash: -3035616681847644249
|
133
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
153
|
none: false
|
135
154
|
requirements:
|
136
155
|
- - ! '>='
|
137
156
|
- !ruby/object:Gem::Version
|
138
157
|
version: '0'
|
158
|
+
segments:
|
159
|
+
- 0
|
160
|
+
hash: -3035616681847644249
|
139
161
|
requirements: []
|
140
162
|
rubyforge_project:
|
141
163
|
rubygems_version: 1.8.23
|