clicksign-api 1.1.0.alpha6 → 1.1.3.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: 12d78c1e1512951c7213b73440679297f738376895698654fd8580a8a0290cf7
4
- data.tar.gz: d899a9ac359212534f3e75a2d77bbe0f0c6e9e01f534a668ce8161e3b7d52d71
3
+ metadata.gz: 764750a15069c2e1aa12f2fa2777436cc21cfdf3fa9b7d7469b2a806c9c77de4
4
+ data.tar.gz: f369ea3517b9174ac50f36dcde37cad63dc7b2309f15ce3aa06085a605cb0cc0
5
5
  SHA512:
6
- metadata.gz: af14c66c6e4a1a5cb8471c0dcc32072e889381aaa815ad65c89b63e6fb830ab48514338f0465d96cd8f6bed8f804cd0ae997abc5056702a4946a9bc67abac6b8
7
- data.tar.gz: e66b3372d2204d83917c65974e6eef811ab4c049cd242b2858dc15a2a8f1a16a2e4571cdbedd31502309be4a654f8e3d2e82add6617c31d929b1f803dc9424c1
6
+ metadata.gz: 470a75dc6e7380cc0126de7624eb2e6afd650d9b6d0846b16c577049f2d63658677ab8d3c8774808ffa7bdd5372dbd7bca9fb75a9c0586785bd81ffd0e9f8693
7
+ data.tar.gz: d0c80bccd33b516b9704564516decb8ef38360d4050909cd4ce430d5691bd34b43bc0566b9524147684170077a6ddbc3d0e9954acc8daf56f792cb343edc8258
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.alpha6)
4
+ clicksign-api (1.1.3.alpha)
5
5
  faraday
6
6
 
7
7
  GEM
@@ -56,7 +56,7 @@ GEM
56
56
  rspec-mocks (3.10.2)
57
57
  diff-lcs (>= 1.2.0, < 2.0)
58
58
  rspec-support (~> 3.10.0)
59
- rspec-support (3.10.2)
59
+ rspec-support (3.10.3)
60
60
  ruby2_keywords (0.0.5)
61
61
  simplecov (0.21.2)
62
62
  docile (~> 1.1)
@@ -71,7 +71,6 @@ GEM
71
71
  hashdiff (>= 0.4.0, < 2.0.0)
72
72
 
73
73
  PLATFORMS
74
- x86_64-darwin-20
75
74
  x86_64-linux
76
75
 
77
76
  DEPENDENCIES
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,9 +17,11 @@ 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 = 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,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
@@ -1,5 +1,5 @@
1
1
  module Clicksign
2
2
  module API
3
- VERSION = "1.1.0.alpha6"
3
+ VERSION = "1.1.3.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.alpha6
4
+ version: 1.1.3.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-12-09 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