rightsignature 0.1.5 → 0.1.6
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.
- data/README.md +6 -3
- data/lib/rightsignature/document.rb +8 -2
- data/lib/rightsignature/template.rb +3 -7
- data/lib/rightsignature/version.rb +1 -1
- data/spec/document_spec.rb +19 -8
- data/spec/template_spec.rb +63 -10
- metadata +1 -1
data/README.md
CHANGED
@@ -8,7 +8,7 @@ gem install rightsignature
|
|
8
8
|
```
|
9
9
|
or in your Gemfile
|
10
10
|
```
|
11
|
-
gem 'rightsignature', '~> 0.1.
|
11
|
+
gem 'rightsignature', '~> 0.1.6'
|
12
12
|
```
|
13
13
|
|
14
14
|
Setup
|
@@ -130,7 +130,7 @@ RightSignature::Document.send_document_from_file(File.open("here/is/myfile.pdf",
|
|
130
130
|
```
|
131
131
|
* subject: Document subject
|
132
132
|
* recipients: Recipients of the document, should be an array of hashes with :name, :email, and :role ('cc' or 'signer').
|
133
|
-
|
133
|
+
One recipient requires a :is_sender => true to reference the API User and doesn't need to supply :name and :email. Ex. {:is_sender => true, :role => "cc"}
|
134
134
|
* Optional options:
|
135
135
|
* description: document description that'll appear in the email
|
136
136
|
* action: 'send' or 'redirect'. Redirect will prefill the document and generate a redirect token that can be used on for someone to send document under API user's account.
|
@@ -188,9 +188,12 @@ RightSignature::Template.details(guid)
|
|
188
188
|
#####Prepackage and Send template
|
189
189
|
Most common use of API, clones a template and sends it for signature.
|
190
190
|
```
|
191
|
-
RightSignature::Template.prepackage_and_send(guid,
|
191
|
+
RightSignature::Template.prepackage_and_send(guid, roles, options={})
|
192
192
|
```
|
193
|
+
* guid: template guid to use. Should be a template that was prepackaged
|
194
|
+
* roles: recipient names in array of {:name => "Person's Name", :email => "Email"} hashed by Role ID. Ex. {"signer_A" => {:name => "Your Name", :name => "a@example.com"}}
|
193
195
|
Optional options:
|
196
|
+
* subject: document subject. Defaults to the subject in prepackage response.
|
194
197
|
* description: document description that'll appear in the email
|
195
198
|
* merge_fields: document merge fields, should be an array of merge_field_values in a hash with the merge_field_name.
|
196
199
|
Ex. [{"Salary" => "$1,000,000"}]
|
@@ -217,8 +217,14 @@ module RightSignature
|
|
217
217
|
response = RightSignature::Connection.get "/api/documents/#{guid}/signer_links.xml", params
|
218
218
|
|
219
219
|
signer_links = []
|
220
|
-
|
221
|
-
|
220
|
+
|
221
|
+
if response["document"]["signer_links"]["signer_link"].is_a? Array
|
222
|
+
response["document"]["signer_links"]["signer_link"].each do |signer_link|
|
223
|
+
signer_links << {"name" => signer_link["name"], "url" => "#{RightSignature::Connection.site}/signatures/embedded?rt=#{signer_link["signer_token"]}"}
|
224
|
+
end
|
225
|
+
else
|
226
|
+
signer_link = response["document"]["signer_links"]["signer_link"]
|
227
|
+
signer_links << {"name" => signer_link["name"], "url" => "#{RightSignature::Connection.site}/signatures/embedded?rt=#{signer_link["signer_token"]}"}
|
222
228
|
end
|
223
229
|
signer_links
|
224
230
|
end
|
@@ -90,10 +90,10 @@ module RightSignature
|
|
90
90
|
RightSignature::Connection.post "/api/templates.xml", xml_hash
|
91
91
|
end
|
92
92
|
|
93
|
-
def prepackage_and_send(guid,
|
93
|
+
def prepackage_and_send(guid, roles, options={})
|
94
94
|
response = prepackage(guid)
|
95
95
|
new_guid = response["template"]["guid"]
|
96
|
-
send_template(new_guid, subject, roles, options)
|
96
|
+
send_template(new_guid, options.delete(:subject) || response["template"]["subject"], roles, options)
|
97
97
|
end
|
98
98
|
|
99
99
|
# Sends template.
|
@@ -225,11 +225,7 @@ module RightSignature
|
|
225
225
|
|
226
226
|
recipients.each do |role_hash|
|
227
227
|
key, value = role_hash.first
|
228
|
-
|
229
|
-
role_hash[key]["email"] = "noemail@rightsignature.com"
|
230
|
-
else
|
231
|
-
role_hash[key][:email] = "noemail@rightsignature.com"
|
232
|
-
end
|
228
|
+
role_hash[key][:email] = "noemail@rightsignature.com" unless role_hash[key]["email"] || role_hash[key][:email]
|
233
229
|
end
|
234
230
|
|
235
231
|
response = send_template(template["guid"], options[:subject] || template["subject"], recipients, options)
|
data/spec/document_spec.rb
CHANGED
@@ -256,10 +256,10 @@ describe RightSignature::Document do
|
|
256
256
|
|
257
257
|
describe "get_signer_links_for" do
|
258
258
|
it "should GET /api/documents/GUID123/signer_links.xml and return urls for signers" do
|
259
|
-
RightSignature::Connection.should_receive(:get).with("/api/documents/GUID123/signer_links.xml", {}).and_return({'document' => {'signer_links' => [
|
260
|
-
{
|
261
|
-
{
|
262
|
-
}})
|
259
|
+
RightSignature::Connection.should_receive(:get).with("/api/documents/GUID123/signer_links.xml", {}).and_return({'document' => {'signer_links' => {'signer_link' => [
|
260
|
+
{"signer_token" => "avx37", "name" => "John Bellingham"},
|
261
|
+
{"signer_token" => "fdh89", "name" => "Righty Jones"}]
|
262
|
+
}}})
|
263
263
|
|
264
264
|
response = RightSignature::Document.get_signer_links_for("GUID123")
|
265
265
|
response.size.should == 2
|
@@ -269,15 +269,26 @@ describe RightSignature::Document do
|
|
269
269
|
|
270
270
|
it "should GET /api/documents/GUID123/signer_links.xml with URI encoded redirect location and return urls for signers" do
|
271
271
|
RightSignature::Connection.should_receive(:get).with("/api/documents/GUID123/signer_links.xml", {:redirect_location => "http://google.com/redirected%20location"}
|
272
|
-
).and_return({
|
273
|
-
{
|
274
|
-
{
|
275
|
-
}})
|
272
|
+
).and_return({'document' => {'signer_links' => {'signer_link' => [
|
273
|
+
{"signer_token" => "avx37", "name" => "John Bellingham"},
|
274
|
+
{"signer_token" => "fdh89", "name" => "Righty Jones"}]
|
275
|
+
}}})
|
276
276
|
|
277
277
|
response = RightSignature::Document.get_signer_links_for("GUID123", "http://google.com/redirected location")
|
278
278
|
response.size.should == 2
|
279
279
|
response.include?({"name" => "John Bellingham", "url" => "#{RightSignature::Connection.site}/signatures/embedded?rt=avx37"}).should be_true
|
280
280
|
response.include?({"name" => "Righty Jones", "url" => "#{RightSignature::Connection.site}/signatures/embedded?rt=fdh89"}).should be_true
|
281
281
|
end
|
282
|
+
|
283
|
+
it "should GET /api/documents/GUID123/signer_links.xml with URI encoded redirect location and return urls for 1 signer_link" do
|
284
|
+
RightSignature::Connection.should_receive(:get).with("/api/documents/GUID123/signer_links.xml", {:redirect_location => "http://google.com/redirected%20location"}
|
285
|
+
).and_return({'document' => {'signer_links' => {'signer_link' =>
|
286
|
+
{"signer_token" => "fdh89", "name" => "Righty Jones"}
|
287
|
+
}}})
|
288
|
+
|
289
|
+
response = RightSignature::Document.get_signer_links_for("GUID123", "http://google.com/redirected location")
|
290
|
+
response.size.should == 1
|
291
|
+
response.include?({"name" => "Righty Jones", "url" => "#{RightSignature::Connection.site}/signatures/embedded?rt=fdh89"}).should be_true
|
292
|
+
end
|
282
293
|
end
|
283
294
|
end
|
data/spec/template_spec.rb
CHANGED
@@ -53,7 +53,24 @@ describe RightSignature::Template do
|
|
53
53
|
:subject => "sign me",
|
54
54
|
:roles => []
|
55
55
|
}})
|
56
|
-
RightSignature::Template.prepackage_and_send("GUID123", "sign me"
|
56
|
+
RightSignature::Template.prepackage_and_send("GUID123", [], {:subject => "sign me"})
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should default subject to one in Template prepackage response" do
|
60
|
+
RightSignature::Connection.should_receive(:post).with('/api/templates/GUID123/prepackage.xml',
|
61
|
+
{}
|
62
|
+
).and_return({"template" => {
|
63
|
+
"guid" => "a_123985_1z9v8pd654",
|
64
|
+
"subject" => "subject template",
|
65
|
+
"message" => "Default message here"
|
66
|
+
}})
|
67
|
+
RightSignature::Connection.should_receive(:post).with('/api/templates.xml', {:template => {
|
68
|
+
:guid => "a_123985_1z9v8pd654",
|
69
|
+
:action => "send",
|
70
|
+
:subject => "subject template",
|
71
|
+
:roles => []
|
72
|
+
}})
|
73
|
+
RightSignature::Template.prepackage_and_send("GUID123", [])
|
57
74
|
end
|
58
75
|
end
|
59
76
|
|
@@ -220,10 +237,8 @@ describe RightSignature::Template do
|
|
220
237
|
end
|
221
238
|
|
222
239
|
describe "send_as_self_signers" do
|
223
|
-
|
224
|
-
|
225
|
-
{}
|
226
|
-
).and_return( {"template"=>{
|
240
|
+
before do
|
241
|
+
@prepackage_response = {"template"=>{
|
227
242
|
"type"=>"Document",
|
228
243
|
"guid"=>"a_123_456",
|
229
244
|
"created_at"=>"2012-09-25T14:51:44-07:00",
|
@@ -263,7 +278,19 @@ describe RightSignature::Template do
|
|
263
278
|
"https%3A%2F%2Fs3.amazonaws.com%3A443%2Frightsignature.com%2Fassets%2F1464%2Fabcde_p1_t.png%3FSignature%3D1234AC",
|
264
279
|
"redirect_token"=>
|
265
280
|
"123456bcde"
|
266
|
-
}}
|
281
|
+
}}
|
282
|
+
|
283
|
+
@sent_document_response = {"document"=> {
|
284
|
+
"status"=>"sent",
|
285
|
+
"guid"=>"ABCDEFGH123"
|
286
|
+
}}
|
287
|
+
|
288
|
+
end
|
289
|
+
|
290
|
+
it "should prepackage template, send template with reciepents with noemail@rightsignature.com and return self-signer links" do
|
291
|
+
RightSignature::Connection.should_receive(:post).with('/api/templates/TGUID/prepackage.xml',
|
292
|
+
{}
|
293
|
+
).and_return(@prepackage_response)
|
267
294
|
RightSignature::Connection.should_receive(:post).with('/api/templates.xml', {:template => {
|
268
295
|
:guid => "a_123_456",
|
269
296
|
:action => "send",
|
@@ -272,10 +299,7 @@ describe RightSignature::Template do
|
|
272
299
|
{:role => {:name => "John Bellingham", :email => "noemail@rightsignature.com", "@role_name" => "Leasee"}},
|
273
300
|
{:role => {:name => "Tim Else", :email => "noemail@rightsignature.com", "@role_name" => "Leaser"}}
|
274
301
|
]
|
275
|
-
}}).and_return(
|
276
|
-
"status"=>"sent",
|
277
|
-
"guid"=>"ABCDEFGH123"
|
278
|
-
}})
|
302
|
+
}}).and_return(@sent_document_response)
|
279
303
|
RightSignature::Connection.should_receive(:get).with("/api/documents/ABCDEFGH123/signer_links.xml", {}).and_return({"document" => {
|
280
304
|
"signer_links" => [
|
281
305
|
{"signer_link" => {"name" => "John Bellingham", "role" => "signer_A", "signer_token" => "slkfj2"}},
|
@@ -293,6 +317,35 @@ describe RightSignature::Template do
|
|
293
317
|
results.include?({"name" => "Tim Else", "url" => "#{RightSignature::Connection.site}/signatures/embedded?rt=asfd1"})
|
294
318
|
end
|
295
319
|
|
320
|
+
it "should not overwrite email if one is already set for receipient" do
|
321
|
+
RightSignature::Connection.should_receive(:post).with('/api/templates/TGUID/prepackage.xml',
|
322
|
+
{}
|
323
|
+
).and_return(@prepackage_response)
|
324
|
+
RightSignature::Connection.should_receive(:post).with('/api/templates.xml', {:template => {
|
325
|
+
:guid => "a_123_456",
|
326
|
+
:action => "send",
|
327
|
+
:subject => "subject template",
|
328
|
+
:roles => [
|
329
|
+
{:role => {:name => "John Bellingham", :email => "dontchange@example.com", "@role_name" => "Leasee"}},
|
330
|
+
{:role => {:name => "Tim Else", :email => "noemail@rightsignature.com", "@role_name" => "Leaser"}}
|
331
|
+
]
|
332
|
+
}}).and_return(@sent_document_response)
|
333
|
+
RightSignature::Connection.should_receive(:get).with("/api/documents/ABCDEFGH123/signer_links.xml", {}).and_return({"document" => {
|
334
|
+
"signer_links" => [
|
335
|
+
{"signer_link" => {"name" => "John Bellingham", "email" => "dontchange@example.com", "role" => "signer_A", "signer_token" => "slkfj2"}},
|
336
|
+
{"signer_link" => {"name" => "Tim Else", "role" => "signer_B", "signer_token" => "asfd1"}}
|
337
|
+
]
|
338
|
+
}})
|
339
|
+
|
340
|
+
results = RightSignature::Template.send_as_embedded_signers("TGUID", [
|
341
|
+
{"Leasee" => {:name => "John Bellingham", :email => "dontchange@example.com"}},
|
342
|
+
{"Leaser" => {:name => "Tim Else"}}
|
343
|
+
])
|
344
|
+
results.size.should == 2
|
345
|
+
results.include?({"name" => "John Bellingham", "url" => "#{RightSignature::Connection.site}/signatures/embedded?rt=slkfj2"})
|
346
|
+
results.include?({"name" => "Tim Else", "url" => "#{RightSignature::Connection.site}/signatures/embedded?rt=asfd1"})
|
347
|
+
end
|
348
|
+
|
296
349
|
it "should pass in options"
|
297
350
|
end
|
298
351
|
end
|