esignlive 0.1.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 690f9fc0393b137aa929588d75311ffc286dca3f
4
+ data.tar.gz: 323c49e69175515eb0e8c24ada6f61ccb387723d
5
+ SHA512:
6
+ metadata.gz: 05a7a8ce0cd291f2b9209184e8cf49cde51c42d3d78c6d9d403cdf73c7ee158678de97874afaf349d583e3fe8f829a921c4336877459db0993453d4e5b404c15
7
+ data.tar.gz: c3c702289879dd6e7bf04d8269832d7d578e233afa36438f08632269a2f535b61a0d1365f378e92f3570340823ac676ca32929864011674822c4e5e8faed1d92
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016 Bo Jacobson
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.md ADDED
@@ -0,0 +1,82 @@
1
+ #eSignLive Client
2
+
3
+ [![Build Status](https://travis-ci.org/bjacobson26/esignlive.svg?branch=master)](https://travis-ci.org/bjacobson26/esignlive)
4
+ [![Code Climate](https://codeclimate.com/github/bjacobson26/esignlive/badges/gpa.svg)](https://codeclimate.com/github/bjacobson26/esignlive)
5
+
6
+ ## Usage
7
+
8
+ ###Create a client
9
+
10
+ ```ruby
11
+ client = ESignLive::Client.new(api_key: your_api_key)
12
+ ```
13
+ ###Make some API calls
14
+
15
+ #####Get all packages in your account
16
+ ```ruby
17
+ packages = client.get_packages
18
+ ```
19
+
20
+ #####Get a package:
21
+ ```ruby
22
+ package = client.get_package(package_id: your_package_id)
23
+ ```
24
+ #####API Calls
25
+ - authentication_token(package_id:)
26
+ - sender_authentication_token(package_id:)
27
+ - signer_authentication_token(signer_id:,package_id:)
28
+ - get_packages
29
+ - get_package(package_id:)
30
+ - get_signing_status(package_id:)
31
+ - get_document(package_id: document_id:, pdf: false)
32
+ - get_roles(package_id)
33
+ - update_role_signer(package_id:, role_id:, email:, first_name:, last_name:)
34
+ - create_package(opts={})
35
+ - create_package_from_template(template_id:, opts: {})
36
+ - send_package(package_id:)
37
+ - signing_url(package_id:, role_id:)
38
+ - remove_document_from_package(document_id:, package_id:)
39
+
40
+ ## Installation
41
+ Add this line to your application's Gemfile:
42
+
43
+ ```ruby
44
+ gem 'esignlive'
45
+ ```
46
+
47
+ And then execute:
48
+
49
+ ```bash
50
+ $ bundle
51
+ ```
52
+
53
+ Or install it yourself as:
54
+
55
+ ```bash
56
+ $ gem install esignlive
57
+ ```
58
+
59
+ ## Contributing
60
+ ####Submit a pull request
61
+
62
+ 1. Fork the repo.
63
+
64
+ 2. Push to your fork and submit a pull request.
65
+
66
+
67
+ ####Syntax:
68
+
69
+ - Two spaces, no tabs.
70
+ - No trailing whitespace. Blank lines should not have any space.
71
+ - Prefer &&, || over and, or.
72
+ - MyClass.my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
73
+ - a = b and not a=b.
74
+ - Follow the conventions you see used in the source already.
75
+
76
+
77
+ ##TODO
78
+ - More API calls
79
+ - Tests
80
+
81
+ ## License
82
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Esignlivefairy'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
data/lib/esignlive.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'esignlive/client'
2
+ module ESignLive
3
+ # Your code goes here...
4
+ end
@@ -0,0 +1,176 @@
1
+ require 'httparty'
2
+
3
+ module ESignLive
4
+ module API
5
+ module Calls
6
+ URL = "https://sandbox.esignlive.com/api/packages"
7
+ AUTH_URL = "https://sandbox.esignlive.com/api/authenticationTokens"
8
+ SENDER_AUTH_URL = "https://sandbox.esignlive.com/api/senderAuthenticationTokens"
9
+ SIGNER_AUTH_URL = "https://sandbox.esignlive.com/api/signerAuthenticationTokens"
10
+ PACKAGE_DEFAULTS = {
11
+ name: "New Package #{Time.now}",
12
+ language: "en",
13
+ email_message: "Documents to sign!",
14
+ description: "Document(s) require your signature",
15
+ visibility: "ACCOUNT",
16
+ settings: {
17
+ ceremony: {
18
+ inPerson: false
19
+ }
20
+ },
21
+ autocomplete: true
22
+ }
23
+
24
+ def authentication_token(package_id:)
25
+ ::HTTParty.post(
26
+ AUTH_URL,
27
+ body: { packageId: package_id }.to_json,
28
+ headers: headers
29
+ ).parsed_response
30
+ end
31
+
32
+ def sender_authentication_token(package_id:)
33
+ ::HTTParty.post(
34
+ SENDER_AUTH_URL,
35
+ body: { packageId: package_id }.to_json,
36
+ headers: headers
37
+ ).parsed_response
38
+ end
39
+
40
+ def signer_authentication_token(signer_id:, package_id:)
41
+ ::HTTParty.post(
42
+ SIGNER_AUTH_URL,
43
+ body: {
44
+ signerId: signer_id,
45
+ sipackageId: package_id
46
+ }.to_json,
47
+ headers: headers
48
+ ).parsed_response
49
+ end
50
+
51
+ def get_packages
52
+ ::HTTParty.get(
53
+ URL,
54
+ headers: headers
55
+ ).parsed_response
56
+ end
57
+
58
+ def get_package(package_id:)
59
+ ::HTTParty.get(
60
+ "#{URL}/#{package_id}",
61
+ headers: headers
62
+ ).parsed_response
63
+ end
64
+
65
+ def get_signing_status(package_id:)
66
+ ::HTTParty.get(
67
+ "#{URL}/#{package_id}/signingStatus",
68
+ headers: headers
69
+ ).parsed_response
70
+ end
71
+
72
+ def get_document(package_id:, document_id:, pdf: false)
73
+ endpoint = "#{URL}/#{package_id}/documents/#{document_id}"
74
+ pdf ? url = "#{endpoint}/pdf" : url = endpoint
75
+ ::HTTParty.get(
76
+ url,
77
+ headers: headers
78
+ ).parsed_response
79
+ end
80
+
81
+ def get_roles(package_id:)
82
+ ::HTTParty.get(
83
+ "#{URL}/#{package_id}/roles",
84
+ headers: headers
85
+ ).parsed_response["results"]
86
+ end
87
+
88
+ def get_role(package_id:, role_id:)
89
+ ::HTTParty.get(
90
+ "#{URL}/#{package_id}/roles/#{role_id}",
91
+ headers: headers
92
+ ).parsed_response
93
+ end
94
+
95
+ def update_role_signer(package_id:, role_id:, email:, first_name:, last_name:)
96
+ body = {
97
+ signers: [
98
+ {
99
+ email: email,
100
+ firstName: first_name,
101
+ lastName: last_name
102
+ }
103
+ ]
104
+ }
105
+ ::HTTParty.put(
106
+ "#{URL}/#{package_id}/roles/#{role_id}",
107
+ body: body.to_json,
108
+ headers: headers
109
+ ).parsed_response
110
+ end
111
+
112
+ def create_package(opts: {})
113
+ body = package_hash(opts)
114
+ if opts[:sender].is_a? Hash
115
+ sender_hash = {
116
+ sender: {
117
+ lastName: sender_opts[:last_name],
118
+ firstName: sender_opts[:first_name],
119
+ email: sender_opts[:email]
120
+ }
121
+ }
122
+ body.merge!(sender_hash)
123
+ end
124
+ ::HTTParty.post(
125
+ URL,
126
+ body: body.to_json,
127
+ headers: headers
128
+ ).parsed_response
129
+ end
130
+
131
+ def create_package_from_template(template_id:, opts: {})
132
+ ::HTTParty.post(
133
+ "https://sandbox.esignlive.com/api/packages/#{template_id}/clone",
134
+ headers: headers,
135
+ body: package_hash(opts).to_json
136
+ ).parsed_response
137
+ end
138
+
139
+ def send_package(package_id:)
140
+ ::HTTParty.post(
141
+ "#{URL}/#{package_id}",
142
+ body: { status: "SENT" }.to_json,
143
+ headers: headers
144
+ )
145
+ true
146
+ end
147
+
148
+ def remove_document_from_package(document_id:, package_id:)
149
+ ::HTTParty.delete(
150
+ "#{URL}/#{package_id}/documents/#{document_id}",
151
+ headers: headers
152
+ ).parsed_response
153
+ end
154
+
155
+ def signing_url(package_id:, role_id:)
156
+ ::HTTParty.get(
157
+ "#{URL}/#{package_id}/roles/#{role_id}/signingUrl",
158
+ headers: headers
159
+ ).parsed_response["url"]
160
+ end
161
+
162
+ def package_hash(opts)
163
+ {
164
+ type: "PACKAGE",
165
+ name: opts[:name] || PACKAGE_DEFAULTS[:name],
166
+ language: opts[:language] || PACKAGE_DEFAULTS[:language],
167
+ emailMessage: opts[:email_message] || PACKAGE_DEFAULTS[:email_message],
168
+ description: opts[:description] || PACKAGE_DEFAULTS[:description],
169
+ autocomplete: opts[:autocomplete] || PACKAGE_DEFAULTS[:autocomplete],
170
+ settings: opts[:settings] || PACKAGE_DEFAULTS[:settings],
171
+ visibility: opts[:visibility] || PACKAGE_DEFAULTS[:visibility]
172
+ }
173
+ end
174
+ end
175
+ end
176
+ end
@@ -0,0 +1,22 @@
1
+ require 'esignlive/api/calls'
2
+
3
+ module ESignLive
4
+ class Client
5
+ include ESignLive::API::Calls
6
+
7
+ attr_reader :headers
8
+
9
+ def initialize(api_key:)
10
+ @headers = create_headers(api_key)
11
+ end
12
+
13
+ private
14
+
15
+ def create_headers(api_key)
16
+ {
17
+ 'Content-Type' => 'application/json',
18
+ 'Authorization' => "Basic #{api_key}"
19
+ }
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module ESignLive
2
+ VERSION = '0.1.1'
3
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: esignlive
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Bo Jacobson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-10-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.14.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.14.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.5'
41
+ description: A Ruby interface to the eSignLive REST API
42
+ email:
43
+ - bjacobson26@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - README.md
50
+ - Rakefile
51
+ - lib/esignlive.rb
52
+ - lib/esignlive/api/calls.rb
53
+ - lib/esignlive/client.rb
54
+ - lib/esignlive/version.rb
55
+ homepage: https://github.com/bjacobson26/esignlive
56
+ licenses:
57
+ - MIT
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 2.5.1
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: A Ruby client for eSignLive's REST API
79
+ test_files: []