rightsignature 0.1.3 → 0.1.4
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 +24 -1
- data/lib/rightsignature.rb +1 -0
- data/lib/rightsignature/account.rb +20 -0
- data/lib/rightsignature/version.rb +1 -1
- data/spec/account_spec.rb +54 -0
- metadata +3 -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.4'
|
12
12
|
```
|
13
13
|
|
14
14
|
Setup
|
@@ -330,6 +330,28 @@ RightSignature::Template.generate_build_url(options)
|
|
330
330
|
```
|
331
331
|
|
332
332
|
|
333
|
+
Account
|
334
|
+
---------
|
335
|
+
API calls involving API user's account.
|
336
|
+
|
337
|
+
#####User Details
|
338
|
+
```
|
339
|
+
RightSignature::Account.user_details
|
340
|
+
```
|
341
|
+
|
342
|
+
#####Add User to Account
|
343
|
+
```
|
344
|
+
RightSignature::Account.add_user(name, email)
|
345
|
+
```
|
346
|
+
|
347
|
+
#####Usage Report
|
348
|
+
Returns number of documents sent. Can scope to week, month, or day and count only signed, unsigned, or all documents.
|
349
|
+
```
|
350
|
+
RightSignature::Account.usage_report(since=nil, signed=nil)
|
351
|
+
```
|
352
|
+
* since: Only count documents sent withing the 'week', 'month', or 'day'.
|
353
|
+
* signed: Only count signed documents if 'true', else all documents
|
354
|
+
|
333
355
|
Custom API calls using RightSignature::Connection
|
334
356
|
-------------------------------------------------
|
335
357
|
|
@@ -359,4 +381,5 @@ $:.push File.expand_path("../lib", __FILE__); require "rightsignature"; RightSig
|
|
359
381
|
|
360
382
|
TODO:
|
361
383
|
-----
|
384
|
+
* Parse error message from response body on unsuccessful requests
|
362
385
|
* Have a way for to generate an OAuth Access Token from RightSignature
|
data/lib/rightsignature.rb
CHANGED
@@ -5,6 +5,7 @@ require 'rightsignature/errors'
|
|
5
5
|
require 'rightsignature/helpers/normalizing'
|
6
6
|
require 'rightsignature/document'
|
7
7
|
require 'rightsignature/template'
|
8
|
+
require 'rightsignature/account'
|
8
9
|
require 'rightsignature/connection/oauth_connection'
|
9
10
|
require 'rightsignature/connection/token_connection'
|
10
11
|
require 'rightsignature/connection'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module RightSignature
|
2
|
+
class Account
|
3
|
+
class <<self
|
4
|
+
def user_details
|
5
|
+
RightSignature::Connection.get "/api/users/user_details.xml"
|
6
|
+
end
|
7
|
+
|
8
|
+
def add_user(name, email)
|
9
|
+
RightSignature::Connection.post "/api/users.xml", {:user => {:name => name, :email => email}}
|
10
|
+
end
|
11
|
+
|
12
|
+
def usage_report(since=nil, signed=nil)
|
13
|
+
options = {}
|
14
|
+
options[:since] = since if since && ["month", "week", "day"].include?(since)
|
15
|
+
options[:signed] = signed.to_s unless signed.nil?
|
16
|
+
RightSignature::Connection.get "/api/account/usage_report.xml", options
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe RightSignature::Account do
|
4
|
+
describe "user_details" do
|
5
|
+
it "should GET /api/users/user_details.xml" do
|
6
|
+
RightSignature::Connection.should_receive(:get).with('/api/users/user_details.xml')
|
7
|
+
RightSignature::Account.user_details
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "add_user" do
|
12
|
+
it "should POST /api/users.xml with user email and name in hash" do
|
13
|
+
RightSignature::Connection.should_receive(:post).with('/api/users.xml', {:user => {:name => "Jimmy Cricket", :email => "jimmy@example.com"}})
|
14
|
+
RightSignature::Account.add_user("Jimmy Cricket", "jimmy@example.com")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "usage_report" do
|
19
|
+
it "should GET /api/account/usage_report.xml" do
|
20
|
+
RightSignature::Connection.should_receive(:get).with('/api/account/usage_report.xml', {})
|
21
|
+
RightSignature::Account.usage_report
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should GET /api/account/usage_report.xml with acceptable param for :since" do
|
25
|
+
RightSignature::Connection.should_receive(:get).with('/api/account/usage_report.xml', {:since => "week"})
|
26
|
+
RightSignature::Account.usage_report("week")
|
27
|
+
|
28
|
+
RightSignature::Connection.should_receive(:get).with('/api/account/usage_report.xml', {:since => "month"})
|
29
|
+
RightSignature::Account.usage_report("month")
|
30
|
+
|
31
|
+
RightSignature::Connection.should_receive(:get).with('/api/account/usage_report.xml', {:since => "day"})
|
32
|
+
RightSignature::Account.usage_report("day")
|
33
|
+
|
34
|
+
RightSignature::Connection.should_receive(:get).with('/api/account/usage_report.xml', {})
|
35
|
+
RightSignature::Account.usage_report("1/4/90")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should GET /api/account/usage_report.xml with param :signed" do
|
39
|
+
RightSignature::Connection.should_receive(:get).with('/api/account/usage_report.xml', {:signed => "true"})
|
40
|
+
RightSignature::Account.usage_report(nil, true)
|
41
|
+
|
42
|
+
RightSignature::Connection.should_receive(:get).with('/api/account/usage_report.xml', {:signed => "false"})
|
43
|
+
RightSignature::Account.usage_report(nil, false)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should GET /api/account/usage_report.xml with params :since and :signed" do
|
47
|
+
RightSignature::Connection.should_receive(:get).with('/api/account/usage_report.xml', {:signed => "true"})
|
48
|
+
RightSignature::Account.usage_report(nil, true)
|
49
|
+
|
50
|
+
RightSignature::Connection.should_receive(:get).with('/api/account/usage_report.xml', {:signed => "false"})
|
51
|
+
RightSignature::Account.usage_report(nil, false)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
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.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- Gemfile
|
121
121
|
- README.md
|
122
122
|
- lib/rightsignature.rb
|
123
|
+
- lib/rightsignature/account.rb
|
123
124
|
- lib/rightsignature/connection.rb
|
124
125
|
- lib/rightsignature/connection/oauth_connection.rb
|
125
126
|
- lib/rightsignature/connection/token_connection.rb
|
@@ -129,6 +130,7 @@ files:
|
|
129
130
|
- lib/rightsignature/template.rb
|
130
131
|
- lib/rightsignature/version.rb
|
131
132
|
- rightsignature-api.gemspec
|
133
|
+
- spec/account_spec.rb
|
132
134
|
- spec/api_token_connection_spec.rb
|
133
135
|
- spec/configuration_spec.rb
|
134
136
|
- spec/connection_spec.rb
|