paperlex 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +37 -0
- data/Rakefile +34 -0
- data/lib/paperlex/base/base.rb +39 -0
- data/lib/paperlex/base/root_object.rb +33 -0
- data/lib/paperlex/base/sub_object.rb +45 -0
- data/lib/paperlex/contract/responses.rb +47 -0
- data/lib/paperlex/contract/review_sessions.rb +31 -0
- data/lib/paperlex/contract/signers.rb +31 -0
- data/lib/paperlex/contract/versions.rb +9 -0
- data/lib/paperlex/contract.rb +190 -0
- data/lib/paperlex/review_session.rb +9 -0
- data/lib/paperlex/signer.rb +6 -0
- data/lib/paperlex/slaw/versions.rb +9 -0
- data/lib/paperlex/slaw.rb +62 -0
- data/lib/paperlex/version.rb +3 -0
- data/lib/paperlex/versions.rb +37 -0
- data/lib/paperlex.rb +44 -0
- data/lib/paperlex_api_client.rb +1 -0
- data/lib/tasks/paperlex_api_client_tasks.rake +4 -0
- metadata +153 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2011 Paperlex, LLC.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
= Paperlex
|
2
|
+
|
3
|
+
Read more at https://sandbox.api.paperlex.com.
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'paperlex'
|
7
|
+
|
8
|
+
Paperlex.token = "b53b0c15dce176b4"
|
9
|
+
|
10
|
+
templates = Paperlex::Slaw.all
|
11
|
+
|
12
|
+
nda_template = templates.first
|
13
|
+
|
14
|
+
contract = Paperlex::Contract.create({
|
15
|
+
:slaw_id => nda_template.uuid,
|
16
|
+
:subject => "My First NDA",
|
17
|
+
:number_of_signers => 2,
|
18
|
+
:responses => {
|
19
|
+
:party_a => "John Smith",
|
20
|
+
:party_b => "Jane Smith",
|
21
|
+
:party_a_address => "john_smith@example.com",
|
22
|
+
:party_b_address => "jane_smith@example.com",
|
23
|
+
:confidential_duration => "1 year"
|
24
|
+
}
|
25
|
+
})
|
26
|
+
|
27
|
+
contract.responses[:confidential_duration] = "2 years"
|
28
|
+
contract.responses[:state] = "New York"
|
29
|
+
|
30
|
+
contract.save_responses
|
31
|
+
|
32
|
+
contract.create_signer(:email => "john_smith@example.com")
|
33
|
+
contract.create_signer(:email => "jane_smith@example.com")
|
34
|
+
|
35
|
+
review_session = contract.create_review_session(:email => "john_smith@example.com", :expires_in => 172800)
|
36
|
+
|
37
|
+
puts "URL: #{review_session.url}"
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'bundler/setup'
|
5
|
+
rescue LoadError
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'rspec/core/rake_task'
|
10
|
+
|
11
|
+
RSpec::Core::RakeTask.new do |t|
|
12
|
+
t.pattern = "./spec/**/*_spec.rb"
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
begin
|
17
|
+
require 'rdoc/task'
|
18
|
+
rescue LoadError
|
19
|
+
require 'rdoc/rdoc'
|
20
|
+
require 'rake/rdoctask'
|
21
|
+
RDoc::Task = Rake::RDocTask
|
22
|
+
end
|
23
|
+
|
24
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
25
|
+
rdoc.rdoc_dir = 'rdoc'
|
26
|
+
rdoc.title = 'PaperlexApiClient'
|
27
|
+
rdoc.options << '--line-numbers'
|
28
|
+
rdoc.rdoc_files.include('README.rdoc')
|
29
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
30
|
+
end
|
31
|
+
|
32
|
+
task :default => :spec
|
33
|
+
|
34
|
+
Bundler::GemHelper.install_tasks
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Paperlex
|
2
|
+
class Base < Hashie::Dash
|
3
|
+
property :uuid, :required => true
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def parse(result)
|
7
|
+
if result == "null"
|
8
|
+
nil
|
9
|
+
else
|
10
|
+
JSON.parse(result)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(url, *attrs)
|
15
|
+
parse(RestClient.get("#{Paperlex.base_url}/#{url}?token=#{Paperlex.token}", *attrs))
|
16
|
+
end
|
17
|
+
|
18
|
+
def post(url, attrs = {})
|
19
|
+
parse(RestClient.post("#{Paperlex.base_url}/#{url}", attrs.merge(:token => Paperlex.token)))
|
20
|
+
end
|
21
|
+
|
22
|
+
def put(url, attrs = {})
|
23
|
+
parse(RestClient.put("#{Paperlex.base_url}/#{url}", attrs.merge(:token => Paperlex.token)))
|
24
|
+
end
|
25
|
+
|
26
|
+
def delete(url, attrs = {})
|
27
|
+
parse(RestClient.delete("#{Paperlex.base_url}/#{url}", attrs.merge(:token => Paperlex.token)))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize(uuid, attrs = {})
|
32
|
+
super(uuid.is_a?(Hash) ? uuid.merge(attrs) : attrs.merge(:uuid => uuid))
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_uuid(object)
|
36
|
+
object.respond_to?(:uuid) ? object.uuid : object
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Paperlex
|
2
|
+
module RootObject
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
def collection_url
|
7
|
+
"#{url_name}.json"
|
8
|
+
end
|
9
|
+
|
10
|
+
def url_for(uuid)
|
11
|
+
"#{url_name}/#{uuid}.json"
|
12
|
+
end
|
13
|
+
|
14
|
+
def all
|
15
|
+
get(collection_url).map {|attrs| new(attrs) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def find(uuid)
|
19
|
+
new(get(url_for(uuid)))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_html
|
24
|
+
RestClient.get(html_url(responses))
|
25
|
+
end
|
26
|
+
|
27
|
+
def save!(fields = nil)
|
28
|
+
fields ||= self.class.update_fields
|
29
|
+
self.class.put(self.class.url_for(uuid), short_name => Hash[fields.map {|field| [field, self[field]]}])
|
30
|
+
self
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Paperlex
|
2
|
+
module SubObject
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attr_reader :contract_uuid
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def [](parent_uuid)
|
11
|
+
new(parent_uuid)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(contract_uuid)
|
16
|
+
@contract_uuid = contract_uuid
|
17
|
+
end
|
18
|
+
|
19
|
+
def new_object(attrs)
|
20
|
+
object_class.new(attrs.merge(:contract_uuid => contract_uuid))
|
21
|
+
end
|
22
|
+
|
23
|
+
def all
|
24
|
+
self.class.get(collection_url)
|
25
|
+
end
|
26
|
+
|
27
|
+
def create(attrs = {})
|
28
|
+
attrs.symbolize_keys!
|
29
|
+
attrs.assert_valid_keys(self.class.create_fields)
|
30
|
+
new_object(self.class.post(collection_url, short_name => attrs))
|
31
|
+
end
|
32
|
+
|
33
|
+
def find(uuid)
|
34
|
+
new_object(self.class.get(url_for(uuid)))
|
35
|
+
end
|
36
|
+
|
37
|
+
def update(uuid, attrs)
|
38
|
+
new_object(self.class.put(url_for(uuid), short_name => attrs))
|
39
|
+
end
|
40
|
+
|
41
|
+
def destroy(uuid)
|
42
|
+
self.class.delete(url_for(uuid))
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Paperlex
|
2
|
+
class Contract < Base
|
3
|
+
class Responses < Base
|
4
|
+
attr_reader :contract_uuid
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def [](contract_uuid)
|
8
|
+
new(contract_uuid)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(contract_uuid)
|
13
|
+
@contract_uuid = contract_uuid
|
14
|
+
end
|
15
|
+
|
16
|
+
def all
|
17
|
+
self.class.get(collection_url)
|
18
|
+
end
|
19
|
+
|
20
|
+
def update_all(responses)
|
21
|
+
self.class.post(collection_url, {:responses => responses})
|
22
|
+
end
|
23
|
+
|
24
|
+
def find(key)
|
25
|
+
self.class.get(url_for(key)).first
|
26
|
+
end
|
27
|
+
|
28
|
+
def update(key, value)
|
29
|
+
self.class.put(url_for(key), {:value => value})
|
30
|
+
end
|
31
|
+
|
32
|
+
def destroy(key)
|
33
|
+
self.class.delete(url_for(key))
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def collection_url
|
39
|
+
"contracts/#{contract_uuid}/responses.json"
|
40
|
+
end
|
41
|
+
|
42
|
+
def url_for(key)
|
43
|
+
"contracts/#{contract_uuid}/responses/#{key}.json"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Paperlex
|
2
|
+
class Contract < Base
|
3
|
+
class ReviewSessions < Paperlex::Base
|
4
|
+
include SubObject
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def create_fields
|
8
|
+
[:email, :expires_at, :expires_in]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def object_class
|
13
|
+
Paperlex::ReviewSession
|
14
|
+
end
|
15
|
+
|
16
|
+
def short_name
|
17
|
+
:review_session
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def collection_url
|
23
|
+
"contracts/#{contract_uuid}/review_sessions.json"
|
24
|
+
end
|
25
|
+
|
26
|
+
def url_for(uuid)
|
27
|
+
"contracts/#{contract_uuid}/review_sessions/#{to_uuid(uuid)}.json"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Paperlex
|
2
|
+
class Contract < Base
|
3
|
+
class Signers < Paperlex::Base
|
4
|
+
include SubObject
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def create_fields
|
8
|
+
[:email]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def object_class
|
13
|
+
Paperlex::Signer
|
14
|
+
end
|
15
|
+
|
16
|
+
def short_name
|
17
|
+
:signer
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def collection_url
|
23
|
+
"contracts/#{contract_uuid}/signers.json"
|
24
|
+
end
|
25
|
+
|
26
|
+
def url_for(uuid)
|
27
|
+
"contracts/#{contract_uuid}/signers/#{to_uuid(uuid)}.json"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
module Paperlex
|
2
|
+
class Contract < Base
|
3
|
+
include RootObject
|
4
|
+
|
5
|
+
extend ActiveSupport::Autoload
|
6
|
+
autoload :Signers
|
7
|
+
autoload :Responses
|
8
|
+
autoload :ReviewSessions
|
9
|
+
autoload :Versions
|
10
|
+
|
11
|
+
# Provided by index
|
12
|
+
property :created_at
|
13
|
+
property :updated_at
|
14
|
+
property :subject
|
15
|
+
|
16
|
+
# Provided by show
|
17
|
+
property :body
|
18
|
+
property :current_version
|
19
|
+
property :locked
|
20
|
+
property :number_of_signers
|
21
|
+
property :number_of_identity_verifications
|
22
|
+
property :responses
|
23
|
+
property :signers
|
24
|
+
property :signatures
|
25
|
+
property :signature_callback_url
|
26
|
+
property :review_sessions
|
27
|
+
|
28
|
+
class << self
|
29
|
+
def update_fields
|
30
|
+
[:subject, :number_of_signers, :responses, :signature_callback_url, :body]
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_fields
|
34
|
+
[*update_fields] << :slaw_id
|
35
|
+
end
|
36
|
+
|
37
|
+
def url_name
|
38
|
+
"contracts"
|
39
|
+
end
|
40
|
+
|
41
|
+
def create(attrs = {})
|
42
|
+
attrs.symbolize_keys!
|
43
|
+
signers = attrs.delete(:signers)
|
44
|
+
attrs.assert_valid_keys(create_fields)
|
45
|
+
result = new(post("contracts.json", :contract => attrs))
|
46
|
+
if signers.present?
|
47
|
+
signers.each do |email|
|
48
|
+
result.create_signer(:email => email)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
result
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def html_url
|
56
|
+
"#{Paperlex.base_url}/contracts/#{uuid}.html?#{{:token => Paperlex.token}.to_query}"
|
57
|
+
end
|
58
|
+
|
59
|
+
# Signers
|
60
|
+
def signers=(signers)
|
61
|
+
self[:signers] = signers.map {|signer| signer.is_a?(Paperlex::Signer) ? signer : Paperlex::Signer.new(signer.merge(:contract_uuid => uuid)) }
|
62
|
+
end
|
63
|
+
|
64
|
+
def create_signer(attrs = {})
|
65
|
+
signer = Signers[uuid].create(attrs)
|
66
|
+
self.signers << signer
|
67
|
+
signer
|
68
|
+
end
|
69
|
+
|
70
|
+
def fetch_signers
|
71
|
+
self.signers = Signers[uuid].all
|
72
|
+
signers
|
73
|
+
end
|
74
|
+
|
75
|
+
def fetch_signer(signer)
|
76
|
+
remove_signer!(signer)
|
77
|
+
new_signer = Signers[uuid].find(signer)
|
78
|
+
self.signers << new_signer
|
79
|
+
new_signer
|
80
|
+
end
|
81
|
+
|
82
|
+
def update_signer(signer, attrs)
|
83
|
+
remove_signer!(signer)
|
84
|
+
updated_signer = Signers[uuid].update(signer, attrs)
|
85
|
+
self.signers << updated_signer
|
86
|
+
updated_signer
|
87
|
+
end
|
88
|
+
|
89
|
+
def delete_signer(signer)
|
90
|
+
remove_signer!(signer)
|
91
|
+
Signers[uuid].destroy(signer)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Review Sessions
|
95
|
+
def review_sessions=(review_sessions)
|
96
|
+
self[:review_sessions] = review_sessions.map {|session| session.is_a?(Paperlex::ReviewSession) ? session : Paperlex::ReviewSession.new(session.merge(:contract_uuid => uuid)) }
|
97
|
+
end
|
98
|
+
|
99
|
+
def review_sessions
|
100
|
+
self[:review_sessions] ||= []
|
101
|
+
end
|
102
|
+
|
103
|
+
def create_review_session(attrs = {})
|
104
|
+
session = ReviewSessions[uuid].create(attrs)
|
105
|
+
self.review_sessions << session
|
106
|
+
session
|
107
|
+
end
|
108
|
+
|
109
|
+
def fetch_review_sessions
|
110
|
+
self.review_sessions = ReviewSessions[uuid].all
|
111
|
+
review_sessions
|
112
|
+
end
|
113
|
+
|
114
|
+
def fetch_review_session(review_session_uuid)
|
115
|
+
remove_review_session!(review_session_uuid)
|
116
|
+
new_session = ReviewSessions[uuid].find(review_session_uuid)
|
117
|
+
self.review_sessions << new_session
|
118
|
+
new_session
|
119
|
+
end
|
120
|
+
|
121
|
+
def update_review_session(review_session_uuid, attrs)
|
122
|
+
remove_review_session!(review_session_uuid)
|
123
|
+
updated_session = ReviewSessions[uuid].update(review_session_uuid, attrs)
|
124
|
+
self.review_sessions << updated_session
|
125
|
+
updated_session
|
126
|
+
end
|
127
|
+
|
128
|
+
def delete_review_session(review_session_uuid)
|
129
|
+
remove_review_session!(review_session_uuid)
|
130
|
+
ReviewSessions[uuid].destroy(review_session_uuid)
|
131
|
+
end
|
132
|
+
|
133
|
+
# Versions
|
134
|
+
def versions
|
135
|
+
Versions[uuid].all.map {|version| Version.new(version) }
|
136
|
+
end
|
137
|
+
|
138
|
+
def at_version(version_index)
|
139
|
+
self.class.new(Versions[uuid].find(version_index))
|
140
|
+
end
|
141
|
+
alias_method :version_at, :at_version
|
142
|
+
|
143
|
+
def revert_to_version(version_index)
|
144
|
+
self.class.new(Versions[uuid].revert_to(version_index))
|
145
|
+
end
|
146
|
+
|
147
|
+
# Responses
|
148
|
+
def responses
|
149
|
+
self[:responses] ||= {}
|
150
|
+
end
|
151
|
+
|
152
|
+
def fetch_responses
|
153
|
+
self.responses = Responses[uuid].all
|
154
|
+
end
|
155
|
+
|
156
|
+
def fetch_response(key)
|
157
|
+
self.responses[key] = Responses[uuid].find(key)
|
158
|
+
end
|
159
|
+
|
160
|
+
def save_responses
|
161
|
+
Responses[uuid].update_all(responses)
|
162
|
+
end
|
163
|
+
|
164
|
+
def save_response(key)
|
165
|
+
Responses[uuid].update(key, responses[key])
|
166
|
+
end
|
167
|
+
|
168
|
+
def delete_response(key)
|
169
|
+
Responses[uuid].destroy(key)
|
170
|
+
self.responses.delete(key)
|
171
|
+
responses
|
172
|
+
end
|
173
|
+
|
174
|
+
private
|
175
|
+
|
176
|
+
def short_name
|
177
|
+
:contract
|
178
|
+
end
|
179
|
+
|
180
|
+
def remove_signer!(signer_to_remove)
|
181
|
+
signer_uuid = to_uuid(signer_to_remove)
|
182
|
+
signers.delete_if {|signer| signer['uuid'] == signer_uuid }
|
183
|
+
end
|
184
|
+
|
185
|
+
def remove_review_session!(review_session_to_remove)
|
186
|
+
review_session_uuid = to_uuid(review_session_to_remove)
|
187
|
+
review_sessions.delete_if {|review_session| review_session['uuid'] == review_session_uuid }
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Paperlex
|
2
|
+
class Slaw < Base
|
3
|
+
include RootObject
|
4
|
+
|
5
|
+
extend ActiveSupport::Autoload
|
6
|
+
autoload :Versions
|
7
|
+
|
8
|
+
property :public
|
9
|
+
property :name
|
10
|
+
property :description
|
11
|
+
property :body
|
12
|
+
property :response_keys
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def url_name
|
16
|
+
"slaws"
|
17
|
+
end
|
18
|
+
|
19
|
+
def update_fields
|
20
|
+
[:name, :body, :description]
|
21
|
+
end
|
22
|
+
alias :create_fields :update_fields
|
23
|
+
|
24
|
+
def create(attrs = {})
|
25
|
+
attrs.symbolize_keys!
|
26
|
+
attrs.assert_valid_keys(create_fields)
|
27
|
+
attrs = post(collection_url, :slaw => attrs)
|
28
|
+
new(attrs)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def html_url(responses)
|
33
|
+
params = {:token => Paperlex.token}
|
34
|
+
params[:responses] = responses if responses.present?
|
35
|
+
"#{Paperlex.base_url}/slaws/#{uuid}.html?#{params.to_query}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def destroy
|
39
|
+
self.class.delete(self.class.url_for(uuid))
|
40
|
+
end
|
41
|
+
|
42
|
+
# Versions
|
43
|
+
def versions
|
44
|
+
Paperlex::Slaw::Versions[uuid].all.map {|version| Version.new(version) }
|
45
|
+
end
|
46
|
+
|
47
|
+
def at_version(version_index)
|
48
|
+
self.class.new(Paperlex::Slaw::Versions[uuid].find(version_index))
|
49
|
+
end
|
50
|
+
alias_method :version_at, :at_version
|
51
|
+
|
52
|
+
def revert_to_version(version_index)
|
53
|
+
self.class.new(Paperlex::Slaw::Versions[uuid].revert_to(version_index))
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def short_name
|
59
|
+
:slaw
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Paperlex
|
2
|
+
class Versions < Base
|
3
|
+
class << self
|
4
|
+
def [](uuid)
|
5
|
+
new(uuid)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :uuid
|
10
|
+
|
11
|
+
def initialize(uuid)
|
12
|
+
@uuid = uuid
|
13
|
+
end
|
14
|
+
|
15
|
+
def all
|
16
|
+
self.class.get(collection_url)
|
17
|
+
end
|
18
|
+
|
19
|
+
def find(version_index)
|
20
|
+
self.class.get(url_for(version_index))
|
21
|
+
end
|
22
|
+
|
23
|
+
def revert_to(version_index)
|
24
|
+
self.class.post("#{base}/#{uuid}/versions/#{version_index}/revert.json")
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def collection_url
|
30
|
+
"#{base}/#{uuid}/versions.json"
|
31
|
+
end
|
32
|
+
|
33
|
+
def url_for(version_index)
|
34
|
+
"#{base}/#{uuid}/versions/#{version_index}.json"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/paperlex.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'active_support/dependencies/autoload'
|
2
|
+
require 'active_support/concern'
|
3
|
+
require 'active_support/core_ext/module/delegation'
|
4
|
+
require 'active_support/core_ext/hash/keys'
|
5
|
+
require 'active_support/core_ext/object/to_query'
|
6
|
+
require 'active_support/core_ext/object/blank'
|
7
|
+
require 'hashie/dash'
|
8
|
+
require 'rest-client'
|
9
|
+
require 'json'
|
10
|
+
require 'configatron'
|
11
|
+
|
12
|
+
module Paperlex
|
13
|
+
extend ActiveSupport::Autoload
|
14
|
+
|
15
|
+
autoload_under 'base' do
|
16
|
+
autoload :Base
|
17
|
+
autoload :RootObject
|
18
|
+
autoload :SubObject
|
19
|
+
end
|
20
|
+
autoload :Contract
|
21
|
+
autoload :Slaw
|
22
|
+
autoload :ReviewSession
|
23
|
+
autoload :Signer
|
24
|
+
autoload :Versions
|
25
|
+
|
26
|
+
class Version < Hashie::Dash
|
27
|
+
property :version, :required => true
|
28
|
+
property :event, :required => true
|
29
|
+
end
|
30
|
+
|
31
|
+
SANDBOX_URL = 'https://sandbox.api.paperlex.com/v1'
|
32
|
+
LIVE_URL = 'https://api.paperlex.com/v1'
|
33
|
+
|
34
|
+
class << self
|
35
|
+
delegate :configure_from_hash, :base_url, :token, :base_url=, :token=, :to => :configatron
|
36
|
+
|
37
|
+
def live!
|
38
|
+
self.base_url = LIVE_URL
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
configatron.set_default(:base_url, SANDBOX_URL)
|
43
|
+
configatron.set_default(:token, nil)
|
44
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'paperlex'
|
metadata
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: paperlex
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Paperlex
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-11-30 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rest-client
|
16
|
+
requirement: &70306626911860 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70306626911860
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: hashie
|
27
|
+
requirement: &70306626908260 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70306626908260
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: json
|
38
|
+
requirement: &70306626907380 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70306626907380
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: configatron
|
49
|
+
requirement: &70306626904780 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70306626904780
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: activesupport
|
60
|
+
requirement: &70306626903080 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 3.0.0
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70306626903080
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: &70306626901940 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70306626901940
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: faker
|
82
|
+
requirement: &70306626900680 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70306626900680
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: fakeweb
|
93
|
+
requirement: &70306626899580 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *70306626899580
|
102
|
+
description: Dead-simple Legal Documents
|
103
|
+
email:
|
104
|
+
- api-help@paperlex.com
|
105
|
+
executables: []
|
106
|
+
extensions: []
|
107
|
+
extra_rdoc_files: []
|
108
|
+
files:
|
109
|
+
- lib/paperlex/base/base.rb
|
110
|
+
- lib/paperlex/base/root_object.rb
|
111
|
+
- lib/paperlex/base/sub_object.rb
|
112
|
+
- lib/paperlex/contract/responses.rb
|
113
|
+
- lib/paperlex/contract/review_sessions.rb
|
114
|
+
- lib/paperlex/contract/signers.rb
|
115
|
+
- lib/paperlex/contract/versions.rb
|
116
|
+
- lib/paperlex/contract.rb
|
117
|
+
- lib/paperlex/review_session.rb
|
118
|
+
- lib/paperlex/signer.rb
|
119
|
+
- lib/paperlex/slaw/versions.rb
|
120
|
+
- lib/paperlex/slaw.rb
|
121
|
+
- lib/paperlex/version.rb
|
122
|
+
- lib/paperlex/versions.rb
|
123
|
+
- lib/paperlex.rb
|
124
|
+
- lib/paperlex_api_client.rb
|
125
|
+
- lib/tasks/paperlex_api_client_tasks.rake
|
126
|
+
- MIT-LICENSE
|
127
|
+
- Rakefile
|
128
|
+
- README.rdoc
|
129
|
+
homepage: https://api.paperlex.com/
|
130
|
+
licenses: []
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
none: false
|
137
|
+
requirements:
|
138
|
+
- - ! '>='
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ! '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubyforge_project:
|
149
|
+
rubygems_version: 1.8.10
|
150
|
+
signing_key:
|
151
|
+
specification_version: 3
|
152
|
+
summary: A Paperlex API client in Ruby
|
153
|
+
test_files: []
|