clicksign-api 1.1.0.alpha → 1.1.0.alpha5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +25 -0
- data/Gemfile.lock +1 -1
- data/README.md +78 -11
- data/lib/clicksign/api/batch.rb +2 -0
- data/lib/clicksign/api/document.rb +5 -3
- data/lib/clicksign/api/documents_signers.rb +2 -0
- data/lib/clicksign/api/notifier.rb +2 -0
- data/lib/clicksign/api/signer.rb +3 -1
- data/lib/clicksign/api/version.rb +1 -1
- data/lib/clicksign/api/whatsapp_notifier.rb +2 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 838efe4044fec37ce55e6a4b18a9c2a2afb69eba26bef730f33ff7b7cd305671
|
4
|
+
data.tar.gz: '094afed7fb78afd56753d16235363668fee91330242d342a0d503a93346cf58f'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25c60f502a51735dea50a60c9f41270a2af592a54fd2eab3f7a1df5974b69bd608dd569e19d32e560b39f1526e71e52bb1173c5b4f6a3e68cddce704b2d86f9a
|
7
|
+
data.tar.gz: c88cb03ad8887973c12b5255c5c878542cf04ca43499473aef6c1e86b9352510121295b47ba316d96a2b57a4dcf07f8b2d6e489889ce330eb40d57606c8402a7
|
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
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.
|
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
|
-
|
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
|
-
|
60
|
+
document.success?
|
54
61
|
=> true # false
|
55
62
|
|
56
|
-
JSON.parse(
|
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
|
-
|
71
|
+
find_document = Clicksign::API::Document.find(params: { key: response_document['document']['key'] }, token: 'valid_token')
|
64
72
|
=> #<Faraday::Response ...>
|
65
73
|
|
66
|
-
|
74
|
+
find_document.success?
|
67
75
|
=> true # false
|
68
76
|
|
69
|
-
JSON.parse(
|
77
|
+
JSON.parse(find_document.body)
|
70
78
|
=> {:document=> {:key=> '...', :path=> '...', :status => '...', ... }
|
71
79
|
```
|
72
80
|
|
73
|
-
####
|
81
|
+
#### Create Signers
|
74
82
|
|
75
83
|
```ruby
|
76
|
-
|
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
|
-
|
87
|
+
signer.success?
|
80
88
|
=> true # false
|
81
89
|
|
82
|
-
JSON.parse(
|
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
|
|
data/lib/clicksign/api/batch.rb
CHANGED
@@ -4,18 +4,20 @@ module Clicksign
|
|
4
4
|
extend Requests
|
5
5
|
|
6
6
|
REQUEST_PATH = '/api/v1/documents/'
|
7
|
-
ATTRIBUTES = [:path, :deadline_at, :auto_close, :locale]
|
7
|
+
ATTRIBUTES = [:path, :deadline_at, :auto_close, :locale, :content_base64]
|
8
8
|
|
9
9
|
class << self
|
10
10
|
def create(token:, params: {})
|
11
11
|
post(REQUEST_PATH, body(params), token)
|
12
12
|
end
|
13
13
|
|
14
|
-
def find(token:,
|
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)
|
19
|
+
params = params.transform_keys(&:to_sym)
|
20
|
+
|
19
21
|
document = ATTRIBUTES.each.with_object({}) do |attribute, hash|
|
20
22
|
hash[attribute] = params[attribute] if params.has_key?(attribute)
|
21
23
|
end
|
data/lib/clicksign/api/signer.rb
CHANGED
@@ -19,11 +19,13 @@ 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
|
25
27
|
|
26
|
-
body = { signer: signer }
|
28
|
+
body = { signer: signer }.to_json
|
27
29
|
end
|
28
30
|
end
|
29
31
|
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.
|
4
|
+
version: 1.1.0.alpha5
|
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-
|
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.
|
201
|
+
rubygems_version: 3.1.6
|
201
202
|
signing_key:
|
202
203
|
specification_version: 4
|
203
204
|
summary: Clicksign API ruby interface
|