docusign_rest 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/README.md +11 -1
- data/lib/docusign_rest/client.rb +40 -2
- data/lib/docusign_rest/version.rb +1 -1
- data/test/docusign_rest/client_test.rb +18 -6
- metadata +2 -2
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -206,6 +206,16 @@ response = client.get_envelope_recipients(
|
|
206
206
|
)
|
207
207
|
```
|
208
208
|
|
209
|
+
**Retrieve a document from an envelope and store it at a local file path**
|
210
|
+
|
211
|
+
```ruby
|
212
|
+
client = DocusignRest::Client.new
|
213
|
+
client.get_document_from_envelope(
|
214
|
+
envelope_id: @envelope_response["envelopeId"],
|
215
|
+
document_id: 1,
|
216
|
+
local_save_path: "#{Rails.root.join('docusign_docs/file_name.pdf')}"
|
217
|
+
)
|
218
|
+
```
|
209
219
|
|
210
220
|
## Breaking out of the iFrame after signing
|
211
221
|
|
@@ -262,4 +272,4 @@ This calls a rake task which adds a non-version controlled file in the test fold
|
|
262
272
|
|
263
273
|
**VCR**
|
264
274
|
|
265
|
-
The test suite uses VCR and is configured to record
|
275
|
+
The test suite uses VCR and is configured to record all requests by using the 'all' configuration option surrounding each API request. If you want to speed up the test suite locally for new feature development, you may want to change the VCR config record setting to 'once' temporarily which will not write a new YAML file for each request each time you hit the API and significantly speed up the tests. However, this can lead to false passing tests as the gem changes so it's recommended that you ensure all tests pass by actually hitting the API before submitting a pull request.
|
data/lib/docusign_rest/client.rb
CHANGED
@@ -268,8 +268,8 @@ module DocusignRest
|
|
268
268
|
\"signHereTabs\":[
|
269
269
|
{
|
270
270
|
\"anchorString\":\"#{signer[:anchor_string]}\",
|
271
|
-
\"anchorXOffset\": \"#{signer[:anchor_x_offset]}\",
|
272
|
-
\"anchorYOffset\": \"#{signer[:anchor_y_offset]}\",
|
271
|
+
\"anchorXOffset\": \"#{signer[:anchor_x_offset] || 0}\",
|
272
|
+
\"anchorYOffset\": \"#{signer[:anchor_y_offset] || 0}\",
|
273
273
|
\"anchorIgnoreIfNotPresent\": false,
|
274
274
|
\"anchorUnits\": \"pixels\",
|
275
275
|
\"conditionalParentLabel\": null,
|
@@ -631,6 +631,44 @@ module DocusignRest
|
|
631
631
|
response = http.request(request)
|
632
632
|
parsed_response = JSON.parse(response.body)
|
633
633
|
end
|
634
|
+
|
635
|
+
# Public retrieves the attached file from a given envelope
|
636
|
+
#
|
637
|
+
# envelope_id - ID of the envelope from which the doc will be retrieved
|
638
|
+
# document_id - ID of the document to retrieve
|
639
|
+
# local_save_path - Local absolute path to save the doc to including the
|
640
|
+
# filename itself
|
641
|
+
# headers - Optional hash of headers to merge into the existing
|
642
|
+
# required headers for a multipart request.
|
643
|
+
#
|
644
|
+
# Example
|
645
|
+
#
|
646
|
+
# client.get_document_from_envelope(
|
647
|
+
# envelope_id: @envelope_response["envelopeId"],
|
648
|
+
# document_id: 1,
|
649
|
+
# local_save_path: 'docusign_docs/file_name.pdf'
|
650
|
+
# )
|
651
|
+
#
|
652
|
+
# Returns the PDF document as a byte stream.
|
653
|
+
def get_document_from_envelope(options={})
|
654
|
+
content_type = {'Content-Type' => 'application/json'}
|
655
|
+
content_type.merge(options[:headers]) if options[:headers]
|
656
|
+
|
657
|
+
uri = build_uri("/accounts/#{@acct_id}/envelopes/#{options[:envelope_id]}/documents/#{options[:document_id]}")
|
658
|
+
|
659
|
+
http = initialize_net_http_ssl(uri)
|
660
|
+
request = Net::HTTP::Get.new(uri.request_uri, headers(content_type))
|
661
|
+
response = http.request(request)
|
662
|
+
|
663
|
+
split_path = options[:local_save_path].split('/')
|
664
|
+
split_path.pop
|
665
|
+
path = split_path.join("/")
|
666
|
+
|
667
|
+
FileUtils.mkdir_p(path)
|
668
|
+
File.open(options[:local_save_path], 'wb') do |output|
|
669
|
+
output << response.body
|
670
|
+
end
|
671
|
+
end
|
634
672
|
end
|
635
673
|
|
636
674
|
end
|
@@ -81,7 +81,7 @@ describe DocusignRest::Client do
|
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should allow creating an envelope from a document" do
|
84
|
-
VCR.use_cassette("create_envelope/from_document", record: :
|
84
|
+
VCR.use_cassette("create_envelope/from_document", record: :all) do
|
85
85
|
response = @client.create_envelope_from_document(
|
86
86
|
email: {
|
87
87
|
subject: "test email subject",
|
@@ -116,7 +116,7 @@ describe DocusignRest::Client do
|
|
116
116
|
describe "embedded signing" do
|
117
117
|
before do
|
118
118
|
# create the template dynamically
|
119
|
-
VCR.use_cassette("create_template", record: :
|
119
|
+
VCR.use_cassette("create_template", record: :all) do
|
120
120
|
@template_response = @client.create_template(
|
121
121
|
description: 'Cool Description',
|
122
122
|
name: "Cool Template Name",
|
@@ -127,7 +127,6 @@ describe DocusignRest::Client do
|
|
127
127
|
email: 'someone@gmail.com',
|
128
128
|
role_name: 'Issuer',
|
129
129
|
anchor_string: 'sign here',
|
130
|
-
sign_here_tab_text: 'Issuer, Please Sign Here',
|
131
130
|
template_locked: true, #doesn't seem to do anything
|
132
131
|
template_required: true, #doesn't seem to do anything
|
133
132
|
email_notification: false #FIXME if signer is setup as 'embedded' initial email notifications don't go out, but even when I set up a signer as non-embedded this setting didn't seem to make the email notifications actually stop...
|
@@ -140,7 +139,7 @@ describe DocusignRest::Client do
|
|
140
139
|
end
|
141
140
|
|
142
141
|
# use the templateId to get the envelopeId
|
143
|
-
VCR.use_cassette("create_envelope/from_template", record: :
|
142
|
+
VCR.use_cassette("create_envelope/from_template", record: :all) do
|
144
143
|
@envelope_response = @client.create_envelope_from_template(
|
145
144
|
status: 'sent',
|
146
145
|
email: {
|
@@ -169,7 +168,7 @@ describe DocusignRest::Client do
|
|
169
168
|
@envelope_response["errorCode"].must_be_nil
|
170
169
|
|
171
170
|
#return the URL for embedded signing
|
172
|
-
VCR.use_cassette("get_recipient_view", record: :
|
171
|
+
VCR.use_cassette("get_recipient_view", record: :all) do
|
173
172
|
response = @client.get_recipient_view(
|
174
173
|
envelope_id: @envelope_response["envelopeId"],
|
175
174
|
name: 'jon',
|
@@ -182,7 +181,7 @@ describe DocusignRest::Client do
|
|
182
181
|
|
183
182
|
#status return values = "sent", "delivered", "completed"
|
184
183
|
it "should retrieve the envelope recipients status" do
|
185
|
-
VCR.use_cassette("get_envelope_recipients", record: :
|
184
|
+
VCR.use_cassette("get_envelope_recipients", record: :all) do
|
186
185
|
response = @client.get_envelope_recipients(
|
187
186
|
envelope_id: @envelope_response["envelopeId"],
|
188
187
|
include_tabs: true,
|
@@ -192,6 +191,19 @@ describe DocusignRest::Client do
|
|
192
191
|
#puts response["signers"]
|
193
192
|
end
|
194
193
|
end
|
194
|
+
|
195
|
+
#status return values = "sent", "delivered", "completed"
|
196
|
+
it "should retrieve the byte stream of the envelope doc from DocuSign" do
|
197
|
+
VCR.use_cassette("get_document_from_envelope", record: :all) do
|
198
|
+
@client.get_document_from_envelope(
|
199
|
+
envelope_id: @envelope_response["envelopeId"],
|
200
|
+
document_id: 1,
|
201
|
+
local_save_path: 'docusign_docs/file_name.pdf'
|
202
|
+
)
|
203
|
+
# NOTE manually check that this file has the content you'd expect
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
195
207
|
end
|
196
208
|
|
197
209
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docusign_rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
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: 2012-06-
|
12
|
+
date: 2012-06-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multipart-post
|