docusign_rest 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/LICENSE +1 -1
- data/README.md +67 -23
- data/docusign_rest.gemspec +5 -7
- data/lib/docusign_rest.rb +0 -1
- data/lib/docusign_rest/client.rb +238 -41
- data/lib/docusign_rest/version.rb +1 -1
- data/lib/tasks/docusign_task.rake +1 -1
- metadata +16 -30
- data/.gitignore +0 -27
- data/Guardfile +0 -10
- data/cacert.pem +0 -3895
- data/lib/multipart_post/parts.rb +0 -20
- data/test.pdf +0 -0
- data/test/docusign_login_config.rb +0 -14
- data/test/docusign_rest/client_test.rb +0 -297
- data/test/docusign_rest/configuration_test.rb +0 -24
- data/test/docusign_rest/docusign_rest_test.rb +0 -7
- data/test/helper.rb +0 -14
- data/test2.pdf +0 -0
data/lib/multipart_post/parts.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'multipart_post'
|
2
|
-
require 'parts'
|
3
|
-
|
4
|
-
Parts::ParamPart.class_eval do
|
5
|
-
def build_part(boundary, name, value, headers = {})
|
6
|
-
part = ""
|
7
|
-
part << "--#{boundary}\r\n"
|
8
|
-
|
9
|
-
# TODO (2014-02-03) jonk => multipart-post seems to allow for adding
|
10
|
-
# a configurable header, hence the headers param in the method definition
|
11
|
-
# above. However, I can't seem to figure out how to acctually get it passed
|
12
|
-
# all the way through to line 42 of the Parts module in the parts.rb file.
|
13
|
-
# So for now, we still monkeypatch the content-type in directly.
|
14
|
-
|
15
|
-
part << "Content-Type: application/json\r\n"
|
16
|
-
part << "Content-Disposition: form-data; name=\"#{name.to_s}\"\r\n"
|
17
|
-
part << "\r\n"
|
18
|
-
part << "#{value}\r\n"
|
19
|
-
end
|
20
|
-
end
|
data/test.pdf
DELETED
Binary file
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# This file was generated by the docusign_rest:generate_config rake task.
|
2
|
-
# You can run 'ruby lib/tasks/docusign_task.rb' as many times as you need
|
3
|
-
# to replace the content of this file with a new config.
|
4
|
-
|
5
|
-
require_relative '../lib/docusign_rest'
|
6
|
-
|
7
|
-
DocusignRest.configure do |config|
|
8
|
-
config.username = 'jonkinney@gmail.com'
|
9
|
-
config.password = 'MnUWneAH3xqL2G'
|
10
|
-
config.integrator_key = 'NAXX-93c39e8c-36c4-4cb5-8099-c4fcedddd7ad'
|
11
|
-
config.account_id = '327367'
|
12
|
-
config.endpoint = 'https://demo.docusign.net/restapi'
|
13
|
-
config.api_version = 'v2'
|
14
|
-
end
|
@@ -1,297 +0,0 @@
|
|
1
|
-
require_relative '../helper'
|
2
|
-
|
3
|
-
describe DocusignRest::Client do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@keys = DocusignRest::Configuration::VALID_CONFIG_KEYS
|
7
|
-
end
|
8
|
-
|
9
|
-
describe 'with module configuration' do
|
10
|
-
before do
|
11
|
-
DocusignRest.configure do |config|
|
12
|
-
@keys.each do |key|
|
13
|
-
config.send("#{key}=", key)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
after do
|
19
|
-
DocusignRest.reset
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should inherit module configuration" do
|
23
|
-
api = DocusignRest::Client.new
|
24
|
-
@keys.each do |key|
|
25
|
-
api.send(key).must_equal key
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe 'with class configuration' do
|
30
|
-
before do
|
31
|
-
@config = {
|
32
|
-
:username => 'un',
|
33
|
-
:password => 'pd',
|
34
|
-
:integrator_key => 'ik',
|
35
|
-
:account_id => 'ai',
|
36
|
-
:format => 'fm',
|
37
|
-
:endpoint => 'ep',
|
38
|
-
:api_version => 'av',
|
39
|
-
:user_agent => 'ua',
|
40
|
-
:method => 'md',
|
41
|
-
:ca_file => 'ca',
|
42
|
-
:access_token => 'at'
|
43
|
-
}
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should override module configuration' do
|
47
|
-
api = DocusignRest::Client.new(@config)
|
48
|
-
@keys.each do |key|
|
49
|
-
api.send(key).must_equal @config[key]
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'should override module configuration after' do
|
54
|
-
api = DocusignRest::Client.new
|
55
|
-
|
56
|
-
@config.each do |key, value|
|
57
|
-
api.send("#{key}=", value)
|
58
|
-
end
|
59
|
-
|
60
|
-
@keys.each do |key|
|
61
|
-
api.send("#{key}").must_equal @config[key]
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe 'client' do
|
68
|
-
before do
|
69
|
-
# Note: to configure the client please run the docusign_task.rb file:
|
70
|
-
#
|
71
|
-
# $ ruby lib/tasks/docusign_task.rb
|
72
|
-
#
|
73
|
-
# which will populate the test/docusign_login_config.rb file
|
74
|
-
@client = DocusignRest::Client.new
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should allow access to the auth headers after initialization" do
|
78
|
-
@client.must_respond_to :docusign_authentication_headers
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should allow access to the acct_id after initialization" do
|
82
|
-
@client.must_respond_to :acct_id
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should return the value of acct_id" do
|
86
|
-
@client.get_account_id.must_equal @client.acct_id
|
87
|
-
end
|
88
|
-
|
89
|
-
it "should allow creating an envelope from a document" do
|
90
|
-
VCR.use_cassette("create_envelope/from_document") do
|
91
|
-
response = @client.create_envelope_from_document(
|
92
|
-
email: {
|
93
|
-
subject: "test email subject",
|
94
|
-
body: "this is the email body and it's large!"
|
95
|
-
},
|
96
|
-
# If embedded is set to true in the signers array below, emails
|
97
|
-
# don't go out and you can embed the signature page in an iFrame
|
98
|
-
# by using the get_recipient_view method. You can choose 'false' or
|
99
|
-
# simply omit the option as I show in the second signer hash.
|
100
|
-
signers: [
|
101
|
-
{
|
102
|
-
embedded: true,
|
103
|
-
name: 'Test Guy',
|
104
|
-
email: 'testguy@example.com',
|
105
|
-
role_name: 'Issuer',
|
106
|
-
sign_here_tabs: [
|
107
|
-
{
|
108
|
-
anchor_string: 'sign here',
|
109
|
-
anchor_x_offset: '125',
|
110
|
-
anchor_y_offset: '-12'
|
111
|
-
}
|
112
|
-
],
|
113
|
-
list_tabs: [
|
114
|
-
{
|
115
|
-
anchor_string: 'another test',
|
116
|
-
width: '180',
|
117
|
-
height: '14',
|
118
|
-
anchor_x_offset: '10',
|
119
|
-
anchor_y_offset: '-5',
|
120
|
-
label: 'another test',
|
121
|
-
selected: true,
|
122
|
-
list_items: [
|
123
|
-
{
|
124
|
-
selected: false,
|
125
|
-
text: 'Option 1',
|
126
|
-
value: 'option_1'
|
127
|
-
},
|
128
|
-
{
|
129
|
-
selected: true,
|
130
|
-
text: 'Option 2',
|
131
|
-
value: 'option_2'
|
132
|
-
}
|
133
|
-
]
|
134
|
-
}
|
135
|
-
],
|
136
|
-
},
|
137
|
-
{
|
138
|
-
embedded: true,
|
139
|
-
name: 'Test Girl',
|
140
|
-
email: 'testgirl@example.com',
|
141
|
-
role_name: 'Attorney',
|
142
|
-
sign_here_tabs: [
|
143
|
-
{
|
144
|
-
anchor_string: 'sign here',
|
145
|
-
anchor_x_offset: '140',
|
146
|
-
anchor_y_offset: '-12'
|
147
|
-
}
|
148
|
-
]
|
149
|
-
}
|
150
|
-
],
|
151
|
-
files: [
|
152
|
-
{path: 'test.pdf', name: 'test.pdf'},
|
153
|
-
{path: 'test2.pdf', name: 'test2.pdf'}
|
154
|
-
],
|
155
|
-
status: 'sent'
|
156
|
-
)
|
157
|
-
|
158
|
-
response["status"].must_equal "sent"
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
describe "embedded signing" do
|
163
|
-
before do
|
164
|
-
# create the template dynamically
|
165
|
-
VCR.use_cassette("create_template") do
|
166
|
-
@template_response = @client.create_template(
|
167
|
-
description: 'Cool Description',
|
168
|
-
name: "Cool Template Name",
|
169
|
-
signers: [
|
170
|
-
{
|
171
|
-
embedded: true,
|
172
|
-
name: 'jon',
|
173
|
-
email: 'someone@example.com',
|
174
|
-
role_name: 'Issuer',
|
175
|
-
sign_here_tabs: [
|
176
|
-
{
|
177
|
-
anchor_string: 'sign here',
|
178
|
-
template_locked: true, #doesn't seem to do anything
|
179
|
-
template_required: true, #doesn't seem to do anything
|
180
|
-
email_notification: {supportedLanguage: 'en'} #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...
|
181
|
-
}
|
182
|
-
]
|
183
|
-
}
|
184
|
-
],
|
185
|
-
files: [
|
186
|
-
{path: 'test.pdf', name: 'test.pdf'}
|
187
|
-
]
|
188
|
-
)
|
189
|
-
if ! @template_response["errorCode"].nil?
|
190
|
-
puts "[API ERROR] (create_template) errorCode: '#{@template_response["errorCode"]}', message: '#{@template_response["message"]}'"
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
|
195
|
-
# use the templateId to get the envelopeId
|
196
|
-
VCR.use_cassette("create_envelope/from_template") do
|
197
|
-
@envelope_response = @client.create_envelope_from_template(
|
198
|
-
status: 'sent',
|
199
|
-
email: {
|
200
|
-
subject: "The test email subject envelope",
|
201
|
-
body: "Envelope body content here"
|
202
|
-
},
|
203
|
-
template_id: @template_response["templateId"],
|
204
|
-
signers: [
|
205
|
-
{
|
206
|
-
embedded: true,
|
207
|
-
name: 'jon',
|
208
|
-
email: 'someone@example.com',
|
209
|
-
role_name: 'Issuer'
|
210
|
-
}
|
211
|
-
]
|
212
|
-
)
|
213
|
-
if ! @envelope_response["errorCode"].nil?
|
214
|
-
puts "[API ERROR] (create_envelope/from_template) errorCode: '#{@envelope_response["errorCode"]}', message: '#{@envelope_response["message"]}'"
|
215
|
-
end
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
it "should get a template" do
|
220
|
-
VCR.use_cassette("get_template", record: :all) do
|
221
|
-
response = @client.get_template(@template_response["templateId"])
|
222
|
-
assert_equal @template_response["templateId"], response['envelopeTemplateDefinition']['templateId']
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
it "should return a URL for embedded signing" do
|
227
|
-
#ensure template was created
|
228
|
-
@template_response["templateId"].wont_be_nil
|
229
|
-
@template_response["name"].must_equal "Cool Template Name"
|
230
|
-
|
231
|
-
#ensure creating an envelope from a dynamic template did not error
|
232
|
-
@envelope_response["errorCode"].must_be_nil
|
233
|
-
|
234
|
-
#return the URL for embedded signing
|
235
|
-
VCR.use_cassette("get_recipient_view") do
|
236
|
-
response = @client.get_recipient_view(
|
237
|
-
envelope_id: @envelope_response["envelopeId"],
|
238
|
-
name: 'jon',
|
239
|
-
email: 'someone@example.com',
|
240
|
-
return_url: 'http://google.com'
|
241
|
-
)
|
242
|
-
response['url'].must_match(/http/)
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
#status return values = "sent", "delivered", "completed"
|
247
|
-
it "should retrieve the envelope recipients status" do
|
248
|
-
VCR.use_cassette("get_envelope_recipients") do
|
249
|
-
response = @client.get_envelope_recipients(
|
250
|
-
envelope_id: @envelope_response["envelopeId"],
|
251
|
-
include_tabs: true,
|
252
|
-
include_extended: true
|
253
|
-
)
|
254
|
-
response["signers"].wont_be_nil
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
#status return values = "sent", "delivered", "completed"
|
259
|
-
it "should retrieve the byte stream of the envelope doc from DocuSign" do
|
260
|
-
VCR.use_cassette("get_document_from_envelope") do
|
261
|
-
@client.get_document_from_envelope(
|
262
|
-
envelope_id: @envelope_response["envelopeId"],
|
263
|
-
document_id: 1,
|
264
|
-
local_save_path: 'docusign_docs/file_name.pdf'
|
265
|
-
)
|
266
|
-
# NOTE manually check that this file has the content you'd expect
|
267
|
-
end
|
268
|
-
end
|
269
|
-
|
270
|
-
it "should add signers to an envelope" do
|
271
|
-
VCR.use_cassette("add_envelope_signers") do
|
272
|
-
response = @client.add_envelope_signers(
|
273
|
-
envelope_id: @envelope_response["envelopeId"],
|
274
|
-
signers: [{
|
275
|
-
email: "signer@example.com",
|
276
|
-
name: "Signer Person",
|
277
|
-
recipientId: 2,
|
278
|
-
}],
|
279
|
-
)
|
280
|
-
|
281
|
-
response["recipientUpdateResults"].first["errorDetails"]["errorCode"]
|
282
|
-
.must_equal "SUCCESS"
|
283
|
-
end
|
284
|
-
end
|
285
|
-
it "should get envelope's sender view" do
|
286
|
-
VCR.use_cassette("get_envelope_sender_view") do
|
287
|
-
response = @client.get_sender_view(
|
288
|
-
envelope_id: @envelope_response["envelopeId"],
|
289
|
-
)
|
290
|
-
|
291
|
-
response['errorCode'].must_be_nil
|
292
|
-
response['url'].must_match(/http/)
|
293
|
-
end
|
294
|
-
end
|
295
|
-
end
|
296
|
-
end
|
297
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require_relative '../helper'
|
2
|
-
|
3
|
-
describe 'configuration' do
|
4
|
-
after do
|
5
|
-
DocusignRest.reset
|
6
|
-
end
|
7
|
-
|
8
|
-
describe '.configure' do
|
9
|
-
DocusignRest::Configuration::VALID_CONFIG_KEYS.each do |key|
|
10
|
-
it "should set the #{key}" do
|
11
|
-
DocusignRest.configure do |config|
|
12
|
-
config.send("#{key}=", key)
|
13
|
-
DocusignRest.send(key).must_equal key
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '.key' do
|
18
|
-
it "should return default value for #{key}" do
|
19
|
-
DocusignRest.send(key).must_equal DocusignRest::Configuration.const_get("DEFAULT_#{key.upcase}")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
data/test/helper.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require_relative '../lib/docusign_rest'
|
2
|
-
require 'minitest/spec'
|
3
|
-
require 'minitest/autorun'
|
4
|
-
require 'turn'
|
5
|
-
require 'json'
|
6
|
-
require 'vcr'
|
7
|
-
require_relative 'docusign_login_config'
|
8
|
-
require 'pry'
|
9
|
-
|
10
|
-
VCR.configure do |c|
|
11
|
-
c.cassette_library_dir = "test/fixtures/vcr"
|
12
|
-
c.hook_into :webmock
|
13
|
-
c.default_cassette_options = { record: :all }
|
14
|
-
end
|
data/test2.pdf
DELETED
Binary file
|