clicksign-api 1.1.0.alpha2 → 1.1.0.alpha6

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
  SHA256:
3
- metadata.gz: 35e2042ab4a9a94f3159c1b56192f92db15a84f301de3c9e9fa8bfe0be7d447a
4
- data.tar.gz: a26c118f1a234525a17a2f6f210ef95eef1112b5405956512e2a5d7b8437f19f
3
+ metadata.gz: 12d78c1e1512951c7213b73440679297f738376895698654fd8580a8a0290cf7
4
+ data.tar.gz: d899a9ac359212534f3e75a2d77bbe0f0c6e9e01f534a668ce8161e3b7d52d71
5
5
  SHA512:
6
- metadata.gz: 901d00b80482587ac7a89af935331109cae51e31e7879d51993e64b5a3ff99214692e124f66478079be84ba1d795837e23502075d9a04738c92ac50014c8fd33
7
- data.tar.gz: 6d32615a4a4dd3e37e73a1190f29ca572a446da50063a51e198bbad5dc8ec4b23a82e4256de6df5b3634f70c6021f42964c10b012b46d7a1cc3aeff27f7a3b31
6
+ metadata.gz: af14c66c6e4a1a5cb8471c0dcc32072e889381aaa815ad65c89b63e6fb830ab48514338f0465d96cd8f6bed8f804cd0ae997abc5056702a4946a9bc67abac6b8
7
+ data.tar.gz: e66b3372d2204d83917c65974e6eef811ab4c049cd242b2858dc15a2a8f1a16a2e4571cdbedd31502309be4a654f8e3d2e82add6617c31d929b1f803dc9424c1
data/CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ # Clicksign::API 1.1.0 (Octuber 29, 2021)
2
+
3
+ Add support to multiple credentials.
4
+ This is useful to work with different environments, providing flexibility.
5
+ For example, applications have different tokens for each environment.
6
+ Other useful case, occurs working with multiple companies.
7
+
8
+ The credentials should be a hash.
9
+ It is possible use a `.yml` file to configure the authentication tokens.
10
+ The `.yml` file can get the tokens using environment variables.
11
+ Now all requests receive token parameter, that represents the key associated with the token.
12
+
13
+ ## Examples:
14
+
15
+ YML file
16
+ ```ruby
17
+ => key.production: ENV['CLICKSIGN_ACCESS_TOKEN_PRODUCTION']
18
+ => key.sandbox: ENV['CLICKSIGN_ACCESS_TOKEN_SANDBOX']
19
+ ```
20
+
21
+ Request:
22
+ ```ruby
23
+ => file = File.open('/path/to/file/local/file.pdf', 'r')
24
+ => response = Clicksign::API::Document.create( params: { path: '/path/to/file/on/clicksign.pdf', file: file }, token: 'key.production')
25
+ ```
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clicksign-api (1.1.0.alpha2)
4
+ clicksign-api (1.1.0.alpha6)
5
5
  faraday
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -26,8 +26,14 @@ Or install it yourself as:
26
26
  By default, all requests use Clicksign's SANDBOX.
27
27
 
28
28
  ```ruby
29
+ credentials = {
30
+ "key.production" => ENV["CLICKSIGN_ACCESS_TOKEN_PRODUCTION"]
31
+ "key.sandbox" => ENV["CLICKSIGN_ACCESS_TOKEN_SANDBOX"]
32
+ }
33
+
29
34
  Clicksign::API.configure do |config|
30
- config.access_token = ENV['CLICKSIGN_ACCESS_TOKEN']
35
+ config.credentials = credentials
36
+ config.production = false
31
37
  end
32
38
  ```
33
39
 
