hello_sign 0.0.4 → 0.0.5
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.
@@ -3,15 +3,26 @@ require 'hello_sign/signature_request_parameters'
|
|
3
3
|
module HelloSign
|
4
4
|
class SignatureRequestProxy
|
5
5
|
attr_reader :client
|
6
|
+
attr_writer :request_parameters
|
6
7
|
|
7
8
|
def initialize(client)
|
8
9
|
@client = client
|
9
10
|
end
|
10
11
|
|
11
12
|
def create(raw_parameters)
|
12
|
-
raw_parameters.call(request_parameters
|
13
|
+
raw_parameters.call(request_parameters)
|
13
14
|
client.post('/signature_request/send', :body => request_parameters.formatted)
|
14
15
|
end
|
15
16
|
|
17
|
+
def status(request_id)
|
18
|
+
client.get("/signature_request/#{request_id}")
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def request_parameters
|
24
|
+
@request_parameters ||= SignatureRequestParameters.new
|
25
|
+
end
|
26
|
+
|
16
27
|
end
|
17
28
|
end
|
data/lib/hello_sign/version.rb
CHANGED
data/lib/hello_sign.rb
CHANGED
@@ -11,8 +11,12 @@ module HelloSign
|
|
11
11
|
AccountProxy.new(client)
|
12
12
|
end
|
13
13
|
|
14
|
-
def signature_request(¶meters)
|
15
|
-
|
14
|
+
def signature_request(request_id = nil, ¶meters)
|
15
|
+
if request_id
|
16
|
+
SignatureRequestProxy.new(client).status(request_id)
|
17
|
+
else
|
18
|
+
SignatureRequestProxy.new(client).create(parameters)
|
19
|
+
end
|
16
20
|
end
|
17
21
|
|
18
22
|
def client
|
@@ -29,4 +29,15 @@ describe HelloSign do
|
|
29
29
|
).to have_been_made
|
30
30
|
end
|
31
31
|
end
|
32
|
+
|
33
|
+
context "when fetching a signature request" do
|
34
|
+
before do
|
35
|
+
stub_get_with_auth('/signature_request/request_id')
|
36
|
+
HelloSign.signature_request('request_id')
|
37
|
+
end
|
38
|
+
|
39
|
+
it "fetches the signature request information from the HelloSign API" do
|
40
|
+
expect(a_get_with_auth('/signature_request/request_id')).to have_been_made
|
41
|
+
end
|
42
|
+
end
|
32
43
|
end
|
@@ -9,15 +9,25 @@ describe HelloSign do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "::signature_request" do
|
12
|
-
let(:sr_proxy)
|
12
|
+
let(:sr_proxy) { mock }
|
13
|
+
let(:request_result) { stub }
|
13
14
|
|
14
|
-
before
|
15
|
-
|
16
|
-
|
15
|
+
before { HelloSign::SignatureRequestProxy.stub(:new).and_return(sr_proxy) }
|
16
|
+
|
17
|
+
context "when called without passing a request ID" do
|
18
|
+
before { sr_proxy.should_receive(:create).and_return(request_result) }
|
19
|
+
|
20
|
+
it "calls #create on the signature request proxy and returns the result" do
|
21
|
+
expect(HelloSign.signature_request).to eq request_result
|
22
|
+
end
|
17
23
|
end
|
18
24
|
|
19
|
-
|
20
|
-
|
25
|
+
context "when called with a signature ID" do
|
26
|
+
before { sr_proxy.should_receive(:status).with('request_id').and_return(request_result) }
|
27
|
+
|
28
|
+
it "calls #status on the signature request proxy and returns the result " do
|
29
|
+
expect(HelloSign.signature_request('request_id')).to eq request_result
|
30
|
+
end
|
21
31
|
end
|
22
32
|
end
|
23
33
|
|
@@ -2,7 +2,8 @@ require 'helper'
|
|
2
2
|
require 'hello_sign/signature_request_proxy'
|
3
3
|
|
4
4
|
describe HelloSign::SignatureRequestProxy do
|
5
|
-
let(:client) {
|
5
|
+
let(:client) { mock }
|
6
|
+
let(:api_response) { stub }
|
6
7
|
subject(:sr_proxy) { HelloSign::SignatureRequestProxy.new(client) }
|
7
8
|
|
8
9
|
describe "#client" do
|
@@ -13,20 +14,32 @@ describe HelloSign::SignatureRequestProxy do
|
|
13
14
|
|
14
15
|
describe "#create" do
|
15
16
|
let(:formatted_request_body) { stub }
|
16
|
-
let(:create_response) { stub }
|
17
17
|
let(:raw_parameters) { Proc.new { |params| params.foo = 'bar' } }
|
18
|
+
let(:request_parameters) { mock }
|
18
19
|
|
19
20
|
before do
|
20
|
-
|
21
|
+
sr_proxy.request_parameters = request_parameters
|
21
22
|
request_parameters.stub(:formatted).and_return(formatted_request_body)
|
22
23
|
request_parameters.should_receive(:foo=).with('bar')
|
23
24
|
client.should_receive(:post)
|
24
25
|
.with('/signature_request/send', :body => formatted_request_body)
|
25
|
-
.and_return(
|
26
|
+
.and_return(api_response)
|
26
27
|
end
|
27
28
|
|
28
29
|
it "sends a signature request creation request and returns the result" do
|
29
|
-
expect(sr_proxy.create(raw_parameters)).to eq
|
30
|
+
expect(sr_proxy.create(raw_parameters)).to eq api_response
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#status" do
|
35
|
+
let(:request_id) { 'request_id' }
|
36
|
+
|
37
|
+
before do
|
38
|
+
client.should_receive(:get).with('/signature_request/request_id').and_return(api_response)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "fetches the signature request status and returns the result" do
|
42
|
+
expect(sr_proxy.status(request_id)).to eq api_response
|
30
43
|
end
|
31
44
|
end
|
32
45
|
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.0.
|
4
|
+
version: 0.0.5
|
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-01-
|
12
|
+
date: 2013-01-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|