rightsignature 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +47 -2
- data/lib/rightsignature/document.rb +12 -0
- data/lib/rightsignature/template.rb +66 -0
- data/lib/rightsignature/version.rb +1 -1
- data/spec/document_spec.rb +27 -0
- data/spec/template_spec.rb +77 -0
- metadata +2 -3
- data/Gemfile.lock +0 -38
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,15 @@ RightSignature API
|
|
2
2
|
==================
|
3
3
|
This gem is a wrapper to RightSignature's API for both OAuth authentication and Token authentication
|
4
4
|
|
5
|
+
#####Install
|
6
|
+
```
|
7
|
+
gem install rightsignature
|
8
|
+
```
|
9
|
+
or in your Gemfile
|
10
|
+
```
|
11
|
+
gem 'rightsignature', '~> 0.1.2'
|
12
|
+
```
|
13
|
+
|
5
14
|
Setup
|
6
15
|
-----
|
7
16
|
After getting an API key from RightSignature, you can use the Secure Token or generate an Access Token with the OAuth key and secret using RightSignature::load_configuration.
|
@@ -13,7 +22,12 @@ RightSignature::load_configuration(:api_token => YOUR_TOKEN)
|
|
13
22
|
|
14
23
|
#####Using OAuth authentication
|
15
24
|
```
|
16
|
-
RightSignature::load_configuration(
|
25
|
+
RightSignature::load_configuration(
|
26
|
+
:consumer_key => "Consumer123",
|
27
|
+
:consumer_secret => "Secret098",
|
28
|
+
:access_token => "AccessToken098",
|
29
|
+
:access_secret => "AccessSecret123"
|
30
|
+
)
|
17
31
|
```
|
18
32
|
Note: if the both OAuth credentials and api_token are set, the default action is to use Token Authentication.
|
19
33
|
|
@@ -140,6 +154,15 @@ filename = "Desired Filename.pdf"
|
|
140
154
|
RightSignature::Document.send_document_from_file(raw_data, filename, 'My Subject', recipients)
|
141
155
|
```
|
142
156
|
|
157
|
+
#####Embedded Signing Links
|
158
|
+
Generates URLs for the embedded signing page for documents with recipients with email of 'noemail@rightsignature.com'.
|
159
|
+
Returns an array of {:name => "John Bellingham", "url" => "https://rightsignature.com/signatures/embedded?rt=1234"}
|
160
|
+
```
|
161
|
+
RightSignature::Document.get_signer_links_for(guid, redirect_location=nil)
|
162
|
+
```
|
163
|
+
Optional Option:
|
164
|
+
* redirect_location: URL to redirect user after signing.
|
165
|
+
|
143
166
|
|
144
167
|
Templates
|
145
168
|
---------
|
@@ -198,6 +221,7 @@ Optional options:
|
|
198
221
|
Ex. ['sent_from_api', {"user_id" => "32"}]
|
199
222
|
* callback_url: A URI encoded URL that specifies the location for API to POST a callback notification to when the document has been created and signed.
|
200
223
|
Ex. "http://yoursite/callback"
|
224
|
+
|
201
225
|
```
|
202
226
|
options = {
|
203
227
|
:description => "Please read over the handbook and sign it.",
|
@@ -231,6 +255,7 @@ Optional options:
|
|
231
255
|
Ex. ['sent_from_api', {"user_id" => "32"}]
|
232
256
|
* callback_url: A URI encoded URL that specifies the location for API to POST a callback notification to when the document has been created and signed.
|
233
257
|
Ex. "http://yoursite/callback"
|
258
|
+
|
234
259
|
```
|
235
260
|
options = {
|
236
261
|
:description => "Please read over the handbook and sign it.",
|
@@ -248,6 +273,26 @@ options = {
|
|
248
273
|
RightSignature::Template.send_template(guid, subject, roles, options)
|
249
274
|
```
|
250
275
|
|
276
|
+
#####Embedded Signing Links for Sent Template
|
277
|
+
Prepackages a template, and sends it out with each recipients marked as a embedded signer (email as noemail@rightsignature.com), then generates embedded signing URLs.
|
278
|
+
Returns an array of {:name => "John Bellingham", "url" => "https://rightsignature.com/signatures/embedded?rt=1234"}
|
279
|
+
```
|
280
|
+
RightSignature::Template.send_as_embedded_signers(guid, recipients, options={})
|
281
|
+
```
|
282
|
+
* guid: guid of template to create document with
|
283
|
+
* recipient: recipient names in array of {"Role Name" => {:name => "Your Name"}}
|
284
|
+
* options:
|
285
|
+
* subject: document subject that'll appear in the email
|
286
|
+
* description: document description that'll appear in the email
|
287
|
+
* merge_fields: document merge fields, should be an array of merge_field_values in a hash with the merge_field_name.
|
288
|
+
Ex. [{"Salary" => "$1,000,000"}]
|
289
|
+
* expires_in: number of days before expiring the document. API only allows 2,5,15, or 30.
|
290
|
+
* tags: document tags, an array of string or hashes 'single_tag' (for simple tag) or {'tag_name' => 'tag_value'} (for tuples pairs)
|
291
|
+
Ex. ['sent_from_api', {"user_id" => "32"}]
|
292
|
+
* callback_url: A URI encoded URL that specifies the location for API to POST a callback notification to when the document has been created and signed.
|
293
|
+
Ex. "http://yoursite/callback"
|
294
|
+
* redirect_location: URL to redirect users after signing.
|
295
|
+
|
251
296
|
#####Create New Template Link
|
252
297
|
Generate a url that let's someone upload and create a template under OAuth user's account.
|
253
298
|
```
|
@@ -265,6 +310,7 @@ You can also add restrictions to what the person can do:
|
|
265
310
|
* acceptable_merge_field_names: The user creating the Template will be forced to select one of the values provided.
|
266
311
|
There will be no free-form name entry when adding merge fields to the Template.
|
267
312
|
Ex. ["Location", "Tax ID", "Company Name"]
|
313
|
+
|
268
314
|
```
|
269
315
|
options = {
|
270
316
|
:acceptable_merge_field_names =>
|
@@ -313,5 +359,4 @@ $:.push File.expand_path("../lib", __FILE__); require "rightsignature"; RightSig
|
|
313
359
|
|
314
360
|
TODO:
|
315
361
|
-----
|
316
|
-
* Gemify me
|
317
362
|
* Have a way for to generate an OAuth Access Token from RightSignature
|
@@ -211,6 +211,18 @@ module RightSignature
|
|
211
211
|
"#{RightSignature::Connection.site}/builder/new?rt=#{response['document']['redirect_token']}"
|
212
212
|
end
|
213
213
|
|
214
|
+
def get_signer_links_for(guid, redirect_location = nil)
|
215
|
+
params = {}
|
216
|
+
params[:redirect_location] = URI.encode(redirect_location) if redirect_location
|
217
|
+
response = RightSignature::Connection.get "/api/documents/#{guid}/signer_links.xml", params
|
218
|
+
|
219
|
+
signer_links = []
|
220
|
+
response["document"]["signer_links"].each do |signer_link|
|
221
|
+
signer_links << {"name" => signer_link["signer_link"]["name"], "url" => "#{RightSignature::Connection.site}/signatures/embedded?rt=#{signer_link["signer_link"]["signer_token"]}"}
|
222
|
+
end
|
223
|
+
signer_links
|
224
|
+
end
|
225
|
+
|
214
226
|
end
|
215
227
|
end
|
216
228
|
end
|
@@ -172,6 +172,72 @@ module RightSignature
|
|
172
172
|
"#{RightSignature::Connection.site}/builder/new?rt=#{redirect_token}"
|
173
173
|
end
|
174
174
|
|
175
|
+
# Sends template with all roles as embedded signers and returns an array of hashes with :name and :url for each signer link.
|
176
|
+
# * guid: templates guid. Ex. a_1_zcfdidf8fi23
|
177
|
+
# * roles: Recipients of the document, should be an array of role names in a hash with keys as role_names.
|
178
|
+
# Ex. [{"Employee" => {:name => "John Employee"}]
|
179
|
+
# is equivalent to
|
180
|
+
# <role role_name="Employee">
|
181
|
+
# <name>John Employee</name>
|
182
|
+
# <email>noemail@rightsignature.com</email>
|
183
|
+
# </role>
|
184
|
+
# * options: other optional values
|
185
|
+
# - subject: subject of the document that'll appear in email. Defaults to Template's subject
|
186
|
+
# - description: document description that'll appear in the email
|
187
|
+
# - merge_fields: document merge fields, should be an array of merge_field_values in a hash with the merge_field_name.
|
188
|
+
# Ex. [{"Salary" => "$1,000,000"}]
|
189
|
+
# is equivalent to
|
190
|
+
# <merge_field merge_field_name="Salary">
|
191
|
+
# <value>$1,000,000</value>
|
192
|
+
# </merge_field>
|
193
|
+
# - expires_in: number of days before expiring the document. API only allows 2,5,15, or 30.
|
194
|
+
# - tags: document tags, an array of {:name => 'tag_name'} (for simple tag) or {:name => 'tag_name', :value => 'value'} (for tuples pairs)
|
195
|
+
# Ex. [{:name => 'sent_from_api'}, {:name => "user_id", :value => "32"}]
|
196
|
+
# - callback_url: A URI encoded URL that specifies the location for API to POST a callback notification to when the document has been created and signed.
|
197
|
+
# Ex. "http://yoursite/callback"
|
198
|
+
# - redirect_location: A URI encoded URL that specifies the location for the signing widget to redirect the user to after it is signed.
|
199
|
+
# Ex. "http://yoursite/thanks_for_signing"
|
200
|
+
#
|
201
|
+
# Ex. call with all options used
|
202
|
+
# RightSignature::Template.prefill(
|
203
|
+
# "a_1_zcfdidf8fi23",
|
204
|
+
# "Your Employee Handbook",
|
205
|
+
# [{"employee" => {:name => "John Employee", :email => "john@employee.com"}}],
|
206
|
+
# {
|
207
|
+
# :description => "Please read over the handbook and sign it.",
|
208
|
+
# :merge_fields => [
|
209
|
+
# { "Department" => "Fun and games" },
|
210
|
+
# { "Salary" => "$1,000,000" }
|
211
|
+
# ],
|
212
|
+
# :expires_in => 5,
|
213
|
+
# :tags => [
|
214
|
+
# {:name => 'sent_from_api'},
|
215
|
+
# {:name => 'user_id', :value => '32'}
|
216
|
+
# ],
|
217
|
+
# :callback_url => "http://yoursite/callback"
|
218
|
+
# })
|
219
|
+
def send_as_embedded_signers(guid, recipients, options={})
|
220
|
+
redirect_location = options.delete(:redirect_location)
|
221
|
+
|
222
|
+
response = prepackage(guid)
|
223
|
+
template = response["template"]
|
224
|
+
|
225
|
+
recipients.each do |role_hash|
|
226
|
+
key, value = role_hash.first
|
227
|
+
if role_hash[key]["email"]
|
228
|
+
role_hash[key]["email"] = "noemail@rightsignature.com"
|
229
|
+
else
|
230
|
+
role_hash[key][:email] = "noemail@rightsignature.com"
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
response = send_template(template["guid"], options[:subject] || template["subject"], recipients, options)
|
235
|
+
document_guid = response["document"]["guid"]
|
236
|
+
|
237
|
+
RightSignature::Document.get_signer_links_for(document_guid, redirect_location)
|
238
|
+
end
|
239
|
+
|
240
|
+
|
175
241
|
end
|
176
242
|
end
|
177
243
|
end
|
data/spec/document_spec.rb
CHANGED
@@ -253,4 +253,31 @@ describe RightSignature::Document do
|
|
253
253
|
RightSignature::Document.generate_document_redirect_url("subjy", [], {}).should == "#{RightSignature::Connection.site}/builder/new?rt=REDIRECT_TOKEN"
|
254
254
|
end
|
255
255
|
end
|
256
|
+
|
257
|
+
describe "get_signer_links_for" do
|
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
|
+
{'signer_link' => {"signer_token" => "avx37", "name" => "John Bellingham"}},
|
261
|
+
{'signer_link' => {"signer_token" => "fdh89", "name" => "Righty Jones"}}]
|
262
|
+
}})
|
263
|
+
|
264
|
+
response = RightSignature::Document.get_signer_links_for("GUID123")
|
265
|
+
response.size.should == 2
|
266
|
+
response.include?({"name" => "John Bellingham", "url" => "#{RightSignature::Connection.site}/signatures/embedded?rt=avx37"}).should be_true
|
267
|
+
response.include?({"name" => "Righty Jones", "url" => "#{RightSignature::Connection.site}/signatures/embedded?rt=fdh89"}).should be_true
|
268
|
+
end
|
269
|
+
|
270
|
+
it "should GET /api/documents/GUID123/signer_links.xml with URI encoded redirect location and return urls for signers" do
|
271
|
+
RightSignature::Connection.should_receive(:get).with("/api/documents/GUID123/signer_links.xml", {:redirect_location => "http://google.com/redirected%20location"}
|
272
|
+
).and_return({"document" => {'signer_links' => [
|
273
|
+
{'signer_link' => {"signer_token" => "avx37", "name" => "John Bellingham", "role" => "signer_A"}},
|
274
|
+
{'signer_link' => {"signer_token" => "fdh89", "name" => "Righty Jones", "role" => "signer_B"}}]
|
275
|
+
}})
|
276
|
+
|
277
|
+
response = RightSignature::Document.get_signer_links_for("GUID123", "http://google.com/redirected location")
|
278
|
+
response.size.should == 2
|
279
|
+
response.include?({"name" => "John Bellingham", "url" => "#{RightSignature::Connection.site}/signatures/embedded?rt=avx37"}).should be_true
|
280
|
+
response.include?({"name" => "Righty Jones", "url" => "#{RightSignature::Connection.site}/signatures/embedded?rt=fdh89"}).should be_true
|
281
|
+
end
|
282
|
+
end
|
256
283
|
end
|
data/spec/template_spec.rb
CHANGED
@@ -186,4 +186,81 @@ describe RightSignature::Template do
|
|
186
186
|
end
|
187
187
|
end
|
188
188
|
end
|
189
|
+
|
190
|
+
describe "send_as_self_signers" do
|
191
|
+
it "should prepackage template, send template with reciepents with noemail@rightsignature.com and return self-signer links" do
|
192
|
+
RightSignature::Connection.should_receive(:post).with('/api/templates/TGUID/prepackage.xml',
|
193
|
+
{}
|
194
|
+
).and_return( {"template"=>{
|
195
|
+
"type"=>"Document",
|
196
|
+
"guid"=>"a_123_456",
|
197
|
+
"created_at"=>"2012-09-25T14:51:44-07:00",
|
198
|
+
"filename"=>"assets-363-demo_document.pdf",
|
199
|
+
"size"=>"14597",
|
200
|
+
"content_type"=>"pdf",
|
201
|
+
"page_count"=>"1",
|
202
|
+
"subject"=>"subject template",
|
203
|
+
"message"=>"Default message here",
|
204
|
+
"tags"=>"template_id:31,user:1",
|
205
|
+
"processing_state"=>"done-processing",
|
206
|
+
"roles"=>
|
207
|
+
{"role"=>
|
208
|
+
[{"role"=>"Document Sender",
|
209
|
+
"name"=>"Document Sender",
|
210
|
+
"must_sign"=>"false",
|
211
|
+
"document_role_id"=>"cc_A",
|
212
|
+
"is_sender"=>"true"},
|
213
|
+
{"role"=>"Leasee",
|
214
|
+
"name"=>"Leasee",
|
215
|
+
"must_sign"=>"true",
|
216
|
+
"document_role_id"=>"signer_A",
|
217
|
+
"is_sender"=>"false"},
|
218
|
+
{"role"=>"Leaser",
|
219
|
+
"name"=>"Leaser",
|
220
|
+
"must_sign"=>"true",
|
221
|
+
"document_role_id"=>"signer_B",
|
222
|
+
"is_sender"=>"true"}]},
|
223
|
+
"merge_fields"=>nil,
|
224
|
+
"pages"=>
|
225
|
+
{"page"=>
|
226
|
+
{"page_number"=>"1",
|
227
|
+
"original_template_guid"=>"GUID123",
|
228
|
+
"original_template_filename"=>"demo_document.pdf"}
|
229
|
+
},
|
230
|
+
"thumbnail_url"=>
|
231
|
+
"https%3A%2F%2Fs3.amazonaws.com%3A443%2Frightsignature.com%2Fassets%2F1464%2Fabcde_p1_t.png%3FSignature%3D1234AC",
|
232
|
+
"redirect_token"=>
|
233
|
+
"123456bcde"
|
234
|
+
}})
|
235
|
+
RightSignature::Connection.should_receive(:post).with('/api/templates.xml', {:template => {
|
236
|
+
:guid => "a_123_456",
|
237
|
+
:action => "send",
|
238
|
+
:subject => "subject template",
|
239
|
+
:roles => [
|
240
|
+
{:role => {:name => "John Bellingham", :email => "noemail@rightsignature.com", "@role_name" => "Leasee"}},
|
241
|
+
{:role => {:name => "Tim Else", :email => "noemail@rightsignature.com", "@role_name" => "Leaser"}}
|
242
|
+
]
|
243
|
+
}}).and_return({"document"=> {
|
244
|
+
"status"=>"sent",
|
245
|
+
"guid"=>"ABCDEFGH123"
|
246
|
+
}})
|
247
|
+
RightSignature::Connection.should_receive(:get).with("/api/documents/ABCDEFGH123/signer_links.xml", {}).and_return({"document" => {
|
248
|
+
"signer_links" => [
|
249
|
+
{"signer_link" => {"name" => "John Bellingham", "role" => "signer_A", "signer_token" => "slkfj2"}},
|
250
|
+
{"signer_link" => {"name" => "Tim Else", "role" => "signer_B", "signer_token" => "asfd1"}}
|
251
|
+
]
|
252
|
+
}})
|
253
|
+
|
254
|
+
|
255
|
+
results = RightSignature::Template.send_as_embedded_signers("TGUID", [
|
256
|
+
{"Leasee" => {:name => "John Bellingham"}},
|
257
|
+
{"Leaser" => {:name => "Tim Else"}}
|
258
|
+
])
|
259
|
+
results.size.should == 2
|
260
|
+
results.include?({"name" => "John Bellingham", "url" => "#{RightSignature::Connection.site}/signatures/embedded?rt=slkfj2"})
|
261
|
+
results.include?({"name" => "Tim Else", "url" => "#{RightSignature::Connection.site}/signatures/embedded?rt=asfd1"})
|
262
|
+
end
|
263
|
+
|
264
|
+
it "should pass in options"
|
265
|
+
end
|
189
266
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rightsignature
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-09-
|
14
|
+
date: 2012-09-26 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -118,7 +118,6 @@ extra_rdoc_files: []
|
|
118
118
|
files:
|
119
119
|
- .gitignore
|
120
120
|
- Gemfile
|
121
|
-
- Gemfile.lock
|
122
121
|
- README.md
|
123
122
|
- lib/rightsignature.rb
|
124
123
|
- lib/rightsignature/connection.rb
|
data/Gemfile.lock
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
rightsignature (0.1.0)
|
5
|
-
bundler (>= 1.0.0)
|
6
|
-
httparty (>= 0.9.0)
|
7
|
-
oauth (= 0.4.3)
|
8
|
-
xml-fu (>= 0.1.7)
|
9
|
-
|
10
|
-
GEM
|
11
|
-
remote: http://rubygems.org/
|
12
|
-
specs:
|
13
|
-
builder (3.1.3)
|
14
|
-
diff-lcs (1.1.3)
|
15
|
-
httparty (0.9.0)
|
16
|
-
multi_json (~> 1.0)
|
17
|
-
multi_xml
|
18
|
-
multi_json (1.3.6)
|
19
|
-
multi_xml (0.5.1)
|
20
|
-
oauth (0.4.3)
|
21
|
-
rspec (2.11.0)
|
22
|
-
rspec-core (~> 2.11.0)
|
23
|
-
rspec-expectations (~> 2.11.0)
|
24
|
-
rspec-mocks (~> 2.11.0)
|
25
|
-
rspec-core (2.11.1)
|
26
|
-
rspec-expectations (2.11.3)
|
27
|
-
diff-lcs (~> 1.1.3)
|
28
|
-
rspec-mocks (2.11.2)
|
29
|
-
xml-fu (0.1.7)
|
30
|
-
builder (>= 2.1.2)
|
31
|
-
|
32
|
-
PLATFORMS
|
33
|
-
ruby
|
34
|
-
|
35
|
-
DEPENDENCIES
|
36
|
-
bundler (>= 1.0.0)
|
37
|
-
rightsignature!
|
38
|
-
rspec (>= 2.11.0)
|