clicksign-api 1.1.2.alpha → 1.1.6.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: a5a70bb08f88deb5af74e43399f3f3176262d66a008757d5a9685d2821c9cb7c
4
- data.tar.gz: 4ebd3827259a3cf829168f61589f7f73960fb8b87efd3264750f93b84b5e5738
3
+ metadata.gz: 0a9eb42d76393834f835ad5d9765289d65f0c68b39a490d94d9542e58476b5f4
4
+ data.tar.gz: d646e41a0b8f8c03635458d82ee1f9b92a0637c85518fa079adb651052cd8ba2
5
5
  SHA512:
6
- metadata.gz: 6adeb414c6e3f9a9dbcb85e25c75c642e9e4e00e04be7e243332b60ae2ad71316b12a30da6e66a1e3a350feb1cfa4f25f3511cb4704fbb5b057a3352068c2a6f
7
- data.tar.gz: 388b2eef8ff721f0f7a961c3136f9481478e3612076a7e800525fbe7afb0e83d855fa1f7d09145871ae715a83e7b3b8f3a6ba7811558b30553d4471f9fe369cc
6
+ metadata.gz: 9a8eb53d21705d3ee6aeb9da94421a4720c159c02291a3a1f93006daf40190ac54ed577b4798d528ad619aed7c057871b0010cb7c62d3bd269591d976cd6191e
7
+ data.tar.gz: fbddf951fc4445b6ac0eb3c300092baee33cbc8655f76b811579bf96fc1ab1f7f45e035a7de98258fc11b78cf5f1dabaeaa66458cfd49088992d6a8ccb655481
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clicksign-api (1.1.2.alpha)
5
- faraday
4
+ clicksign-api (1.1.6.alpha)
5
+ faraday (= 1.8.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -87,4 +87,4 @@ DEPENDENCIES
87
87
  webmock (~> 3.0)
88
88
 
89
89
  BUNDLED WITH
90
- 2.2.29
90
+ 2.2.33
data/README.md CHANGED
@@ -54,32 +54,52 @@ 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: "key.sandbox")
58
- # => {"document"=> {"key"=>"00000000-0000-0000-0000-000000000000"}
57
+ document = Clicksign::API::Document.create( params: { path: '/path/to/file/on/clicksign.pdf', file: file }, token: 'valid_token')
58
+ # => #<Faraday::Response ...>
59
59
 
60
+ document.success?
61
+ # => true # false
62
+
63
+ response_document = JSON.parse(document.body)
64
+ # => {:document=> {:key=> '...', :path=> '...', :status => '...', ... }
60
65
  ```
61
66
 
62
67
  #### View documents
63
68
 
64
69
  ```ruby
65
- find_document = Clicksign::API::Document.find(params: { key: response_document['document']['key'] }, token: "key.sandbox")
66
- # => {"document"=> {"key"=>"00000000-0000-0000-0000-000000000000"}
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
67
75
 
76
+ JSON.parse(find_document.body)
77
+ # => {:document=> {:key=> '...', :path=> '...', :status => '...', ... }
68
78
  ```
69
79
 
70
80
  #### Create Signers
71
81
 
72
82
  ```ruby
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"}
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
75
88
 
89
+ response_signer = JSON.parse(signer.body)
90
+ # => {:signer=> {:key=> '...', :email=> '...', ... }
76
91
  ```
77
92
  #### Add Signers to Document
78
93
 
79
94
  ```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"}
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 ...>
82
97
 
