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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a9eb42d76393834f835ad5d9765289d65f0c68b39a490d94d9542e58476b5f4
4
- data.tar.gz: d646e41a0b8f8c03635458d82ee1f9b92a0637c85518fa079adb651052cd8ba2
3
+ metadata.gz: bea5a754ab560b1b59a2897b6b64deefaca14deb47153800a4a0eebeba0883d3
4
+ data.tar.gz: 479506b71a5048c8610fffafbec6e21f69987bbc7f8dafd9cc266688b1260b4f
5
5
  SHA512:
6
- metadata.gz: 9a8eb53d21705d3ee6aeb9da94421a4720c159c02291a3a1f93006daf40190ac54ed577b4798d528ad619aed7c057871b0010cb7c62d3bd269591d976cd6191e
7
- data.tar.gz: fbddf951fc4445b6ac0eb3c300092baee33cbc8655f76b811579bf96fc1ab1f7f45e035a7de98258fc11b78cf5f1dabaeaa66458cfd49088992d6a8ccb655481
6
+ metadata.gz: 58fd06ac23e271f99f763ba375836512970e0d6f0986e70f7ff23b0b22383c2a8817632184d998c1ba1ccb7dc29d35c9a167f0aed64f5accb60aca59b0356105
7
+ data.tar.gz: c3c1967a2a16697b8b8935cc5f7fab4a8856e8895a664b781aa7c61da07b3db42218371c981baefa8d115ff64fea2b4d3ed57e09d0361041460a343b72784bfa
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clicksign-api (1.1.6.alpha)
4
+ clicksign-api (1.1.7.alpha)
5
5
  faraday (= 1.8.0)
6
6
 
7
7
  GEM
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
 
@@ -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,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
@@ -1,5 +1,5 @@
1
1
  module Clicksign
2
2
  module API
3
- VERSION = "1.1.6.alpha"
3
+ VERSION = "1.1.7.alpha"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clicksign-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6.alpha
4
+ version: 1.1.7.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francisco Martins