clicksign-api 1.1.0.alpha5 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 838efe4044fec37ce55e6a4b18a9c2a2afb69eba26bef730f33ff7b7cd305671
4
- data.tar.gz: '094afed7fb78afd56753d16235363668fee91330242d342a0d503a93346cf58f'
3
+ metadata.gz: a5a70bb08f88deb5af74e43399f3f3176262d66a008757d5a9685d2821c9cb7c
4
+ data.tar.gz: 4ebd3827259a3cf829168f61589f7f73960fb8b87efd3264750f93b84b5e5738
5
5
  SHA512:
6
- metadata.gz: 25c60f502a51735dea50a60c9f41270a2af592a54fd2eab3f7a1df5974b69bd608dd569e19d32e560b39f1526e71e52bb1173c5b4f6a3e68cddce704b2d86f9a
7
- data.tar.gz: c88cb03ad8887973c12b5255c5c878542cf04ca43499473aef6c1e86b9352510121295b47ba316d96a2b57a4dcf07f8b2d6e489889ce330eb40d57606c8402a7
6
+ metadata.gz: 6adeb414c6e3f9a9dbcb85e25c75c642e9e4e00e04be7e243332b60ae2ad71316b12a30da6e66a1e3a350feb1cfa4f25f3511cb4704fbb5b057a3352068c2a6f
7
+ data.tar.gz: 388b2eef8ff721f0f7a961c3136f9481478e3612076a7e800525fbe7afb0e83d855fa1f7d09145871ae715a83e7b3b8f3a6ba7811558b30553d4471f9fe369cc
data/CHANGELOG.md CHANGED
@@ -13,13 +13,13 @@ Now all requests receive token parameter, that represents the key associated wit
13
13
  ## Examples:
14
14
 
15
15
  YML file
16
- ```ruby
17
- => key.production: ENV['CLICKSIGN_ACCESS_TOKEN_PRODUCTION']
18
- => key.sandbox: ENV['CLICKSIGN_ACCESS_TOKEN_SANDBOX']
16
+ ```yml
17
+ key.production: 'CLICKSIGN_ACCESS_TOKEN_PRODUCTION'
18
+ key.sandbox: 'CLICKSIGN_ACCESS_TOKEN_SANDBOX'
19
19
  ```
20
20
 
21
21
  Request:
22
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')
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
25
  ```
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clicksign-api (1.1.0.alpha5)
4
+ clicksign-api (1.1.2.alpha)
5
5
  faraday
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -54,101 +54,62 @@ 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: 'valid_token')
58
- => #<Faraday::Response ...>
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
- => # key: '123abcd' as example!
66
60
  ```
67
61
 
68
62
  #### View documents
69
63
 
70
64
  ```ruby
71
- find_document = Clicksign::API::Document.find(params: { key: response_document['document']['key'] }, token: 'valid_token')
72
- => #<Faraday::Response ...>
73
-
74
- find_document.success?
75
- => 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"}
76
67
 
77
- JSON.parse(find_document.body)
78
- => {:document=> {:key=> '...', :path=> '...', :status => '...', ... }
79
68
  ```
80
69
 
81
70
  #### Create Signers
82
71
 
83
72
  ```ruby
84
- signer = Clicksign::API::Signer.create(params: { email: 'mail@email.com', auths: ['email'], delivery: 'email' }, token: 'valid_token')
85
- => #<Faraday::Response ...>
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"}
86
75
 
87
- signer.success?
88
- => true # false
89
-
90
- response_signer = JSON.parse(signer.body)
91
- => {:document=> {:key=> '...', :path=> '...', :status => '...', ... }
92
- => # signer_key: '999poo' as example!
93
76
  ```
94
77
  #### Add Signers to Document
95
78
 
96
79
  ```ruby
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 = 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
83
  ```
107
84
 
108
85
  ##### Creating Documents in Batches
109
86
 
110
87
  ```ruby
88
+ batch = Clicksign::API::Batch.create(
89
+ params: {
90
+ document_keys: [response_document['document']['key'], 'other_document_key'],
91
+ signer_key: response_signer['key'],
92
+ summary: true
93
+ },
94
+ token: "key.sandbox"
95
+ )
111
96
 
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"
97
+ # => {"batch"=>{"key"=>"00000000-0000-0000-0000-000000000000"}
120
98
 
121
99
  ```
122
100
  #### Notifying Signer by e-mail
123
101
 
124
102
  ```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\":
103
+ notify = Clicksign::API::Notifier.notify(params: { request_signature_key: 'request_signature_key' }, token: "key.sandbox")
104
+ # => {:status=>202}
134
105
 
135
106
  ```
136
107
 
137
108
  #### Notifying Signer by whatsapp
138
109
 
139
110
  ```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
-
111
+ notify = Clicksign::API::Notifier.notify(params: { request_signature_key: 'request_signature_key' }, token: "key.sandbox")
112
+ # => {:status=>202}
152
113
 
153
114
  ## Development
154
115
 
@@ -12,6 +12,7 @@ module Clicksign
12
12
  end
13
13
 
14
14
  def find(token:, params:)
15
+ params = params.transform_keys(&:to_sym)
15
16
  get(REQUEST_PATH + params[:key], token)
16
17
  end
17
18
 
@@ -17,15 +17,13 @@ module Clicksign
17
17
  )
18
18
  end
19
19
 
20
- def batch_create(token:, batch:)
21
- batch.map do |params|
22
- create(token: token, params: 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
@@ -25,7 +25,7 @@ module Clicksign
25
25
  hash[key] = params[key] if params.has_key?(key)
26
26
  end
27
27
 
28
- body = { signer: signer }.to_json
28
+ body = { signer: signer }
29
29
  end
30
30
  end
31
31
  end
@@ -1,5 +1,5 @@
1
1
  module Clicksign
2
2
  module API
3
- VERSION = "1.1.0.alpha5"
3
+ VERSION = "1.1.2.alpha"
4
4
  end
5
5
  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.alpha5
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-03 00:00:00.000000000 Z
11
+ date: 2021-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
198
  - !ruby/object:Gem::Version
199
199
  version: 1.3.1
200
200
  requirements: []
201
- rubygems_version: 3.1.6
201
+ rubygems_version: 3.2.3
202
202
  signing_key:
203
203
  specification_version: 4
204
204
  summary: Clicksign API ruby interface