esignlive 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 690f9fc0393b137aa929588d75311ffc286dca3f
4
- data.tar.gz: 323c49e69175515eb0e8c24ada6f61ccb387723d
3
+ metadata.gz: 3b6052fda556ba79a06d5be1b9d37aecc7e55ef0
4
+ data.tar.gz: d646262e661ded581bda9fba5111550a55f714ad
5
5
  SHA512:
6
- metadata.gz: 05a7a8ce0cd291f2b9209184e8cf49cde51c42d3d78c6d9d403cdf73c7ee158678de97874afaf349d583e3fe8f829a921c4336877459db0993453d4e5b404c15
7
- data.tar.gz: c3c702289879dd6e7bf04d8269832d7d578e233afa36438f08632269a2f535b61a0d1365f378e92f3570340823ac676ca32929864011674822c4e5e8faed1d92
6
+ metadata.gz: e2cbc4bc07b05fc13d0121b3c7caefd644e16fa58285e10b3ce3d45febf9e600063f5f8694d72eb2fbe7fb0a77f66f7e86dd7dab7ba5d58fee969a0a0068f313
7
+ data.tar.gz: 49972629fd941e446fa2aeb7bfee4b1de7a732690eb8d3e8ea27063c5e69673e6237a1024b86df7367463951f07a28f749d24b77bfe939e12a3273af1fc3ac9e
data/README.md CHANGED
@@ -2,14 +2,23 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/bjacobson26/esignlive.svg?branch=master)](https://travis-ci.org/bjacobson26/esignlive)
4
4
  [![Code Climate](https://codeclimate.com/github/bjacobson26/esignlive/badges/gpa.svg)](https://codeclimate.com/github/bjacobson26/esignlive)
5
+ [![Gem Version](https://badge.fury.io/rb/esignlive.svg)](https://badge.fury.io/rb/esignlive)
5
6
 
6
7
  ## Usage
7
8
 
8
9
  ###Create a client
9
10
 
10
11
  ```ruby
11
- client = ESignLive::Client.new(api_key: your_api_key)
12
+ client = ESignLive::Client.new(api_key: your_api_key, environment: 'sandbox')
12
13
  ```
14
+
15
+ For production:
16
+
17
+ ```ruby
18
+ client = ESignLive::Client.new(api_key: your_api_key, environment: 'production')
19
+ ```
20
+
21
+
13
22
  ###Make some API calls
14
23
 
15
24
  #####Get all packages in your account
@@ -3,10 +3,6 @@ require 'httparty'
3
3
  module ESignLive
4
4
  module API
5
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
6
  PACKAGE_DEFAULTS = {
11
7
  name: "New Package #{Time.now}",
12
8
  language: "en",
@@ -23,7 +19,7 @@ module ESignLive
23
19
 
24
20
  def authentication_token(package_id:)
25
21
  ::HTTParty.post(
26
- AUTH_URL,
22
+ "#{url}/authenticationTokens",
27
23
  body: { packageId: package_id }.to_json,
28
24
  headers: headers
29
25
  ).parsed_response
@@ -31,7 +27,7 @@ module ESignLive
31
27
 
32
28
  def sender_authentication_token(package_id:)
33
29
  ::HTTParty.post(
34
- SENDER_AUTH_URL,
30
+ "#{url}/senderAuthenticationTokens",
35
31
  body: { packageId: package_id }.to_json,
36
32
  headers: headers
37
33
  ).parsed_response
@@ -39,7 +35,7 @@ module ESignLive
39
35
 
40
36
  def signer_authentication_token(signer_id:, package_id:)
41
37
  ::HTTParty.post(
42
- SIGNER_AUTH_URL,
38
+ "#{url}/signerAuthenticationTokens",
43
39
  body: {
44
40
  signerId: signer_id,
45
41
  sipackageId: package_id
@@ -50,27 +46,27 @@ module ESignLive
50
46
 
51
47
  def get_packages
52
48
  ::HTTParty.get(
53
- URL,
49
+ "#{url}/packages",
54
50
  headers: headers
55
51
  ).parsed_response
56
52
  end
57
53
 
58
54
  def get_package(package_id:)
59
55
  ::HTTParty.get(
60
- "#{URL}/#{package_id}",
56
+ "#{url}/packages/#{package_id}",
61
57
  headers: headers
62
58
  ).parsed_response
63
59
  end
64
60
 
65
61
  def get_signing_status(package_id:)
66
62
  ::HTTParty.get(
67
- "#{URL}/#{package_id}/signingStatus",
63
+ "#{url}/packages/#{package_id}/signingStatus",
68
64
  headers: headers
69
65
  ).parsed_response
70
66
  end
71
67
 
72
68
  def get_document(package_id:, document_id:, pdf: false)
73
- endpoint = "#{URL}/#{package_id}/documents/#{document_id}"
69
+ endpoint = "#{url}/packages/#{package_id}/documents/#{document_id}"
74
70
  pdf ? url = "#{endpoint}/pdf" : url = endpoint
75
71
  ::HTTParty.get(
76
72
  url,
@@ -80,14 +76,14 @@ module ESignLive
80
76
 
81
77
  def get_roles(package_id:)
82
78
  ::HTTParty.get(
83
- "#{URL}/#{package_id}/roles",
79
+ "#{url}/packages/#{package_id}/roles",
84
80
  headers: headers
85
81
  ).parsed_response["results"]
86
82
  end
87
83
 
88
84
  def get_role(package_id:, role_id:)
89
85
  ::HTTParty.get(
90
- "#{URL}/#{package_id}/roles/#{role_id}",
86
+ "#{url}/packages/#{package_id}/roles/#{role_id}",
91
87
  headers: headers
92
88
  ).parsed_response
93
89
  end
@@ -103,7 +99,7 @@ module ESignLive
103
99
  ]
104
100
  }
105
101
  ::HTTParty.put(
106
- "#{URL}/#{package_id}/roles/#{role_id}",
102
+ "#{url}/packages/#{package_id}/roles/#{role_id}",
107
103
  body: body.to_json,
108
104
  headers: headers
109
105
  ).parsed_response
@@ -122,7 +118,7 @@ module ESignLive
122
118
  body.merge!(sender_hash)
123
119
  end
124
120
  ::HTTParty.post(
125
- URL,
121
+ "#{url}/packages",
126
122
  body: body.to_json,
127
123
  headers: headers
128
124
  ).parsed_response
@@ -130,7 +126,7 @@ module ESignLive
130
126
 
131
127
  def create_package_from_template(template_id:, opts: {})
132
128
  ::HTTParty.post(
133
- "https://sandbox.esignlive.com/api/packages/#{template_id}/clone",
129
+ "#{url}/packages/#{template_id}/clone",
134
130
  headers: headers,
135
131
  body: package_hash(opts).to_json
136
132
  ).parsed_response
@@ -138,7 +134,7 @@ module ESignLive
138
134
 
139
135
  def send_package(package_id:)
140
136
  ::HTTParty.post(
141
- "#{URL}/#{package_id}",
137
+ "#{url}/packages/#{package_id}",
142
138
  body: { status: "SENT" }.to_json,
143
139
  headers: headers
144
140
  )
@@ -147,18 +143,20 @@ module ESignLive
147
143
 
148
144
  def remove_document_from_package(document_id:, package_id:)
149
145
  ::HTTParty.delete(
150
- "#{URL}/#{package_id}/documents/#{document_id}",
146
+ "#{url}/packages/#{package_id}/documents/#{document_id}",
151
147
  headers: headers
152
148
  ).parsed_response
153
149
  end
154
150
 
155
151
  def signing_url(package_id:, role_id:)
156
152
  ::HTTParty.get(
157
- "#{URL}/#{package_id}/roles/#{role_id}/signingUrl",
153
+ "#{url}/packages/#{package_id}/roles/#{role_id}/signingUrl",
158
154
  headers: headers
159
155
  ).parsed_response["url"]
160
156
  end
161
157
 
158
+ private
159
+
162
160
  def package_hash(opts)
163
161
  {
164
162
  type: "PACKAGE",
@@ -4,10 +4,24 @@ module ESignLive
4
4
  class Client
5
5
  include ESignLive::API::Calls
6
6
 
7
- attr_reader :headers
7
+ attr_reader :headers, :environment
8
8
 
9
- def initialize(api_key:)
9
+ VALID_ENVIRONMENTS = %w(sandbox production)
10
+
11
+
12
+ def initialize(api_key:, environment: "sandbox")
13
+ check_environment(environment)
10
14
  @headers = create_headers(api_key)
15
+ @environment = environment
16
+ end
17
+
18
+ def url
19
+ if environment == "sandbox"
20
+ "https://sandbox.esignlive.com/api"
21
+ elsif environment == "production"
22
+ "https://apps.esignlive.com/api"
23
+ else
24
+ end
11
25
  end
12
26
 
13
27
  private
@@ -18,5 +32,13 @@ module ESignLive
18
32
  'Authorization' => "Basic #{api_key}"
19
33
  }
20
34
  end
35
+
36
+ def check_environment(env)
37
+ unless VALID_ENVIRONMENTS.include?(env)
38
+ raise EnvironmentError.new("environment must be set to 'sandbox' or 'production'")
39
+ end
40
+ end
41
+
42
+ class EnvironmentError < StandardError ; end
21
43
  end
22
44
  end
@@ -1,3 +1,3 @@
1
1
  module ESignLive
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esignlive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bo Jacobson
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.14.0
19
+ version: '0.13'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.14.0
26
+ version: '0.13'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement