hello_sign 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/hello_sign.rb +4 -4
- data/lib/hello_sign/client.rb +4 -2
- data/lib/hello_sign/error.rb +4 -1
- data/lib/hello_sign/parameters/reusable_form_signature_request.rb +7 -3
- data/lib/hello_sign/parameters/signature_request.rb +5 -3
- data/lib/hello_sign/proxy/account.rb +4 -8
- data/lib/hello_sign/proxy/object.rb +12 -0
- data/lib/hello_sign/proxy/reusable_form.rb +9 -7
- data/lib/hello_sign/proxy/settings.rb +5 -8
- data/lib/hello_sign/proxy/signature_request.rb +53 -29
- data/lib/hello_sign/proxy/team.rb +9 -12
- data/lib/hello_sign/proxy/unclaimed_draft.rb +5 -17
- data/lib/hello_sign/version.rb +1 -1
- data/spec/integration/error_spec.rb +5 -0
- data/spec/unit/error_spec.rb +7 -0
- data/spec/unit/hello_sign_spec.rb +5 -1
- data/spec/unit/middleware/raise_error_spec.rb +1 -0
- data/spec/unit/parameters/reusable_form_signature_request_spec.rb +4 -2
- data/spec/unit/parameters/signature_request_spec.rb +2 -0
- data/spec/unit/proxy/settings_spec.rb +1 -7
- data/spec/unit/proxy/signature_request_spec.rb +93 -0
- metadata +14 -33
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4d55ba232df29b1b6a7d08b273179fa8db91954d
|
4
|
+
data.tar.gz: cf021a9b4d34149daa2be334b5aef6b12f8e29c0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 81dc3a6e70ac62235de57e239e20d50dd04898606f1552457989dbf14db619e940893916d991c451693c3d52fe75e25962b426933e5592f0bf4300873a5a4d4d
|
7
|
+
data.tar.gz: de8dcb565c71c002508be29cf4763e9bcaa7c678bea8ceb603e81d6a06d951ad55861e6a5a4ab7e55c8e6e5356fa5f956b0a9329acc62015042ee9d8469d5956
|
data/lib/hello_sign.rb
CHANGED
@@ -8,7 +8,7 @@ module HelloSign
|
|
8
8
|
class << self
|
9
9
|
extend Forwardable
|
10
10
|
|
11
|
-
attr_accessor :email_address, :password
|
11
|
+
attr_accessor :email_address, :password, :client_id
|
12
12
|
|
13
13
|
delegate [
|
14
14
|
:account,
|
@@ -20,7 +20,7 @@ module HelloSign
|
|
20
20
|
|
21
21
|
def client
|
22
22
|
unless credentials_match?
|
23
|
-
@client = HelloSign::Client.new(email_address, password)
|
23
|
+
@client = HelloSign::Client.new(email_address, password, client_id)
|
24
24
|
end
|
25
25
|
|
26
26
|
@client
|
@@ -38,11 +38,11 @@ module HelloSign
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def client_credentials
|
41
|
-
[@client.email_address, @client.password]
|
41
|
+
[@client.email_address, @client.password, @client.client_id]
|
42
42
|
end
|
43
43
|
|
44
44
|
def provided_credentials
|
45
|
-
[email_address, password]
|
45
|
+
[email_address, password, client_id]
|
46
46
|
end
|
47
47
|
|
48
48
|
Faraday.register_middleware(
|
data/lib/hello_sign/client.rb
CHANGED
@@ -8,15 +8,17 @@ module HelloSign
|
|
8
8
|
|
9
9
|
include HelloSign::Proxy
|
10
10
|
|
11
|
-
attr_reader :email_address, :password
|
11
|
+
attr_reader :email_address, :password, :client_id
|
12
12
|
|
13
|
-
def initialize(email_or_hash, password = nil)
|
13
|
+
def initialize(email_or_hash, password = nil, client_id = nil)
|
14
14
|
if email_or_hash.is_a?(Hash)
|
15
15
|
@email_address = email_or_hash.fetch(:email_address) { raise ArgumentError }
|
16
16
|
@password = email_or_hash.fetch(:password) { raise ArgumentError }
|
17
|
+
@client_id = email_or_hash.fetch(:client_id)
|
17
18
|
else
|
18
19
|
@email_address = email_or_hash
|
19
20
|
@password = password
|
21
|
+
@client_id = client_id
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
data/lib/hello_sign/error.rb
CHANGED
@@ -22,6 +22,8 @@ module HelloSign
|
|
22
22
|
ConvertFailed
|
23
23
|
when 'signature_request_cancel_failed'
|
24
24
|
SignatureRequestCancelFailed
|
25
|
+
when 'maintenance'
|
26
|
+
Maintenance
|
25
27
|
else
|
26
28
|
Error
|
27
29
|
end
|
@@ -50,7 +52,8 @@ module HelloSign
|
|
50
52
|
:TeamInviteFailed,
|
51
53
|
:InvalidRecipient,
|
52
54
|
:ConvertFailed,
|
53
|
-
:SignatureRequestCancelFailed
|
55
|
+
:SignatureRequestCancelFailed,
|
56
|
+
:Maintenance
|
54
57
|
].each do |error_name|
|
55
58
|
const_set(error_name, Class.new(HelloSign::Error))
|
56
59
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
module HelloSign
|
2
2
|
module Parameters
|
3
3
|
class ReusableFormSignatureRequest
|
4
|
-
attr_accessor :test_mode, :reusable_form_id, :title, :subject, :message
|
5
|
-
|
4
|
+
attr_accessor :test_mode, :reusable_form_id, :title, :subject, :message,
|
5
|
+
:client_id
|
6
|
+
private :test_mode, :reusable_form_id, :title, :subject, :message,
|
7
|
+
:client_id
|
6
8
|
|
7
9
|
attr_writer :ccs, :signers, :custom_fields
|
8
10
|
|
@@ -20,7 +22,9 @@ module HelloSign
|
|
20
22
|
ccs: formatted_ccs,
|
21
23
|
signers: formatted_signers,
|
22
24
|
custom_fields: formatted_custom_fields
|
23
|
-
}
|
25
|
+
}.tap do |f|
|
26
|
+
f.merge!(client_id: client_id) unless client_id.nil?
|
27
|
+
end
|
24
28
|
end
|
25
29
|
|
26
30
|
private
|
@@ -4,8 +4,8 @@ require 'json'
|
|
4
4
|
module HelloSign
|
5
5
|
module Parameters
|
6
6
|
class SignatureRequest
|
7
|
-
attr_accessor :title, :subject, :message, :ccs, :test_mode
|
8
|
-
private :title, :subject, :message, :ccs, :test_mode
|
7
|
+
attr_accessor :title, :subject, :message, :ccs, :test_mode, :client_id
|
8
|
+
private :title, :subject, :message, :ccs, :test_mode, :client_id
|
9
9
|
|
10
10
|
attr_writer :signers, :files, :form_fields_per_document
|
11
11
|
|
@@ -23,7 +23,9 @@ module HelloSign
|
|
23
23
|
signers: formatted_signers,
|
24
24
|
file: formatted_files,
|
25
25
|
form_fields_per_document: formatted_form_fields_per_document
|
26
|
-
}
|
26
|
+
}.tap do |f|
|
27
|
+
f.merge!(client_id: client_id) unless client_id.nil?
|
28
|
+
end
|
27
29
|
end
|
28
30
|
|
29
31
|
private
|
@@ -1,20 +1,16 @@
|
|
1
|
+
require 'hello_sign/proxy/object'
|
1
2
|
require 'hello_sign/proxy/settings'
|
2
3
|
|
3
4
|
module HelloSign
|
4
5
|
module Proxy
|
5
|
-
class Account
|
6
|
-
attr_reader :client
|
7
|
-
|
8
|
-
def initialize(client)
|
9
|
-
@client = client
|
10
|
-
end
|
6
|
+
class Account < Object
|
11
7
|
|
12
8
|
def create(params = {})
|
13
|
-
client.post('/account/create', body: params, auth_not_required: true)
|
9
|
+
@client.post('/account/create', body: params, auth_not_required: true)
|
14
10
|
end
|
15
11
|
|
16
12
|
def settings
|
17
|
-
HelloSign::Proxy::Settings.new(client)
|
13
|
+
HelloSign::Proxy::Settings.new(@client)
|
18
14
|
end
|
19
15
|
|
20
16
|
end
|
@@ -1,27 +1,29 @@
|
|
1
|
+
require 'hello_sign/proxy/object'
|
2
|
+
|
1
3
|
module HelloSign
|
2
4
|
module Proxy
|
3
|
-
class ReusableForm
|
4
|
-
attr_reader :client, :form_id
|
5
|
+
class ReusableForm < Object
|
5
6
|
|
6
7
|
def initialize(client, form_id)
|
7
|
-
|
8
|
+
super(client)
|
9
|
+
|
8
10
|
@form_id = form_id
|
9
11
|
end
|
10
12
|
|
11
13
|
def list(params = {})
|
12
|
-
client.get('/reusable_form/list', params: params)
|
14
|
+
@client.get('/reusable_form/list', params: params)
|
13
15
|
end
|
14
16
|
|
15
17
|
def show
|
16
|
-
client.get("/reusable_form
|
18
|
+
@client.get("/reusable_form/#@form_id")
|
17
19
|
end
|
18
20
|
|
19
21
|
def grant_access(params = {})
|
20
|
-
client.post("/reusable_form/add_user
|
22
|
+
@client.post("/reusable_form/add_user/#@form_id", body: params)
|
21
23
|
end
|
22
24
|
|
23
25
|
def revoke_access(params = {})
|
24
|
-
client.post("/reusable_form/remove_user
|
26
|
+
@client.post("/reusable_form/remove_user/#@form_id", body: params)
|
25
27
|
end
|
26
28
|
|
27
29
|
end
|
@@ -1,18 +1,15 @@
|
|
1
|
+
require 'hello_sign/proxy/object'
|
2
|
+
|
1
3
|
module HelloSign
|
2
4
|
module Proxy
|
3
|
-
class Settings
|
4
|
-
attr_reader :client
|
5
|
-
|
6
|
-
def initialize(client)
|
7
|
-
@client = client
|
8
|
-
end
|
5
|
+
class Settings < Object
|
9
6
|
|
10
7
|
def show
|
11
|
-
client.get('/account')
|
8
|
+
@client.get('/account')
|
12
9
|
end
|
13
10
|
|
14
11
|
def update(params = {})
|
15
|
-
client.post('/account', body: params)
|
12
|
+
@client.post('/account', body: params)
|
16
13
|
end
|
17
14
|
|
18
15
|
end
|
@@ -1,76 +1,100 @@
|
|
1
|
+
require 'hello_sign/proxy/object'
|
1
2
|
require 'hello_sign/parameters/signature_request'
|
2
3
|
require 'hello_sign/parameters/reusable_form_signature_request'
|
3
4
|
|
4
5
|
module HelloSign
|
5
6
|
module Proxy
|
6
|
-
class SignatureRequest
|
7
|
-
attr_reader :client, :request_id
|
7
|
+
class SignatureRequest < Object
|
8
8
|
|
9
9
|
def initialize(client, request_id)
|
10
|
-
|
10
|
+
super(client)
|
11
|
+
|
11
12
|
@request_id = request_id
|
12
13
|
end
|
13
14
|
|
14
15
|
def deliver(params = {}, &block)
|
15
|
-
if form_id = params[:form]
|
16
|
+
if (form_id = params[:form])
|
16
17
|
deliver_request_with_form(form_id, &block)
|
17
18
|
else
|
18
19
|
deliver_request(&block)
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
23
|
+
def create_embedded_request(params = {}, &block)
|
24
|
+
if (form_id = params[:form])
|
25
|
+
deliver_embedded_request_with_form(form_id, &block)
|
26
|
+
else
|
27
|
+
deliver_embedded_request(&block)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
22
31
|
def status
|
23
|
-
client.get("/signature_request
|
32
|
+
@client.get("/signature_request/#@request_id")
|
24
33
|
end
|
25
34
|
|
26
35
|
def list(params = {})
|
27
|
-
client.get('/signature_request/list',
|
28
|
-
|
36
|
+
@client.get('/signature_request/list', {
|
37
|
+
params: {page: DEFAULT_PAGE}.merge(params)
|
38
|
+
})
|
29
39
|
end
|
30
40
|
|
31
41
|
def remind(params = {})
|
32
|
-
client.post(
|
33
|
-
"/signature_request/remind/#{request_id}",
|
42
|
+
@client.post("/signature_request/remind/#@request_id", {
|
34
43
|
body: {email_address: params.delete(:email)}.merge(params)
|
35
|
-
)
|
44
|
+
})
|
36
45
|
end
|
37
46
|
|
38
47
|
def cancel
|
39
|
-
client.post("/signature_request/cancel
|
48
|
+
@client.post("/signature_request/cancel/#@request_id")
|
40
49
|
end
|
41
50
|
|
42
51
|
def final_copy
|
43
|
-
client.get("/signature_request/final_copy
|
52
|
+
@client.get("/signature_request/final_copy/#@request_id")
|
53
|
+
end
|
54
|
+
|
55
|
+
def temporary_signature_url(signature_id)
|
56
|
+
@client.get("/embedded/sign_url/#{signature_id}")
|
44
57
|
end
|
45
58
|
|
46
59
|
private
|
47
60
|
|
48
61
|
def deliver_request
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
'/signature_request/send',
|
53
|
-
body: request_parameters.formatted
|
54
|
-
)
|
62
|
+
@client.post('/signature_request/send', {
|
63
|
+
body: Parameters::SignatureRequest.new.tap { |p| yield p }.formatted
|
64
|
+
})
|
55
65
|
end
|
56
66
|
|
57
67
|
def deliver_request_with_form(form_id)
|
58
|
-
|
59
|
-
|
68
|
+
@client.post('/signature_request/send_with_reusable_form', {
|
69
|
+
body:
|
70
|
+
Parameters::ReusableFormSignatureRequest.new.tap do |p|
|
71
|
+
p.reusable_form_id = form_id
|
72
|
+
yield p
|
73
|
+
end.formatted
|
74
|
+
})
|
75
|
+
end
|
60
76
|
|
61
|
-
|
62
|
-
|
63
|
-
body:
|
77
|
+
def deliver_embedded_request
|
78
|
+
@client.post('/signature_request/create_embedded',
|
79
|
+
body:
|
80
|
+
Parameters::SignatureRequest.new.tap do |p|
|
81
|
+
p.client_id = @client.client_id
|
82
|
+
|
83
|
+
yield p
|
84
|
+
end.formatted
|
64
85
|
)
|
65
86
|
end
|
66
87
|
|
67
|
-
def
|
68
|
-
@
|
69
|
-
|
88
|
+
def deliver_embedded_request_with_form(form_id)
|
89
|
+
@client.post('/signature_request/create_embedded_with_reusable_form',
|
90
|
+
body:
|
91
|
+
Parameters::ReusableFormSignatureRequest.new.tap do |p|
|
92
|
+
p.reusable_form_id = form_id
|
93
|
+
p.client_id = @client.client_id
|
70
94
|
|
71
|
-
|
72
|
-
|
73
|
-
|
95
|
+
yield p
|
96
|
+
end.formatted
|
97
|
+
)
|
74
98
|
end
|
75
99
|
|
76
100
|
end
|
@@ -1,34 +1,31 @@
|
|
1
|
+
require 'hello_sign/proxy/object'
|
2
|
+
|
1
3
|
module HelloSign
|
2
4
|
module Proxy
|
3
|
-
class Team
|
4
|
-
attr_reader :client
|
5
|
-
|
6
|
-
def initialize(client)
|
7
|
-
@client = client
|
8
|
-
end
|
5
|
+
class Team < Object
|
9
6
|
|
10
7
|
def create(params = {})
|
11
|
-
client.post('/team/create', body: params)
|
8
|
+
@client.post('/team/create', body: params)
|
12
9
|
end
|
13
10
|
|
14
11
|
def show
|
15
|
-
client.get('/team')
|
12
|
+
@client.get('/team')
|
16
13
|
end
|
17
14
|
|
18
15
|
def update(params = {})
|
19
|
-
client.post('/team', body: params)
|
16
|
+
@client.post('/team', body: params)
|
20
17
|
end
|
21
18
|
|
22
19
|
def destroy
|
23
|
-
client.post('/team/destroy')
|
20
|
+
@client.post('/team/destroy')
|
24
21
|
end
|
25
22
|
|
26
23
|
def add_member(params = {})
|
27
|
-
client.post('/team/add_member', body: params)
|
24
|
+
@client.post('/team/add_member', body: params)
|
28
25
|
end
|
29
26
|
|
30
27
|
def remove_member(params = {})
|
31
|
-
client.post('/team/remove_member', body: params)
|
28
|
+
@client.post('/team/remove_member', body: params)
|
32
29
|
end
|
33
30
|
|
34
31
|
end
|
@@ -1,26 +1,14 @@
|
|
1
|
+
require 'hello_sign/proxy/object'
|
1
2
|
require 'hello_sign/parameters/unclaimed_draft'
|
2
3
|
|
3
4
|
module HelloSign
|
4
5
|
module Proxy
|
5
|
-
class UnclaimedDraft
|
6
|
-
attr_reader :client
|
7
|
-
|
8
|
-
def initialize(client)
|
9
|
-
@client = client
|
10
|
-
end
|
6
|
+
class UnclaimedDraft < Object
|
11
7
|
|
12
8
|
def create
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
body: draft_parameters.formatted
|
17
|
-
)
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def draft_parameters
|
23
|
-
@draft_parameters ||= Parameters::UnclaimedDraft.new
|
9
|
+
@client.post('/unclaimed_draft/create', {
|
10
|
+
body: Parameters::UnclaimedDraft.new.tap { |p| yield p }.formatted
|
11
|
+
})
|
24
12
|
end
|
25
13
|
|
26
14
|
end
|
data/lib/hello_sign/version.rb
CHANGED
@@ -47,4 +47,9 @@ describe HelloSign do
|
|
47
47
|
stub_request_with_error('signature_request_cancel_failed')
|
48
48
|
expect { any_call }.to raise_error HelloSign::Error::SignatureRequestCancelFailed
|
49
49
|
end
|
50
|
+
|
51
|
+
specify do
|
52
|
+
stub_request_with_error('maintenance')
|
53
|
+
expect { any_call }.to raise_error HelloSign::Error::Maintenance
|
54
|
+
end
|
50
55
|
end
|
data/spec/unit/error_spec.rb
CHANGED
@@ -13,6 +13,7 @@ describe HelloSign::Error do
|
|
13
13
|
invalid_recipient
|
14
14
|
convert_failed
|
15
15
|
signature_request_cancel_failed
|
16
|
+
maintenance
|
16
17
|
).each do |error_name|
|
17
18
|
context "when the error name is #{error_name}" do
|
18
19
|
it "returns the proper exception" do
|
@@ -95,6 +96,12 @@ describe HelloSign::Error do
|
|
95
96
|
)
|
96
97
|
end
|
97
98
|
|
99
|
+
specify do
|
100
|
+
expect { raise HelloSign::Error::Maintenance }.to(
|
101
|
+
raise_error HelloSign::Error
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
98
105
|
describe "#to_s" do
|
99
106
|
let(:error) {
|
100
107
|
HelloSign::Error.new('This is why an error was received.', 401)
|
@@ -4,10 +4,12 @@ require 'hello_sign'
|
|
4
4
|
describe HelloSign do
|
5
5
|
let(:email_address) { double('email address') }
|
6
6
|
let(:password) { double('password') }
|
7
|
+
let(:client_id) { double('client_id') }
|
7
8
|
|
8
9
|
before do
|
9
10
|
HelloSign.email_address = email_address
|
10
11
|
HelloSign.password = password
|
12
|
+
HelloSign.client_id = client_id
|
11
13
|
end
|
12
14
|
|
13
15
|
after do
|
@@ -26,7 +28,7 @@ describe HelloSign do
|
|
26
28
|
|
27
29
|
it "passes the credentials when creating the client" do
|
28
30
|
expect(HelloSign::Client).to(
|
29
|
-
have_received(:new).with(email_address, password)
|
31
|
+
have_received(:new).with(email_address, password, client_id)
|
30
32
|
)
|
31
33
|
end
|
32
34
|
end
|
@@ -38,6 +40,7 @@ describe HelloSign do
|
|
38
40
|
allow(HelloSign::Client).to receive(:new).and_return(client, new_client)
|
39
41
|
allow(client).to receive(:email_address).and_return(email_address)
|
40
42
|
allow(client).to receive(:password).and_return(password)
|
43
|
+
allow(client).to receive(:client_id).and_return(client_id)
|
41
44
|
|
42
45
|
HelloSign.client
|
43
46
|
end
|
@@ -48,6 +51,7 @@ describe HelloSign do
|
|
48
51
|
before do
|
49
52
|
HelloSign.email_address = 'bob@earth.com'
|
50
53
|
HelloSign.password = 'being_human'
|
54
|
+
HelloSign.client_id = 'client_id'
|
51
55
|
end
|
52
56
|
|
53
57
|
its(:client) { should be new_client }
|
@@ -18,6 +18,7 @@ describe HelloSign::Middleware::RaiseError do
|
|
18
18
|
'invalid_recipient' => HelloSign::Error::InvalidRecipient,
|
19
19
|
'convert_failed' => HelloSign::Error::ConvertFailed,
|
20
20
|
'signature_request_cancel_failed' => HelloSign::Error::SignatureRequestCancelFailed,
|
21
|
+
'maintenance' => HelloSign::Error::Maintenance,
|
21
22
|
'unidentified_error' => HelloSign::Error
|
22
23
|
}.each { |error_pair| it_raises_the_proper_exception(*error_pair) }
|
23
24
|
|
@@ -17,18 +17,20 @@ describe HelloSign::Parameters::ReusableFormSignatureRequest do
|
|
17
17
|
'accountant' => {email_address: 'accountant@llc.com'}
|
18
18
|
},
|
19
19
|
signers: {
|
20
|
-
'consultant' => {name: 'Jack', email_address: 'jack@hill.com'},
|
20
|
+
'consultant' => {name: 'Jack', email_address: 'jack@hill.com'},
|
21
21
|
'client' => {name: 'Jill', email_address: 'jill@hill.com'}
|
22
22
|
},
|
23
23
|
custom_fields: {
|
24
24
|
'cost' => '$20,000',
|
25
25
|
'time' => 'two weeks'
|
26
26
|
},
|
27
|
-
test_mode: 1
|
27
|
+
test_mode: 1,
|
28
|
+
client_id: 'client_id'
|
28
29
|
}
|
29
30
|
end
|
30
31
|
|
31
32
|
before do
|
33
|
+
request_parameters.client_id = 'client_id'
|
32
34
|
request_parameters.test_mode = 1
|
33
35
|
request_parameters.reusable_form_id = 'form_id'
|
34
36
|
request_parameters.title = 'Lease'
|
@@ -11,6 +11,7 @@ describe HelloSign::Parameters::SignatureRequest do
|
|
11
11
|
context "when all required arguments are set" do
|
12
12
|
let(:expected) do
|
13
13
|
{
|
14
|
+
client_id: 'client_id',
|
14
15
|
test_mode: 1,
|
15
16
|
title: 'Lease',
|
16
17
|
subject: 'Sign this',
|
@@ -39,6 +40,7 @@ describe HelloSign::Parameters::SignatureRequest do
|
|
39
40
|
end
|
40
41
|
|
41
42
|
before do
|
43
|
+
request_parameters.client_id = 'client_id'
|
42
44
|
request_parameters.test_mode = 1
|
43
45
|
request_parameters.title = 'Lease'
|
44
46
|
request_parameters.subject = 'Sign this'
|
@@ -2,16 +2,10 @@ require 'helper'
|
|
2
2
|
require 'hello_sign/proxy/settings'
|
3
3
|
|
4
4
|
describe HelloSign::Proxy::Settings do
|
5
|
-
let(:client)
|
5
|
+
let(:client) { double('client') }
|
6
6
|
|
7
7
|
subject(:settings) { HelloSign::Proxy::Settings.new(client) }
|
8
8
|
|
9
|
-
describe "#client" do
|
10
|
-
it "returns the client" do
|
11
|
-
expect(settings.client).to eq client
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
9
|
describe "#update" do
|
16
10
|
let(:callback_url) { 'http://www.callmemaybe.com' }
|
17
11
|
let(:api_response) { double('API response') }
|
@@ -75,6 +75,83 @@ describe HelloSign::Proxy::SignatureRequest do
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
+
describe "#create_embedded_request" do
|
79
|
+
let(:formatted_request_body) { double('formatted request body') }
|
80
|
+
let(:request_parameters) { double('request parameters') }
|
81
|
+
|
82
|
+
before do
|
83
|
+
allow(client).to receive(:client_id).and_return('client_id')
|
84
|
+
allow(request_parameters).to receive(:foo=)
|
85
|
+
allow(request_parameters).to receive(:client_id=)
|
86
|
+
allow(request_parameters).to(
|
87
|
+
receive(:formatted).and_return(formatted_request_body)
|
88
|
+
)
|
89
|
+
allow(HelloSign::Parameters::SignatureRequest).to(
|
90
|
+
receive(:new).and_return(request_parameters)
|
91
|
+
)
|
92
|
+
|
93
|
+
@response = sr_proxy.create_embedded_request { |p| p.foo = 'bar' }
|
94
|
+
end
|
95
|
+
|
96
|
+
it "yields the request parameters to the block" do
|
97
|
+
expect(request_parameters).to have_received(:foo=).with('bar')
|
98
|
+
end
|
99
|
+
|
100
|
+
it "sets the client ID in the request parameters" do
|
101
|
+
expect(request_parameters).to(
|
102
|
+
have_received(:client_id=).with('client_id')
|
103
|
+
)
|
104
|
+
end
|
105
|
+
|
106
|
+
it "sends a signature request" do
|
107
|
+
expect(client).to have_received(:post).with(
|
108
|
+
'/signature_request/create_embedded',
|
109
|
+
body: formatted_request_body
|
110
|
+
)
|
111
|
+
end
|
112
|
+
|
113
|
+
it "returns the response" do
|
114
|
+
expect(@response).to eq api_response
|
115
|
+
end
|
116
|
+
|
117
|
+
context "when a reusable form is specified" do
|
118
|
+
let(:form_request_parameters) { double('form request parameters') }
|
119
|
+
|
120
|
+
before do
|
121
|
+
allow(client).to receive(:client_id).and_return('client_id')
|
122
|
+
|
123
|
+
allow(form_request_parameters).to receive(:client_id=)
|
124
|
+
allow(form_request_parameters).to(
|
125
|
+
receive(:formatted).and_return(formatted_request_body)
|
126
|
+
)
|
127
|
+
allow(form_request_parameters).to receive(:reusable_form_id=)
|
128
|
+
|
129
|
+
allow(HelloSign::Parameters::ReusableFormSignatureRequest).to(
|
130
|
+
receive(:new).and_return(form_request_parameters)
|
131
|
+
)
|
132
|
+
|
133
|
+
@response = sr_proxy.create_embedded_request(form: 'form_id') { }
|
134
|
+
end
|
135
|
+
|
136
|
+
it "sets the reusable form ID in the request parameters" do
|
137
|
+
expect(form_request_parameters).to(
|
138
|
+
have_received(:reusable_form_id=).with('form_id')
|
139
|
+
)
|
140
|
+
end
|
141
|
+
|
142
|
+
it "sends a reusable form signature request" do
|
143
|
+
expect(client).to have_received(:post).with(
|
144
|
+
'/signature_request/create_embedded_with_reusable_form',
|
145
|
+
body: formatted_request_body
|
146
|
+
)
|
147
|
+
end
|
148
|
+
|
149
|
+
it "returns the response" do
|
150
|
+
expect(@response).to eq api_response
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
78
155
|
describe "#status" do
|
79
156
|
before { @response = sr_proxy.status }
|
80
157
|
|
@@ -165,4 +242,20 @@ describe HelloSign::Proxy::SignatureRequest do
|
|
165
242
|
expect(@response).to eq api_response
|
166
243
|
end
|
167
244
|
end
|
245
|
+
|
246
|
+
describe "#temporary_signature_url" do
|
247
|
+
let(:signature_id) { double('signature_id') }
|
248
|
+
|
249
|
+
before { @response = sr_proxy.temporary_signature_url(signature_id) }
|
250
|
+
|
251
|
+
it "fetches the temporary URL for an embedded request" do
|
252
|
+
expect(client).to have_received(:get).with(
|
253
|
+
"/embedded/sign_url/#{signature_id}"
|
254
|
+
)
|
255
|
+
end
|
256
|
+
|
257
|
+
it "returns the response" do
|
258
|
+
expect(@response).to eq api_response
|
259
|
+
end
|
260
|
+
end
|
168
261
|
end
|
metadata
CHANGED
@@ -1,36 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hello_sign
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.4.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Craig Little
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-03-14 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: faraday
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
19
|
+
version: 0.8.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
26
|
+
version: 0.8.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: faraday_middleware
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,9 +41,8 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: hashie
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '1.0'
|
54
48
|
- - <
|
@@ -57,9 +51,8 @@ dependencies:
|
|
57
51
|
type: :runtime
|
58
52
|
prerelease: false
|
59
53
|
version_requirements: !ruby/object:Gem::Requirement
|
60
|
-
none: false
|
61
54
|
requirements:
|
62
|
-
- -
|
55
|
+
- - '>='
|
63
56
|
- !ruby/object:Gem::Version
|
64
57
|
version: '1.0'
|
65
58
|
- - <
|
@@ -68,23 +61,20 @@ dependencies:
|
|
68
61
|
- !ruby/object:Gem::Dependency
|
69
62
|
name: rake
|
70
63
|
requirement: !ruby/object:Gem::Requirement
|
71
|
-
none: false
|
72
64
|
requirements:
|
73
|
-
- -
|
65
|
+
- - '>='
|
74
66
|
- !ruby/object:Gem::Version
|
75
67
|
version: '0'
|
76
68
|
type: :development
|
77
69
|
prerelease: false
|
78
70
|
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
none: false
|
80
71
|
requirements:
|
81
|
-
- -
|
72
|
+
- - '>='
|
82
73
|
- !ruby/object:Gem::Version
|
83
74
|
version: '0'
|
84
75
|
- !ruby/object:Gem::Dependency
|
85
76
|
name: rspec
|
86
77
|
requirement: !ruby/object:Gem::Requirement
|
87
|
-
none: false
|
88
78
|
requirements:
|
89
79
|
- - ~>
|
90
80
|
- !ruby/object:Gem::Version
|
@@ -92,7 +82,6 @@ dependencies:
|
|
92
82
|
type: :development
|
93
83
|
prerelease: false
|
94
84
|
version_requirements: !ruby/object:Gem::Requirement
|
95
|
-
none: false
|
96
85
|
requirements:
|
97
86
|
- - ~>
|
98
87
|
- !ruby/object:Gem::Version
|
@@ -100,7 +89,6 @@ dependencies:
|
|
100
89
|
- !ruby/object:Gem::Dependency
|
101
90
|
name: webmock
|
102
91
|
requirement: !ruby/object:Gem::Requirement
|
103
|
-
none: false
|
104
92
|
requirements:
|
105
93
|
- - ~>
|
106
94
|
- !ruby/object:Gem::Version
|
@@ -108,7 +96,6 @@ dependencies:
|
|
108
96
|
type: :development
|
109
97
|
prerelease: false
|
110
98
|
version_requirements: !ruby/object:Gem::Requirement
|
111
|
-
none: false
|
112
99
|
requirements:
|
113
100
|
- - ~>
|
114
101
|
- !ruby/object:Gem::Version
|
@@ -131,6 +118,7 @@ files:
|
|
131
118
|
- lib/hello_sign/parameters/signature_request.rb
|
132
119
|
- lib/hello_sign/parameters/unclaimed_draft.rb
|
133
120
|
- lib/hello_sign/proxy/account.rb
|
121
|
+
- lib/hello_sign/proxy/object.rb
|
134
122
|
- lib/hello_sign/proxy/reusable_form.rb
|
135
123
|
- lib/hello_sign/proxy/settings.rb
|
136
124
|
- lib/hello_sign/proxy/signature_request.rb
|
@@ -172,33 +160,26 @@ files:
|
|
172
160
|
homepage: https://github.com/craiglittle/hello_sign
|
173
161
|
licenses:
|
174
162
|
- MIT
|
163
|
+
metadata: {}
|
175
164
|
post_install_message:
|
176
165
|
rdoc_options: []
|
177
166
|
require_paths:
|
178
167
|
- lib
|
179
168
|
required_ruby_version: !ruby/object:Gem::Requirement
|
180
|
-
none: false
|
181
169
|
requirements:
|
182
|
-
- -
|
170
|
+
- - '>='
|
183
171
|
- !ruby/object:Gem::Version
|
184
172
|
version: '0'
|
185
|
-
segments:
|
186
|
-
- 0
|
187
|
-
hash: 772753378671627303
|
188
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
|
-
none: false
|
190
174
|
requirements:
|
191
|
-
- -
|
175
|
+
- - '>='
|
192
176
|
- !ruby/object:Gem::Version
|
193
177
|
version: '0'
|
194
|
-
segments:
|
195
|
-
- 0
|
196
|
-
hash: 772753378671627303
|
197
178
|
requirements: []
|
198
179
|
rubyforge_project:
|
199
|
-
rubygems_version:
|
180
|
+
rubygems_version: 2.0.3
|
200
181
|
signing_key:
|
201
|
-
specification_version:
|
182
|
+
specification_version: 4
|
202
183
|
summary: A Ruby interface to the HelloSign API
|
203
184
|
test_files:
|
204
185
|
- spec/fixtures/test.jpg
|