clicksign-api 1.1.6.alpha → 1.1.7.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +14 -46
- data/lib/clicksign/api/documents_signers.rb +5 -3
- data/lib/clicksign/api/requests.rb +26 -2
- data/lib/clicksign/api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bea5a754ab560b1b59a2897b6b64deefaca14deb47153800a4a0eebeba0883d3
|
4
|
+
data.tar.gz: 479506b71a5048c8610fffafbec6e21f69987bbc7f8dafd9cc266688b1260b4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58fd06ac23e271f99f763ba375836512970e0d6f0986e70f7ff23b0b22383c2a8817632184d998c1ba1ccb7dc29d35c9a167f0aed64f5accb60aca59b0356105
|
7
|
+
data.tar.gz: c3c1967a2a16697b8b8935cc5f7fab4a8856e8895a664b781aa7c61da07b3db42218371c981baefa8d115ff64fea2b4d3ed57e09d0361041460a343b72784bfa
|
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,9 +17,11 @@ module Clicksign
|
|
17
17
|
)
|
18
18
|
end
|
19
19
|
|
20
|
-
def batch_create(token:,
|
21
|
-
|
22
|
-
|
20
|
+
def batch_create(token:, params:)
|
21
|
+
params = params.transform_keys(&:to_sym)
|
22
|
+
|
23
|
+
params[:batch].map do |single_params|
|
24
|
+
create(token: token, params: single_params)
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
@@ -2,20 +2,36 @@ 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
|
18
22
|
|
23
|
+
def patch(request_path, body, token)
|
24
|
+
response = conn.patch do |req|
|
25
|
+
req.url request_path, { access_token: Clicksign::API.credentials[token] }
|
26
|
+
req.headers['Content-Type'] = 'application/json'
|
27
|
+
req.body = body.to_json
|
28
|
+
end
|
29
|
+
|
30
|
+
parse(response)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
19
35
|
def patch(request_path, body, token)
|
20
36
|
conn.patch do |req|
|
21
37
|
req.url request_path, { access_token: Clicksign::API.credentials[token] }
|
@@ -27,6 +43,14 @@ module Clicksign
|
|
27
43
|
def conn
|
28
44
|
@conn ||= Faraday.new(url: Clicksign::API.url)
|
29
45
|
end
|
46
|
+
|
47
|
+
def parse(response)
|
48
|
+
if !response.body.empty?
|
49
|
+
JSON.parse(response.body, symbolize_keys: true).merge(status: response.status)
|
50
|
+
else
|
51
|
+
{ status: response.status }
|
52
|
+
end
|
53
|
+
end
|
30
54
|
end
|
31
55
|
end
|
32
56
|
end
|