telerivet 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/telerivet.rb +3 -3
- data/lib/telerivet/airtimetransaction.rb +139 -0
- data/lib/telerivet/broadcast.rb +42 -2
- data/lib/telerivet/contact.rb +38 -13
- data/lib/telerivet/datatable.rb +76 -7
- data/lib/telerivet/group.rb +17 -17
- data/lib/telerivet/label.rb +7 -3
- data/lib/telerivet/message.rb +72 -2
- data/lib/telerivet/organization.rb +1 -1
- data/lib/telerivet/phone.rb +7 -3
- data/lib/telerivet/project.rb +595 -92
- data/lib/telerivet/scheduledmessage.rb +22 -1
- data/lib/telerivet/service.rb +40 -9
- data/lib/telerivet/task.rb +151 -0
- metadata +5 -4
data/lib/telerivet/group.rb
CHANGED
@@ -50,7 +50,7 @@ class Group < Entity
|
|
50
50
|
# * Filter contacts by phone number
|
51
51
|
# * Allowed modifiers: phone_number[ne], phone_number[prefix],
|
52
52
|
# phone_number[not_prefix], phone_number[gte], phone_number[gt], phone_number[lt],
|
53
|
-
# phone_number[lte]
|
53
|
+
# phone_number[lte], phone_number[exists]
|
54
54
|
#
|
55
55
|
# - time_created (UNIX timestamp)
|
56
56
|
# * Filter contacts by time created
|
@@ -58,20 +58,20 @@ class Group < Entity
|
|
58
58
|
#
|
59
59
|
# - last_message_time (UNIX timestamp)
|
60
60
|
# * Filter contacts by last time a message was sent or received
|
61
|
-
# * Allowed modifiers: last_message_time[
|
62
|
-
# last_message_time[
|
61
|
+
# * Allowed modifiers: last_message_time[ne], last_message_time[min],
|
62
|
+
# last_message_time[max], last_message_time[exists]
|
63
63
|
#
|
64
64
|
# - last_incoming_message_time (UNIX timestamp)
|
65
65
|
# * Filter contacts by last time a message was received
|
66
|
-
# * Allowed modifiers: last_incoming_message_time[
|
67
|
-
# last_incoming_message_time[
|
68
|
-
# last_incoming_message_time[
|
66
|
+
# * Allowed modifiers: last_incoming_message_time[ne],
|
67
|
+
# last_incoming_message_time[min], last_incoming_message_time[max],
|
68
|
+
# last_incoming_message_time[exists]
|
69
69
|
#
|
70
70
|
# - last_outgoing_message_time (UNIX timestamp)
|
71
71
|
# * Filter contacts by last time a message was sent
|
72
|
-
# * Allowed modifiers: last_outgoing_message_time[
|
73
|
-
# last_outgoing_message_time[
|
74
|
-
# last_outgoing_message_time[
|
72
|
+
# * Allowed modifiers: last_outgoing_message_time[ne],
|
73
|
+
# last_outgoing_message_time[min], last_outgoing_message_time[max],
|
74
|
+
# last_outgoing_message_time[exists]
|
75
75
|
#
|
76
76
|
# - incoming_message_count (int)
|
77
77
|
# * Filter contacts by number of messages received from the contact
|
@@ -88,9 +88,9 @@ class Group < Entity
|
|
88
88
|
#
|
89
89
|
# - vars (Hash)
|
90
90
|
# * Filter contacts by value of a custom variable (e.g. vars[email], vars[foo], etc.)
|
91
|
-
# * Allowed modifiers: vars[foo][
|
92
|
-
# vars[foo][
|
93
|
-
# vars[foo][
|
91
|
+
# * Allowed modifiers: vars[foo][ne], vars[foo][prefix], vars[foo][not_prefix],
|
92
|
+
# vars[foo][gte], vars[foo][gt], vars[foo][lt], vars[foo][lte], vars[foo][min],
|
93
|
+
# vars[foo][max], vars[foo][exists]
|
94
94
|
#
|
95
95
|
# - sort
|
96
96
|
# * Sort the results based on a field
|
@@ -103,7 +103,7 @@ class Group < Entity
|
|
103
103
|
# * Default: asc
|
104
104
|
#
|
105
105
|
# - page_size (int)
|
106
|
-
# * Number of results returned per page (max
|
106
|
+
# * Number of results returned per page (max 500)
|
107
107
|
# * Default: 50
|
108
108
|
#
|
109
109
|
# - offset (int)
|
@@ -126,7 +126,7 @@ class Group < Entity
|
|
126
126
|
#
|
127
127
|
# - message_type
|
128
128
|
# * Filter scheduled messages by message_type
|
129
|
-
# * Allowed values: sms, mms, ussd, call
|
129
|
+
# * Allowed values: sms, mms, ussd, call, service
|
130
130
|
#
|
131
131
|
# - time_created (UNIX timestamp)
|
132
132
|
# * Filter scheduled messages by time_created
|
@@ -134,8 +134,8 @@ class Group < Entity
|
|
134
134
|
#
|
135
135
|
# - next_time (UNIX timestamp)
|
136
136
|
# * Filter scheduled messages by next_time
|
137
|
-
# * Allowed modifiers: next_time[
|
138
|
-
# next_time[
|
137
|
+
# * Allowed modifiers: next_time[ne], next_time[min], next_time[max],
|
138
|
+
# next_time[exists]
|
139
139
|
#
|
140
140
|
# - sort
|
141
141
|
# * Sort the results based on a field
|
@@ -148,7 +148,7 @@ class Group < Entity
|
|
148
148
|
# * Default: asc
|
149
149
|
#
|
150
150
|
# - page_size (int)
|
151
|
-
# * Number of results returned per page (max
|
151
|
+
# * Number of results returned per page (max 500)
|
152
152
|
# * Default: 50
|
153
153
|
#
|
154
154
|
# - offset (int)
|
data/lib/telerivet/label.rb
CHANGED
@@ -39,11 +39,12 @@ class Label < Entity
|
|
39
39
|
#
|
40
40
|
# - message_type
|
41
41
|
# * Filter messages by message_type
|
42
|
-
# * Allowed values: sms, mms, ussd, call
|
42
|
+
# * Allowed values: sms, mms, ussd, call, service
|
43
43
|
#
|
44
44
|
# - source
|
45
45
|
# * Filter messages by source
|
46
|
-
# * Allowed values: phone, provider, web, api, service, webhook, scheduled
|
46
|
+
# * Allowed values: phone, provider, web, api, service, webhook, scheduled,
|
47
|
+
# integration
|
47
48
|
#
|
48
49
|
# - starred (bool)
|
49
50
|
# * Filter messages by starred/unstarred
|
@@ -71,6 +72,9 @@ class Label < Entity
|
|
71
72
|
# - broadcast_id
|
72
73
|
# * ID of the broadcast containing the message
|
73
74
|
#
|
75
|
+
# - scheduled_id
|
76
|
+
# * ID of the scheduled message that created this message
|
77
|
+
#
|
74
78
|
# - sort
|
75
79
|
# * Sort the results based on a field
|
76
80
|
# * Allowed values: default
|
@@ -82,7 +86,7 @@ class Label < Entity
|
|
82
86
|
# * Default: asc
|
83
87
|
#
|
84
88
|
# - page_size (int)
|
85
|
-
# * Number of results returned per page (max
|
89
|
+
# * Number of results returned per page (max 500)
|
86
90
|
# * Default: 50
|
87
91
|
#
|
88
92
|
# - offset (int)
|
data/lib/telerivet/message.rb
CHANGED
@@ -23,12 +23,12 @@ module Telerivet
|
|
23
23
|
#
|
24
24
|
# - message_type
|
25
25
|
# * Type of the message
|
26
|
-
# * Allowed values: sms, mms, ussd, call
|
26
|
+
# * Allowed values: sms, mms, ussd, call, service
|
27
27
|
# * Read-only
|
28
28
|
#
|
29
29
|
# - source
|
30
30
|
# * How the message originated within Telerivet
|
31
|
-
# * Allowed values: phone, provider, web, api, service, webhook, scheduled
|
31
|
+
# * Allowed values: phone, provider, web, api, service, webhook, scheduled, integration
|
32
32
|
# * Read-only
|
33
33
|
#
|
34
34
|
# - time_created (UNIX timestamp)
|
@@ -40,6 +40,10 @@ module Telerivet
|
|
40
40
|
# and messages that have not yet been sent)
|
41
41
|
# * Read-only
|
42
42
|
#
|
43
|
+
# - time_updated (UNIX timestamp)
|
44
|
+
# * The time that the message was last updated in Telerivet.
|
45
|
+
# * Read-only
|
46
|
+
#
|
43
47
|
# - from_number (string)
|
44
48
|
# * The phone number that the message originated from (your number for outgoing
|
45
49
|
# messages, the contact's number for incoming messages)
|
@@ -71,6 +75,11 @@ module Telerivet
|
|
71
75
|
# * Custom variables stored for this message
|
72
76
|
# * Updatable via API
|
73
77
|
#
|
78
|
+
# - priority (int)
|
79
|
+
# * Priority of this message. Telerivet will attempt to send messages with higher
|
80
|
+
# priority numbers first. Only defined for outgoing messages.
|
81
|
+
# * Read-only
|
82
|
+
#
|
74
83
|
# - error_message
|
75
84
|
# * A description of the error encountered while sending a message. (This field is
|
76
85
|
# omitted from the API response if there is no error message.)
|
@@ -122,6 +131,35 @@ module Telerivet
|
|
122
131
|
# [getMMSParts](#Message.getMMSParts).
|
123
132
|
# * Read-only
|
124
133
|
#
|
134
|
+
# - track_clicks (boolean)
|
135
|
+
# * If true, URLs in the message content are short URLs that redirect to a destination
|
136
|
+
# URL.
|
137
|
+
# * Read-only
|
138
|
+
#
|
139
|
+
# - short_urls (array)
|
140
|
+
# * For text messages containing short URLs, this is an array of objects with the
|
141
|
+
# properties `short_url`, `link_type`, and `time_clicked` (the first time that URL was
|
142
|
+
# clicked). If `link_type` is "redirect", the object also contains a `destination_url`
|
143
|
+
# property. If `link_type` is "media", the object also contains an `media_index`
|
144
|
+
# property (the index in the media array). If `link_type` is "service", the object also
|
145
|
+
# contains a `service_id` property. This property is undefined for messages that do not
|
146
|
+
# contain short URLs.
|
147
|
+
# * Read-only
|
148
|
+
#
|
149
|
+
# - media (array)
|
150
|
+
# * For text messages containing media files, this is an array of objects with the
|
151
|
+
# properties `url`, `type` (MIME type), `filename`, and `size` (file size in bytes).
|
152
|
+
# Unknown properties are null. This property is undefined for messages that do not
|
153
|
+
# contain media files. Note: For files uploaded via the Telerivet web app, the URL is
|
154
|
+
# temporary and may not be valid for more than 1 day.
|
155
|
+
# * Read-only
|
156
|
+
#
|
157
|
+
# - time_clicked (UNIX timestamp)
|
158
|
+
# * If the message contains any short URLs, this is the first time that a short URL in
|
159
|
+
# the message was clicked. This property is undefined for messages that do not contain
|
160
|
+
# short URLs.
|
161
|
+
# * Read-only
|
162
|
+
#
|
125
163
|
# - service_id (string, max 34 characters)
|
126
164
|
# * ID of the service that handled the message (for voice calls, the service defines the
|
127
165
|
# call flow)
|
@@ -143,6 +181,10 @@ module Telerivet
|
|
143
181
|
# * ID of the broadcast that this message is part of (if applicable)
|
144
182
|
# * Read-only
|
145
183
|
#
|
184
|
+
# - scheduled_id (string, max 34 characters)
|
185
|
+
# * ID of the scheduled message that created this message is part of (if applicable)
|
186
|
+
# * Read-only
|
187
|
+
#
|
146
188
|
# - user_id (string, max 34 characters)
|
147
189
|
# * ID of the Telerivet user who sent the message (if applicable)
|
148
190
|
# * Read-only
|
@@ -290,6 +332,10 @@ class Message < Entity
|
|
290
332
|
get('time_sent')
|
291
333
|
end
|
292
334
|
|
335
|
+
def time_updated
|
336
|
+
get('time_updated')
|
337
|
+
end
|
338
|
+
|
293
339
|
def from_number
|
294
340
|
get('from_number')
|
295
341
|
end
|
@@ -318,6 +364,10 @@ class Message < Entity
|
|
318
364
|
get('label_ids')
|
319
365
|
end
|
320
366
|
|
367
|
+
def priority
|
368
|
+
get('priority')
|
369
|
+
end
|
370
|
+
|
321
371
|
def error_message
|
322
372
|
get('error_message')
|
323
373
|
end
|
@@ -362,6 +412,22 @@ class Message < Entity
|
|
362
412
|
get('mms_parts')
|
363
413
|
end
|
364
414
|
|
415
|
+
def track_clicks
|
416
|
+
get('track_clicks')
|
417
|
+
end
|
418
|
+
|
419
|
+
def short_urls
|
420
|
+
get('short_urls')
|
421
|
+
end
|
422
|
+
|
423
|
+
def media
|
424
|
+
get('media')
|
425
|
+
end
|
426
|
+
|
427
|
+
def time_clicked
|
428
|
+
get('time_clicked')
|
429
|
+
end
|
430
|
+
|
365
431
|
def service_id
|
366
432
|
get('service_id')
|
367
433
|
end
|
@@ -382,6 +448,10 @@ class Message < Entity
|
|
382
448
|
get('broadcast_id')
|
383
449
|
end
|
384
450
|
|
451
|
+
def scheduled_id
|
452
|
+
get('scheduled_id')
|
453
|
+
end
|
454
|
+
|
385
455
|
def user_id
|
386
456
|
get('user_id')
|
387
457
|
end
|
data/lib/telerivet/phone.rb
CHANGED
@@ -111,11 +111,12 @@ class Phone < Entity
|
|
111
111
|
#
|
112
112
|
# - message_type
|
113
113
|
# * Filter messages by message_type
|
114
|
-
# * Allowed values: sms, mms, ussd, call
|
114
|
+
# * Allowed values: sms, mms, ussd, call, service
|
115
115
|
#
|
116
116
|
# - source
|
117
117
|
# * Filter messages by source
|
118
|
-
# * Allowed values: phone, provider, web, api, service, webhook, scheduled
|
118
|
+
# * Allowed values: phone, provider, web, api, service, webhook, scheduled,
|
119
|
+
# integration
|
119
120
|
#
|
120
121
|
# - starred (bool)
|
121
122
|
# * Filter messages by starred/unstarred
|
@@ -143,6 +144,9 @@ class Phone < Entity
|
|
143
144
|
# - broadcast_id
|
144
145
|
# * ID of the broadcast containing the message
|
145
146
|
#
|
147
|
+
# - scheduled_id
|
148
|
+
# * ID of the scheduled message that created this message
|
149
|
+
#
|
146
150
|
# - sort
|
147
151
|
# * Sort the results based on a field
|
148
152
|
# * Allowed values: default
|
@@ -154,7 +158,7 @@ class Phone < Entity
|
|
154
158
|
# * Default: asc
|
155
159
|
#
|
156
160
|
# - page_size (int)
|
157
|
-
# * Number of results returned per page (max
|
161
|
+
# * Number of results returned per page (max 500)
|
158
162
|
# * Default: 50
|
159
163
|
#
|
160
164
|
# - offset (int)
|
data/lib/telerivet/project.rb
CHANGED
@@ -37,16 +37,17 @@ module Telerivet
|
|
37
37
|
#
|
38
38
|
class Project < Entity
|
39
39
|
#
|
40
|
-
# Sends one message (SMS, voice call, or USSD request).
|
40
|
+
# Sends one message (SMS, MMS, voice call, or USSD request).
|
41
41
|
#
|
42
42
|
# Arguments:
|
43
43
|
# - options (Hash)
|
44
44
|
# * Required
|
45
45
|
#
|
46
46
|
# - message_type
|
47
|
-
# * Type of message to send
|
48
|
-
#
|
49
|
-
# *
|
47
|
+
# * Type of message to send. If `text`, will use the default text message type for the
|
48
|
+
# selected route.
|
49
|
+
# * Allowed values: sms, mms, ussd, call, text
|
50
|
+
# * Default: text
|
50
51
|
#
|
51
52
|
# - content
|
52
53
|
# * Content of the message to send (if `message_type` is `call`, the text will be
|
@@ -65,6 +66,45 @@ class Project < Entity
|
|
65
66
|
# * ID of the phone or route to send the message from
|
66
67
|
# * Default: default sender route ID for your project
|
67
68
|
#
|
69
|
+
# - status_url
|
70
|
+
# * Webhook callback URL to be notified when message status changes
|
71
|
+
#
|
72
|
+
# - status_secret
|
73
|
+
# * POST parameter 'secret' passed to status_url
|
74
|
+
#
|
75
|
+
# - is_template (bool)
|
76
|
+
# * Set to true to evaluate variables like [[contact.name]] in message content. [(See
|
77
|
+
# available variables)](#variables)
|
78
|
+
# * Default: false
|
79
|
+
#
|
80
|
+
# - track_clicks (boolean)
|
81
|
+
# * If true, URLs in the message content will automatically be replaced with unique
|
82
|
+
# short URLs.
|
83
|
+
# * Default: false
|
84
|
+
#
|
85
|
+
# - media_urls (array)
|
86
|
+
# * URLs of media files to attach to the text message. If `message_type` is `sms`,
|
87
|
+
# short links to each media URL will be appended to the end of the content (separated
|
88
|
+
# by a new line).
|
89
|
+
#
|
90
|
+
# - label_ids (array)
|
91
|
+
# * List of IDs of labels to add to this message
|
92
|
+
#
|
93
|
+
# - vars (Hash)
|
94
|
+
# * Custom variables to store with the message
|
95
|
+
#
|
96
|
+
# - priority (int)
|
97
|
+
# * Priority of the message. Telerivet will attempt to send messages with higher
|
98
|
+
# priority numbers first (for example, so you can prioritize an auto-reply ahead of a
|
99
|
+
# bulk message to a large group).
|
100
|
+
# * Allowed values: 1, 2
|
101
|
+
# * Default: 1
|
102
|
+
#
|
103
|
+
# - simulated (bool)
|
104
|
+
# * Set to true to test the Telerivet API without actually sending a message from the
|
105
|
+
# route
|
106
|
+
# * Default: false
|
107
|
+
#
|
68
108
|
# - service_id
|
69
109
|
# * Service that defines the call flow of the voice call (when `message_type` is
|
70
110
|
# `call`)
|
@@ -90,29 +130,6 @@ class Project < Entity
|
|
90
130
|
# * The name of the text-to-speech voice (when message_type=call)
|
91
131
|
# * Allowed values: female, male
|
92
132
|
# * Default: female
|
93
|
-
#
|
94
|
-
# - status_url
|
95
|
-
# * Webhook callback URL to be notified when message status changes
|
96
|
-
#
|
97
|
-
# - status_secret
|
98
|
-
# * POST parameter 'secret' passed to status_url
|
99
|
-
#
|
100
|
-
# - is_template (bool)
|
101
|
-
# * Set to true to evaluate variables like [[contact.name]] in message content. [(See
|
102
|
-
# available variables)](#variables)
|
103
|
-
# * Default: false
|
104
|
-
#
|
105
|
-
# - label_ids (array)
|
106
|
-
# * List of IDs of labels to add to this message
|
107
|
-
#
|
108
|
-
# - vars (Hash)
|
109
|
-
# * Custom variables to store with the message
|
110
|
-
#
|
111
|
-
# - priority (int)
|
112
|
-
# * Priority of the message (currently only observed for Android phones). Telerivet
|
113
|
-
# will attempt to send messages with higher priority numbers first (for example, so
|
114
|
-
# you can prioritize an auto-reply ahead of a bulk message to a large group).
|
115
|
-
# * Default: 1
|
116
133
|
#
|
117
134
|
# Returns:
|
118
135
|
# Telerivet::Message
|
@@ -124,16 +141,21 @@ class Project < Entity
|
|
124
141
|
|
125
142
|
#
|
126
143
|
# Sends a text message (optionally with mail-merge templates) or voice call to a group or a
|
127
|
-
# list of up to 500 phone numbers
|
144
|
+
# list of up to 500 phone numbers.
|
145
|
+
#
|
146
|
+
# With `message_type`=`service`, invokes an automated service (such as
|
147
|
+
# a poll) for a group or list of phone numbers. Any service that can be triggered for a
|
148
|
+
# contact can be invoked via this method, whether or not the service actually sends a message.
|
128
149
|
#
|
129
150
|
# Arguments:
|
130
151
|
# - options (Hash)
|
131
152
|
# * Required
|
132
153
|
#
|
133
154
|
# - message_type
|
134
|
-
# * Type of message to send
|
135
|
-
#
|
136
|
-
# *
|
155
|
+
# * Type of message to send. If `text`, will use the default text message type for the
|
156
|
+
# selected route.
|
157
|
+
# * Allowed values: sms, mms, call, service, text
|
158
|
+
# * Default: text
|
137
159
|
#
|
138
160
|
# - content
|
139
161
|
# * Content of the message to send
|
@@ -155,9 +177,42 @@ class Project < Entity
|
|
155
177
|
# * Title of the broadcast. If a title is not provided, a title will automatically be
|
156
178
|
# generated from the recipient group name or phone numbers.
|
157
179
|
#
|
180
|
+
# - status_url
|
181
|
+
# * Webhook callback URL to be notified when message status changes
|
182
|
+
#
|
183
|
+
# - status_secret
|
184
|
+
# * POST parameter 'secret' passed to status_url
|
185
|
+
#
|
186
|
+
# - label_ids (array)
|
187
|
+
# * Array of IDs of labels to add to all messages sent (maximum 5). Does not apply
|
188
|
+
# when `message_type`=`service`, since the labels are determined by the service
|
189
|
+
# itself.
|
190
|
+
#
|
191
|
+
# - exclude_contact_id
|
192
|
+
# * Optionally excludes one contact from receiving the message (only when group_id is
|
193
|
+
# set)
|
194
|
+
#
|
195
|
+
# - is_template (bool)
|
196
|
+
# * Set to true to evaluate variables like [[contact.name]] in message content [(See
|
197
|
+
# available variables)](#variables)
|
198
|
+
# * Default: false
|
199
|
+
#
|
200
|
+
# - track_clicks (boolean)
|
201
|
+
# * If true, URLs in the message content will automatically be replaced with unique
|
202
|
+
# short URLs.
|
203
|
+
# * Default: false
|
204
|
+
#
|
205
|
+
# - media_urls (array)
|
206
|
+
# * URLs of media files to attach to the text message. If `message_type` is `sms`,
|
207
|
+
# short links to each URL will be appended to the end of the content (separated by a
|
208
|
+
# new line).
|
209
|
+
#
|
210
|
+
# - vars (Hash)
|
211
|
+
# * Custom variables to set for each message
|
212
|
+
#
|
158
213
|
# - service_id
|
159
|
-
# * Service
|
160
|
-
#
|
214
|
+
# * Service to invoke for each recipient (when `message_type` is `call` or `service`)
|
215
|
+
# * Required if message_type is service
|
161
216
|
#
|
162
217
|
# - audio_url
|
163
218
|
# * The URL of an MP3 file to play when the contact answers the call (when
|
@@ -180,27 +235,6 @@ class Project < Entity
|
|
180
235
|
# * The name of the text-to-speech voice (when message_type=call)
|
181
236
|
# * Allowed values: female, male
|
182
237
|
# * Default: female
|
183
|
-
#
|
184
|
-
# - status_url
|
185
|
-
# * Webhook callback URL to be notified when message status changes
|
186
|
-
#
|
187
|
-
# - status_secret
|
188
|
-
# * POST parameter 'secret' passed to status_url
|
189
|
-
#
|
190
|
-
# - label_ids (array)
|
191
|
-
# * Array of IDs of labels to add to all messages sent (maximum 5)
|
192
|
-
#
|
193
|
-
# - exclude_contact_id
|
194
|
-
# * Optionally excludes one contact from receiving the message (only when group_id is
|
195
|
-
# set)
|
196
|
-
#
|
197
|
-
# - is_template (bool)
|
198
|
-
# * Set to true to evaluate variables like [[contact.name]] in message content [(See
|
199
|
-
# available variables)](#variables)
|
200
|
-
# * Default: false
|
201
|
-
#
|
202
|
-
# - vars (Hash)
|
203
|
-
# * Custom variables to set for each message
|
204
238
|
#
|
205
239
|
# Returns:
|
206
240
|
# Telerivet::Broadcast
|
@@ -219,13 +253,17 @@ class Project < Entity
|
|
219
253
|
# * Required
|
220
254
|
#
|
221
255
|
# - messages (array)
|
222
|
-
# * Array of up to 100 objects with `content` and `to_number` properties
|
256
|
+
# * Array of up to 100 objects with `content` and `to_number` properties. Each object
|
257
|
+
# may also contain the optional properties `status_url`, `status_secret`, `vars`,
|
258
|
+
# and/or `priority`, which override the parameters of the same name defined below, to
|
259
|
+
# allow passing different values for each message.
|
223
260
|
# * Required
|
224
261
|
#
|
225
262
|
# - message_type
|
226
|
-
# * Type of message to send
|
227
|
-
#
|
228
|
-
# *
|
263
|
+
# * Type of message to send. If `text`, will use the default text message type for the
|
264
|
+
# selected route.
|
265
|
+
# * Allowed values: sms, mms, chat, text
|
266
|
+
# * Default: text
|
229
267
|
#
|
230
268
|
# - route_id
|
231
269
|
# * ID of the phone or route to send the messages from
|
@@ -256,6 +294,26 @@ class Project < Entity
|
|
256
294
|
# * Set to true to evaluate variables like [[contact.name]] in message content [(See
|
257
295
|
# available variables)](#variables)
|
258
296
|
# * Default: false
|
297
|
+
#
|
298
|
+
# - media_urls (array)
|
299
|
+
# * URLs of media files to attach to the text message. If `message_type` is `sms`,
|
300
|
+
# short links to each media URL will be appended to the end of the content (separated
|
301
|
+
# by a new line).
|
302
|
+
#
|
303
|
+
# - vars (Hash)
|
304
|
+
# * Custom variables to store with the message
|
305
|
+
#
|
306
|
+
# - priority (int)
|
307
|
+
# * Priority of the message. Telerivet will attempt to send messages with higher
|
308
|
+
# priority numbers first (for example, so you can prioritize an auto-reply ahead of a
|
309
|
+
# bulk message to a large group).
|
310
|
+
# * Allowed values: 1, 2
|
311
|
+
# * Default: 1
|
312
|
+
#
|
313
|
+
# - simulated (bool)
|
314
|
+
# * Set to true to test the Telerivet API without actually sending a message from the
|
315
|
+
# route
|
316
|
+
# * Default: false
|
259
317
|
#
|
260
318
|
# Returns:
|
261
319
|
# (associative array)
|
@@ -314,13 +372,18 @@ class Project < Entity
|
|
314
372
|
# messages approximately once every 15 seconds, so it is not possible to control the exact
|
315
373
|
# second at which a scheduled message is sent.
|
316
374
|
#
|
375
|
+
# With `message_type`=`service`, schedules an automated service (such
|
376
|
+
# as a poll) to be invoked for a group or list of phone numbers. Any service that can be
|
377
|
+
# triggered for a contact can be scheduled via this method, whether or not the service
|
378
|
+
# actually sends a message.
|
379
|
+
#
|
317
380
|
# Arguments:
|
318
381
|
# - options (Hash)
|
319
382
|
# * Required
|
320
383
|
#
|
321
384
|
# - message_type
|
322
385
|
# * Type of message to send
|
323
|
-
# * Allowed values: sms, ussd, call
|
386
|
+
# * Allowed values: sms, ussd, call, service
|
324
387
|
# * Default: sms
|
325
388
|
#
|
326
389
|
# - content
|
@@ -354,8 +417,8 @@ class Project < Entity
|
|
354
417
|
# * Default: default sender route ID
|
355
418
|
#
|
356
419
|
# - service_id
|
357
|
-
# * Service
|
358
|
-
#
|
420
|
+
# * Service to invoke for each recipient (when `message_type` is `call` or `service`)
|
421
|
+
# * Required if message_type is service
|
359
422
|
#
|
360
423
|
# - audio_url
|
361
424
|
# * The URL of an MP3 file to play when the contact answers the call (when
|
@@ -379,12 +442,24 @@ class Project < Entity
|
|
379
442
|
# * Allowed values: female, male
|
380
443
|
# * Default: female
|
381
444
|
#
|
445
|
+
# - track_clicks (boolean)
|
446
|
+
# * If true, URLs in the message content will automatically be replaced with unique
|
447
|
+
# short URLs.
|
448
|
+
# * Default: false
|
449
|
+
#
|
382
450
|
# - is_template (bool)
|
383
451
|
# * Set to true to evaluate variables like [[contact.name]] in message content
|
384
452
|
# * Default: false
|
385
453
|
#
|
454
|
+
# - media_urls (array)
|
455
|
+
# * URLs of media files to attach to the text message. If `message_type` is `sms`,
|
456
|
+
# short links to each media URL will be appended to the end of the content (separated
|
457
|
+
# by a new line).
|
458
|
+
#
|
386
459
|
# - label_ids (array)
|
387
|
-
# * Array of IDs of labels to add to the sent messages (maximum 5)
|
460
|
+
# * Array of IDs of labels to add to the sent messages (maximum 5). Does not apply
|
461
|
+
# when `message_type`=`service`, since the labels are determined by the service
|
462
|
+
# itself.
|
388
463
|
#
|
389
464
|
# - timezone_id
|
390
465
|
# * TZ database timezone ID; see
|
@@ -397,6 +472,10 @@ class Project < Entity
|
|
397
472
|
#
|
398
473
|
# - end_time_offset (int)
|
399
474
|
# * Number of seconds from now until the recurring message will stop
|
475
|
+
#
|
476
|
+
# - vars (Hash)
|
477
|
+
# * Custom variables to set for this scheduled message, which will be copied to each
|
478
|
+
# message sent from this scheduled message
|
400
479
|
#
|
401
480
|
# Returns:
|
402
481
|
# Telerivet::ScheduledMessage
|
@@ -512,12 +591,66 @@ class Project < Entity
|
|
512
591
|
Contact.new(@api, @api.do_request("POST", get_base_api_path() + "/contacts", options))
|
513
592
|
end
|
514
593
|
|
594
|
+
#
|
595
|
+
# Creates and/or updates up to 200 contacts in a single API call. When creating or updating a
|
596
|
+
# large number of contacts, this method is significantly faster than sending a separate API
|
597
|
+
# request for each contact.
|
598
|
+
#
|
599
|
+
# By default, if the phone number for any contact matches an existing
|
600
|
+
# contact, the existing contact will be updated with any information provided. This behavior
|
601
|
+
# can be modified by setting the `lookup_key` parameter to look up contacts by another field,
|
602
|
+
# including a custom variable.
|
603
|
+
#
|
604
|
+
# If any contact was not found matching the provided `lookup_key`, a
|
605
|
+
# new contact will be created.
|
606
|
+
#
|
607
|
+
# Arguments:
|
608
|
+
# - options (Hash)
|
609
|
+
# * Required
|
610
|
+
#
|
611
|
+
# - contacts (array)
|
612
|
+
# * Array of up to 200 objects which may contain the properties `name` (string),
|
613
|
+
# `phone_number` (string), `vars` (object), and `send_blocked` (boolean). All
|
614
|
+
# properties are optional, unless used as a lookup key; however, either a `name` or
|
615
|
+
# `phone_number` property must be provided for new contacts.
|
616
|
+
# * Required
|
617
|
+
#
|
618
|
+
# - lookup_key
|
619
|
+
# * The field used to search for a matching contact, or 'none' to always create a new
|
620
|
+
# contact. To search by a custom variable, precede the variable name with 'vars.'.
|
621
|
+
# * Allowed values: phone_number, id, vars.variable_name, none
|
622
|
+
# * Default: phone_number
|
623
|
+
#
|
624
|
+
# - add_group_ids (array)
|
625
|
+
# * ID of one or more groups to add these contacts as members (max 5)
|
626
|
+
#
|
627
|
+
# - remove_group_ids (array)
|
628
|
+
# * ID of one or more groups to remove these contacts as members (max 5)
|
629
|
+
#
|
630
|
+
# - default_route_id
|
631
|
+
# * ID of the route to use by default to send messages to these contacts
|
632
|
+
#
|
633
|
+
# Returns:
|
634
|
+
# (associative array)
|
635
|
+
# - contacts (array)
|
636
|
+
# * List of objects representing each contact, with the same length and order as
|
637
|
+
# provided in the `contacts` parameter in the API request. Each object has a string
|
638
|
+
# `id` property.
|
639
|
+
#
|
640
|
+
def import_contacts(options)
|
641
|
+
data = @api.do_request("POST", get_base_api_path() + "/import_contacts", options)
|
642
|
+
return data
|
643
|
+
end
|
644
|
+
|
515
645
|
#
|
516
646
|
# Queries contacts within the given project.
|
517
647
|
#
|
518
648
|
# Arguments:
|
519
649
|
# - options (Hash)
|
520
650
|
#
|
651
|
+
# - group_id
|
652
|
+
# * Filter contacts within a group
|
653
|
+
#
|
521
654
|
# - name
|
522
655
|
# * Filter contacts by name
|
523
656
|
# * Allowed modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt],
|
@@ -527,7 +660,7 @@ class Project < Entity
|
|
527
660
|
# * Filter contacts by phone number
|
528
661
|
# * Allowed modifiers: phone_number[ne], phone_number[prefix],
|
529
662
|
# phone_number[not_prefix], phone_number[gte], phone_number[gt], phone_number[lt],
|
530
|
-
# phone_number[lte]
|
663
|
+
# phone_number[lte], phone_number[exists]
|
531
664
|
#
|
532
665
|
# - time_created (UNIX timestamp)
|
533
666
|
# * Filter contacts by time created
|
@@ -535,20 +668,20 @@ class Project < Entity
|
|
535
668
|
#
|
536
669
|
# - last_message_time (UNIX timestamp)
|
537
670
|
# * Filter contacts by last time a message was sent or received
|
538
|
-
# * Allowed modifiers: last_message_time[
|
539
|
-
# last_message_time[
|
671
|
+
# * Allowed modifiers: last_message_time[ne], last_message_time[min],
|
672
|
+
# last_message_time[max], last_message_time[exists]
|
540
673
|
#
|
541
674
|
# - last_incoming_message_time (UNIX timestamp)
|
542
675
|
# * Filter contacts by last time a message was received
|
543
|
-
# * Allowed modifiers: last_incoming_message_time[
|
544
|
-
# last_incoming_message_time[
|
545
|
-
# last_incoming_message_time[
|
676
|
+
# * Allowed modifiers: last_incoming_message_time[ne],
|
677
|
+
# last_incoming_message_time[min], last_incoming_message_time[max],
|
678
|
+
# last_incoming_message_time[exists]
|
546
679
|
#
|
547
680
|
# - last_outgoing_message_time (UNIX timestamp)
|
548
681
|
# * Filter contacts by last time a message was sent
|
549
|
-
# * Allowed modifiers: last_outgoing_message_time[
|
550
|
-
# last_outgoing_message_time[
|
551
|
-
# last_outgoing_message_time[
|
682
|
+
# * Allowed modifiers: last_outgoing_message_time[ne],
|
683
|
+
# last_outgoing_message_time[min], last_outgoing_message_time[max],
|
684
|
+
# last_outgoing_message_time[exists]
|
552
685
|
#
|
553
686
|
# - incoming_message_count (int)
|
554
687
|
# * Filter contacts by number of messages received from the contact
|
@@ -565,9 +698,9 @@ class Project < Entity
|
|
565
698
|
#
|
566
699
|
# - vars (Hash)
|
567
700
|
# * Filter contacts by value of a custom variable (e.g. vars[email], vars[foo], etc.)
|
568
|
-
# * Allowed modifiers: vars[foo][
|
569
|
-
# vars[foo][
|
570
|
-
# vars[foo][
|
701
|
+
# * Allowed modifiers: vars[foo][ne], vars[foo][prefix], vars[foo][not_prefix],
|
702
|
+
# vars[foo][gte], vars[foo][gt], vars[foo][lt], vars[foo][lte], vars[foo][min],
|
703
|
+
# vars[foo][max], vars[foo][exists]
|
571
704
|
#
|
572
705
|
# - sort
|
573
706
|
# * Sort the results based on a field
|
@@ -580,7 +713,7 @@ class Project < Entity
|
|
580
713
|
# * Default: asc
|
581
714
|
#
|
582
715
|
# - page_size (int)
|
583
|
-
# * Number of results returned per page (max
|
716
|
+
# * Number of results returned per page (max 500)
|
584
717
|
# * Default: 50
|
585
718
|
#
|
586
719
|
# - offset (int)
|
@@ -646,8 +779,8 @@ class Project < Entity
|
|
646
779
|
#
|
647
780
|
# - last_active_time (UNIX timestamp)
|
648
781
|
# * Filter phones by last active time
|
649
|
-
# * Allowed modifiers: last_active_time[
|
650
|
-
# last_active_time[
|
782
|
+
# * Allowed modifiers: last_active_time[ne], last_active_time[min],
|
783
|
+
# last_active_time[max], last_active_time[exists]
|
651
784
|
#
|
652
785
|
# - sort
|
653
786
|
# * Sort the results based on a field
|
@@ -660,7 +793,7 @@ class Project < Entity
|
|
660
793
|
# * Default: asc
|
661
794
|
#
|
662
795
|
# - page_size (int)
|
663
|
-
# * Number of results returned per page (max
|
796
|
+
# * Number of results returned per page (max 500)
|
664
797
|
# * Default: 50
|
665
798
|
#
|
666
799
|
# - offset (int)
|
@@ -713,17 +846,21 @@ class Project < Entity
|
|
713
846
|
# Arguments:
|
714
847
|
# - options (Hash)
|
715
848
|
#
|
849
|
+
# - label_id
|
850
|
+
# * Filter messages with a label
|
851
|
+
#
|
716
852
|
# - direction
|
717
853
|
# * Filter messages by direction
|
718
854
|
# * Allowed values: incoming, outgoing
|
719
855
|
#
|
720
856
|
# - message_type
|
721
857
|
# * Filter messages by message_type
|
722
|
-
# * Allowed values: sms, mms, ussd, call
|
858
|
+
# * Allowed values: sms, mms, ussd, call, service
|
723
859
|
#
|
724
860
|
# - source
|
725
861
|
# * Filter messages by source
|
726
|
-
# * Allowed values: phone, provider, web, api, service, webhook, scheduled
|
862
|
+
# * Allowed values: phone, provider, web, api, service, webhook, scheduled,
|
863
|
+
# integration
|
727
864
|
#
|
728
865
|
# - starred (bool)
|
729
866
|
# * Filter messages by starred/unstarred
|
@@ -751,6 +888,9 @@ class Project < Entity
|
|
751
888
|
# - broadcast_id
|
752
889
|
# * ID of the broadcast containing the message
|
753
890
|
#
|
891
|
+
# - scheduled_id
|
892
|
+
# * ID of the scheduled message that created this message
|
893
|
+
#
|
754
894
|
# - sort
|
755
895
|
# * Sort the results based on a field
|
756
896
|
# * Allowed values: default
|
@@ -762,7 +902,7 @@ class Project < Entity
|
|
762
902
|
# * Default: asc
|
763
903
|
#
|
764
904
|
# - page_size (int)
|
765
|
-
# * Number of results returned per page (max
|
905
|
+
# * Number of results returned per page (max 500)
|
766
906
|
# * Default: 50
|
767
907
|
#
|
768
908
|
# - offset (int)
|
@@ -838,7 +978,7 @@ class Project < Entity
|
|
838
978
|
# * Default: asc
|
839
979
|
#
|
840
980
|
# - page_size (int)
|
841
|
-
# * Number of results returned per page (max
|
981
|
+
# * Number of results returned per page (max 500)
|
842
982
|
# * Default: 50
|
843
983
|
#
|
844
984
|
# - offset (int)
|
@@ -885,6 +1025,290 @@ class Project < Entity
|
|
885
1025
|
return Broadcast.new(@api, {'project_id' => self.id, 'id' => id}, false)
|
886
1026
|
end
|
887
1027
|
|
1028
|
+
#
|
1029
|
+
# Creates and starts an asynchronous task that is applied to all entities matching a filter
|
1030
|
+
# (e.g. contacts, messages, or data rows).
|
1031
|
+
# Tasks are designed to efficiently process a large number of
|
1032
|
+
# entities. When processing a large number of entities,
|
1033
|
+
# tasks are much faster than using the API to query and loop over
|
1034
|
+
# all objects matching a filter.
|
1035
|
+
#
|
1036
|
+
# Several different types of tasks are supported, including
|
1037
|
+
# applying services to contacts, messages, or data rows;
|
1038
|
+
# adding or removing contacts from a group; blocking or unblocking
|
1039
|
+
# sending messages to a contact; updating a custom variable;
|
1040
|
+
# deleting contacts, messages, or data rows; or exporting data to
|
1041
|
+
# CSV.
|
1042
|
+
#
|
1043
|
+
# When using a task to apply a Custom Actions or Cloud Script API
|
1044
|
+
# service (`apply_service_to_contacts`, `apply_service_to_rows`, or
|
1045
|
+
# `apply_service_to_messages`),
|
1046
|
+
# the `task` variable will be available within the service. The
|
1047
|
+
# service can use custom variables on the task object (e.g. `task.vars.example`), such as
|
1048
|
+
# to store aggregate statistics for the rows matching the filter.
|
1049
|
+
#
|
1050
|
+
# Arguments:
|
1051
|
+
# - options (Hash)
|
1052
|
+
# * Required
|
1053
|
+
#
|
1054
|
+
# - task_type
|
1055
|
+
# * Type of task to create. Each `task_type` applies to a certain type of entity (such
|
1056
|
+
# as a contact, message, or data row).
|
1057
|
+
#
|
1058
|
+
# Tasks for contacts:
|
1059
|
+
#
|
1060
|
+
# - `update_contact_var`
|
1061
|
+
# - `add_group_members`
|
1062
|
+
# - `remove_group_members`
|
1063
|
+
# - `set_conversation_status`
|
1064
|
+
# - `set_send_blocked`
|
1065
|
+
# - `apply_service_to_contacts`
|
1066
|
+
# - `delete_contacts`
|
1067
|
+
# - `export_contacts`
|
1068
|
+
#
|
1069
|
+
# Tasks for data rows:
|
1070
|
+
#
|
1071
|
+
# - `update_row_var`
|
1072
|
+
# - `apply_service_to_rows`
|
1073
|
+
# - `delete_rows`
|
1074
|
+
# - `export_rows`
|
1075
|
+
#
|
1076
|
+
# Tasks for messages:
|
1077
|
+
#
|
1078
|
+
# - `cancel_messages`
|
1079
|
+
# - `resend_messages`
|
1080
|
+
# - `retry_message_services`
|
1081
|
+
# - `apply_service_to_messages`
|
1082
|
+
# - `add_label`
|
1083
|
+
# - `remove_label`
|
1084
|
+
# - `update_message_var`
|
1085
|
+
# - `delete_messages`
|
1086
|
+
# - `export_messages`
|
1087
|
+
# * Allowed values: update_contact_var, delete_contacts, add_group_members,
|
1088
|
+
# remove_group_members, set_conversation_status, set_send_blocked,
|
1089
|
+
# apply_service_to_contacts, update_row_var, delete_rows, apply_service_to_rows,
|
1090
|
+
# delete_messages, cancel_messages, resend_messages, retry_message_services,
|
1091
|
+
# apply_service_to_messages, add_label, remove_label, update_message_var,
|
1092
|
+
# export_messages, export_contacts, export_rows
|
1093
|
+
# * Required
|
1094
|
+
#
|
1095
|
+
# - task_params (Hash)
|
1096
|
+
# * Parameters applied to all matching rows (specific to `task_type`).
|
1097
|
+
#
|
1098
|
+
# **`apply_service_to_contacts`**,
|
1099
|
+
# **`apply_service_to_messages`**, **`apply_service_to_rows`**:
|
1100
|
+
# <table>
|
1101
|
+
# <tr><td> `service_id` </td> <td> The ID of the
|
1102
|
+
# service to apply (string) </td></tr>
|
1103
|
+
# </table>
|
1104
|
+
#
|
1105
|
+
# **`update_contact_var`**, **`update_message_var`**,
|
1106
|
+
# **`update_row_var`**:
|
1107
|
+
# <table>
|
1108
|
+
# <tr><td> `variable` </td> <td> The custom variable
|
1109
|
+
# name (string) </td></tr>
|
1110
|
+
# <tr><td> `value` </td> <td> The value to set
|
1111
|
+
# (string, boolean, float, null) </td></tr>
|
1112
|
+
# </table>
|
1113
|
+
#
|
1114
|
+
# **`add_group_members`**, **`remove_group_members`**:
|
1115
|
+
# <table>
|
1116
|
+
# <tr><td> `group_id` </td> <td> The ID of the group
|
1117
|
+
# (string) </td></tr>
|
1118
|
+
# </table>
|
1119
|
+
#
|
1120
|
+
# **`add_label`**, **`remove_label`**:
|
1121
|
+
# <table>
|
1122
|
+
# <tr><td> `label_id` </td> <td> The ID of the label
|
1123
|
+
# (string) </td></tr>
|
1124
|
+
# </table>
|
1125
|
+
#
|
1126
|
+
# **`resend_messages`**:
|
1127
|
+
# <table>
|
1128
|
+
# <tr><td> `route_id` </td> <td> ID of the new route
|
1129
|
+
# to use, or null to use the original route (string) </td></tr>
|
1130
|
+
# </table>
|
1131
|
+
#
|
1132
|
+
# **`set_send_blocked`**:
|
1133
|
+
# <table>
|
1134
|
+
# <tr><td> `send_blocked` </td> <td> `true` to block
|
1135
|
+
# sending messages, `false` to unblock sending messages (boolean) </td></tr>
|
1136
|
+
# </table>
|
1137
|
+
#
|
1138
|
+
# **`set_conversation_status`**:
|
1139
|
+
# <table>
|
1140
|
+
# <tr><td> `conversation_status` </td> <td> "active",
|
1141
|
+
# "handled", or "closed" (string) </td></tr>
|
1142
|
+
# </table>
|
1143
|
+
#
|
1144
|
+
# **`export_contacts`**, **`export_messages`**,
|
1145
|
+
# **`export_rows`**:
|
1146
|
+
# <table>
|
1147
|
+
# <tr><td>`storage_id` </td> <td> ID of a storage
|
1148
|
+
# backend where the CSV file will be saved. (string)
|
1149
|
+
#
|
1150
|
+
# Currently only AWS S3 is supported as a storage
|
1151
|
+
# backend.
|
1152
|
+
# This requires creating a S3 bucket in your own
|
1153
|
+
# AWS account, as well as an IAM user with access key and secret that has permission
|
1154
|
+
# to write to that bucket.
|
1155
|
+
# To configure your own S3 bucket as a storage
|
1156
|
+
# backend, contact support.
|
1157
|
+
#
|
1158
|
+
# Direct downloads are not supported when
|
1159
|
+
# exporting data via the API.
|
1160
|
+
# (string) </td></tr>
|
1161
|
+
# <tr><td>`filename` </td> <td> Path within the
|
1162
|
+
# storage backend where the CSV file will be saved </td></tr>
|
1163
|
+
# <tr><td>`column_ids` </td> <td> IDs of columns to
|
1164
|
+
# save in the CSV file. If not provided, all default columns will be saved. (array of
|
1165
|
+
# strings, optional) </td></tr>
|
1166
|
+
# </table>
|
1167
|
+
#
|
1168
|
+
# **`delete_contacts`**, **`delete_messages`**,
|
1169
|
+
# **`delete_rows`**, **`cancel_messages`**, **`retry_message_services`**: <br />
|
1170
|
+
# No parameters.
|
1171
|
+
#
|
1172
|
+
# - filter_type
|
1173
|
+
# * Type of filter defining the rows that the task is applied to.
|
1174
|
+
#
|
1175
|
+
# Each `filter_type` queries a certain type of
|
1176
|
+
# entity (such as contacts, messages, or data rows).
|
1177
|
+
#
|
1178
|
+
# In general, the `task_type` and the
|
1179
|
+
# `filter_type` must return the same type of entity; however, tasks applied to
|
1180
|
+
# contacts (other than `export_contacts`) can also be applied
|
1181
|
+
# when the filter returns entities that are
|
1182
|
+
# associated with a contact, such as messages or data rows. (Note that in this case,
|
1183
|
+
# it is possible for the task to be applied multiple times to an individual contact if
|
1184
|
+
# multiple messages or data rows are associated with the same contact.)
|
1185
|
+
# * Allowed values: query_contacts, contact_ids, query_rows, row_ids, query_messages,
|
1186
|
+
# message_ids
|
1187
|
+
# * Required
|
1188
|
+
#
|
1189
|
+
# - filter_params (Hash)
|
1190
|
+
# * Parameters defining the rows that the task is applied to (specific to
|
1191
|
+
# `filter_type`).
|
1192
|
+
#
|
1193
|
+
# **`query_contacts`**: <br />
|
1194
|
+
# The same filter parameters as used by
|
1195
|
+
# [project.queryContacts](#Project.queryContacts). If you want to apply the task to
|
1196
|
+
# all contacts, use the parameters {"all": true}.
|
1197
|
+
#
|
1198
|
+
# **`contact_ids`**:
|
1199
|
+
# <table>
|
1200
|
+
# <tr><td> `contact_ids` </td> <td> IDs of up to 100
|
1201
|
+
# contacts to apply this task to (array of strings) </td></tr>
|
1202
|
+
# </table>
|
1203
|
+
#
|
1204
|
+
# **`query_messages`**: <br />
|
1205
|
+
# The same filter parameters as used by
|
1206
|
+
# [project.queryMessages](#Project.queryMessages). If you want to apply the task to
|
1207
|
+
# all messages, use the parameters {"all": true}.
|
1208
|
+
#
|
1209
|
+
# **`message_ids`**:
|
1210
|
+
# <table>
|
1211
|
+
# <tr><td> `message_ids` </td> <td> IDs of up to 100
|
1212
|
+
# messages to apply this task to (array of strings) </td></tr>
|
1213
|
+
# </table>
|
1214
|
+
#
|
1215
|
+
# **`query_rows`**: <br />
|
1216
|
+
# The same filter parameters as used by
|
1217
|
+
# [table.queryRows](#DataTable.queryRows). If you want to apply the task to all rows
|
1218
|
+
# in the table, use the parameters {"all": true}.
|
1219
|
+
#
|
1220
|
+
# **`row_ids`**:
|
1221
|
+
# <table>
|
1222
|
+
# <tr><td> `row_ids` </td> <td> IDs of up to 100 data
|
1223
|
+
# rows to apply this task to (array of strings) </td></tr>
|
1224
|
+
# </table>
|
1225
|
+
# * Required
|
1226
|
+
#
|
1227
|
+
# - table_id (string, max 34 characters)
|
1228
|
+
# * ID of the data table this task is applied to (if applicable).
|
1229
|
+
#
|
1230
|
+
# Required if filter_type is `query_rows` or `row_ids`.
|
1231
|
+
#
|
1232
|
+
# - vars (Hash)
|
1233
|
+
# * Initial custom variables to set for the task.
|
1234
|
+
#
|
1235
|
+
# If the task applies a service, the service can read
|
1236
|
+
# and write custom variables on the task object (e.g. `task.vars.example`), such as
|
1237
|
+
# to store aggregate statistics for the rows matching
|
1238
|
+
# the filter.
|
1239
|
+
#
|
1240
|
+
# Returns:
|
1241
|
+
# Telerivet::Task
|
1242
|
+
#
|
1243
|
+
def create_task(options)
|
1244
|
+
require_relative 'task'
|
1245
|
+
Task.new(@api, @api.do_request("POST", get_base_api_path() + "/tasks", options))
|
1246
|
+
end
|
1247
|
+
|
1248
|
+
#
|
1249
|
+
# Queries batch tasks within the given project.
|
1250
|
+
#
|
1251
|
+
# Arguments:
|
1252
|
+
# - options (Hash)
|
1253
|
+
#
|
1254
|
+
# - sort
|
1255
|
+
# * Sort the results based on a field
|
1256
|
+
# * Allowed values: default
|
1257
|
+
# * Default: default
|
1258
|
+
#
|
1259
|
+
# - sort_dir
|
1260
|
+
# * Sort the results in ascending or descending order
|
1261
|
+
# * Allowed values: asc, desc
|
1262
|
+
# * Default: asc
|
1263
|
+
#
|
1264
|
+
# - page_size (int)
|
1265
|
+
# * Number of results returned per page (max 500)
|
1266
|
+
# * Default: 50
|
1267
|
+
#
|
1268
|
+
# - offset (int)
|
1269
|
+
# * Number of items to skip from beginning of result set
|
1270
|
+
# * Default: 0
|
1271
|
+
#
|
1272
|
+
# Returns:
|
1273
|
+
# Telerivet::APICursor (of Telerivet::Task)
|
1274
|
+
#
|
1275
|
+
def query_tasks(options = nil)
|
1276
|
+
require_relative 'task'
|
1277
|
+
@api.cursor(Task, get_base_api_path() + "/tasks", options)
|
1278
|
+
end
|
1279
|
+
|
1280
|
+
#
|
1281
|
+
# Retrieves the task with the given ID.
|
1282
|
+
#
|
1283
|
+
# Arguments:
|
1284
|
+
# - id
|
1285
|
+
# * ID of the task
|
1286
|
+
# * Required
|
1287
|
+
#
|
1288
|
+
# Returns:
|
1289
|
+
# Telerivet::Task
|
1290
|
+
#
|
1291
|
+
def get_task_by_id(id)
|
1292
|
+
require_relative 'task'
|
1293
|
+
Task.new(@api, @api.do_request("GET", get_base_api_path() + "/tasks/#{id}"))
|
1294
|
+
end
|
1295
|
+
|
1296
|
+
#
|
1297
|
+
# Initializes the task with the given ID without making an API request.
|
1298
|
+
#
|
1299
|
+
# Arguments:
|
1300
|
+
# - id
|
1301
|
+
# * ID of the task
|
1302
|
+
# * Required
|
1303
|
+
#
|
1304
|
+
# Returns:
|
1305
|
+
# Telerivet::Task
|
1306
|
+
#
|
1307
|
+
def init_task_by_id(id)
|
1308
|
+
require_relative 'task'
|
1309
|
+
return Task.new(@api, {'project_id' => self.id, 'id' => id}, false)
|
1310
|
+
end
|
1311
|
+
|
888
1312
|
#
|
889
1313
|
# Queries groups within the given project.
|
890
1314
|
#
|
@@ -910,7 +1334,7 @@ class Project < Entity
|
|
910
1334
|
# * Default: asc
|
911
1335
|
#
|
912
1336
|
# - page_size (int)
|
913
|
-
# * Number of results returned per page (max
|
1337
|
+
# * Number of results returned per page (max 500)
|
914
1338
|
# * Default: 50
|
915
1339
|
#
|
916
1340
|
# - offset (int)
|
@@ -995,7 +1419,7 @@ class Project < Entity
|
|
995
1419
|
# * Default: asc
|
996
1420
|
#
|
997
1421
|
# - page_size (int)
|
998
|
-
# * Number of results returned per page (max
|
1422
|
+
# * Number of results returned per page (max 500)
|
999
1423
|
# * Default: 50
|
1000
1424
|
#
|
1001
1425
|
# - offset (int)
|
@@ -1080,7 +1504,7 @@ class Project < Entity
|
|
1080
1504
|
# * Default: asc
|
1081
1505
|
#
|
1082
1506
|
# - page_size (int)
|
1083
|
-
# * Number of results returned per page (max
|
1507
|
+
# * Number of results returned per page (max 500)
|
1084
1508
|
# * Default: 50
|
1085
1509
|
#
|
1086
1510
|
# - offset (int)
|
@@ -1151,7 +1575,7 @@ class Project < Entity
|
|
1151
1575
|
#
|
1152
1576
|
# - message_type
|
1153
1577
|
# * Filter scheduled messages by message_type
|
1154
|
-
# * Allowed values: sms, mms, ussd, call
|
1578
|
+
# * Allowed values: sms, mms, ussd, call, service
|
1155
1579
|
#
|
1156
1580
|
# - time_created (UNIX timestamp)
|
1157
1581
|
# * Filter scheduled messages by time_created
|
@@ -1159,8 +1583,8 @@ class Project < Entity
|
|
1159
1583
|
#
|
1160
1584
|
# - next_time (UNIX timestamp)
|
1161
1585
|
# * Filter scheduled messages by next_time
|
1162
|
-
# * Allowed modifiers: next_time[
|
1163
|
-
# next_time[
|
1586
|
+
# * Allowed modifiers: next_time[ne], next_time[min], next_time[max],
|
1587
|
+
# next_time[exists]
|
1164
1588
|
#
|
1165
1589
|
# - sort
|
1166
1590
|
# * Sort the results based on a field
|
@@ -1173,7 +1597,7 @@ class Project < Entity
|
|
1173
1597
|
# * Default: asc
|
1174
1598
|
#
|
1175
1599
|
# - page_size (int)
|
1176
|
-
# * Number of results returned per page (max
|
1600
|
+
# * Number of results returned per page (max 500)
|
1177
1601
|
# * Default: 50
|
1178
1602
|
#
|
1179
1603
|
# - offset (int)
|
@@ -1236,7 +1660,7 @@ class Project < Entity
|
|
1236
1660
|
#
|
1237
1661
|
# - context
|
1238
1662
|
# * Filter services that can be invoked in a particular context
|
1239
|
-
# * Allowed values: message, call, contact, project
|
1663
|
+
# * Allowed values: message, call, ussd_session, row, contact, project
|
1240
1664
|
#
|
1241
1665
|
# - sort
|
1242
1666
|
# * Sort the results based on a field
|
@@ -1249,7 +1673,7 @@ class Project < Entity
|
|
1249
1673
|
# * Default: asc
|
1250
1674
|
#
|
1251
1675
|
# - page_size (int)
|
1252
|
-
# * Number of results returned per page (max
|
1676
|
+
# * Number of results returned per page (max 500)
|
1253
1677
|
# * Default: 50
|
1254
1678
|
#
|
1255
1679
|
# - offset (int)
|
@@ -1318,7 +1742,7 @@ class Project < Entity
|
|
1318
1742
|
# * Default: asc
|
1319
1743
|
#
|
1320
1744
|
# - page_size (int)
|
1321
|
-
# * Number of results returned per page (max
|
1745
|
+
# * Number of results returned per page (max 500)
|
1322
1746
|
# * Default: 50
|
1323
1747
|
#
|
1324
1748
|
# - offset (int)
|
@@ -1377,6 +1801,85 @@ class Project < Entity
|
|
1377
1801
|
return @api.do_request("GET", get_base_api_path() + "/users")
|
1378
1802
|
end
|
1379
1803
|
|
1804
|
+
#
|
1805
|
+
# Returns information about each airtime transaction.
|
1806
|
+
#
|
1807
|
+
# Arguments:
|
1808
|
+
# - options (Hash)
|
1809
|
+
#
|
1810
|
+
# - time_created[min] (UNIX timestamp)
|
1811
|
+
# * Filter transactions created on or after a particular time
|
1812
|
+
#
|
1813
|
+
# - time_created[max] (UNIX timestamp)
|
1814
|
+
# * Filter transactions created before a particular time
|
1815
|
+
#
|
1816
|
+
# - contact_id
|
1817
|
+
# * Filter transactions sent to a particular contact
|
1818
|
+
#
|
1819
|
+
# - to_number
|
1820
|
+
# * Filter transactions sent to a particular phone number
|
1821
|
+
#
|
1822
|
+
# - service_id
|
1823
|
+
# * Filter transactions sent by a particular service
|
1824
|
+
#
|
1825
|
+
# - status
|
1826
|
+
# * Filter transactions by status
|
1827
|
+
# * Allowed values: pending, queued, processing, successful, failed, cancelled,
|
1828
|
+
# pending_payment, pending_approval
|
1829
|
+
#
|
1830
|
+
# - sort_dir
|
1831
|
+
# * Sort the results in ascending or descending order
|
1832
|
+
# * Allowed values: asc, desc
|
1833
|
+
# * Default: asc
|
1834
|
+
#
|
1835
|
+
# - page_size (int)
|
1836
|
+
# * Number of results returned per page (max 500)
|
1837
|
+
# * Default: 50
|
1838
|
+
#
|
1839
|
+
# - offset (int)
|
1840
|
+
# * Number of items to skip from beginning of result set
|
1841
|
+
# * Default: 0
|
1842
|
+
#
|
1843
|
+
# Returns:
|
1844
|
+
# Telerivet::APICursor (of Telerivet::AirtimeTransaction)
|
1845
|
+
#
|
1846
|
+
def query_airtime_transactions(options = nil)
|
1847
|
+
require_relative 'airtimetransaction'
|
1848
|
+
@api.cursor(AirtimeTransaction, get_base_api_path() + "/airtime_transactions", options)
|
1849
|
+
end
|
1850
|
+
|
1851
|
+
#
|
1852
|
+
# Gets an airtime transaction by ID
|
1853
|
+
#
|
1854
|
+
# Arguments:
|
1855
|
+
# - id
|
1856
|
+
# * ID of the airtime transaction
|
1857
|
+
# * Required
|
1858
|
+
#
|
1859
|
+
# Returns:
|
1860
|
+
# Telerivet::AirtimeTransaction
|
1861
|
+
#
|
1862
|
+
def get_airtime_transaction_by_id(id)
|
1863
|
+
require_relative 'airtimetransaction'
|
1864
|
+
AirtimeTransaction.new(@api, @api.do_request("GET", get_base_api_path() + "/airtime_transactions/#{id}"))
|
1865
|
+
end
|
1866
|
+
|
1867
|
+
#
|
1868
|
+
# Initializes an airtime transaction by ID without making an API request.
|
1869
|
+
#
|
1870
|
+
# Arguments:
|
1871
|
+
# - id
|
1872
|
+
# * ID of the airtime transaction
|
1873
|
+
# * Required
|
1874
|
+
#
|
1875
|
+
# Returns:
|
1876
|
+
# Telerivet::AirtimeTransaction
|
1877
|
+
#
|
1878
|
+
def init_airtime_transaction_by_id(id)
|
1879
|
+
require_relative 'airtimetransaction'
|
1880
|
+
return AirtimeTransaction.new(@api, {'project_id' => self.id, 'id' => id}, false)
|
1881
|
+
end
|
1882
|
+
|
1380
1883
|
#
|
1381
1884
|
# Saves any fields or custom variables that have changed for the project.
|
1382
1885
|
#
|