98
+ signer_document.success?
99
+ # => true # false
100
+
101
+ response_signer_document = JSON.parse(signer_document.body)
102
+ # => {:list=> {:key=> '...', ... }
83
103
  ```
84
104
 
85
105
  ##### Creating Documents in Batches
@@ -91,25 +111,37 @@ batch = Clicksign::API::Batch.create(
91
111
  signer_key: response_signer['key'],
92
112
  summary: true
93
113
  },
94
- token: "key.sandbox"
114
+ token: 'valid_token'
95
115
  )
116
+ # => #<Faraday::Response ...>
96
117
 
97
- # => {"batch"=>{"key"=>"00000000-0000-0000-0000-000000000000"}
118
+ batch.success?
119
+ # => true # false
98
120
 
121
+ rseponse_batch = JSON.parse(batch.body)
122
+ # => #{"batch"=> {"key"=>"..."
99
123
  ```
100
124
  #### Notifying Signer by e-mail
101
125
 
102
126
  ```ruby
103
- notify = Clicksign::API::Notifier.notify(params: { request_signature_key: 'request_signature_key' }, token: "key.sandbox")
104
- # => {:status=>202}
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
105
132
 
133
+ JSON.parse(notify.body)
134
+ # => ##<struct Faraday::Env, method=:post request_body="{\"request_signature_key\":
106
135
  ```
107
136
 
108
137
  #### Notifying Signer by whatsapp
109
138
 
110
139
  ```ruby
111
- notify = Clicksign::API::Notifier.notify(params: { request_signature_key: 'request_signature_key' }, token: "key.sandbox")
112
- # => {:status=>202}
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
113
145
 
114
146
  ## Development
115
147
 
@@ -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'
@@ -16,6 +16,11 @@ module Clicksign
16
16
  get(REQUEST_PATH + params[:key], token)
17
17
  end
18
18
 
19
+ def cancel(token:, params: {})
20
+ params = params.transform_keys(&:to_sym)
21
+ patch("#{REQUEST_PATH}#{params[:key]}/cancel", body(params), token)
22
+ end
23
+
19
24
  def body(params)
20
25
  params = params.transform_keys(&:to_sym)
21
26
 
@@ -17,13 +17,15 @@ module Clicksign
17
17
  )
18
18
  end
19
19
 
20
- def batch_create(token:, params:)
21
- params[:batch].map do |single_params|
22
- create(token: token, params: single_params)
20
+ def batch_create(token:, batch:)
21
+ batch.map do |params|
22
+ create(token: token, params: params)
23
23
  end
24
24
  end
25
25
 
26
26
  def body(params)
27
+ params = params.transform_keys(&:to_sym)
28
+
27
29
  list = ATTRIBUTES.each.with_object({}) do |key, hash|
28
30
  hash[key] = params[key] if params.has_key?(key)
29
31
  end
@@ -2,37 +2,31 @@ module Clicksign
2
2
  module API
3
3
  module Requests
4
4
  def post(request_path, body, token)
5
- response = conn.post do |req|
5
+ 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)
12
10
  end
13
11
 
14
12
  def get(request_path, token)
15
- response = conn.get do |req|
13
+ conn.get do |req|
16
14
  req.url request_path, { access_token: Clicksign::API.credentials[token] }
17
15
  req.headers['Content-Type'] = 'application/json'
18
16
  end
19
-
20
- parse(response)
21
17
  end
22
-
23
- private
18
+
19
+ def patch(request_path, body, token)
20
+ conn.patch do |req|
21
+ req.url request_path, { access_token: Clicksign::API.credentials[token] }
22
+ req.headers['Content-Type'] = 'application/json'
23
+ req.body = body.to_json
24
+ end
25
+ end
24
26
 
25
27
  def conn
26
28
  @conn ||= Faraday.new(url: Clicksign::API.url)
27
29
  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
36
30
  end
37
31
  end
38
- end
32
+ end
@@ -1,5 +1,5 @@
1
1
  module Clicksign
2
2
  module API
3
- VERSION = "1.1.2.alpha"
3
+ VERSION = "1.1.6.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.2.alpha
4
+ version: 1.1.6.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-16 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.2.3
201
+ rubygems_version: 3.0.8
202
202
  signing_key:
203
203
  specification_version: 4
204
204
  summary: Clicksign API ruby interface