telerivet 1.4.5 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/telerivet/airtimetransaction.rb +155 -0
- data/lib/telerivet/apicursor.rb +26 -22
- data/lib/telerivet/broadcast.rb +16 -5
- data/lib/telerivet/contact.rb +38 -14
- data/lib/telerivet/datatable.rb +20 -8
- data/lib/telerivet/group.rb +18 -18
- data/lib/telerivet/label.rb +12 -3
- data/lib/telerivet/message.rb +77 -35
- data/lib/telerivet/organization.rb +124 -2
- data/lib/telerivet/phone.rb +21 -10
- data/lib/telerivet/project.rb +1237 -49
- data/lib/telerivet/relativescheduledmessage.rb +361 -0
- data/lib/telerivet/route.rb +1 -1
- data/lib/telerivet/scheduledmessage.rb +112 -22
- data/lib/telerivet/service.rb +175 -38
- data/lib/telerivet/task.rb +151 -0
- data/lib/telerivet.rb +1 -1
- metadata +5 -2
data/lib/telerivet/service.rb
CHANGED
@@ -21,6 +21,10 @@ module Telerivet
|
|
21
21
|
# * Name of the service
|
22
22
|
# * Updatable via API
|
23
23
|
#
|
24
|
+
# - service_type
|
25
|
+
# * Type of the service.
|
26
|
+
# * Read-only
|
27
|
+
#
|
24
28
|
# - active (bool)
|
25
29
|
# * Whether the service is active or inactive. Inactive services are not automatically
|
26
30
|
# triggered and cannot be invoked via the API.
|
@@ -48,31 +52,48 @@ module Telerivet
|
|
48
52
|
# * ID of the project this service belongs to
|
49
53
|
# * Read-only
|
50
54
|
#
|
51
|
-
# - label_id
|
52
|
-
# * ID of the label containing messages sent or received by this service (currently only
|
53
|
-
# used for polls)
|
54
|
-
# * Read-only
|
55
|
-
#
|
56
55
|
# - response_table_id
|
57
|
-
# * ID of the data table where responses to this service will be stored
|
58
|
-
#
|
59
|
-
# * Read-only
|
56
|
+
# * ID of the data table where responses to this service will be stored
|
57
|
+
# * Updatable via API
|
60
58
|
#
|
61
|
-
# -
|
62
|
-
# *
|
63
|
-
#
|
64
|
-
#
|
59
|
+
# - phone_ids
|
60
|
+
# * IDs of phones (basic routes) associated with this service, or null if the service is
|
61
|
+
# associated with all routes. Only applies for service types that handle incoming
|
62
|
+
# messages, voice calls, or USSD sessions.
|
63
|
+
# * Updatable via API
|
65
64
|
#
|
66
|
-
# -
|
67
|
-
# *
|
68
|
-
#
|
69
|
-
#
|
65
|
+
# - apply_mode
|
66
|
+
# * If apply_mode is `unhandled`, the service will not be triggered if another service
|
67
|
+
# has already handled the incoming message. If apply_mode is `always`, the service will
|
68
|
+
# always be triggered regardless of other services. Only applies to services that handle
|
69
|
+
# incoming messages.
|
70
|
+
# * Allowed values: always, unhandled
|
71
|
+
# * Updatable via API
|
72
|
+
#
|
73
|
+
# - contact_number_filter
|
74
|
+
# * If contact_number_filter is `long_number`, this service will only be triggered if
|
75
|
+
# the contact phone number has at least 7 digits (ignoring messages from shortcodes and
|
76
|
+
# alphanumeric senders). If contact_number_filter is `all`, the service will be
|
77
|
+
# triggered for all contact phone numbers. Only applies to services that handle
|
78
|
+
# incoming messages.
|
79
|
+
# * Allowed values: long_number, all
|
80
|
+
# * Updatable via API
|
81
|
+
#
|
82
|
+
# - show_action (bool)
|
83
|
+
# * Whether this service is shown in the 'Actions' menu within the Telerivet web app
|
84
|
+
# when the service is active. Only provided for service types that are manually
|
85
|
+
# triggered.
|
86
|
+
# * Updatable via API
|
87
|
+
#
|
88
|
+
# - direction
|
89
|
+
# * Determines whether the service handles incoming voice calls, outgoing voice calls,
|
90
|
+
# or both. Only applies to services that handle voice calls.
|
91
|
+
# * Allowed values: incoming, outgoing, both
|
92
|
+
# * Updatable via API
|
70
93
|
#
|
71
|
-
# -
|
72
|
-
# *
|
73
|
-
#
|
74
|
-
# question), and `"question_type"` (either `"multiple_choice"`, `"missed_call"`, or
|
75
|
-
# `"open"`).
|
94
|
+
# - webhook_url
|
95
|
+
# * URL that a third-party can invoke to trigger this service. Only provided for
|
96
|
+
# services that are triggered by a webhook request.
|
76
97
|
# * Read-only
|
77
98
|
#
|
78
99
|
class Service < Entity
|
@@ -97,7 +118,7 @@ class Service < Entity
|
|
97
118
|
#
|
98
119
|
# - context
|
99
120
|
# * The name of the context in which this service is invoked
|
100
|
-
# * Allowed values: message, call, contact, project
|
121
|
+
# * Allowed values: message, call, ussd_session, row, contact, project
|
101
122
|
# * Required
|
102
123
|
#
|
103
124
|
# - event
|
@@ -109,11 +130,49 @@ class Service < Entity
|
|
109
130
|
# * Required if context is 'message'
|
110
131
|
#
|
111
132
|
# - contact_id
|
112
|
-
# * The ID of the contact this service is triggered for
|
113
|
-
#
|
133
|
+
# * The ID of the contact this service is triggered for (either `contact_id` or
|
134
|
+
# `phone_number` is required if `context` is 'contact')
|
135
|
+
#
|
136
|
+
# - phone_number
|
137
|
+
# * The phone number of the contact this service is triggered for (either `contact_id`
|
138
|
+
# or `phone_number` is required if `context` is 'contact'). If no contact exists with
|
139
|
+
# this phone number, a new contact will be created.
|
140
|
+
#
|
141
|
+
# - variables (Hash)
|
142
|
+
# * Object containing up to 25 temporary variable names and their corresponding values
|
143
|
+
# to set when invoking the service. Values may be strings, numbers, or boolean
|
144
|
+
# (true/false). String values may be up to 4096 bytes in length. Arrays and objects
|
145
|
+
# are not supported. Within Custom Actions, each variable can be used like `[[$name]]`
|
146
|
+
# (with a leading `$` character and surrounded by double square brackets). Within a
|
147
|
+
# Cloud Script API service or JavaScript action, each variable will be available as a
|
148
|
+
# global JavaScript variable like `$name` (with a leading `$` character).
|
149
|
+
#
|
150
|
+
# - route_id
|
151
|
+
# * The ID of the phone or route that the service will use for sending messages by
|
152
|
+
# default
|
153
|
+
#
|
154
|
+
# - async (bool)
|
155
|
+
# * If set to true, the service will be invoked asynchronously. By default, queued
|
156
|
+
# services will be invoked one at a time for each project.
|
114
157
|
#
|
115
158
|
# Returns:
|
116
|
-
#
|
159
|
+
# (associative array)
|
160
|
+
# - return_value (any)
|
161
|
+
# * Return value of the service. May be any JSON type (boolean, number, string,
|
162
|
+
# array, object, or null). (Undefined if async=true.)
|
163
|
+
#
|
164
|
+
# - log_entries (array)
|
165
|
+
# * Array of log entry strings generated by the service. (Undefined if async=true.)
|
166
|
+
#
|
167
|
+
# - errors (array)
|
168
|
+
# * Array of error message strings generated by the service. (Undefined if
|
169
|
+
# async=true.)
|
170
|
+
#
|
171
|
+
# - sent_messages (array of objects)
|
172
|
+
# * Array of messages sent by the service.
|
173
|
+
#
|
174
|
+
# - airtime_transactions (array of objects)
|
175
|
+
# * Array of airtime transactions sent by the service (Undefined if async=true.)
|
117
176
|
#
|
118
177
|
def invoke(options)
|
119
178
|
invoke_result = @api.do_request('POST', get_base_api_path() + '/invoke', options)
|
@@ -210,9 +269,9 @@ class Service < Entity
|
|
210
269
|
#
|
211
270
|
# - vars (Hash)
|
212
271
|
# * Filter states by value of a custom variable (e.g. vars[email], vars[foo], etc.)
|
213
|
-
# * Allowed modifiers: vars[foo][
|
214
|
-
# vars[foo][
|
215
|
-
# vars[foo][
|
272
|
+
# * Allowed modifiers: vars[foo][ne], vars[foo][prefix], vars[foo][not_prefix],
|
273
|
+
# vars[foo][gte], vars[foo][gt], vars[foo][lt], vars[foo][lte], vars[foo][min],
|
274
|
+
# vars[foo][max], vars[foo][exists]
|
216
275
|
#
|
217
276
|
# - sort
|
218
277
|
# * Sort the results based on a field
|
@@ -240,6 +299,41 @@ class Service < Entity
|
|
240
299
|
@api.cursor(ContactServiceState, get_base_api_path() + "/states", options)
|
241
300
|
end
|
242
301
|
|
302
|
+
#
|
303
|
+
# Gets configuration specific to the type of automated service.
|
304
|
+
#
|
305
|
+
# Only certain types of services provide their configuration via the
|
306
|
+
# API.
|
307
|
+
#
|
308
|
+
# Returns:
|
309
|
+
# object
|
310
|
+
#
|
311
|
+
def get_config()
|
312
|
+
return @api.do_request("GET", get_base_api_path() + "/config")
|
313
|
+
end
|
314
|
+
|
315
|
+
#
|
316
|
+
# Updates configuration specific to the type of automated service.
|
317
|
+
#
|
318
|
+
# Only certain types of services support updating their configuration
|
319
|
+
# via the API.
|
320
|
+
#
|
321
|
+
# Note: when updating a service of type custom_template_instance,
|
322
|
+
# the validation script will be invoked when calling this method.
|
323
|
+
#
|
324
|
+
# Arguments:
|
325
|
+
# - options (Hash)
|
326
|
+
# * Configuration for this service type. See
|
327
|
+
# [project.createService](#Project.createService) for available configuration options.
|
328
|
+
# * Required
|
329
|
+
#
|
330
|
+
# Returns:
|
331
|
+
# object
|
332
|
+
#
|
333
|
+
def set_config(options)
|
334
|
+
return @api.do_request("POST", get_base_api_path() + "/config", options)
|
335
|
+
end
|
336
|
+
|
243
337
|
#
|
244
338
|
# Saves any fields or custom variables that have changed for this service.
|
245
339
|
#
|
@@ -247,6 +341,13 @@ class Service < Entity
|
|
247
341
|
super
|
248
342
|
end
|
249
343
|
|
344
|
+
#
|
345
|
+
# Deletes this service.
|
346
|
+
#
|
347
|
+
def delete()
|
348
|
+
@api.do_request("DELETE", get_base_api_path())
|
349
|
+
end
|
350
|
+
|
250
351
|
def id
|
251
352
|
get('id')
|
252
353
|
end
|
@@ -259,6 +360,10 @@ class Service < Entity
|
|
259
360
|
set('name', value)
|
260
361
|
end
|
261
362
|
|
363
|
+
def service_type
|
364
|
+
get('service_type')
|
365
|
+
end
|
366
|
+
|
262
367
|
def active
|
263
368
|
get('active')
|
264
369
|
end
|
@@ -283,24 +388,56 @@ class Service < Entity
|
|
283
388
|
get('project_id')
|
284
389
|
end
|
285
390
|
|
286
|
-
def label_id
|
287
|
-
get('label_id')
|
288
|
-
end
|
289
|
-
|
290
391
|
def response_table_id
|
291
392
|
get('response_table_id')
|
292
393
|
end
|
293
394
|
|
294
|
-
def
|
295
|
-
|
395
|
+
def response_table_id=(value)
|
396
|
+
set('response_table_id', value)
|
397
|
+
end
|
398
|
+
|
399
|
+
def phone_ids
|
400
|
+
get('phone_ids')
|
401
|
+
end
|
402
|
+
|
403
|
+
def phone_ids=(value)
|
404
|
+
set('phone_ids', value)
|
405
|
+
end
|
406
|
+
|
407
|
+
def apply_mode
|
408
|
+
get('apply_mode')
|
409
|
+
end
|
410
|
+
|
411
|
+
def apply_mode=(value)
|
412
|
+
set('apply_mode', value)
|
413
|
+
end
|
414
|
+
|
415
|
+
def contact_number_filter
|
416
|
+
get('contact_number_filter')
|
417
|
+
end
|
418
|
+
|
419
|
+
def contact_number_filter=(value)
|
420
|
+
set('contact_number_filter', value)
|
421
|
+
end
|
422
|
+
|
423
|
+
def show_action
|
424
|
+
get('show_action')
|
425
|
+
end
|
426
|
+
|
427
|
+
def show_action=(value)
|
428
|
+
set('show_action', value)
|
429
|
+
end
|
430
|
+
|
431
|
+
def direction
|
432
|
+
get('direction')
|
296
433
|
end
|
297
434
|
|
298
|
-
def
|
299
|
-
|
435
|
+
def direction=(value)
|
436
|
+
set('direction', value)
|
300
437
|
end
|
301
438
|
|
302
|
-
def
|
303
|
-
get('
|
439
|
+
def webhook_url
|
440
|
+
get('webhook_url')
|
304
441
|
end
|
305
442
|
|
306
443
|
def get_base_api_path()
|
@@ -0,0 +1,151 @@
|
|
1
|
+
|
2
|
+
module Telerivet
|
3
|
+
|
4
|
+
#
|
5
|
+
# Represents an asynchronous task that is applied to all entities matching a filter.
|
6
|
+
#
|
7
|
+
# Tasks include services applied to contacts, messages, or data rows; adding
|
8
|
+
# or removing contacts from a group; blocking or unblocking sending messages to a contact;
|
9
|
+
# updating a custom variable; deleting contacts, messages, or data rows; or
|
10
|
+
# exporting data to CSV.
|
11
|
+
#
|
12
|
+
# Fields:
|
13
|
+
#
|
14
|
+
# - id (string, max 34 characters)
|
15
|
+
# * ID of the task
|
16
|
+
# * Read-only
|
17
|
+
#
|
18
|
+
# - task_type (string)
|
19
|
+
# * The task type
|
20
|
+
# * Read-only
|
21
|
+
#
|
22
|
+
# - task_params (Hash)
|
23
|
+
# * Parameters applied to all matching rows (specific to `task_type`). See
|
24
|
+
# [project.createTask](#Project.createTask).
|
25
|
+
# * Read-only
|
26
|
+
#
|
27
|
+
# - filter_type
|
28
|
+
# * Type of filter defining the rows that the task is applied to
|
29
|
+
# * Read-only
|
30
|
+
#
|
31
|
+
# - filter_params (Hash)
|
32
|
+
# * Parameters defining the rows that the task is applied to (specific to
|
33
|
+
# `filter_type`). See [project.createTask](#Project.createTask).
|
34
|
+
# * Read-only
|
35
|
+
#
|
36
|
+
# - time_created (UNIX timestamp)
|
37
|
+
# * Time the task was created in Telerivet
|
38
|
+
# * Read-only
|
39
|
+
#
|
40
|
+
# - time_active (UNIX timestamp)
|
41
|
+
# * Time Telerivet started executing the task
|
42
|
+
# * Read-only
|
43
|
+
#
|
44
|
+
# - time_complete (UNIX timestamp)
|
45
|
+
# * Time Telerivet finished executing the task
|
46
|
+
# * Read-only
|
47
|
+
#
|
48
|
+
# - total_rows (int)
|
49
|
+
# * The total number of rows matching the filter (null if not known)
|
50
|
+
# * Read-only
|
51
|
+
#
|
52
|
+
# - current_row (int)
|
53
|
+
# * The number of rows that have been processed so far
|
54
|
+
# * Read-only
|
55
|
+
#
|
56
|
+
# - status (string)
|
57
|
+
# * The current status of the task
|
58
|
+
# * Allowed values: created, queued, active, complete, failed, cancelled
|
59
|
+
# * Read-only
|
60
|
+
#
|
61
|
+
# - vars (Hash)
|
62
|
+
# * Custom variables stored for this task
|
63
|
+
# * Read-only
|
64
|
+
#
|
65
|
+
# - table_id (string, max 34 characters)
|
66
|
+
# * ID of the data table this task is applied to (if applicable)
|
67
|
+
# * Read-only
|
68
|
+
#
|
69
|
+
# - user_id (string, max 34 characters)
|
70
|
+
# * ID of the Telerivet user who created the task (if applicable)
|
71
|
+
# * Read-only
|
72
|
+
#
|
73
|
+
# - project_id
|
74
|
+
# * ID of the project this task belongs to
|
75
|
+
# * Read-only
|
76
|
+
#
|
77
|
+
class Task < Entity
|
78
|
+
#
|
79
|
+
# Cancels a task that is not yet complete.
|
80
|
+
#
|
81
|
+
# Returns:
|
82
|
+
# Telerivet::Task
|
83
|
+
#
|
84
|
+
def cancel()
|
85
|
+
require_relative 'task'
|
86
|
+
Task.new(@api, @api.do_request("POST", get_base_api_path() + "/cancel"))
|
87
|
+
end
|
88
|
+
|
89
|
+
def id
|
90
|
+
get('id')
|
91
|
+
end
|
92
|
+
|
93
|
+
def task_type
|
94
|
+
get('task_type')
|
95
|
+
end
|
96
|
+
|
97
|
+
def task_params
|
98
|
+
get('task_params')
|
99
|
+
end
|
100
|
+
|
101
|
+
def filter_type
|
102
|
+
get('filter_type')
|
103
|
+
end
|
104
|
+
|
105
|
+
def filter_params
|
106
|
+
get('filter_params')
|
107
|
+
end
|
108
|
+
|
109
|
+
def time_created
|
110
|
+
get('time_created')
|
111
|
+
end
|
112
|
+
|
113
|
+
def time_active
|
114
|
+
get('time_active')
|
115
|
+
end
|
116
|
+
|
117
|
+
def time_complete
|
118
|
+
get('time_complete')
|
119
|
+
end
|
120
|
+
|
121
|
+
def total_rows
|
122
|
+
get('total_rows')
|
123
|
+
end
|
124
|
+
|
125
|
+
def current_row
|
126
|
+
get('current_row')
|
127
|
+
end
|
128
|
+
|
129
|
+
def status
|
130
|
+
get('status')
|
131
|
+
end
|
132
|
+
|
133
|
+
def table_id
|
134
|
+
get('table_id')
|
135
|
+
end
|
136
|
+
|
137
|
+
def user_id
|
138
|
+
get('user_id')
|
139
|
+
end
|
140
|
+
|
141
|
+
def project_id
|
142
|
+
get('project_id')
|
143
|
+
end
|
144
|
+
|
145
|
+
def get_base_api_path()
|
146
|
+
"/projects/#{get('project_id')}/tasks/#{get('id')}"
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
data/lib/telerivet.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: telerivet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesse Young
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ruby client library for Telerivet REST API
|
14
14
|
email: support@telerivet.com
|
@@ -18,6 +18,7 @@ extra_rdoc_files: []
|
|
18
18
|
files:
|
19
19
|
- lib/cacert.pem
|
20
20
|
- lib/telerivet.rb
|
21
|
+
- lib/telerivet/airtimetransaction.rb
|
21
22
|
- lib/telerivet/apicursor.rb
|
22
23
|
- lib/telerivet/broadcast.rb
|
23
24
|
- lib/telerivet/contact.rb
|
@@ -31,9 +32,11 @@ files:
|
|
31
32
|
- lib/telerivet/organization.rb
|
32
33
|
- lib/telerivet/phone.rb
|
33
34
|
- lib/telerivet/project.rb
|
35
|
+
- lib/telerivet/relativescheduledmessage.rb
|
34
36
|
- lib/telerivet/route.rb
|
35
37
|
- lib/telerivet/scheduledmessage.rb
|
36
38
|
- lib/telerivet/service.rb
|
39
|
+
- lib/telerivet/task.rb
|
37
40
|
homepage: http://telerivet.com
|
38
41
|
licenses:
|
39
42
|
- MIT
|