@@ -47,41 +53,102 @@ To see all available parameters, please, check the [API docs](https://developers
47
53
  #### Create documents
48
54
 
49
55
  ```ruby
50
- response = Clicksign::API::Document.create(path: '/path/to/file.pdf', file: file)
56
+ file = File.open('/path/to/file/local/file.pdf', 'r')
57
+ document = Clicksign::API::Document.create( params: { path: '/path/to/file/on/clicksign.pdf', file: file }, token: 'valid_token')
51
58
  => #<Faraday::Response ...>
52
59
 
53
- response.success?
60
+ document.success?
54
61
  => true # false
55
62
 
56
- JSON.parse(response.body)
63
+ response_document = JSON.parse(document.body)
57
64
  => {:document=> {:key=> '...', :path=> '...', :status => '...', ... }
65
+ => # key: '123abcd' as example!
58
66
  ```
59
67
 
60
68
  #### View documents
61
69
 
62
70
  ```ruby
63
- response = Clicksign::API::Document.find('DOCUMENT_KEY')
71
+ find_document = Clicksign::API::Document.find(params: { key: response_document['document']['key'] }, token: 'valid_token')
64
72
  => #<Faraday::Response ...>
65
73
 
66
- response.success?
74
+ find_document.success?
67
75
  => true # false
68
76
 
69
- JSON.parse(response.body)
77
+ JSON.parse(find_document.body)
70
78
  => {:document=> {:key=> '...', :path=> '...', :status => '...', ... }
71
79
  ```
72
80
 
73
- #### Add signers
81
+ #### Create Signers
74
82
 
75
83
  ```ruby
76
- response = Clicksign::API::Signer.create('DOCUMENT_KEY', signer)
84
+ signer = Clicksign::API::Signer.create(params: { email: 'mail@email.com', auths: ['email'], delivery: 'email' }, token: 'valid_token')
77
85
  => #<Faraday::Response ...>
78
86
 
79
- response.success?
87
+ signer.success?
80
88
  => true # false
81
89
 
82
- JSON.parse(response.body)
90
+ response_signer = JSON.parse(signer.body)
83
91
  => {:document=> {:key=> '...', :path=> '...', :status => '...', ... }
92
+ => # signer_key: '999poo' as example!
84
93
  ```
94
+ #### Add Signers to Document
95
+
96
+ ```ruby
97
+
98
+ signer_document = Clicksign::API::DocumentsSigners.create(params: { document_key: response_document['document']['key'], signer_key: response_signer['key'], sign_as: 'sign_as' }, token: 'valid_token')
99
+ => #<Faraday::Response ...>
100
+
101
+ signer_document.success?
102
+ => true # false
103
+
104
+ response_signer_document = JSON.parse(signer_document.body)
105
+ => {:document=> {:key=> '...', :path=> '...', :status => '...', ... }
106
+ ```
107
+
108
+ ##### Creating Documents in Batches
109
+
110
+ ```ruby
111
+
112
+ batch = Clicksign::API::Batch.create(params: { document_keys: [response_document['document']['key'], 'other_document_key'], signer_key: response_signer['key'], summary: true}, token: 'valid_token')
113
+ => #<Faraday::Response ...>
114
+
115
+ batch.success?
116
+ => true # false
117
+
118
+ rseponse_batch = JSON.parse(batch.body)
119
+ => #{"batch"=> {"key"=>"3dd7fa89-15f7-48b6-81e8-7d14a273bbb8"
120
+
121
+ ```
122
+ #### Notifying Signer by e-mail
123
+
124
+ ```ruby
125
+ request_signature_key = JSON.parse(response_document_above.body)['document']['signers'].first['request_signature_key']
126
+ notify = Clicksign::API::Notifier.notify(params: { request_signature_key: request_signature_key }, token: 'valid_token')
127
+ => #<Faraday::Response ...>
128
+
129
+ notify.success?
130
+ => true # false
131
+
132
+ JSON.parse(notify.body)
133
+ => ##<struct Faraday::Env, method=:post request_body="{\"request_signature_key\":
134
+
135
+ ```
136
+
137
+ #### Notifying Signer by whatsapp
138
+
139
+ ```ruby
140
+ => # To deliver this content, its necessary add `phone_number` on Signer
141
+
142
+ request_signature_key = JSON.parse(response_document_above.body)['document']['signers'].first['request_signature_key']
143
+ notify = Clicksign::API::Notifier.notify(params: { request_signature_key: request_signature_key }, token: 'valid_token')
144
+ => #<Faraday::Response ...>
145
+
146
+ notify.success?
147
+ => true # false
148
+
149
+ JSON.parse(notify.body)
150
+ => ##<struct Faraday::Env, method=:post request_body="{\"request_signature_key\":
151
+
85
152
 
86
153
  ## Development
87
154
 
@@ -16,6 +16,8 @@ module Clicksign
16
16
  end
17
17
 
18
18
  def body(params)
19
+ params = params.transform_keys(&:to_sym)
20
+
19
21
  batch = ATTRIBUTES.each.with_object({}) do |attribute, hash|
20
22
  hash[attribute] = params[attribute] if params.has_key?(attribute)
21
23
  end
@@ -11,8 +11,8 @@ module Clicksign
11
11
  post(REQUEST_PATH, body(params), token)
12
12
  end
13
13
 
14
- def find(token:, key:)
15
- get(REQUEST_PATH + key, token)
14
+ def find(token:, params:)
15
+ get(REQUEST_PATH + params[:key], token)
16
16
  end
17
17
 
18
18
  def body(params)
@@ -24,6 +24,8 @@ module Clicksign
24
24
  end
25
25
 
26
26
  def body(params)
27
+ params = params.transform_keys(&:to_sym)
28
+
27
29
  list = ATTRIBUTES.each.with_object({}) do |key, hash|
28
30
  hash[key] = params[key] if params.has_key?(key)
29
31
  end
@@ -16,6 +16,8 @@ module Clicksign
16
16
  end
17
17
 
18
18
  def body(params)
19
+ params = params.transform_keys(&:to_sym)
20
+
19
21
  ATTRIBUTES.each.with_object({}) do |attribute, hash|
20
22
  hash[attribute] = params[attribute] if params.has_key?(attribute)
21
23
  end
@@ -19,6 +19,8 @@ module Clicksign
19
19
  end
20
20
 
21
21
  def body(params)
22
+ params = params.transform_keys(&:to_sym)
23
+
22
24
  signer = ATTRIBUTES.each.with_object({}) do |key, hash|
23
25
  hash[key] = params[key] if params.has_key?(key)
24
26
  end
@@ -1,5 +1,5 @@
1
1
  module Clicksign
2
2
  module API
3
- VERSION = "1.1.0.alpha2"
3
+ VERSION = "1.1.0.alpha6"
4
4
  end
5
5
  end
@@ -16,6 +16,8 @@ module Clicksign
16
16
  end
17
17
 
18
18
  def body(params)
19
+ params = params.transform_keys(&:to_sym)
20
+
19
21
  ATTRIBUTES.each.with_object({}) do |attribute, hash|
20
22
  hash[attribute] = params[attribute] if params.has_key?(attribute)
21
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clicksign-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.alpha2
4
+ version: 1.1.0.alpha6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francisco Martins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-27 00:00:00.000000000 Z
11
+ date: 2021-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -163,6 +163,7 @@ files:
163
163
  - ".ruby-gemset"
164
164
  - ".ruby-version"
165
165
  - ".travis.yml"
166
+ - CHANGELOG.md
166
167
  - Gemfile
167
168
  - Gemfile.lock
168
169
  - README.md
@@ -197,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
198
  - !ruby/object:Gem::Version
198
199
  version: 1.3.1
199
200
  requirements: []
200
- rubygems_version: 3.0.3
201
+ rubygems_version: 3.1.6
201
202
  signing_key:
202
203
  specification_version: 4
203
204
  summary: Clicksign API ruby interface