rightsignature 0.1.8 → 1.0.0

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/spec/spec_helper.rb CHANGED
@@ -7,6 +7,6 @@ RSpec.configure do |c|
7
7
  c.mock_with :rspec
8
8
 
9
9
  c.before(:each) do
10
- RightSignature::configuration = {:consumer_key => "Consumer123", :consumer_secret => "Secret098", :access_token => "AccessToken098", :access_secret => "AccessSecret123", :api_token => "APITOKEN"}
10
+ @rs = RightSignature::Connection.new({:consumer_key => "Consumer123", :consumer_secret => "Secret098", :access_token => "AccessToken098", :access_secret => "AccessSecret123", :api_token => "APITOKEN"})
11
11
  end
12
12
  end
@@ -1,87 +1,87 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
3
  describe RightSignature::Template do
4
- describe "list" do
4
+ describe "templates_list" do
5
5
  it "should GET /api/templates.xml" do
6
- RightSignature::Connection.should_receive(:get).with('/api/templates.xml', {})
7
- RightSignature::Template.list
6
+ @rs.should_receive(:get).with('/api/templates.xml', {})
7
+ @rs.templates_list
8
8
  end
9
9
 
10
10
  it "should pass search options to /api/templates.xml" do
11
- RightSignature::Connection.should_receive(:get).with('/api/templates.xml', {:search => "search", :page => 2})
12
- RightSignature::Template.list(:search => "search", :page => 2)
11
+ @rs.should_receive(:get).with('/api/templates.xml', {:search => "search", :page => 2})
12
+ @rs.templates_list(:search => "search", :page => 2)
13
13
  end
14
14
 
15
15
  it "should convert tags array of mixed strings and hashes into into normalized Tag string" do
16
- RightSignature::Connection.should_receive(:get).with('/api/templates.xml', {:tags => "hello,abc:def,there"})
17
- RightSignature::Template.list(:tags => ["hello", {"abc" => "def"}, "there"])
16
+ @rs.should_receive(:get).with('/api/templates.xml', {:tags => "hello,abc:def,there"})
17
+ @rs.templates_list(:tags => ["hello", {"abc" => "def"}, "there"])
18
18
  end
19
19
 
20
20
  it "should keep tags as string if :tags is a string" do
21
- RightSignature::Connection.should_receive(:get).with('/api/templates.xml', {:tags => "voice,no:way,microphone"})
22
- RightSignature::Template.list(:tags => "voice,no:way,microphone")
21
+ @rs.should_receive(:get).with('/api/templates.xml', {:tags => "voice,no:way,microphone"})
22
+ @rs.templates_list(:tags => "voice,no:way,microphone")
23
23
  end
24
24
  end
25
25
 
26
- describe "details" do
26
+ describe "template_details" do
27
27
  it "should GET /api/templates/MYGUID.xml" do
28
- RightSignature::Connection.should_receive(:get).with('/api/templates/MYGUID.xml', {})
29
- RightSignature::Template.details('MYGUID')
28
+ @rs.should_receive(:get).with('/api/templates/MYGUID.xml', {})
29
+ @rs.template_details('MYGUID')
30
30
  end
31
31
  end
32
32
 
33
33
  describe "prepackage" do
34
34
  it "should POST /api/templates/MYGUID/prepackage.xml" do
35
- RightSignature::Connection.should_receive(:post).with('/api/templates/MYGUID/prepackage.xml', {})
36
- RightSignature::Template.prepackage('MYGUID')
35
+ @rs.should_receive(:post).with('/api/templates/MYGUID/prepackage.xml', {})
36
+ @rs.prepackage('MYGUID')
37
37
  end
38
38
  end
39
39
 
40
40
 
41
41
  describe "prepackage_and_send" do
42
42
  it "should POST /api/templates/GUID123/prepackage.xml and POST /api/templates.xml using guid, and subject from prepackage response" do
