clicksign-api 1.1.1 → 1.1.2.alpha
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 +4 -4
- data/CHANGELOG.md +15 -5
- data/Gemfile.lock +1 -1
- data/README.md +14 -46
- data/lib/clicksign/api/documents_signers.rb +3 -5
- data/lib/clicksign/api/requests.rb +17 -3
- data/lib/clicksign/api/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5a70bb08f88deb5af74e43399f3f3176262d66a008757d5a9685d2821c9cb7c
|
4
|
+
data.tar.gz: 4ebd3827259a3cf829168f61589f7f73960fb8b87efd3264750f93b84b5e5738
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6adeb414c6e3f9a9dbcb85e25c75c642e9e4e00e04be7e243332b60ae2ad71316b12a30da6e66a1e3a350feb1cfa4f25f3511cb4704fbb5b057a3352068c2a6f
|
7
|
+
data.tar.gz: 388b2eef8ff721f0f7a961c3136f9481478e3612076a7e800525fbe7afb0e83d855fa1f7d09145871ae715a83e7b3b8f3a6ba7811558b30553d4471f9fe369cc
|
data/CHANGELOG.md
CHANGED
@@ -1,15 +1,25 @@
|
|
1
1
|
# Clicksign::API 1.1.0 (Octuber 29, 2021)
|
2
2
|
|
3
3
|
Add support to multiple credentials.
|
4
|
-
This is useful to work with different
|
4
|
+
This is useful to work with different environments, providing flexibility.
|
5
5
|
For example, applications have different tokens for each environment.
|
6
6
|
Other useful case, occurs working with multiple companies.
|
7
7
|
|
8
|
-
The credentials should be a hash.
|
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
|
+
```yml
|
17
|
+
key.production: 'CLICKSIGN_ACCESS_TOKEN_PRODUCTION'
|
18
|
+
key.sandbox: 'CLICKSIGN_ACCESS_TOKEN_SANDBOX'
|
19
|
+
```
|
9
20
|
|
10
21
|
Request:
|
11
22
|
```ruby
|
12
23
|
file = File.open('/path/to/file/local/file.pdf', 'r')
|
13
|
-
response = Clicksign::API::Document.create(params: { path: '/path/to/file/on/clicksign.pdf', file: file }, token: 'key.production')
|
14
|
-
|
15
|
-
```
|
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
@@ -54,52 +54,32 @@ To see all available parameters, please, check the [API docs](https://developers
|
|
54
54
|
|
55
55
|
```ruby
|
56
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:
|
58
|
-
# =>
|
57
|
+
document = Clicksign::API::Document.create( params: { path: '/path/to/file/on/clicksign.pdf', file: file }, token: "key.sandbox")
|
58
|
+
# => {"document"=> {"key"=>"00000000-0000-0000-0000-000000000000"}
|
59
59
|
|
60
|
-
document.success?
|
61
|
-
# => true # false
|
62
|
-
|
63
|
-
response_document = JSON.parse(document.body)
|
64
|
-
# => {:document=> {:key=> '...', :path=> '...', :status => '...', ... }
|
65
60
|
```
|
66
61
|
|
67
62
|
#### View documents
|
68
63
|
|
69
64
|
```ruby
|
70
|
-
find_document = Clicksign::API::Document.find(params: { key: response_document['document']['key'] }, token:
|
71
|
-
# =>
|
72
|
-
|
73
|
-
find_document.success?
|
74
|
-
# => true # false
|
65
|
+
find_document = Clicksign::API::Document.find(params: { key: response_document['document']['key'] }, token: "key.sandbox")
|
66
|
+
# => {"document"=> {"key"=>"00000000-0000-0000-0000-000000000000"}
|
75
67
|
|
76
|
-
JSON.parse(find_document.body)
|
77
|
-
# => {:document=> {:key=> '...', :path=> '...', :status => '...', ... }
|
78
68
|
```
|
79
69
|
|
80
70
|
#### Create Signers
|
81
71
|
|
82
72
|
```ruby
|
83
|
-
signer = Clicksign::API::Signer.create(params: { email: 'mail@email.com', auths: ['email'], delivery: 'email' }, token:
|
84
|
-
# =>
|
85
|
-
|
86
|
-
signer.success?
|
87
|
-
# => true # false
|
73
|
+
signer = Clicksign::API::Signer.create(params: { email: 'mail@email.com', auths: ['email'], delivery: 'email' }, token: "key.sandbox")
|
74
|
+
# => {"signer"=> {"key"=>"00000000-0000-0000-0000-000000000000"}
|
88
75
|
|
89
|
-
response_signer = JSON.parse(signer.body)
|
90
|
-
# => {:signer=> {:key=> '...', :email=> '...', ... }
|
91
76
|
```
|
92
77
|
#### Add Signers to Document
|
93
78
|
|
94
79
|
```ruby
|
95
|
-
signer_document = Clicksign::API::DocumentsSigners.create(params: { document_key: response_document['document']['key'], signer_key: response_signer['key'], sign_as: 'sign_as' }, token:
|
96
|
-
# =>
|
80
|
+
signer_document = Clicksign::API::DocumentsSigners.create(params: { document_key: response_document['document']['key'], signer_key: response_signer['key'], sign_as: 'sign_as' }, token: "key.sandbox")
|
81
|
+
# => {"list"=>{"key"=>"00000000-0000-0000-0000-000000000000"}
|
97
82
|
|
98
|
-
signer_document.success?
|
99
|
-
# => true # false
|
100
|
-
|
101
|
-
response_signer_document = JSON.parse(signer_document.body)
|
102
|
-
# => {:list=> {:key=> '...', ... }
|
103
83
|
```
|
104
84
|
|
105
85
|
##### Creating Documents in Batches
|
@@ -111,37 +91,25 @@ batch = Clicksign::API::Batch.create(
|
|
111
91
|
signer_key: response_signer['key'],
|
112
92
|
summary: true
|
113
93
|
},
|
114
|
-
token:
|
94
|
+
token: "key.sandbox"
|
115
95
|
)
|
116
|
-
# => #<Faraday::Response ...>
|
117
96
|
|
118
|
-
batch
|
119
|
-
# => true # false
|
97
|
+
# => {"batch"=>{"key"=>"00000000-0000-0000-0000-000000000000"}
|
120
98
|
|
121
|
-
rseponse_batch = JSON.parse(batch.body)
|
122
|
-
# => #{"batch"=> {"key"=>"..."
|
123
99
|
```
|
124
100
|
#### Notifying Signer by e-mail
|
125
101
|
|
126
102
|
```ruby
|
127
|
-
notify = Clicksign::API::Notifier.notify(params: { request_signature_key: 'request_signature_key' }, token:
|
128
|
-
# =>
|
129
|
-
|
130
|
-
notify.success?
|
131
|
-
# => true # false
|
103
|
+
notify = Clicksign::API::Notifier.notify(params: { request_signature_key: 'request_signature_key' }, token: "key.sandbox")
|
104
|
+
# => {:status=>202}
|
132
105
|
|
133
|
-
JSON.parse(notify.body)
|
134
|
-
# => ##<struct Faraday::Env, method=:post request_body="{\"request_signature_key\":
|
135
106
|
```
|
136
107
|
|
137
108
|
#### Notifying Signer by whatsapp
|
138
109
|
|
139
110
|
```ruby
|
140
|
-
notify = Clicksign::API::Notifier.notify(params: { request_signature_key: 'request_signature_key' }, token:
|
141
|
-
# =>
|
142
|
-
|
143
|
-
notify.success?
|
144
|
-
# => true # false
|
111
|
+
notify = Clicksign::API::Notifier.notify(params: { request_signature_key: 'request_signature_key' }, token: "key.sandbox")
|
112
|
+
# => {:status=>202}
|
145
113
|
|
146
114
|
## Development
|
147
115
|
|
@@ -17,15 +17,13 @@ module Clicksign
|
|
17
17
|
)
|
18
18
|
end
|
19
19
|
|
20
|
-
def batch_create(token:,
|
21
|
-
batch.map do |
|
22
|
-
create(token: token, params:
|
20
|
+
def batch_create(token:, params:)
|
21
|
+
params[:batch].map do |single_params|
|
22
|
+
create(token: token, params: single_params)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
def body(params)
|
27
|
-
params = params.transform_keys(&:to_sym)
|
28
|
-
|
29
27
|
list = ATTRIBUTES.each.with_object({}) do |key, hash|
|
30
28
|
hash[key] = params[key] if params.has_key?(key)
|
31
29
|
end
|
@@ -2,23 +2,37 @@ module Clicksign
|
|
2
2
|
module API
|
3
3
|
module Requests
|
4
4
|
def post(request_path, body, token)
|
5
|
-
conn.post do |req|
|
5
|
+
response = conn.post do |req|
|
6
6
|
req.url request_path, { access_token: Clicksign::API.credentials[token] }
|
7
7
|
req.headers['Content-Type'] = 'application/json'
|
8
8
|
req.body = body.to_json
|
9
9
|
end
|
10
|
+
|
11
|
+
parse(response)
|
10
12
|
end
|
11
13
|
|
12
14
|
def get(request_path, token)
|
13
|
-
conn.get do |req|
|
15
|
+
response = conn.get do |req|
|
14
16
|
req.url request_path, { access_token: Clicksign::API.credentials[token] }
|
15
17
|
req.headers['Content-Type'] = 'application/json'
|
16
18
|
end
|
19
|
+
|
20
|
+
parse(response)
|
17
21
|
end
|
22
|
+
|
23
|
+
private
|
18
24
|
|
19
25
|
def conn
|
20
26
|
@conn ||= Faraday.new(url: Clicksign::API.url)
|
21
27
|
end
|
28
|
+
|
29
|
+
def parse(response)
|
30
|
+
if !response.body.empty?
|
31
|
+
JSON.parse(response.body, symbolize_keys: true).merge(status: response.status)
|
32
|
+
else
|
33
|
+
{ status: response.status }
|
34
|
+
end
|
35
|
+
end
|
22
36
|
end
|
23
37
|
end
|
24
|
-
end
|
38
|
+
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.
|
4
|
+
version: 1.1.2.alpha
|
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-
|
11
|
+
date: 2021-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -194,11 +194,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
194
194
|
version: '0'
|
195
195
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
196
196
|
requirements:
|
197
|
-
- - "
|
197
|
+
- - ">"
|
198
198
|
- !ruby/object:Gem::Version
|
199
|
-
version:
|
199
|
+
version: 1.3.1
|
200
200
|
requirements: []
|
201
|
-
rubygems_version: 3.
|
201
|
+
rubygems_version: 3.2.3
|
202
202
|
signing_key:
|
203
203
|
specification_version: 4
|
204
204
|
summary: Clicksign API ruby interface
|