active_call-zoho_sign 0.1.5 → 0.1.7
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 +4 -4
- data/.rubocop.yml +5 -1
- data/CHANGELOG.md +13 -0
- data/README.md +70 -12
- data/lib/zoho_sign/access_token/get_service.rb +4 -1
- data/lib/zoho_sign/base_service.rb +22 -7
- data/lib/zoho_sign/concerns/enumerable.rb +4 -2
- data/lib/zoho_sign/document/action/embed_token/get_service.rb +3 -1
- data/lib/zoho_sign/document/create_service.rb +2 -0
- data/lib/zoho_sign/document/delete_service.rb +2 -0
- data/lib/zoho_sign/document/get_service.rb +2 -0
- data/lib/zoho_sign/document/list_service.rb +3 -1
- data/lib/zoho_sign/document/update_service.rb +2 -0
- data/lib/zoho_sign/error.rb +3 -0
- data/lib/zoho_sign/grant_token/facade.rb +14 -0
- data/lib/zoho_sign/grant_token/get_service.rb +66 -0
- data/lib/zoho_sign/template/document/create_service.rb +2 -0
- data/lib/zoho_sign/template/get_service.rb +2 -0
- data/lib/zoho_sign/template/list_service.rb +3 -1
- data/lib/zoho_sign/version.rb +1 -1
- metadata +7 -60
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24fd5f8a6cedfeae21a85de1412a2c6abefa4b8749151f8e55f63200460a3307
|
4
|
+
data.tar.gz: 05f78e8283339dc0703ceee1e64ac997c3e2ae3018b709e7ce24a43dfcf91979
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5f686d8c6a75657ab589f4ea999614e2e2340f52f760816036da2be33a271a3001c63a36a4713891c7a00b8b03da0b6036fda0e69146112998987324077029d
|
7
|
+
data.tar.gz: 8bcca9f1cc1fb120a724093d2f6bd31b1694afcb4c9889753433335ac0b304a4ff3fee22e74853533be663b030c4be5e80c90db45f92771a6a73a79763b935af
|
data/.rubocop.yml
CHANGED
@@ -22,6 +22,7 @@ Layout/HashAlignment:
|
|
22
22
|
Layout/LineLength:
|
23
23
|
AllowedPatterns:
|
24
24
|
- initialize
|
25
|
+
- '#'
|
25
26
|
|
26
27
|
Lint/MissingSuper:
|
27
28
|
Enabled: false
|
@@ -43,9 +44,12 @@ Metrics/CyclomaticComplexity:
|
|
43
44
|
Metrics/MethodLength:
|
44
45
|
Enabled: false
|
45
46
|
|
47
|
+
Metrics/ParameterLists:
|
48
|
+
Enabled: false
|
49
|
+
|
46
50
|
Metrics/PerceivedComplexity:
|
47
51
|
Exclude:
|
48
|
-
- lib/zoho_sign/
|
52
|
+
- lib/zoho_sign/concerns/enumerable.rb
|
49
53
|
|
50
54
|
Naming/FileName:
|
51
55
|
Exclude:
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## [0.1.7] - 2025-05-09
|
2
|
+
|
3
|
+
- README updates with links to API endpoint docs.
|
4
|
+
- `EmbedToken::GetService` path does not need to set the full path `/api/v1/requests/...` -> `requests/...`.
|
5
|
+
- README and Gemspec description updates.
|
6
|
+
|
7
|
+
## [0.1.6] - 2025-04-05
|
8
|
+
|
9
|
+
- Added `ZohoSign::GrantToken::GetService`.
|
10
|
+
- Set access token in `before_call` hook instead of lambda so we can capture errors from the access token service objects.
|
11
|
+
- Fixed empty list enumerable errors.
|
12
|
+
- Remove spec dependencies already included in `active_call-api`.
|
13
|
+
|
1
14
|
## [0.1.5] - 2025-04-03
|
2
15
|
|
3
16
|
- Refactor list endpoints to use `ZohoSign::Enumerable`.
|
data/README.md
CHANGED
@@ -2,7 +2,15 @@
|
|
2
2
|
|
3
3
|
[](https://badge.fury.io/rb/active_call-zoho_sign)
|
4
4
|
|
5
|
-
Zoho Sign exposes the [Zoho Sign API](https://www.zoho.com/sign/api) endpoints through service objects.
|
5
|
+
Zoho Sign exposes the [Zoho Sign API](https://www.zoho.com/sign/api) endpoints through [Active Call](https://rubygems.org/gems/active_call) service objects.
|
6
|
+
|
7
|
+
<div align="center">
|
8
|
+
<a href="https://platform45.com?utm_source=github&utm_content=zoho_sign">
|
9
|
+
<picture>
|
10
|
+
<img src="https://github.com/user-attachments/assets/19fd40df-2ce9-4f30-8120-d53f3fbf9f07">
|
11
|
+
</picture>
|
12
|
+
</a>
|
13
|
+
</div>
|
6
14
|
|
7
15
|
- [Installation](#installation)
|
8
16
|
- [Configuration](#configuration)
|
@@ -11,9 +19,7 @@ Zoho Sign exposes the [Zoho Sign API](https://www.zoho.com/sign/api) endpoints t
|
|
11
19
|
- [Using call!](#using-call!)
|
12
20
|
- [When to use call or call!](#using-call-or-call!)
|
13
21
|
- [Using lists](#using-lists)
|
14
|
-
|
15
|
-
- [Folders](#folders)
|
16
|
-
- [Templates](#templates)
|
22
|
+
- [Service Objects](#service-objects)
|
17
23
|
- [Development](#development)
|
18
24
|
- [Contributing](#contributing)
|
19
25
|
- [License](#license)
|
@@ -34,6 +40,12 @@ gem install active_call-zoho_sign
|
|
34
40
|
|
35
41
|
## Configuration
|
36
42
|
|
43
|
+
Create a new **Self Client** client type from the [Zoho Developer Console](https://api-console.zoho.com) to retrieve your **Client ID** and **Client Secret**.
|
44
|
+
|
45
|
+
Choose what you need from the list of [Zoho Scopes](https://www.zoho.com/sign/api/oauth.html) like `ZohoSign.documents.ALL` to generate your **Grant Token**.
|
46
|
+
|
47
|
+
Get your **Refresh Token** by calling `ZohoSign::GrantToken::GetService.call(grant_token: '', client_id: '', client_secret: '').refresh_token`
|
48
|
+
|
37
49
|
Configure your API credentials.
|
38
50
|
|
39
51
|
In a Rails application, the standard practice is to place this code in a file named `zoho_sign.rb` within the `config/initializers` directory.
|
@@ -173,7 +185,7 @@ rescue ZohoSign::RequestError => exception
|
|
173
185
|
An example of where to use `call` would be in a **controller** doing an inline synchronous request.
|
174
186
|
|
175
187
|
```ruby
|
176
|
-
class
|
188
|
+
class SomeController < ApplicationController
|
177
189
|
def update
|
178
190
|
@document = ZohoSign::Document::UpdateService.call(**params)
|
179
191
|
|
@@ -192,7 +204,7 @@ An example of where to use `call!` would be in a **job** doing an asynchronous r
|
|
192
204
|
You can use the exceptions to determine which retry strategy to use and which to discard.
|
193
205
|
|
194
206
|
```ruby
|
195
|
-
class
|
207
|
+
class SomeJob < ApplicationJob
|
196
208
|
discard_on ZohoSign::NotFoundError
|
197
209
|
|
198
210
|
retry_on ZohoSign::RequestTimeoutError, wait: 5.minutes, attempts: :unlimited
|
@@ -210,12 +222,19 @@ If you don't provide the `limit` argument, multiple API requests will be made un
|
|
210
222
|
|
211
223
|
Note that the `offset` argument starts at `1` for the first item.
|
212
224
|
|
225
|
+
## Service Objects
|
226
|
+
|
227
|
+
<details open>
|
228
|
+
<summary>Documents</summary>
|
229
|
+
|
213
230
|
### Documents
|
214
231
|
|
215
232
|
#### List documents
|
216
233
|
|
217
234
|
```ruby
|
218
|
-
|
235
|
+
# https://www.zoho.com/sign/api/document-managment/get-document-list.html
|
236
|
+
|
237
|
+
ZohoSign::Document::ListService.call(offset: 1, limit: 10).each do |facade|
|
219
238
|
facade.description
|
220
239
|
end
|
221
240
|
```
|
@@ -237,6 +256,8 @@ Columns to sort and filter by are `request_name`, `folder_name`, `owner_full_nam
|
|
237
256
|
#### Get a document
|
238
257
|
|
239
258
|
```ruby
|
259
|
+
# https://www.zoho.com/sign/api/document-managment/get-details-of-a-particular-document.html
|
260
|
+
|
240
261
|
service = ZohoSign::Document::GetService.call(id: '')
|
241
262
|
service.request_name
|
242
263
|
service.request_id
|
@@ -252,7 +273,9 @@ service.sign_percentage
|
|
252
273
|
#### Create a document
|
253
274
|
|
254
275
|
```ruby
|
255
|
-
|
276
|
+
# https://www.zoho.com/sign/api/document-managment/create-document.html
|
277
|
+
|
278
|
+
ZohoSign::Document::CreateService.call(
|
256
279
|
file: '/path/to/file.pdf', # or File.open('/path/to/file.pdf')
|
257
280
|
file_name: 'file.pdf',
|
258
281
|
file_content_type: 'application/pdf',
|
@@ -275,7 +298,9 @@ service = ZohoSign::Document::CreateService.call(
|
|
275
298
|
#### Update a document
|
276
299
|
|
277
300
|
```ruby
|
278
|
-
|
301
|
+
# https://www.zoho.com/sign/api/document-managment/update-document.html
|
302
|
+
|
303
|
+
ZohoSign::Document::UpdateService.call(
|
279
304
|
id: '',
|
280
305
|
data: {
|
281
306
|
requests: {
|
@@ -294,7 +319,9 @@ service = ZohoSign::Document::UpdateService.call(
|
|
294
319
|
#### Delete a document
|
295
320
|
|
296
321
|
```ruby
|
297
|
-
|
322
|
+
# https://www.zoho.com/sign/api/document-managment/delete-document.html
|
323
|
+
|
324
|
+
ZohoSign::Document::DeleteService.call(id: '')
|
298
325
|
```
|
299
326
|
|
300
327
|
#### Sign a document
|
@@ -302,28 +329,52 @@ service = ZohoSign::Document::DeleteService.call(id: '')
|
|
302
329
|
A unique signing URL will be generated, which will be valid for two minutes. If the signing page is not open by then, a new link needs to be generated and it is a one-time usable URL.
|
303
330
|
|
304
331
|
```ruby
|
332
|
+
# https://www.zoho.com/sign/api/embedded-signing.html
|
333
|
+
|
305
334
|
service = ZohoSign::Document::Action::EmbedToken::GetService.call(request_id: '', action_id: '', host: '')
|
306
335
|
service.sign_url
|
307
336
|
```
|
308
337
|
|
338
|
+
</details>
|
339
|
+
|
340
|
+
<details>
|
341
|
+
<summary>Folders</summary>
|
342
|
+
|
309
343
|
### Folders
|
310
344
|
|
311
345
|
TODO: ...
|
312
346
|
|
347
|
+
</details>
|
348
|
+
|
349
|
+
<details>
|
350
|
+
<summary>Field Types</summary>
|
351
|
+
|
313
352
|
### Field Types
|
314
353
|
|
315
354
|
TODO: ...
|
316
355
|
|
356
|
+
</details>
|
357
|
+
|
358
|
+
<details>
|
359
|
+
<summary>Request Types</summary>
|
360
|
+
|
317
361
|
### Request Types
|
318
362
|
|
319
363
|
TODO: ...
|
320
364
|
|
365
|
+
</details>
|
366
|
+
|
367
|
+
<details>
|
368
|
+
<summary>Templates</summary>
|
369
|
+
|
321
370
|
### Templates
|
322
371
|
|
323
372
|
#### List templates
|
324
373
|
|
325
374
|
```ruby
|
326
|
-
|
375
|
+
# https://www.zoho.com/sign/api/template-managment/get-template-list.html
|
376
|
+
|
377
|
+
ZohoSign::Template::ListService.call(offset: 1, limit: 10).each do |facade|
|
327
378
|
facade.description
|
328
379
|
end
|
329
380
|
```
|
@@ -345,6 +396,8 @@ Columns to sort and filter by are `template_name`, `owner_first_name` and `modif
|
|
345
396
|
#### Get a template
|
346
397
|
|
347
398
|
```ruby
|
399
|
+
# https://www.zoho.com/sign/api/template-managment/get-template-details.html
|
400
|
+
|
348
401
|
service = ZohoSign::Template::GetService.call(id: '')
|
349
402
|
service.description
|
350
403
|
service.document_fields
|
@@ -354,6 +407,7 @@ service.folder_name
|
|
354
407
|
service.folder_id
|
355
408
|
service.owner_email
|
356
409
|
service.template_name
|
410
|
+
service.request_status
|
357
411
|
...
|
358
412
|
```
|
359
413
|
|
@@ -374,7 +428,9 @@ TODO: ...
|
|
374
428
|
The auto filled fields specified in the `field_data` object should be marked as **Prefill by you** when creating the document template.
|
375
429
|
|
376
430
|
```ruby
|
377
|
-
|
431
|
+
# https://www.zoho.com/sign/api/template-managment/send-documents-using-template.html
|
432
|
+
|
433
|
+
ZohoSign::Template::Document::CreateService.call!(
|
378
434
|
id: '',
|
379
435
|
is_quicksend: true,
|
380
436
|
data: {
|
@@ -406,6 +462,8 @@ service = ZohoSign::Template::Document::CreateService.call!(
|
|
406
462
|
)
|
407
463
|
```
|
408
464
|
|
465
|
+
</details>
|
466
|
+
|
409
467
|
## Development
|
410
468
|
|
411
469
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -1,12 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class ZohoSign::AccessToken::GetService < ZohoSign::BaseService
|
4
|
+
skip_callback :call, :before, :set_access_token
|
5
|
+
|
4
6
|
after_call :set_facade
|
5
7
|
|
6
8
|
delegate_missing_to :@facade
|
7
9
|
|
8
10
|
# Get access token.
|
9
11
|
#
|
12
|
+
# https://www.zoho.com/accounts/protocol/oauth/web-apps/access-token-expiry.html
|
13
|
+
#
|
10
14
|
# ==== Examples
|
11
15
|
#
|
12
16
|
# service = ZohoSign::AccessToken::GetService.call
|
@@ -38,7 +42,6 @@ class ZohoSign::AccessToken::GetService < ZohoSign::BaseService
|
|
38
42
|
client_id: client_id,
|
39
43
|
client_secret: client_secret,
|
40
44
|
refresh_token: refresh_token,
|
41
|
-
redirect_uri: 'https://sign.zoho.com',
|
42
45
|
grant_type: 'refresh_token'
|
43
46
|
}
|
44
47
|
end
|
@@ -15,7 +15,15 @@ class ZohoSign::BaseService < ActiveCall::Base
|
|
15
15
|
config_accessor :log_bodies, default: false, instance_writer: false
|
16
16
|
config_accessor :client_id, :client_secret, :refresh_token, instance_writer: false
|
17
17
|
|
18
|
-
attr_reader :facade
|
18
|
+
attr_reader :access_token, :facade
|
19
|
+
|
20
|
+
before_call :set_access_token
|
21
|
+
|
22
|
+
validate on: :request do
|
23
|
+
next if is_a?(ZohoSign::AccessToken::GetService)
|
24
|
+
|
25
|
+
errors.merge!(access_token_service.errors) if access_token.nil? && !access_token_service.success?
|
26
|
+
end
|
19
27
|
|
20
28
|
class << self
|
21
29
|
def exception_mapping
|
@@ -32,6 +40,7 @@ class ZohoSign::BaseService < ActiveCall::Base
|
|
32
40
|
proxy_authentication_required: ZohoSign::ProxyAuthenticationRequiredError,
|
33
41
|
request_timeout: ZohoSign::RequestTimeoutError,
|
34
42
|
conflict: ZohoSign::ConflictError,
|
43
|
+
gone: ZohoSign::GoneError,
|
35
44
|
unprocessable_entity: ZohoSign::UnprocessableEntityError,
|
36
45
|
too_many_requests: ZohoSign::TooManyRequestsError,
|
37
46
|
internal_server_error: ZohoSign::InternalServerError,
|
@@ -48,7 +57,7 @@ class ZohoSign::BaseService < ActiveCall::Base
|
|
48
57
|
def connection
|
49
58
|
@_connection ||= Faraday.new do |conn|
|
50
59
|
conn.url_prefix = base_url
|
51
|
-
conn.request :authorization, 'Zoho-oauthtoken',
|
60
|
+
conn.request :authorization, 'Zoho-oauthtoken', access_token
|
52
61
|
conn.request :multipart
|
53
62
|
conn.request :url_encoded
|
54
63
|
conn.request :retry
|
@@ -69,12 +78,18 @@ class ZohoSign::BaseService < ActiveCall::Base
|
|
69
78
|
}
|
70
79
|
end
|
71
80
|
|
72
|
-
def
|
73
|
-
access_token = ENV['ZOHO_SIGN_ACCESS_TOKEN'].presence || cache.read(CACHE_KEY[:access_token])
|
74
|
-
return
|
81
|
+
def set_access_token
|
82
|
+
@access_token = ENV['ZOHO_SIGN_ACCESS_TOKEN'].presence || cache.read(CACHE_KEY[:access_token])
|
83
|
+
return if @access_token.present?
|
84
|
+
return unless access_token_service.success?
|
85
|
+
|
86
|
+
@access_token = cache.fetch(CACHE_KEY[:access_token], expires_in: [access_token_service.expires_in - 10, 0].max) do
|
87
|
+
access_token_service.facade.access_token
|
88
|
+
end
|
89
|
+
end
|
75
90
|
|
76
|
-
|
77
|
-
|
91
|
+
def access_token_service
|
92
|
+
@_access_token_service ||= ZohoSign::AccessToken::GetService.call
|
78
93
|
end
|
79
94
|
|
80
95
|
def forbidden?
|
@@ -6,13 +6,13 @@ module ZohoSign::Enumerable
|
|
6
6
|
included do
|
7
7
|
include Enumerable
|
8
8
|
|
9
|
-
attr_reader :path, :list_key, :facade_klass, :
|
9
|
+
attr_reader :path, :list_key, :facade_klass, :offset, :limit
|
10
10
|
|
11
11
|
validates :path, :list_key, :facade_klass, presence: true
|
12
12
|
validates :limit, presence: true, numericality: { greater_than_or_equal_to: 1 }
|
13
13
|
end
|
14
14
|
|
15
|
-
def initialize(path:, list_key:, facade_klass:, limit: Float::INFINITY
|
15
|
+
def initialize(path:, list_key:, facade_klass:, offset: 1, limit: Float::INFINITY)
|
16
16
|
@path = path
|
17
17
|
@list_key = list_key
|
18
18
|
@facade_klass = facade_klass
|
@@ -41,6 +41,8 @@ module ZohoSign::Enumerable
|
|
41
41
|
throw :list_end
|
42
42
|
end
|
43
43
|
|
44
|
+
throw :list_end unless response.body
|
45
|
+
|
44
46
|
response.body[list_key].each do |hash|
|
45
47
|
yield facade_klass.new(hash)
|
46
48
|
total += 1
|
@@ -17,6 +17,8 @@ class ZohoSign::Document::Action::EmbedToken::GetService < ZohoSign::BaseService
|
|
17
17
|
|
18
18
|
# Get a signing URL.
|
19
19
|
#
|
20
|
+
# https://www.zoho.com/sign/api/embedded-signing.html
|
21
|
+
#
|
20
22
|
# A unique signing URL will be generated, which will be valid for two minutes. If the signing page is not open by
|
21
23
|
# then, a new link needs to be generated and it is a one-time usable URL.
|
22
24
|
#
|
@@ -37,7 +39,7 @@ class ZohoSign::Document::Action::EmbedToken::GetService < ZohoSign::BaseService
|
|
37
39
|
#
|
38
40
|
# POST /api/v1/requests/:request_id/actions/:action_id/embedtoken
|
39
41
|
def call
|
40
|
-
connection.post("
|
42
|
+
connection.post("requests/#{request_id}/actions/#{action_id}/embedtoken", **params)
|
41
43
|
end
|
42
44
|
|
43
45
|
private
|
@@ -11,6 +11,8 @@ class ZohoSign::Document::DeleteService < ZohoSign::BaseService
|
|
11
11
|
|
12
12
|
# Delete a document.
|
13
13
|
#
|
14
|
+
# https://www.zoho.com/sign/api/document-managment/delete-document.html
|
15
|
+
#
|
14
16
|
# ==== Examples
|
15
17
|
#
|
16
18
|
# service = ZohoSign::Document::DeleteService.call(id: '')
|
@@ -15,6 +15,8 @@ class ZohoSign::Document::GetService < ZohoSign::BaseService
|
|
15
15
|
|
16
16
|
# Get a document.
|
17
17
|
#
|
18
|
+
# https://www.zoho.com/sign/api/document-managment/get-details-of-a-particular-document.html
|
19
|
+
#
|
18
20
|
# ==== Examples
|
19
21
|
#
|
20
22
|
# service = ZohoSign::Document::GetService.call(id: '')
|
@@ -25,6 +25,8 @@ class ZohoSign::Document::ListService < ZohoSign::BaseService
|
|
25
25
|
|
26
26
|
# List documents.
|
27
27
|
#
|
28
|
+
# https://www.zoho.com/sign/api/document-managment/get-document-list.html
|
29
|
+
#
|
28
30
|
# ==== Examples
|
29
31
|
#
|
30
32
|
# service = ZohoSign::Document::ListService.call.first
|
@@ -47,7 +49,7 @@ class ZohoSign::Document::ListService < ZohoSign::BaseService
|
|
47
49
|
# and `created_time`.
|
48
50
|
#
|
49
51
|
# GET /api/v1/requests
|
50
|
-
def initialize(limit: Float::INFINITY,
|
52
|
+
def initialize(offset: 1, limit: Float::INFINITY, sort_column: 'created_time', sort_order: 'DESC', search_columns: {})
|
51
53
|
@sort_column = sort_column
|
52
54
|
@sort_order = sort_order
|
53
55
|
@search_columns = search_columns
|
data/lib/zoho_sign/error.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ZohoSign::GrantToken::Facade
|
4
|
+
attr_reader :access_token, :refresh_token, :scope, :api_domain, :expires_in, :token_type
|
5
|
+
|
6
|
+
def initialize(hash)
|
7
|
+
@access_token = hash['access_token']
|
8
|
+
@api_domain = hash['api_domain']
|
9
|
+
@expires_in = hash['expires_in']
|
10
|
+
@refresh_token = hash['refresh_token']
|
11
|
+
@scope = hash['scope']
|
12
|
+
@token_type = hash['token_type']
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ZohoSign::GrantToken::GetService < ZohoSign::BaseService
|
4
|
+
attr_reader :grant_token, :client_id, :client_secret
|
5
|
+
|
6
|
+
after_call :set_facade
|
7
|
+
|
8
|
+
delegate_missing_to :@facade
|
9
|
+
delegate :refresh_token, to: :@facade, allow_nil: true
|
10
|
+
|
11
|
+
validates :grant_token, presence: true
|
12
|
+
|
13
|
+
def initialize(grant_token:, client_id: nil, client_secret: nil)
|
14
|
+
@grant_token = grant_token
|
15
|
+
@client_id = client_id.presence || ZohoSign::BaseService.client_id
|
16
|
+
@client_secret = client_secret.presence || ZohoSign::BaseService.client_secret
|
17
|
+
end
|
18
|
+
|
19
|
+
# Get refresh token from grant token.
|
20
|
+
#
|
21
|
+
# https://www.zoho.com/accounts/protocol/oauth/web-apps/access-token.html
|
22
|
+
#
|
23
|
+
# ==== Examples
|
24
|
+
#
|
25
|
+
# service = ZohoSign::GrantToken::GetService.call(grant_token: '', client_id: '', client_secret: '')
|
26
|
+
# service.refresh_token # => '1000.xxxx.yyyy'
|
27
|
+
# service.expires_in # => 3600
|
28
|
+
#
|
29
|
+
# POST /oauth/v2/token
|
30
|
+
def call
|
31
|
+
connection.post('oauth/v2/token', params.to_param)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def connection
|
37
|
+
@_connection ||= Faraday.new do |conn|
|
38
|
+
conn.url_prefix = 'https://accounts.zoho.com'
|
39
|
+
conn.request :retry
|
40
|
+
conn.response :json
|
41
|
+
conn.response :logger, logger, **logger_options do |logger|
|
42
|
+
logger.filter(/(code|client_id|client_secret)=([^&]+)/i, '\1=[FILTERED]')
|
43
|
+
logger.filter(/"access_token":"([^"]+)"/i, '"access_token":"[FILTERED]"')
|
44
|
+
logger.filter(/"refresh_token":"([^"]+)"/i, '"refresh_token":"[FILTERED]"')
|
45
|
+
end
|
46
|
+
conn.adapter Faraday.default_adapter
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def params
|
51
|
+
{
|
52
|
+
client_id: client_id,
|
53
|
+
client_secret: client_secret,
|
54
|
+
code: grant_token,
|
55
|
+
grant_type: 'authorization_code'
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
def unauthorized?
|
60
|
+
response.status == 200 && response.body.key?('error')
|
61
|
+
end
|
62
|
+
|
63
|
+
def set_facade
|
64
|
+
@facade = ZohoCrm::GrantToken::Facade.new(response.body)
|
65
|
+
end
|
66
|
+
end
|
@@ -18,6 +18,8 @@ class ZohoSign::Template::Document::CreateService < ZohoSign::BaseService
|
|
18
18
|
|
19
19
|
# Create a document from a template.
|
20
20
|
#
|
21
|
+
# https://www.zoho.com/sign/api/template-managment/send-documents-using-template.html
|
22
|
+
#
|
21
23
|
# ==== Examples
|
22
24
|
#
|
23
25
|
# service = ZohoSign::Template::Document::CreateService.call!(
|
@@ -25,6 +25,8 @@ class ZohoSign::Template::ListService < ZohoSign::BaseService
|
|
25
25
|
|
26
26
|
# List documents.
|
27
27
|
#
|
28
|
+
# https://www.zoho.com/sign/api/template-managment/get-template-list.html
|
29
|
+
#
|
28
30
|
# ==== Examples
|
29
31
|
#
|
30
32
|
# service = ZohoSign::Template::ListService.call.first
|
@@ -46,7 +48,7 @@ class ZohoSign::Template::ListService < ZohoSign::BaseService
|
|
46
48
|
# Columns to sort and filter by are `template_name`, `owner_first_name` and `modified_time`.
|
47
49
|
#
|
48
50
|
# GET /api/v1/templates
|
49
|
-
def initialize(limit: Float::INFINITY,
|
51
|
+
def initialize(offset: 1, limit: Float::INFINITY, sort_column: 'template_name', sort_order: 'DESC', search_columns: {})
|
50
52
|
@sort_column = sort_column
|
51
53
|
@sort_order = sort_order
|
52
54
|
@search_columns = search_columns
|
data/lib/zoho_sign/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_call-zoho_sign
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kobus Joubert
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: active_call
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0.2'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0.2'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: active_call-api
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,34 +24,6 @@ dependencies:
|
|
38
24
|
- - "~>"
|
39
25
|
- !ruby/object:Gem::Version
|
40
26
|
version: '0.1'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: faraday
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '2.0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '2.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: faraday-retry
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '2.0'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '2.0'
|
69
27
|
- !ruby/object:Gem::Dependency
|
70
28
|
name: faraday-multipart
|
71
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,21 +38,8 @@ dependencies:
|
|
80
38
|
- - "~>"
|
81
39
|
- !ruby/object:Gem::Version
|
82
40
|
version: '1.1'
|
83
|
-
|
84
|
-
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0.2'
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0.2'
|
97
|
-
description: Zoho Sign exposes the Zoho Sign API endpoints through service objects.
|
41
|
+
description: Zoho Sign exposes the Zoho Sign API endpoints through Active Call service
|
42
|
+
objects.
|
98
43
|
email:
|
99
44
|
- kobus@translate3d.com
|
100
45
|
executables: []
|
@@ -124,6 +69,8 @@ files:
|
|
124
69
|
- lib/zoho_sign/document/list_service.rb
|
125
70
|
- lib/zoho_sign/document/update_service.rb
|
126
71
|
- lib/zoho_sign/error.rb
|
72
|
+
- lib/zoho_sign/grant_token/facade.rb
|
73
|
+
- lib/zoho_sign/grant_token/get_service.rb
|
127
74
|
- lib/zoho_sign/template/document/create_service.rb
|
128
75
|
- lib/zoho_sign/template/document/facade.rb
|
129
76
|
- lib/zoho_sign/template/facade.rb
|
@@ -158,5 +105,5 @@ requirements: []
|
|
158
105
|
rubygems_version: 3.3.27
|
159
106
|
signing_key:
|
160
107
|
specification_version: 4
|
161
|
-
summary: Zoho Sign
|
108
|
+
summary: Zoho Sign service objects
|
162
109
|
test_files: []
|