signatory 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile.lock +21 -18
- data/README.rdoc +18 -5
- data/lib/signatory.rb +1 -0
- data/lib/signatory/api/base.rb +24 -0
- data/lib/signatory/credentials.rb +6 -5
- data/lib/signatory/document.rb +6 -6
- data/lib/signatory/document_package.rb +46 -0
- data/lib/signatory/merge_field.rb +2 -2
- data/lib/signatory/template.rb +7 -14
- data/lib/signatory/version.rb +1 -1
- data/signatory.gemspec +2 -2
- data/spec/document_package_spec.rb +61 -0
- data/spec/document_spec.rb +15 -1
- data/spec/fixtures/document.xml.erb +6 -5
- data/spec/fixtures/documents.xml.erb +16 -15
- data/spec/fixtures/template.xml.erb +33 -22
- data/spec/helpers/right_signature_stub.rb +13 -1
- data/spec/template_spec.rb +14 -20
- metadata +66 -110
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
signatory (0.0.
|
4
|
+
signatory (0.0.7)
|
5
5
|
activeresource (>= 2.3.9)
|
6
6
|
bundler (>= 1.0.0)
|
7
7
|
oauth (= 0.4.3)
|
@@ -9,24 +9,29 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: http://rubygems.org/
|
11
11
|
specs:
|
12
|
-
|
13
|
-
activesupport (=
|
14
|
-
|
15
|
-
|
12
|
+
activemodel (3.0.5)
|
13
|
+
activesupport (= 3.0.5)
|
14
|
+
builder (~> 2.1.2)
|
15
|
+
i18n (~> 0.4)
|
16
|
+
activeresource (3.0.5)
|
17
|
+
activemodel (= 3.0.5)
|
18
|
+
activesupport (= 3.0.5)
|
19
|
+
activesupport (3.0.5)
|
20
|
+
addressable (2.2.4)
|
21
|
+
builder (2.1.2)
|
16
22
|
crack (0.1.8)
|
17
23
|
diff-lcs (1.1.2)
|
24
|
+
i18n (0.5.0)
|
18
25
|
oauth (0.4.3)
|
19
26
|
rake (0.8.7)
|
20
|
-
rspec (2.
|
21
|
-
rspec-core (
|
22
|
-
rspec-expectations (
|
23
|
-
rspec-mocks (
|
24
|
-
rspec-core (2.
|
25
|
-
rspec-expectations (2.
|
26
|
-
diff-lcs (
|
27
|
-
rspec-mocks (2.
|
28
|
-
rspec-core (= 2.0.0.beta.22)
|
29
|
-
rspec-expectations (= 2.0.0.beta.22)
|
27
|
+
rspec (2.5.0)
|
28
|
+
rspec-core (~> 2.5.0)
|
29
|
+
rspec-expectations (~> 2.5.0)
|
30
|
+
rspec-mocks (~> 2.5.0)
|
31
|
+
rspec-core (2.5.1)
|
32
|
+
rspec-expectations (2.5.0)
|
33
|
+
diff-lcs (~> 1.1.2)
|
34
|
+
rspec-mocks (2.5.0)
|
30
35
|
webmock (1.3.5)
|
31
36
|
addressable (>= 2.1.1)
|
32
37
|
crack (>= 0.1.7)
|
@@ -35,10 +40,8 @@ PLATFORMS
|
|
35
40
|
ruby
|
36
41
|
|
37
42
|
DEPENDENCIES
|
38
|
-
activeresource (>= 2.3.9)
|
39
43
|
bundler (>= 1.0.0)
|
40
|
-
oauth (= 0.4.3)
|
41
44
|
rake
|
42
|
-
rspec (= 2.
|
45
|
+
rspec (= 2.5.0)
|
43
46
|
signatory!
|
44
47
|
webmock (= 1.3.5)
|
data/README.rdoc
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
= signatory
|
2
2
|
|
3
|
-
* http://github.com/
|
3
|
+
* http://github.com/rgarver/signatory
|
4
|
+
|
5
|
+
formerly profounder/signatory
|
4
6
|
|
5
7
|
== DESCRIPTION:
|
6
8
|
|
7
9
|
A library to simplify interactions with the RightSignature API. One of the primary goals of this library is to make the workflow clear to developers for using some of the more interesting features of the RightSignature system, eg: templates, document merges, and embedded signature frames.
|
8
10
|
|
11
|
+
Now requires the 1.1 or 1.2 api versions. Handles the double URL escaping on documents and templates.
|
12
|
+
|
9
13
|
== FEATURES/PROBLEMS:
|
10
14
|
|
11
15
|
* FIX (list of features or problems)
|
@@ -58,13 +62,22 @@ A library to simplify interactions with the RightSignature API. One of the prim
|
|
58
62
|
... begin oauth workflow ...
|
59
63
|
end
|
60
64
|
|
65
|
+
If you need some debugging output (I have) try this:
|
66
|
+
Signatory::Document.connection.send(:http).consumer.http.set_debug_output($stderr)
|
67
|
+
|
61
68
|
== REQUIREMENTS:
|
62
69
|
|
63
|
-
|
70
|
+
Depends on the gems `oauth` and `activeresource`
|
64
71
|
|
65
72
|
== INSTALL:
|
66
73
|
|
67
|
-
|
74
|
+
From the command line:
|
75
|
+
|
76
|
+
gem install signatory
|
77
|
+
|
78
|
+
From `bundler`:
|
79
|
+
|
80
|
+
gem 'signatory'
|
68
81
|
|
69
82
|
== THANKS:
|
70
83
|
|
@@ -74,7 +87,7 @@ Special thanks to Cary Dunn at RightSignature for putting together a sample Rail
|
|
74
87
|
|
75
88
|
(The MIT License)
|
76
89
|
|
77
|
-
Copyright (c)
|
90
|
+
Copyright (c) 2012 Ryan Garver
|
78
91
|
|
79
92
|
Permission is hereby granted, free of charge, to any person obtaining
|
80
93
|
a copy of this software and associated documentation files (the
|
@@ -93,4 +106,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
93
106
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
94
107
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
95
108
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
96
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
109
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/signatory.rb
CHANGED
@@ -25,6 +25,7 @@ require 'signatory/api/connection'
|
|
25
25
|
require 'signatory/api/base'
|
26
26
|
require 'signatory/credentials'
|
27
27
|
require 'signatory/document'
|
28
|
+
require 'signatory/document_package'
|
28
29
|
require 'signatory/template'
|
29
30
|
require 'signatory/role'
|
30
31
|
require 'signatory/merge_field'
|
data/lib/signatory/api/base.rb
CHANGED
@@ -8,6 +8,30 @@ module Signatory
|
|
8
8
|
end
|
9
9
|
|
10
10
|
class << self
|
11
|
+
def escape_url_attrs(*attrs)
|
12
|
+
attrs.each do |attr|
|
13
|
+
define_method attr do
|
14
|
+
if Signatory.credentials.api_version == '1.0' || attributes[attr].blank?
|
15
|
+
attributes[attr]
|
16
|
+
else
|
17
|
+
CGI::unescape(attributes[attr])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def has_many(sym)
|
24
|
+
self.write_inheritable_attribute(:__has_many, (read_inheritable_attribute(:__has_many)||[])+[sym])
|
25
|
+
end
|
26
|
+
|
27
|
+
def instantiate_record(record, opts={})
|
28
|
+
(self.read_inheritable_attribute(:__has_many)||[]).each do |sym|
|
29
|
+
record[sym.to_s] = [record[sym.to_s].try(:[],sym.to_s.singularize)].flatten.compact unless record[sym.to_s].is_a?(Array)
|
30
|
+
end
|
31
|
+
|
32
|
+
super(record, opts)
|
33
|
+
end
|
34
|
+
|
11
35
|
def instantiate_collection(collection, opts)
|
12
36
|
if collection.has_key?(formatted_collection_name)
|
13
37
|
collection = collection[formatted_collection_name]
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module Signatory
|
2
2
|
class Credentials
|
3
|
-
attr_accessor :key, :secret, :access_token, :access_secret
|
3
|
+
attr_accessor :key, :secret, :access_token, :access_secret, :api_version
|
4
4
|
|
5
|
-
def initialize(key, secret, access_token, access_secret)
|
6
|
-
|
5
|
+
def initialize(key, secret, access_token, access_secret, api_version='1.2')
|
6
|
+
$stderr.puts "Deprecation Warning: Signatory is now compatible with RightSignature API version 1.2, you have chosen #{api_version}. Please upgrade." if api_version != '1.2'
|
7
|
+
@key, @secret, @access_token, @access_secret, @api_version = key, secret, access_token, access_secret, api_version
|
7
8
|
end
|
8
9
|
|
9
10
|
def self.load(source)
|
@@ -13,7 +14,7 @@ module Signatory
|
|
13
14
|
source.inject({}){ |acc, (k, v)| acc[k.to_s] = v; acc}
|
14
15
|
end
|
15
16
|
|
16
|
-
new(h['key'], h['secret'], h['access_token'], h['access_secret'])
|
17
|
+
new(h['key'], h['secret'], h['access_token'], h['access_secret'], h['api_version']||'1.2')
|
17
18
|
end
|
18
19
|
|
19
20
|
def token
|
@@ -32,4 +33,4 @@ module Signatory
|
|
32
33
|
)
|
33
34
|
end
|
34
35
|
end
|
35
|
-
end
|
36
|
+
end
|
data/lib/signatory/document.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Signatory
|
2
2
|
class Document < API::Base
|
3
|
+
has_many :recipients
|
4
|
+
escape_url_attrs :signed_pdf_url, :pdf_url, :original_url, :thumbnail_url
|
3
5
|
|
4
6
|
def extend_expiration
|
5
7
|
connection.post("#{self.class.site}documents/#{id}/extend_expiration")
|
@@ -11,11 +13,9 @@ module Signatory
|
|
11
13
|
|
12
14
|
private
|
13
15
|
def self.instantiate_record(record, opts = {})
|
14
|
-
record
|
15
|
-
|
16
|
-
|
17
|
-
doc.recipients.each {|r| r.document = doc } if doc.respond_to?(:recipients)
|
18
|
-
doc
|
16
|
+
super(record, opts).tap do |doc|
|
17
|
+
doc.recipients.each {|r| r.document = doc }
|
18
|
+
end
|
19
19
|
end
|
20
20
|
end
|
21
|
-
end
|
21
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Signatory
|
2
|
+
class DocumentPackage < API::Base
|
3
|
+
self.element_name = "template"
|
4
|
+
has_many :roles
|
5
|
+
has_many :merge_fields
|
6
|
+
def self.all; raise NoMethodError; end
|
7
|
+
def self.find; raise NoMethodError; end
|
8
|
+
|
9
|
+
def prefill_and_send(merge_fields, roles, opts={})
|
10
|
+
attributes.merge!({
|
11
|
+
'merge_fields' => merge_fields,
|
12
|
+
'roles' => roles,
|
13
|
+
'action' => 'send'
|
14
|
+
})
|
15
|
+
if opts[:document_data].present?
|
16
|
+
attributes.merge!({
|
17
|
+
'document_data' => {
|
18
|
+
'type' => 'base64',
|
19
|
+
'filename' => 'document.pdf',
|
20
|
+
'value' => Base64.encode64(opts[:document_data])
|
21
|
+
}
|
22
|
+
})
|
23
|
+
end
|
24
|
+
|
25
|
+
doc = connection.format.decode(connection.post("/api/templates.xml", self.to_xml).body)
|
26
|
+
Document.find(doc['guid'])
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_xml(opts = {})
|
30
|
+
super(opts.merge(:dasherize => false, :skip_types => true, :except => [:pages, :_type, :redirect_token, :content_type, :size, :tags])) do |b|
|
31
|
+
b.tag!(:tags) do
|
32
|
+
tags.split(" ").each do |tag|
|
33
|
+
b.tag!(:tag) { b.value tag}
|
34
|
+
end
|
35
|
+
end unless attributes['tags'].blank?
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def self.instantiate_record(record, opts = {})
|
41
|
+
record['_type'] = record.delete('type') if record.has_key?('type')
|
42
|
+
|
43
|
+
super(record, opts)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -14,7 +14,7 @@ module Signatory
|
|
14
14
|
options[:indent] ||= 2
|
15
15
|
xml = options[:builder] ||= ::Builder::XmlMarkup.new(:indent => options[:indent])
|
16
16
|
xml.tag!('merge_field', identifier) do
|
17
|
-
if attributes
|
17
|
+
if attributes.has_key?(:page)
|
18
18
|
xml.page page
|
19
19
|
xml.name name
|
20
20
|
xml.id id
|
@@ -25,4 +25,4 @@ module Signatory
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
28
|
-
end
|
28
|
+
end
|
data/lib/signatory/template.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
+
# Template.prepackage -> creates a send/redirect-able Template
|
2
|
+
# Documents are "sent"
|
1
3
|
module Signatory
|
2
4
|
class Template < API::Base
|
5
|
+
has_many :roles
|
6
|
+
has_many :merge_fields
|
7
|
+
escape_url_attrs :thumbnail_url
|
8
|
+
|
3
9
|
def prepackage
|
4
10
|
record = connection.format.decode(post(:prepackage).body)
|
5
|
-
|
11
|
+
DocumentPackage.send(:instantiate_record, record)
|
6
12
|
end
|
7
13
|
|
8
14
|
def build_document(merge_fields, roles)
|
@@ -10,17 +16,6 @@ module Signatory
|
|
10
16
|
doc_pkg.prefill_and_send(merge_fields, roles)
|
11
17
|
end
|
12
18
|
|
13
|
-
def prefill_and_send(merge_fields, roles)
|
14
|
-
attributes.merge!({
|
15
|
-
'merge_fields' => merge_fields,
|
16
|
-
'roles' => roles,
|
17
|
-
'action' => 'send'
|
18
|
-
})
|
19
|
-
|
20
|
-
doc = connection.format.decode(connection.post("/api/templates.xml", self.to_xml).body)
|
21
|
-
Document.find(doc['guid'])
|
22
|
-
end
|
23
|
-
|
24
19
|
def to_xml(opts = {})
|
25
20
|
super(opts.merge(:dasherize => false, :skip_types => true, :except => [:pages, :_type, :redirect_token, :content_type, :size, :tags])) do |b|
|
26
21
|
b.tag!(:tags) do
|
@@ -34,8 +29,6 @@ module Signatory
|
|
34
29
|
private
|
35
30
|
def self.instantiate_record(record, opts = {})
|
36
31
|
record['_type'] = record.delete('type') if record.has_key?('type')
|
37
|
-
record['roles'] = [record['roles']['role']].flatten unless record['roles'].nil? || record['roles'].is_a?(Array)
|
38
|
-
record['merge_fields'] = [record['merge_fields']['merge_field']].flatten unless record['merge_fields'].nil? || record['merge_fields'].is_a?(Array)
|
39
32
|
|
40
33
|
super(record, opts)
|
41
34
|
end
|
data/lib/signatory/version.rb
CHANGED
data/signatory.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.version = Signatory::VERSION
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["Ryan Garver"]
|
9
|
-
s.email = ["
|
9
|
+
s.email = ["ragarver@gmail.com"]
|
10
10
|
s.homepage = "http://rubygems.org/gems/signatory"
|
11
11
|
s.summary = "API wrapper for RightSignature"
|
12
12
|
s.description = "Signatory provides a simple wrapper around the RightSignature API."
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.rubyforge_project = "signatory"
|
16
16
|
|
17
17
|
s.add_development_dependency "bundler", ">= 1.0.0"
|
18
|
-
s.add_development_dependency "rspec", "= 2.
|
18
|
+
s.add_development_dependency "rspec", "= 2.5.0"
|
19
19
|
s.add_development_dependency "webmock", "= 1.3.5"
|
20
20
|
|
21
21
|
s.add_dependency "bundler", ">= 1.0.0"
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe Signatory::DocumentPackage do
|
4
|
+
describe "not findable" do # DocumentsSessions are temporary and not searchable
|
5
|
+
it "No method for .all" do
|
6
|
+
lambda do
|
7
|
+
Signatory::DocumentPackage.all
|
8
|
+
end.should raise_error(NoMethodError)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "No method for .find" do
|
12
|
+
lambda do
|
13
|
+
Signatory::DocumentPackage.find
|
14
|
+
end.should raise_error(NoMethodError)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe ".signing_parties" do
|
19
|
+
it "returns all of the roles that must sign"
|
20
|
+
end
|
21
|
+
|
22
|
+
describe ".sender" do
|
23
|
+
it "returns the role who sent the document"
|
24
|
+
end
|
25
|
+
|
26
|
+
describe ".prefill_and_send" do
|
27
|
+
let(:roles) {[Signatory::Role.new(:name => "Ryan Garver", :role_name => 'Issuer'), Signatory::Role.new(:name => "Cary Dunn", :role_name => 'Investor')]}
|
28
|
+
let(:merge_fields) {[Signatory::MergeField.new(:name => 'Company Name', :value => 'ABC Corp')]}
|
29
|
+
|
30
|
+
it "returns the sent document" do
|
31
|
+
doc_pkg = Signatory::DocumentPackage.new(:guid => 'templid')
|
32
|
+
|
33
|
+
id, subject = rand.to_s, "Subject #{rand}"
|
34
|
+
stub_template_send('templid', id, :roles => roles, :merge_fields => merge_fields)
|
35
|
+
stub_document(id, :subject => subject)
|
36
|
+
doc = doc_pkg.prefill_and_send(merge_fields, roles)
|
37
|
+
doc.guid.should == id
|
38
|
+
doc.subject.should == subject
|
39
|
+
end
|
40
|
+
|
41
|
+
it "can do a PDF swap" do
|
42
|
+
stub_template('123')
|
43
|
+
stub_prepackage('123', '321')
|
44
|
+
doc_pkg = Signatory::Template.find('123').prepackage
|
45
|
+
file = "Lorem ipsum"
|
46
|
+
|
47
|
+
stub_template_send('321', '111', :roles => roles,
|
48
|
+
:merge_fields => merge_fields,
|
49
|
+
:match => {
|
50
|
+
'document_data' => {
|
51
|
+
'type' => 'base64',
|
52
|
+
'filename' => 'document.pdf',
|
53
|
+
'value' => Base64.encode64(file)
|
54
|
+
}
|
55
|
+
})
|
56
|
+
stub_document(111, :subject => 'blah')
|
57
|
+
|
58
|
+
doc = doc_pkg.prefill_and_send(merge_fields, roles, :document_data => file)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/spec/document_spec.rb
CHANGED
@@ -60,4 +60,18 @@ describe Signatory::Document do
|
|
60
60
|
@doc.expired?.should be_false
|
61
61
|
end
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
|
+
describe "#signed_pdf_url" do
|
65
|
+
it "should return a valid url" do
|
66
|
+
stub_document("XXXX")
|
67
|
+
doc = Signatory::Document.find("XXXX")
|
68
|
+
doc.signed_pdf_url.should =~ /^https:\/\//
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should return blank when it's blank" do
|
72
|
+
stub_document("XXXX", :signed_pdf_url => '')
|
73
|
+
doc = Signatory::Document.find("XXXX")
|
74
|
+
doc.signed_pdf_url.should be_nil
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<document>
|
2
2
|
<completed-at>2009-11-01T13:14:28-08:00</completed-at>
|
3
|
-
<thumbnail-url>https
|
3
|
+
<thumbnail-url>https%3A%2F%2Fthumbnail.png</thumbnail-url>
|
4
4
|
<message>Please sign the document.</message>
|
5
5
|
<form-fields>
|
6
6
|
<form-field>
|
@@ -12,11 +12,11 @@
|
|
12
12
|
</form-field>
|
13
13
|
</form-fields>
|
14
14
|
<state>signed</state>
|
15
|
-
<pdf-url>https
|
15
|
+
<pdf-url>https%3A%2F%2Fpdfurl.pdf</pdf-url>
|
16
16
|
<deleted-at nil="true"></deleted-at>
|
17
17
|
<created-at>2009-11-01T12:29:36-08:00</created-at>
|
18
18
|
<is-public>false</is-public>
|
19
|
-
<signed-pdf-url
|
19
|
+
<signed-pdf-url><%= options[:signed_pdf_url] || "https%3A%2F%2Fsignedpdf.pdf" %></signed-pdf-url>
|
20
20
|
<original-filename>Application.pdf</original-filename>
|
21
21
|
<size>231740</size>
|
22
22
|
<recipients>
|
@@ -45,7 +45,8 @@
|
|
45
45
|
<guid><%= options[:guid] || 'ABCXYZ' %></guid>
|
46
46
|
<callback-location nil="true"></callback-location>
|
47
47
|
<processing-state>done-processing</processing-state>
|
48
|
-
<original-url>https
|
48
|
+
<original-url>https%3A%2F%2Foriginaldoc.doc</original-url>
|
49
49
|
<content-type>package</content-type>
|
50
50
|
<expires-on><%= options[:expires_on] && options[:expires_on].iso8601 || '2009-11-06T16:00:00-08:00' %></expires-on>
|
51
|
-
</
|
51
|
+
<is-trashed>false</is-trashed>
|
52
|
+
</document>
|
@@ -1,23 +1,14 @@
|
|
1
1
|
<page>
|
2
2
|
<total-documents><%= options[:total_documents] %></total-documents>
|
3
3
|
<current-page>1</current-page>
|
4
|
-
<total-pages>1</total-pages>
|
5
4
|
<per-page>10</per-page>
|
5
|
+
<total-pages>1</total-pages>
|
6
6
|
<documents>
|
7
7
|
<% options[:total_documents].times do |i| %>
|
8
8
|
<% document = options[:documents][i] %>
|
9
9
|
<document>
|
10
|
-
<
|
11
|
-
<
|
12
|
-
<message>Please sign this document.</message>
|
13
|
-
<state>pending</state>
|
14
|
-
<pdf-url>http://pdfurl.pdf</pdf-url>
|
15
|
-
<deleted-at nil="true"></deleted-at>
|
16
|
-
<created-at>2009-11-04T10:15:14-08:00</created-at>
|
17
|
-
<is-public>false</is-public>
|
18
|
-
<signed-pdf-url>http://signedpdfurl.pdf</signed-pdf-url>
|
19
|
-
<original-filename>Application.pdf</original-filename>
|
20
|
-
<size>47351</size>
|
10
|
+
<guid><%= document.nil? ? 'ABCXYZ' : document[:guid] %></guid>
|
11
|
+
<subject><%= document.nil? ? "Employment Application" : document[:subject] %></subject>
|
21
12
|
<recipients>
|
22
13
|
<recipient>
|
23
14
|
<state>pending</state>
|
@@ -36,8 +27,18 @@
|
|
36
27
|
<name>Maria Montes</name>
|
37
28
|
</recipient>
|
38
29
|
</recipients>
|
39
|
-
<
|
40
|
-
<
|
30
|
+
<is-public>false</is-public>
|
31
|
+
<tags>sendfromapi,tag2,user_id:1234</tags>
|
32
|
+
<completed-at nil="true"></completed-at>
|
33
|
+
<thumbnail-url>http://thumbnailurl.png</thumbnail-url>
|
34
|
+
<message>Please sign this document.</message>
|
35
|
+
<state>pending</state>
|
36
|
+
<pdf-url>http://pdfurl.pdf</pdf-url>
|
37
|
+
<deleted-at nil="true"></deleted-at>
|
38
|
+
<created-at>2009-11-04T10:15:14-08:00</created-at>
|
39
|
+
<signed-pdf-url>http://signedpdfurl.pdf</signed-pdf-url>
|
40
|
+
<original-filename>Application.pdf</original-filename>
|
41
|
+
<size>47351</size>
|
41
42
|
<callback-location>http://callbacklocation.com/gateway</callback-location>
|
42
43
|
<processing-state>done-processing</processing-state>
|
43
44
|
<original-url>http://pdfurl.pdf</original-url>
|
@@ -46,4 +47,4 @@
|
|
46
47
|
</document>
|
47
48
|
<% end %>
|
48
49
|
</documents>
|
49
|
-
</page>
|
50
|
+
</page>
|
@@ -1,32 +1,43 @@
|
|
1
1
|
<template>
|
2
2
|
<thumbnail-url>https://thumbnail.png</thumbnail-url>
|
3
|
-
|
4
|
-
<merge-
|
5
|
-
<
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
<% unless options[:no_merge_fields] %>
|
4
|
+
<merge-fields>
|
5
|
+
<merge-field>
|
6
|
+
<page>1</page>
|
7
|
+
<name>Employee Name</name>
|
8
|
+
<id><%= options[:guid] || "a_951_5c0634d166d44916b9e0b3" %></id>
|
9
|
+
</merge-field>
|
10
|
+
<% if options[:one_merge_field] %>
|
11
|
+
<merge-field>
|
12
|
+
<page>1</page>
|
13
|
+
<name>Employee Title</name>
|
14
|
+
<id><%= options[:guid] || "a_951_5c0634d166d44916b9e0b3" %></id>
|
15
|
+
</merge-field>
|
16
|
+
<% end %>
|
17
|
+
</merge-fields>
|
18
|
+
<% end %>
|
10
19
|
<message>Please sign this document.</message>
|
11
20
|
<created-at>2009-10-28T19:03:26-07:00</created-at>
|
12
|
-
|
13
|
-
<
|
14
|
-
<
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
<
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
<% unless options[:no_roles] %>
|
22
|
+
<roles>
|
23
|
+
<role>
|
24
|
+
<must-sign>false</must-sign>
|
25
|
+
<document-role-id>cc_A</document-role-id>
|
26
|
+
<role>Document Sender</role>
|
27
|
+
<is-sender>true</is-sender>
|
28
|
+
</role>
|
29
|
+
<role>
|
30
|
+
<must-sign>true</must-sign>
|
31
|
+
<document-role-id>cc_B</document-role-id>
|
32
|
+
<role>Employer</role>
|
33
|
+
<is-sender>false</is-sender>
|
34
|
+
</role>
|
35
|
+
</roles>
|
36
|
+
<% end %>
|
26
37
|
<size>3524</size>
|
27
38
|
<subject><%= options[:subject] || "Employment Application Template" %></subject>
|
28
39
|
<guid><%= options[:guid] || "a_951_5c0634d166d44916b9e0b3" %></guid>
|
29
40
|
<processing-state>done-processing</processing-state>
|
30
41
|
<content-type>pdf</content-type>
|
31
42
|
<filename>Application.pdf</filename>
|
32
|
-
</template>
|
43
|
+
</template>
|
@@ -49,6 +49,7 @@ module RightSignatureStub
|
|
49
49
|
|
50
50
|
stub_request(:post, "https://rightsignature.com/api/templates.xml").with do |req|
|
51
51
|
sent = Hash.from_xml(req.body)['template']
|
52
|
+
deep_match(sent, options[:match]) if options[:match].present?
|
52
53
|
|
53
54
|
sent['guid'] == id &&
|
54
55
|
sent['action'] == 'send' &&
|
@@ -78,4 +79,15 @@ module RightSignatureStub
|
|
78
79
|
def fixture(name)
|
79
80
|
File.read(File.join(File.dirname(__FILE__), '..', 'fixtures', name))
|
80
81
|
end
|
81
|
-
|
82
|
+
|
83
|
+
def deep_match(source, matching)
|
84
|
+
matching.each do |k, v|
|
85
|
+
source.should have_key(k)
|
86
|
+
if v.is_a?(String)
|
87
|
+
source[k].should include(v)
|
88
|
+
elsif v.is_a?(Hash)
|
89
|
+
deep_match(source[k], v)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
data/spec/template_spec.rb
CHANGED
@@ -38,7 +38,7 @@ describe Signatory::Template do
|
|
38
38
|
describe ".build_document" do
|
39
39
|
it "returns a new document" do
|
40
40
|
temp = Signatory::Template.new(:guid => 'xxxyyy', :subject => 'Blah blah')
|
41
|
-
doc_pkg = Signatory::
|
41
|
+
doc_pkg = Signatory::DocumentPackage.new(:guid => 'abcabc', :type => 'DocumentPackage')
|
42
42
|
doc = Signatory::Document.new
|
43
43
|
|
44
44
|
roles = [{:name => "Ryan Garver"}, {:name => "Cary Dunn"}]
|
@@ -52,28 +52,22 @@ describe Signatory::Template do
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
describe "#merge_fields" do
|
56
|
+
it "returns empty array when there are none" do
|
57
|
+
stub_template('123', :no_merge_fields => true)
|
58
|
+
templ = Signatory::Template.find('123')
|
59
59
|
|
60
|
-
|
61
|
-
|
60
|
+
templ.merge_fields.should be_a(Array)
|
61
|
+
templ.merge_fields.should be_empty
|
62
62
|
end
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
roles = [Signatory::Role.new(:name => "Ryan Garver", :role_name => 'Issuer'), Signatory::Role.new(:name => "Cary Dunn", :role_name => 'Investor')]
|
68
|
-
merge_fields = [Signatory::MergeField.new(:name => 'Company Name', :value => 'ABC Corp')]
|
64
|
+
it "returns array with one merge field when there is one" do
|
65
|
+
stub_template('123', :one_merge_field => true)
|
66
|
+
templ = Signatory::Template.find('123')
|
69
67
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
doc = doc_pkg.prefill_and_send(merge_fields, roles)
|
74
|
-
doc.guid.should == id
|
75
|
-
doc.subject.should == subject
|
76
|
-
end
|
68
|
+
templ.merge_fields.should be_a(Array)
|
69
|
+
templ.merge_fields.should_not be_empty
|
70
|
+
templ.merge_fields[0].should be_a(Signatory::MergeField)
|
77
71
|
end
|
78
72
|
end
|
79
|
-
end
|
73
|
+
end
|
metadata
CHANGED
@@ -1,124 +1,89 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: signatory
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 6
|
9
|
-
version: 0.0.6
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.7
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Ryan Garver
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-05-17 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: bundler
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70134095110220 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 1
|
30
|
-
- 0
|
31
|
-
- 0
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
32
21
|
version: 1.0.0
|
33
22
|
type: :development
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: rspec
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: *70134095110220
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &70134095109760 !ruby/object:Gem::Requirement
|
39
28
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
- 2
|
45
|
-
- 0
|
46
|
-
- 0
|
47
|
-
- beta
|
48
|
-
- 22
|
49
|
-
version: 2.0.0.beta.22
|
29
|
+
requirements:
|
30
|
+
- - =
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.5.0
|
50
33
|
type: :development
|
51
|
-
version_requirements: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
name: webmock
|
54
34
|
prerelease: false
|
55
|
-
|
35
|
+
version_requirements: *70134095109760
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: webmock
|
38
|
+
requirement: &70134095109300 !ruby/object:Gem::Requirement
|
56
39
|
none: false
|
57
|
-
requirements:
|
58
|
-
- -
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
segments:
|
61
|
-
- 1
|
62
|
-
- 3
|
63
|
-
- 5
|
40
|
+
requirements:
|
41
|
+
- - =
|
42
|
+
- !ruby/object:Gem::Version
|
64
43
|
version: 1.3.5
|
65
44
|
type: :development
|
66
|
-
version_requirements: *id003
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: bundler
|
69
45
|
prerelease: false
|
70
|
-
|
46
|
+
version_requirements: *70134095109300
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: &70134095108840 !ruby/object:Gem::Requirement
|
71
50
|
none: false
|
72
|
-
requirements:
|
73
|
-
- -
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
segments:
|
76
|
-
- 1
|
77
|
-
- 0
|
78
|
-
- 0
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
79
54
|
version: 1.0.0
|
80
55
|
type: :runtime
|
81
|
-
version_requirements: *id004
|
82
|
-
- !ruby/object:Gem::Dependency
|
83
|
-
name: oauth
|
84
56
|
prerelease: false
|
85
|
-
|
57
|
+
version_requirements: *70134095108840
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: oauth
|
60
|
+
requirement: &70134095108380 !ruby/object:Gem::Requirement
|
86
61
|
none: false
|
87
|
-
requirements:
|
88
|
-
- -
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
segments:
|
91
|
-
- 0
|
92
|
-
- 4
|
93
|
-
- 3
|
62
|
+
requirements:
|
63
|
+
- - =
|
64
|
+
- !ruby/object:Gem::Version
|
94
65
|
version: 0.4.3
|
95
66
|
type: :runtime
|
96
|
-
version_requirements: *id005
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: activeresource
|
99
67
|
prerelease: false
|
100
|
-
|
68
|
+
version_requirements: *70134095108380
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activeresource
|
71
|
+
requirement: &70134095138880 !ruby/object:Gem::Requirement
|
101
72
|
none: false
|
102
|
-
requirements:
|
103
|
-
- -
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
segments:
|
106
|
-
- 2
|
107
|
-
- 3
|
108
|
-
- 9
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
109
76
|
version: 2.3.9
|
110
77
|
type: :runtime
|
111
|
-
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70134095138880
|
112
80
|
description: Signatory provides a simple wrapper around the RightSignature API.
|
113
|
-
email:
|
114
|
-
-
|
81
|
+
email:
|
82
|
+
- ragarver@gmail.com
|
115
83
|
executables: []
|
116
|
-
|
117
84
|
extensions: []
|
118
|
-
|
119
85
|
extra_rdoc_files: []
|
120
|
-
|
121
|
-
files:
|
86
|
+
files:
|
122
87
|
- .gitignore
|
123
88
|
- .rvmrc
|
124
89
|
- Gemfile
|
@@ -131,6 +96,7 @@ files:
|
|
131
96
|
- lib/signatory/api/connection.rb
|
132
97
|
- lib/signatory/credentials.rb
|
133
98
|
- lib/signatory/document.rb
|
99
|
+
- lib/signatory/document_package.rb
|
134
100
|
- lib/signatory/legacy_active_resource_hacks.rb
|
135
101
|
- lib/signatory/merge_field.rb
|
136
102
|
- lib/signatory/recipient.rb
|
@@ -140,6 +106,7 @@ files:
|
|
140
106
|
- lib/signatory/version.rb
|
141
107
|
- signatory.gemspec
|
142
108
|
- spec/credentials_spec.rb
|
109
|
+
- spec/document_package_spec.rb
|
143
110
|
- spec/document_spec.rb
|
144
111
|
- spec/fixtures/document.xml.erb
|
145
112
|
- spec/fixtures/documents.xml.erb
|
@@ -154,39 +121,28 @@ files:
|
|
154
121
|
- spec/signatory_spec.rb
|
155
122
|
- spec/spec_helper.rb
|
156
123
|
- spec/template_spec.rb
|
157
|
-
has_rdoc: true
|
158
124
|
homepage: http://rubygems.org/gems/signatory
|
159
125
|
licenses: []
|
160
|
-
|
161
126
|
post_install_message:
|
162
127
|
rdoc_options: []
|
163
|
-
|
164
|
-
require_paths:
|
128
|
+
require_paths:
|
165
129
|
- lib
|
166
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
167
131
|
none: false
|
168
|
-
requirements:
|
169
|
-
- -
|
170
|
-
- !ruby/object:Gem::Version
|
171
|
-
|
172
|
-
|
173
|
-
version: "0"
|
174
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ! '>='
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
137
|
none: false
|
176
|
-
requirements:
|
177
|
-
- -
|
178
|
-
- !ruby/object:Gem::Version
|
179
|
-
segments:
|
180
|
-
- 1
|
181
|
-
- 3
|
182
|
-
- 6
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
183
141
|
version: 1.3.6
|
184
142
|
requirements: []
|
185
|
-
|
186
143
|
rubyforge_project: signatory
|
187
|
-
rubygems_version: 1.
|
144
|
+
rubygems_version: 1.8.6
|
188
145
|
signing_key:
|
189
146
|
specification_version: 3
|
190
147
|
summary: API wrapper for RightSignature
|
191
148
|
test_files: []
|
192
|
-
|