43
- RightSignature::Connection.should_receive(:post).with('/api/templates/GUID123/prepackage.xml',
43
+ @rs.should_receive(:post).with('/api/templates/GUID123/prepackage.xml',
44
44
  {}
45
45
  ).and_return({"template" => {
46
46
  "guid" => "a_123985_1z9v8pd654",
47
47
  "subject" => "subject template",
48
48
  "message" => "Default message here"
49
49
  }})
50
- RightSignature::Connection.should_receive(:post).with('/api/templates.xml', {:template => {
50
+ @rs.should_receive(:post).with('/api/templates.xml', {:template => {
51
51
  :guid => "a_123985_1z9v8pd654",
52
52
  :action => "send",
53
53
  :subject => "sign me",
54
54
  :roles => []
55
55
  }})
56
- RightSignature::Template.prepackage_and_send("GUID123", [], {:subject => "sign me"})
56
+ @rs.prepackage_and_send("GUID123", [], {:subject => "sign me"})
57
57
  end
58
58
 
59
59
  it "should default subject to one in Template prepackage response" do
60
- RightSignature::Connection.should_receive(:post).with('/api/templates/GUID123/prepackage.xml',
60
+ @rs.should_receive(:post).with('/api/templates/GUID123/prepackage.xml',
61
61
  {}
62
62
  ).and_return({"template" => {
63
63
  "guid" => "a_123985_1z9v8pd654",
64
64
  "subject" => "subject template",
65
65
  "message" => "Default message here"
66
66
  }})
67
- RightSignature::Connection.should_receive(:post).with('/api/templates.xml', {:template => {
67
+ @rs.should_receive(:post).with('/api/templates.xml', {:template => {
68
68
  :guid => "a_123985_1z9v8pd654",
69
69
  :action => "send",
70
70
  :subject => "subject template",
71
71
  :roles => []
72
72
  }})
73
- RightSignature::Template.prepackage_and_send("GUID123", [])
73
+ @rs.prepackage_and_send("GUID123", [])
74
74
  end
75
75
  end
76
76
 
77
77
  describe "prefill/send_template" do
78
78
  it "should POST /api/templates.xml with action of 'prefill', MYGUID guid, roles, and \"sign me\" subject in template hash" do
79
- RightSignature::Connection.should_receive(:post).with('/api/templates.xml', {:template => {:guid => "MYGUID", :action => "prefill", :subject => "sign me", :roles => []}})
80
- RightSignature::Template.prefill("MYGUID", "sign me", [])
79
+ @rs.should_receive(:post).with('/api/templates.xml', {:template => {:guid => "MYGUID", :action => "prefill", :subject => "sign me", :roles => []}})
80
+ @rs.prefill("MYGUID", "sign me", [])
81
81
  end
82
82
 
83
83
  it "should add \"@role_name\"=>'Employee' key to roles in xml hash" do
84
- RightSignature::Connection.should_receive(:post).with('/api/templates.xml', {
84
+ @rs.should_receive(:post).with('/api/templates.xml', {
85
85
  :template => {
86
86
  :guid => "MYGUID",
87
87
  :action => "prefill",
@@ -95,11 +95,11 @@ describe RightSignature::Template do
95
95
  ]
96
96
  }
97
97
  })
98
- RightSignature::Template.prefill("MYGUID", "sign me", [{"Employee" => {:name => "John Employee", :email => "john@employee.com"}}])
98
+ @rs.prefill("MYGUID", "sign me", [{"Employee" => {:name => "John Employee", :email => "john@employee.com"}}])
99
99
  end
100
100
 
101
101
  it "should add \"@role_id\"=>'signer_A' key to roles in xml hash" do
102
- RightSignature::Connection.should_receive(:post).with('/api/templates.xml', {
102
+ @rs.should_receive(:post).with('/api/templates.xml', {
103
103
  :template => {
104
104
  :guid => "MYGUID",
105
105
  :action => "prefill",
@@ -113,12 +113,12 @@ describe RightSignature::Template do
113
113
  ]
114
114
  }
115
115
  })
116
- RightSignature::Template.prefill("MYGUID", "sign me", [{"signer_A" => {:name => "John Employee", :email => "john@employee.com"}}])
116
+ @rs.prefill("MYGUID", "sign me", [{"signer_A" => {:name => "John Employee", :email => "john@employee.com"}}])
117
117
  end
118
118
 
119
119
  describe "optional options" do
120
120
  it "should add \"@merge_field_name\"=>'Tax_id' key to merge_fields in xml hash" do
121
- RightSignature::Connection.should_receive(:post).with('/api/templates.xml', {
121
+ @rs.should_receive(:post).with('/api/templates.xml', {
122
122
  :template => {
123
123
  :guid => "MYGUID",
124
124
  :action => "prefill",
@@ -128,11 +128,11 @@ describe RightSignature::Template do
128
128
  :merge_fields => [{:merge_field => {:value => "123456", "@merge_field_name" => "Tax_id"}}]
129
129
  }
130
130
  })
131
- RightSignature::Template.prefill("MYGUID", "sign me", [], {:merge_fields => [{"Tax_id" => "123456"}]})
131
+ @rs.prefill("MYGUID", "sign me", [], {:merge_fields => [{"Tax_id" => "123456"}]})
132
132
  end
133
133
 
134
134
  it "should add \"@merge_field_id\"=>'123_abc_78' key to merge_fields in xml hash" do
135
- RightSignature::Connection.should_receive(:post).with('/api/templates.xml', {
135
+ @rs.should_receive(:post).with('/api/templates.xml', {
136
136
  :template => {
137
137
  :guid => "MYGUID",
138
138
  :action => "prefill",
@@ -142,11 +142,11 @@ describe RightSignature::Template do
142
142
  :merge_fields => [{:merge_field => {:value => "123456", "@merge_field_id" => "123_abc_78"}}]
143
143
  }
144
144
  })
145
- RightSignature::Template.prefill("MYGUID", "sign me", [], {:merge_fields => [{"123_abc_78" => "123456"}], :use_merge_field_ids => true})
145
+ @rs.prefill("MYGUID", "sign me", [], {:merge_fields => [{"123_abc_78" => "123456"}], :use_merge_field_ids => true})
146
146
  end
147
147
 
148
148
  it "should add \"tag\" key to tags in xml hash" do
149
- RightSignature::Connection.should_receive(:post).with('/api/templates.xml', {
149
+ @rs.should_receive(:post).with('/api/templates.xml', {
150
150
  :template => {
151
151
  :guid => "MYGUID",
152
152
  :action => "prefill",
@@ -155,11 +155,11 @@ describe RightSignature::Template do
155
155
  :tags => [{:tag => {:name => "I_Key", :value => "I_Value"}}, {:tag => {:name => "Alone"}}]
156
156
  }
157
157
  })
158
- RightSignature::Template.prefill("MYGUID", "sign me", [], {:tags => [{"I_Key" => "I_Value"}, "Alone"]})
158
+ @rs.prefill("MYGUID", "sign me", [], {:tags => [{"I_Key" => "I_Value"}, "Alone"]})
159
159
  end
160
160
 
161
161
  it "should include options :expires_in, :description, and :callback_url" do
162
- RightSignature::Connection.should_receive(:post).with('/api/templates.xml', {
162
+ @rs.should_receive(:post).with('/api/templates.xml', {
163
163
  :template => {
164
164
  :guid => "MYGUID",
165
165
  :action => "prefill",
@@ -170,68 +170,68 @@ describe RightSignature::Template do
170
170
  :callback_url => 'http://example.com/callie'
171
171
  }
172
172
  })
173
- RightSignature::Template.prefill("MYGUID", "sign me", [], {:expires_in => 15, :description => "Hey, I'm a description", :callback_url => "http://example.com/callie"})
173
+ @rs.prefill("MYGUID", "sign me", [], {:expires_in => 15, :description => "Hey, I'm a description", :callback_url => "http://example.com/callie"})
174
174
  end
175
175
  end
176
176
 
177
177
  it "should POST /api/templates.xml with action of 'send', MYGUID guid, roles, and \"sign me\" subject in template hash" do
178
- RightSignature::Connection.should_receive(:post).with('/api/templates.xml', {:template => {:guid => "MYGUID", :action => "send", :subject => "sign me", :roles => []}})
179
- RightSignature::Template.send_template("MYGUID", "sign me", [])
178
+ @rs.should_receive(:post).with('/api/templates.xml', {:template => {:guid => "MYGUID", :action => "send", :subject => "sign me", :roles => []}})
179
+ @rs.send_template("MYGUID", "sign me", [])
180
180
  end
181
181
  end
182
182
 
183
183
  describe "generate_build_url" do
184
184
  it "should POST /api/templates/generate_build_token.xml" do
185
- RightSignature::Connection.should_receive(:post).with("/api/templates/generate_build_token.xml", {:template => {}}).and_return({"token"=>{"redirect_token" => "REDIRECT_TOKEN"}})
186
- RightSignature::Template.generate_build_url
185
+ @rs.should_receive(:post).with("/api/templates/generate_build_token.xml", {:template => {}}).and_return({"token"=>{"redirect_token" => "REDIRECT_TOKEN"}})
186
+ @rs.generate_build_url
187
187
  end
188
188
 
189
189
  it "should return https://rightsignature.com/builder/new?rt=REDIRECT_TOKEN" do
190
- RightSignature::Connection.should_receive(:post).with("/api/templates/generate_build_token.xml", {:template => {}}).and_return({"token"=>{"redirect_token" => "REDIRECT_TOKEN"}})
191
- RightSignature::Template.generate_build_url.should == "#{RightSignature::Connection.site}/builder/new?rt=REDIRECT_TOKEN"
190
+ @rs.should_receive(:post).with("/api/templates/generate_build_token.xml", {:template => {}}).and_return({"token"=>{"redirect_token" => "REDIRECT_TOKEN"}})
191
+ @rs.generate_build_url.should == "#{@rs.site}/builder/new?rt=REDIRECT_TOKEN"
192
192
  end
193
193
 
194
194
  describe "options" do
195
195
  it "should include normalized :acceptable_merge_field_names in params" do
196
- RightSignature::Connection.should_receive(:post).with("/api/templates/generate_build_token.xml", {:template =>
196
+ @rs.should_receive(:post).with("/api/templates/generate_build_token.xml", {:template =>
197
197
  {:acceptable_merge_field_names =>
198
198
  [
199
199
  {:name => "Site ID"},
200
200
  {:name => "Starting City"}
201
201
  ]}
202
202
  }).and_return({"token"=>{"redirect_token" => "REDIRECT_TOKEN"}})
203
- RightSignature::Template.generate_build_url(:acceptable_merge_field_names => ["Site ID", "Starting City"])
203
+ @rs.generate_build_url(:acceptable_merge_field_names => ["Site ID", "Starting City"])
204
204
  end
205
205
 
206
- it "should include normalized :acceptabled_role_names, in params" do
207
- RightSignature::Connection.should_receive(:post).with("/api/templates/generate_build_token.xml", {:template =>
208
- {:acceptabled_role_names =>
206
+ it "should include normalized :acceptable_role_names, in params" do
207
+ @rs.should_receive(:post).with("/api/templates/generate_build_token.xml", {:template =>
208
+ {:acceptable_role_names =>
209
209
  [
210
210
  {:name => "Http Monster"},
211
211
  {:name => "Party Monster"}
212
212
  ]}
213
213
  }).and_return({"token"=>{"redirect_token" => "REDIRECT_TOKEN"}})
214
- RightSignature::Template.generate_build_url(:acceptabled_role_names => ["Http Monster", "Party Monster"])
214
+ @rs.generate_build_url(:acceptable_role_names => ["Http Monster", "Party Monster"])
215
215
  end
216
216
 
217
217
  it "should include normalized :tags in params" do
218
- RightSignature::Connection.should_receive(:post).with("/api/templates/generate_build_token.xml", {:template =>
218
+ @rs.should_receive(:post).with("/api/templates/generate_build_token.xml", {:template =>
219
219
  {:tags =>
220
220
  [
221
221
  {:tag => {:name => "Site"}},
222
222
  {:tag => {:name => "Starting City", :value => "NY"}}
223
223
  ]}
224
224
  }).and_return({"token"=>{"redirect_token" => "REDIRECT_TOKEN"}})
225
- RightSignature::Template.generate_build_url(:tags => ["Site", "Starting City" => "NY"])
225
+ @rs.generate_build_url(:tags => ["Site", "Starting City" => "NY"])
226
226
  end
227
227
 
228
228
  it "should include :callback_location and :redirect_location in params" do
229
- RightSignature::Connection.should_receive(:post).with("/api/templates/generate_build_token.xml", {:template => {
229
+ @rs.should_receive(:post).with("/api/templates/generate_build_token.xml", {:template => {
230
230
  :callback_location => "http://example.com/done_signing",
231
231
  :redirect_location => "http://example.com/come_back_here"
232
232
  }}).and_return({"token"=>{"redirect_token" => "REDIRECT_TOKEN"}})
233
233
 
234
- RightSignature::Template.generate_build_url(:callback_location => "http://example.com/done_signing", :redirect_location => "http://example.com/come_back_here")
234
+ @rs.generate_build_url(:callback_location => "http://example.com/done_signing", :redirect_location => "http://example.com/come_back_here")
235
235
  end
236
236
  end
237
237
  end
@@ -288,10 +288,10 @@ describe RightSignature::Template do
288
288
  end
289
289
 
290
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',
291
+ @rs.should_receive(:post).with('/api/templates/TGUID/prepackage.xml',
292
292
  {}
293
293
  ).and_return(@prepackage_response)
294
- RightSignature::Connection.should_receive(:post).with('/api/templates.xml', {:template => {
294
+ @rs.should_receive(:post).with('/api/templates.xml', {:template => {
295
295
  :guid => "a_123_456",
296
296
  :action => "send",
297
297
  :subject => "subject template",
@@ -300,7 +300,7 @@ describe RightSignature::Template do
300
300
  {:role => {:name => "Tim Else", :email => "noemail@rightsignature.com", "@role_name" => "Leaser"}}
301
301
  ]
302
302
  }}).and_return(@sent_document_response)
303
- RightSignature::Connection.should_receive(:get).with("/api/documents/ABCDEFGH123/signer_links.xml", {}).and_return({"document" => {
303
+ @rs.should_receive(:get).with("/api/documents/ABCDEFGH123/signer_links.xml", {}).and_return({"document" => {
304
304
  "signer_links" => {"signer_link" => [
305
305
  {"name" => "John Bellingham", "role" => "signer_A", "signer_token" => "slkfj2"},
306
306
  {"name" => "Tim Else", "role" => "signer_B", "signer_token" => "asfd1"}
@@ -308,20 +308,20 @@ describe RightSignature::Template do
308
308
  }})
309
309
 
310
310
 
311
- results = RightSignature::Template.send_as_embedded_signers("TGUID", [
311
+ results = @rs.send_as_embedded_signers("TGUID", [
312
312
  {"Leasee" => {:name => "John Bellingham"}},
313
313
  {"Leaser" => {:name => "Tim Else"}}
314
314
  ])
315
315
  results.size.should == 2
316
- results.include?({"name" => "John Bellingham", "url" => "#{RightSignature::Connection.site}/signatures/embedded?rt=slkfj2"})
317
- results.include?({"name" => "Tim Else", "url" => "#{RightSignature::Connection.site}/signatures/embedded?rt=asfd1"})
316
+ results.include?({"name" => "John Bellingham", "url" => "#{@rs.site}/signatures/embedded?rt=slkfj2"})
317
+ results.include?({"name" => "Tim Else", "url" => "#{@rs.site}/signatures/embedded?rt=asfd1"})
318
318
  end
319
319
 
320
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',
321
+ @rs.should_receive(:post).with('/api/templates/TGUID/prepackage.xml',
322
322
  {}
323
323
  ).and_return(@prepackage_response)
324
- RightSignature::Connection.should_receive(:post).with('/api/templates.xml', {:template => {
324
+ @rs.should_receive(:post).with('/api/templates.xml', {:template => {
325
325
  :guid => "a_123_456",
326
326
  :action => "send",
327
327
  :subject => "subject template",
@@ -330,20 +330,20 @@ describe RightSignature::Template do
330
330
  {:role => {:name => "Tim Else", :email => "noemail@rightsignature.com", "@role_name" => "Leaser"}}
331
331
  ]
332
332
  }}).and_return(@sent_document_response)
333
- RightSignature::Connection.should_receive(:get).with("/api/documents/ABCDEFGH123/signer_links.xml", {}).and_return({"document" => {
333
+ @rs.should_receive(:get).with("/api/documents/ABCDEFGH123/signer_links.xml", {}).and_return({"document" => {
334
334
  "signer_links" => {"signer_link" => [
335
335
  {"name" => "John Bellingham", "email" => "dontchange@example.com", "role" => "signer_A", "signer_token" => "slkfj2"},
336
336
  {"name" => "Tim Else", "role" => "signer_B", "signer_token" => "asfd1"}
337
337
  ]}
338
338
  }})
339
339
 
340
- results = RightSignature::Template.send_as_embedded_signers("TGUID", [
340
+ results = @rs.send_as_embedded_signers("TGUID", [
341
341
  {"Leasee" => {:name => "John Bellingham", :email => "dontchange@example.com"}},
342
342
  {"Leaser" => {:name => "Tim Else"}}
343
343
  ])
344
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"})
345
+ results.include?({"name" => "John Bellingham", "url" => "#{@rs.site}/signatures/embedded?rt=slkfj2"})
346
+ results.include?({"name" => "Tim Else", "url" => "#{@rs.site}/signatures/embedded?rt=asfd1"})
347
347
  end
348
348
 
349
349
  it "should pass in options"
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.8
4
+ version: 1.0.0
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-10-05 00:00:00.000000000 Z
14
+ date: 2012-10-12 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler