active_call-zoho_sign 0.1.3 → 0.1.5
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 +3 -3
- data/CHANGELOG.md +7 -1
- data/README.md +48 -30
- data/lib/zoho_sign/concerns/enumerable.rb +71 -0
- data/lib/zoho_sign/document/action/embed_token/get_service.rb +15 -12
- data/lib/zoho_sign/document/get_service.rb +1 -1
- data/lib/zoho_sign/document/list_service.rb +27 -48
- data/lib/zoho_sign/template/get_service.rb +1 -1
- data/lib/zoho_sign/template/list_service.rb +26 -48
- data/lib/zoho_sign/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba562fec7bae27b72ad781e923c0b1db6f0076568a170769ed9490dd0927ca9d
|
4
|
+
data.tar.gz: a2e7dc48e0a7b6cf7774e23a5b93be6026bf7c58b695598a79bd570a5a3e84a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 309cf5cdb4c67fbb25e470000a3a81dd21c19209018ecd8e206a8be79ef396537bd5e835e928a0e39ed454bf92327ad9f44c5e77c07279b71ea752d408245a7f
|
7
|
+
data.tar.gz: ea0fd98f0da44b1c564a7f743187f71e3691cd820d8485700e6f21502bc5c9d308d9dcfe68e1e8ed0f2b75a27bffb3b7cafdeb7cfc7530389e656cb4d9105bfc
|
data/.rubocop.yml
CHANGED
@@ -20,7 +20,8 @@ Layout/HashAlignment:
|
|
20
20
|
EnforcedColonStyle: table
|
21
21
|
|
22
22
|
Layout/LineLength:
|
23
|
-
AllowedPatterns:
|
23
|
+
AllowedPatterns:
|
24
|
+
- initialize
|
24
25
|
|
25
26
|
Lint/MissingSuper:
|
26
27
|
Enabled: false
|
@@ -37,8 +38,7 @@ Metrics/ClassLength:
|
|
37
38
|
|
38
39
|
Metrics/CyclomaticComplexity:
|
39
40
|
Exclude:
|
40
|
-
- lib/zoho_sign/
|
41
|
-
- lib/zoho_sign/template/list_service.rb
|
41
|
+
- lib/zoho_sign/concerns/enumerable.rb
|
42
42
|
|
43
43
|
Metrics/MethodLength:
|
44
44
|
Enabled: false
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,20 @@
|
|
4
4
|
|
5
5
|
Zoho Sign exposes the [Zoho Sign API](https://www.zoho.com/sign/api) endpoints through service objects.
|
6
6
|
|
7
|
+
- [Installation](#installation)
|
8
|
+
- [Configuration](#configuration)
|
9
|
+
- [Usage](#usage)
|
10
|
+
- [Using call](#using-call)
|
11
|
+
- [Using call!](#using-call!)
|
12
|
+
- [When to use call or call!](#using-call-or-call!)
|
13
|
+
- [Using lists](#using-lists)
|
14
|
+
- [Documents](#documents)
|
15
|
+
- [Folders](#folders)
|
16
|
+
- [Templates](#templates)
|
17
|
+
- [Development](#development)
|
18
|
+
- [Contributing](#contributing)
|
19
|
+
- [License](#license)
|
20
|
+
|
7
21
|
## Installation
|
8
22
|
|
9
23
|
Install the gem and add to the application's Gemfile by executing:
|
@@ -45,7 +59,7 @@ While testing, you can set your temporary development OAuth access token in the
|
|
45
59
|
|
46
60
|
## Usage
|
47
61
|
|
48
|
-
### Using
|
62
|
+
### <a name='using-call'></a>Using `call`
|
49
63
|
|
50
64
|
Each service object returned will undergo validation before the `call` method is invoked to access API endpoints.
|
51
65
|
|
@@ -99,7 +113,7 @@ service.response.status # => 400
|
|
99
113
|
service.response.body # => {"code"=>9004, "message"=>"No match found", "status"=>"failure"}
|
100
114
|
```
|
101
115
|
|
102
|
-
### Using
|
116
|
+
### <a name='using-call!'></a>Using `call!`
|
103
117
|
|
104
118
|
Each service object returned will undergo validation before the `call!` method is invoked to access API endpoints.
|
105
119
|
|
@@ -154,14 +168,14 @@ rescue ZohoSign::RequestError => exception
|
|
154
168
|
exception.response.body # => {"code"=>9004, "message"=>"No match found", "status"=>"failure"}
|
155
169
|
```
|
156
170
|
|
157
|
-
### When to use
|
171
|
+
### <a name='using-call-or-call!'></a>When to use `call` or `call!`
|
158
172
|
|
159
|
-
An example of where to use
|
173
|
+
An example of where to use `call` would be in a **controller** doing an inline synchronous request.
|
160
174
|
|
161
175
|
```ruby
|
162
176
|
class DocumentController < ApplicationController
|
163
177
|
def update
|
164
|
-
@document = ZohoSign::Document::UpdateService.call(params)
|
178
|
+
@document = ZohoSign::Document::UpdateService.call(**params)
|
165
179
|
|
166
180
|
if @document.success?
|
167
181
|
redirect_to [@document], notice: 'Success', status: :see_other
|
@@ -173,7 +187,7 @@ class DocumentController < ApplicationController
|
|
173
187
|
end
|
174
188
|
```
|
175
189
|
|
176
|
-
An example of where to use
|
190
|
+
An example of where to use `call!` would be in a **job** doing an asynchronous request.
|
177
191
|
|
178
192
|
You can use the exceptions to determine which retry strategy to use and which to discard.
|
179
193
|
|
@@ -185,19 +199,20 @@ class DocumentJob < ApplicationJob
|
|
185
199
|
retry_on ZohoSign::TooManyRequestsError, wait: :polynomially_longer, attempts: 10
|
186
200
|
|
187
201
|
def perform
|
188
|
-
ZohoSign::Document::UpdateService.call!(params)
|
202
|
+
ZohoSign::Document::UpdateService.call!(**params)
|
189
203
|
end
|
190
204
|
end
|
191
205
|
```
|
192
206
|
|
193
|
-
###
|
207
|
+
### Using lists
|
208
|
+
|
209
|
+
If you don't provide the `limit` argument, multiple API requests will be made untill all records have been returned. You could be rate limited, so use wisely.
|
194
210
|
|
195
|
-
|
211
|
+
Note that the `offset` argument starts at `1` for the first item.
|
196
212
|
|
197
|
-
|
213
|
+
### Documents
|
198
214
|
|
199
|
-
|
200
|
-
rate limited, so use wisely.
|
215
|
+
#### List documents
|
201
216
|
|
202
217
|
```ruby
|
203
218
|
service = ZohoSign::Document::ListService.call(offset: 1, limit: 10).each do |facade|
|
@@ -217,10 +232,9 @@ Filter by column.
|
|
217
232
|
ZohoSign::Document::ListService.call(search_columns: { recipient_email: 'eric.cartman@example.com' }).map { _1 }
|
218
233
|
```
|
219
234
|
|
220
|
-
Columns to sort and filter by are `request_name`, `folder_name`, `owner_full_name`, `recipient_email`,
|
221
|
-
`form_name` `created_time`.
|
235
|
+
Columns to sort and filter by are `request_name`, `folder_name`, `owner_full_name`, `recipient_email`, `form_name` and `created_time`.
|
222
236
|
|
223
|
-
#### Get a document
|
237
|
+
#### Get a document
|
224
238
|
|
225
239
|
```ruby
|
226
240
|
service = ZohoSign::Document::GetService.call(id: '')
|
@@ -235,7 +249,7 @@ service.sign_percentage
|
|
235
249
|
...
|
236
250
|
```
|
237
251
|
|
238
|
-
#### Create a document
|
252
|
+
#### Create a document
|
239
253
|
|
240
254
|
```ruby
|
241
255
|
service = ZohoSign::Document::CreateService.call(
|
@@ -258,7 +272,7 @@ service = ZohoSign::Document::CreateService.call(
|
|
258
272
|
)
|
259
273
|
```
|
260
274
|
|
261
|
-
#### Update a document
|
275
|
+
#### Update a document
|
262
276
|
|
263
277
|
```ruby
|
264
278
|
service = ZohoSign::Document::UpdateService.call(
|
@@ -277,12 +291,21 @@ service = ZohoSign::Document::UpdateService.call(
|
|
277
291
|
)
|
278
292
|
```
|
279
293
|
|
280
|
-
#### Delete a document
|
294
|
+
#### Delete a document
|
281
295
|
|
282
296
|
```ruby
|
283
297
|
service = ZohoSign::Document::DeleteService.call(id: '')
|
284
298
|
```
|
285
299
|
|
300
|
+
#### Sign a document
|
301
|
+
|
302
|
+
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
|
+
|
304
|
+
```ruby
|
305
|
+
service = ZohoSign::Document::Action::EmbedToken::GetService.call(request_id: '', action_id: '', host: '')
|
306
|
+
service.sign_url
|
307
|
+
```
|
308
|
+
|
286
309
|
### Folders
|
287
310
|
|
288
311
|
TODO: ...
|
@@ -297,12 +320,7 @@ TODO: ...
|
|
297
320
|
|
298
321
|
### Templates
|
299
322
|
|
300
|
-
#### List templates
|
301
|
-
|
302
|
-
Note that the `offset` starts at `1` for the first item.
|
303
|
-
|
304
|
-
If you don't provide a `limit`, multiple API requests will be made untill all records have been returned. You could be
|
305
|
-
rate limited, so use wisely.
|
323
|
+
#### List templates
|
306
324
|
|
307
325
|
```ruby
|
308
326
|
service = ZohoSign::Template::ListService.call(offset: 1, limit: 10).each do |facade|
|
@@ -322,9 +340,9 @@ Filter by column.
|
|
322
340
|
ZohoSign::Template::ListService.call(search_columns: { template_name: 'Eric Template' }).map { _1 }
|
323
341
|
```
|
324
342
|
|
325
|
-
Columns to sort and filter by are `template_name`, `owner_first_name
|
343
|
+
Columns to sort and filter by are `template_name`, `owner_first_name` and `modified_time`.
|
326
344
|
|
327
|
-
#### Get a template
|
345
|
+
#### Get a template
|
328
346
|
|
329
347
|
```ruby
|
330
348
|
service = ZohoSign::Template::GetService.call(id: '')
|
@@ -339,19 +357,19 @@ service.template_name
|
|
339
357
|
...
|
340
358
|
```
|
341
359
|
|
342
|
-
#### Create a template
|
360
|
+
#### Create a template
|
343
361
|
|
344
362
|
TODO: ...
|
345
363
|
|
346
|
-
#### Update a template
|
364
|
+
#### Update a template
|
347
365
|
|
348
366
|
TODO: ...
|
349
367
|
|
350
|
-
#### Delete a template
|
368
|
+
#### Delete a template
|
351
369
|
|
352
370
|
TODO: ...
|
353
371
|
|
354
|
-
#### Create document from template
|
372
|
+
#### Create document from template
|
355
373
|
|
356
374
|
The auto filled fields specified in the `field_data` object should be marked as **Prefill by you** when creating the document template.
|
357
375
|
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ZohoSign::Enumerable
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
include Enumerable
|
8
|
+
|
9
|
+
attr_reader :path, :list_key, :facade_klass, :limit, :offset
|
10
|
+
|
11
|
+
validates :path, :list_key, :facade_klass, presence: true
|
12
|
+
validates :limit, presence: true, numericality: { greater_than_or_equal_to: 1 }
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(path:, list_key:, facade_klass:, limit: Float::INFINITY, offset: 1)
|
16
|
+
@path = path
|
17
|
+
@list_key = list_key
|
18
|
+
@facade_klass = facade_klass
|
19
|
+
@limit = limit
|
20
|
+
@offset = offset
|
21
|
+
end
|
22
|
+
|
23
|
+
def call
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
27
|
+
def each
|
28
|
+
return to_enum(:each) unless block_given?
|
29
|
+
return if invalid?
|
30
|
+
|
31
|
+
total = 0
|
32
|
+
|
33
|
+
catch :list_end do
|
34
|
+
loop do
|
35
|
+
@response = connection.get(path, data: params.to_json)
|
36
|
+
validate(:response)
|
37
|
+
|
38
|
+
unless success?
|
39
|
+
raise exception_for(response, errors) if bang?
|
40
|
+
|
41
|
+
throw :list_end
|
42
|
+
end
|
43
|
+
|
44
|
+
response.body[list_key].each do |hash|
|
45
|
+
yield facade_klass.new(hash)
|
46
|
+
total += 1
|
47
|
+
throw :list_end if total >= limit
|
48
|
+
end
|
49
|
+
|
50
|
+
break unless response.body.dig('page_context', 'has_more_rows')
|
51
|
+
|
52
|
+
@_params[:page_context][:start_index] += max_limit_per_request
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def params
|
60
|
+
@_params ||= {
|
61
|
+
page_context: {
|
62
|
+
row_count: max_limit_per_request,
|
63
|
+
start_index: offset
|
64
|
+
}
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
def max_limit_per_request
|
69
|
+
@_max_limit_per_request ||= limit.infinite? ? 100 : [limit, 100].min
|
70
|
+
end
|
71
|
+
end
|
@@ -1,25 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class ZohoSign::Document::Action::EmbedToken::GetService < ZohoSign::BaseService
|
4
|
-
attr_reader :
|
4
|
+
attr_reader :request_id, :action_id, :host
|
5
|
+
|
6
|
+
validates :request_id, :action_id, :host, presence: true
|
5
7
|
|
6
8
|
after_call :set_facade
|
7
9
|
|
8
10
|
delegate_missing_to :@facade
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
def initialize(id:, request_id:, host:)
|
13
|
-
@id = id
|
12
|
+
def initialize(request_id:, action_id:, host:)
|
14
13
|
@request_id = request_id
|
14
|
+
@action_id = action_id
|
15
15
|
@host = host
|
16
16
|
end
|
17
17
|
|
18
|
-
# Get a
|
18
|
+
# Get a signing URL.
|
19
|
+
#
|
20
|
+
# A unique signing URL will be generated, which will be valid for two minutes. If the signing page is not open by
|
21
|
+
# then, a new link needs to be generated and it is a one-time usable URL.
|
19
22
|
#
|
20
23
|
# ==== Examples
|
21
24
|
#
|
22
|
-
# service = ZohoSign::Document::Action::EmbedToken::GetService.call(
|
25
|
+
# service = ZohoSign::Document::Action::EmbedToken::GetService.call(request_id: '', action_id: '', host: '')
|
23
26
|
#
|
24
27
|
# service.success? # => true
|
25
28
|
# service.errors # => #<ActiveModel::Errors []>
|
@@ -29,12 +32,12 @@ class ZohoSign::Document::Action::EmbedToken::GetService < ZohoSign::BaseService
|
|
29
32
|
# service.response.body # => {}
|
30
33
|
#
|
31
34
|
# service.facade # => #<ZohoSign::Document::Action::EmbedToken::Facade ...>
|
32
|
-
# service.facade.
|
33
|
-
# service.
|
35
|
+
# service.facade.sign_url
|
36
|
+
# service.sign_url
|
34
37
|
#
|
35
|
-
# POST /api/v1/requests/:request_id/actions/:
|
38
|
+
# POST /api/v1/requests/:request_id/actions/:action_id/embedtoken
|
36
39
|
def call
|
37
|
-
connection.post("/api/v1/requests/#{request_id}/actions/#{
|
40
|
+
connection.post("/api/v1/requests/#{request_id}/actions/#{action_id}/embedtoken", **params)
|
38
41
|
end
|
39
42
|
|
40
43
|
private
|
@@ -46,6 +49,6 @@ class ZohoSign::Document::Action::EmbedToken::GetService < ZohoSign::BaseService
|
|
46
49
|
end
|
47
50
|
|
48
51
|
def set_facade
|
49
|
-
@facade = ZohoSign::Document::Action::EmbedToken.new(response.body)
|
52
|
+
@facade = ZohoSign::Document::Action::EmbedToken::Facade.new(response.body)
|
50
53
|
end
|
51
54
|
end
|
@@ -4,11 +4,10 @@ class ZohoSign::Document::ListService < ZohoSign::BaseService
|
|
4
4
|
SORT_COLUMNS = %w[request_name folder_name owner_full_name recipient_email form_name created_time].freeze
|
5
5
|
SORT_ORDERS = %w[ASC DESC].freeze
|
6
6
|
|
7
|
-
include Enumerable
|
7
|
+
include ZohoSign::Enumerable
|
8
8
|
|
9
|
-
attr_reader :
|
9
|
+
attr_reader :sort_column, :sort_order, :search_columns
|
10
10
|
|
11
|
-
validates :limit, presence: true, numericality: { greater_than_or_equal_to: 1 }
|
12
11
|
validates :sort_order, inclusion: { in: SORT_ORDERS, message: "Sort order must be one of #{SORT_ORDERS.join(', ')}" }
|
13
12
|
|
14
13
|
validates :sort_column, inclusion: {
|
@@ -24,14 +23,6 @@ class ZohoSign::Document::ListService < ZohoSign::BaseService
|
|
24
23
|
throw :abort
|
25
24
|
end
|
26
25
|
|
27
|
-
def initialize(limit: Float::INFINITY, offset: 1, sort_column: 'created_time', sort_order: 'DESC', search_columns: {})
|
28
|
-
@limit = limit
|
29
|
-
@offset = offset
|
30
|
-
@sort_column = sort_column
|
31
|
-
@sort_order = sort_order
|
32
|
-
@search_columns = search_columns
|
33
|
-
end
|
34
|
-
|
35
26
|
# List documents.
|
36
27
|
#
|
37
28
|
# ==== Examples
|
@@ -39,43 +30,35 @@ class ZohoSign::Document::ListService < ZohoSign::BaseService
|
|
39
30
|
# service = ZohoSign::Document::ListService.call.first
|
40
31
|
# service.request_name
|
41
32
|
#
|
33
|
+
# If you don't provide the `limit` argument, multiple API requests will be made untill all records have been returned.
|
34
|
+
# You could be rate limited, so use wisely.
|
35
|
+
#
|
42
36
|
# ZohoSign::Document::ListService.call(offset: 11, limit: 10).each { _1 }
|
43
|
-
#
|
44
|
-
#
|
37
|
+
#
|
38
|
+
# Sort by column.
|
39
|
+
#
|
40
|
+
# ZohoSign::Document::ListService.call(sort_column: 'recipient_email', sort_order: 'ASC').map { _1 }
|
41
|
+
#
|
42
|
+
# Filter by column.
|
43
|
+
#
|
44
|
+
# ZohoSign::Document::ListService.call(search_columns: { recipient_email: 'eric.cartman@example.com' }).map { _1 }
|
45
|
+
#
|
46
|
+
# Columns to sort and filter by are `request_name`, `folder_name`, `owner_full_name`, `recipient_email`, `form_name`
|
47
|
+
# and `created_time`.
|
45
48
|
#
|
46
49
|
# GET /api/v1/requests
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
def each
|
52
|
-
return to_enum(:each) unless block_given?
|
53
|
-
return if invalid?
|
54
|
-
|
55
|
-
total = 0
|
56
|
-
|
57
|
-
catch :list_end do
|
58
|
-
loop do
|
59
|
-
@response = connection.get('requests', data: params.to_json)
|
60
|
-
validate(:response)
|
61
|
-
|
62
|
-
unless success?
|
63
|
-
raise exception_for(response, errors) if bang?
|
64
|
-
|
65
|
-
throw :list_end
|
66
|
-
end
|
67
|
-
|
68
|
-
response.body['requests'].each do |hash|
|
69
|
-
yield ZohoSign::Document::Facade.new(hash)
|
70
|
-
total += 1
|
71
|
-
throw :list_end if total >= limit
|
72
|
-
end
|
73
|
-
|
74
|
-
break unless response.body.dig('page_context', 'has_more_rows')
|
50
|
+
def initialize(limit: Float::INFINITY, offset: 1, sort_column: 'created_time', sort_order: 'DESC', search_columns: {})
|
51
|
+
@sort_column = sort_column
|
52
|
+
@sort_order = sort_order
|
53
|
+
@search_columns = search_columns
|
75
54
|
|
76
|
-
|
77
|
-
|
78
|
-
|
55
|
+
super(
|
56
|
+
path: 'requests',
|
57
|
+
list_key: 'requests',
|
58
|
+
facade_klass: ZohoSign::Document::Facade,
|
59
|
+
limit: limit,
|
60
|
+
offset: offset
|
61
|
+
)
|
79
62
|
end
|
80
63
|
|
81
64
|
private
|
@@ -91,8 +74,4 @@ class ZohoSign::Document::ListService < ZohoSign::BaseService
|
|
91
74
|
}
|
92
75
|
}
|
93
76
|
end
|
94
|
-
|
95
|
-
def max_limit_per_request
|
96
|
-
@_max_limit_per_request ||= limit.infinite? ? 100 : [limit, 100].min
|
97
|
-
end
|
98
77
|
end
|
@@ -4,11 +4,10 @@ class ZohoSign::Template::ListService < ZohoSign::BaseService
|
|
4
4
|
SORT_COLUMNS = %w[template_name owner_first_name modified_time].freeze
|
5
5
|
SORT_ORDERS = %w[ASC DESC].freeze
|
6
6
|
|
7
|
-
include Enumerable
|
7
|
+
include ZohoSign::Enumerable
|
8
8
|
|
9
|
-
attr_reader :
|
9
|
+
attr_reader :sort_column, :sort_order, :search_columns
|
10
10
|
|
11
|
-
validates :limit, presence: true, numericality: { greater_than_or_equal_to: 1 }
|
12
11
|
validates :sort_order, inclusion: { in: SORT_ORDERS, message: "Sort order must be one of #{SORT_ORDERS.join(', ')}" }
|
13
12
|
|
14
13
|
validates :sort_column, inclusion: {
|
@@ -24,14 +23,6 @@ class ZohoSign::Template::ListService < ZohoSign::BaseService
|
|
24
23
|
throw :abort
|
25
24
|
end
|
26
25
|
|
27
|
-
def initialize(limit: Float::INFINITY, offset: 1, sort_column: 'template_name', sort_order: 'DESC', search_columns: {})
|
28
|
-
@limit = limit
|
29
|
-
@offset = offset
|
30
|
-
@sort_column = sort_column
|
31
|
-
@sort_order = sort_order
|
32
|
-
@search_columns = search_columns
|
33
|
-
end
|
34
|
-
|
35
26
|
# List documents.
|
36
27
|
#
|
37
28
|
# ==== Examples
|
@@ -39,43 +30,34 @@ class ZohoSign::Template::ListService < ZohoSign::BaseService
|
|
39
30
|
# service = ZohoSign::Template::ListService.call.first
|
40
31
|
# service.request_name
|
41
32
|
#
|
33
|
+
# If you don't provide the `limit` argument, multiple API requests will be made untill all records have been returned.
|
34
|
+
# You could be rate limited, so use wisely.
|
35
|
+
#
|
42
36
|
# ZohoSign::Template::ListService.call(offset: 11, limit: 10).each { _1 }
|
43
|
-
#
|
44
|
-
#
|
37
|
+
#
|
38
|
+
# Sort by column.
|
39
|
+
#
|
40
|
+
# ZohoSign::Template::ListService.call(sort_column: 'template_name', sort_order: 'ASC').map { _1 }
|
41
|
+
#
|
42
|
+
# Filter by column.
|
43
|
+
#
|
44
|
+
# ZohoSign::Template::ListService.call(search_columns: { template_name: 'Eric Template' }).map { _1 }
|
45
|
+
#
|
46
|
+
# Columns to sort and filter by are `template_name`, `owner_first_name` and `modified_time`.
|
45
47
|
#
|
46
48
|
# GET /api/v1/templates
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
def each
|
52
|
-
return to_enum(:each) unless block_given?
|
53
|
-
return if invalid?
|
54
|
-
|
55
|
-
total = 0
|
56
|
-
|
57
|
-
catch :list_end do
|
58
|
-
loop do
|
59
|
-
@response = connection.get('templates', data: params.to_json)
|
60
|
-
validate(:response)
|
61
|
-
|
62
|
-
unless success?
|
63
|
-
raise exception_for(response, errors) if bang?
|
64
|
-
|
65
|
-
throw :list_end
|
66
|
-
end
|
67
|
-
|
68
|
-
response.body['templates'].each do |hash|
|
69
|
-
yield ZohoSign::Template::Facade.new(hash)
|
70
|
-
total += 1
|
71
|
-
throw :list_end if total >= limit
|
72
|
-
end
|
73
|
-
|
74
|
-
break unless response.body.dig('page_context', 'has_more_rows')
|
49
|
+
def initialize(limit: Float::INFINITY, offset: 1, sort_column: 'template_name', sort_order: 'DESC', search_columns: {})
|
50
|
+
@sort_column = sort_column
|
51
|
+
@sort_order = sort_order
|
52
|
+
@search_columns = search_columns
|
75
53
|
|
76
|
-
|
77
|
-
|
78
|
-
|
54
|
+
super(
|
55
|
+
path: 'templates',
|
56
|
+
list_key: 'templates',
|
57
|
+
facade_klass: ZohoSign::Template::Facade,
|
58
|
+
limit: limit,
|
59
|
+
offset: offset
|
60
|
+
)
|
79
61
|
end
|
80
62
|
|
81
63
|
private
|
@@ -91,8 +73,4 @@ class ZohoSign::Template::ListService < ZohoSign::BaseService
|
|
91
73
|
}
|
92
74
|
}
|
93
75
|
end
|
94
|
-
|
95
|
-
def max_limit_per_request
|
96
|
-
@_max_limit_per_request ||= limit.infinite? ? 100 : [limit, 100].min
|
97
|
-
end
|
98
76
|
end
|
data/lib/zoho_sign/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.5
|
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-03
|
11
|
+
date: 2025-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_call
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- lib/zoho_sign/access_token/facade.rb
|
113
113
|
- lib/zoho_sign/access_token/get_service.rb
|
114
114
|
- lib/zoho_sign/base_service.rb
|
115
|
+
- lib/zoho_sign/concerns/enumerable.rb
|
115
116
|
- lib/zoho_sign/current_user/facade.rb
|
116
117
|
- lib/zoho_sign/current_user/get_service.rb
|
117
118
|
- lib/zoho_sign/document/action/embed_token/facade.rb
|