clicksign-api 1.1.4.alpha → 1.1.8.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: 3df69ceb1c08c6411ce3ed4cab0912a63038c01d49f55a45ae05f046a88a0f2f
4
- data.tar.gz: 49bc96cf8c1f9bd1312c7144e2da82b56fe938aa8acbe93a450af6219f53e6ca
3
+ metadata.gz: 9c6e4b5ae39f037d3ea4ce8ce455ebc92ca492832e54de93e24286fbb108ab8e
4
+ data.tar.gz: 79fc0a42e8a53fb4081a5a6861a1ffdcd63b67b03793683659627f57de982913
5
5
  SHA512:
6
- metadata.gz: 2e0bdd9f9e064ccaf6958367857aca6794dd13882a98334838d5f960508479977b0fc2991f7f0d0b68d96757d97cc66bc0c82353e4d147bbf8e712346de5ead3
7
- data.tar.gz: 17ae913e31d97eb98f5c30e3adff8ba3e1f32d5dd20e9c84beee3f974a41f055400682dfbbdae7076ebf2b5e071fa2aee79b66ed66c22202d4f2501355b02e8b
6
+ metadata.gz: 26a9030878a01ea4c5867a3b07345b939a9a48bfcb6a8f0a46f7ce66d0a965ad09e5eb67a8bd6235dd02e44dfb757b502986ca348a50fb81d8f4b7963d453b95
7
+ data.tar.gz: 471e4123343623857176947d282862fd16f22f071889015603eaba9ceba6c7d311868179a127fefc08c72a9ac0f8d8fe2e99b05c46f48aa21eeb8e3c28cd263b
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clicksign-api (1.1.4.alpha)
5
- faraday
4
+ clicksign-api (1.1.8.alpha)
5
+ faraday (= 1.8.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
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: '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
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: 'valid_token')
71
- # => #<Faraday::Response ...>
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: 'valid_token')
84
- # => #<Faraday::Response ...>
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: 'valid_token')
96
- # => #<Faraday::Response ...>
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: 'valid_token'
94
+ token: "key.sandbox"
115
95
  )
116
- # => #<Faraday::Response ...>
117
96
 
118
- batch.success?
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: 'valid_token')
128
- # => #<Faraday::Response ...>
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: 'valid_token')
141
- # => #<Faraday::Response ...>
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
 
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'bundler', '~> 2.2'
25
25
  spec.add_development_dependency 'rake', '~> 13.0'
26
26
  spec.add_development_dependency 'rspec', '~> 3.0'
27
- spec.add_dependency 'faraday'
27
+ spec.add_dependency 'faraday', '1.8.0'
28
28
 
29
29
  spec.add_development_dependency 'simplecov', '~> 0.16'
30
30
  spec.add_development_dependency 'vcr', '~> 4.0'
@@ -17,6 +17,7 @@ module Clicksign
17
17
  end
18
18
 
19
19
  def cancel(token:, params: {})
20
+ params = params.transform_keys(&:to_sym)
20
21
  patch("#{REQUEST_PATH}#{params[:key]}/cancel", body(params), token)
21
22
  end
22
23
 
@@ -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,31 +2,47 @@ 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
 
19
23
  def patch(request_path, body, token)
20
- conn.patch do |req|
24
+ response = conn.patch do |req|
21
25
  req.url request_path, { access_token: Clicksign::API.credentials[token] }
22
26
  req.headers['Content-Type'] = 'application/json'
23
27
  req.body = body.to_json
24
28
  end
29
+
30
+ parse(response)
25
31
  end
32
+
33
+ private
26
34
 
27
35
  def conn
28
36
  @conn ||= Faraday.new(url: Clicksign::API.url)
29
37
  end
38
+
39
+ def parse(response)
40
+ if !response.body.empty?
41
+ JSON.parse(response.body, symbolize_keys: true).merge(status: response.status)
42
+ else
43
+ { status: response.status }
44
+ end
45
+ end
30
46
  end
31
47
  end
32
48
  end
@@ -1,5 +1,5 @@
1
1
  module Clicksign
2
2
  module API
3
- VERSION = "1.1.4.alpha"
3
+ VERSION = "1.1.8.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.4.alpha
4
+ version: 1.1.8.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: 2022-01-28 00:00:00.000000000 Z
11
+ date: 2022-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: faraday
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 1.8.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 1.8.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -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.0.8
201
+ rubygems_version: 3.0.9
202
202
  signing_key:
203
203
  specification_version: 4
204
204
  summary: Clicksign API ruby interface