telerivet 1.4.5 → 1.7.0
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/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/project.rb
CHANGED
@@ -19,13 +19,27 @@ module Telerivet
|
|
19
19
|
# * Updatable via API
|
20
20
|
#
|
21
21
|
# - timezone_id
|
22
|
-
# * Default TZ database timezone ID; see
|
23
|
-
#
|
24
|
-
# *
|
22
|
+
# * Default TZ database timezone ID; see [List of tz database time zones Wikipedia
|
23
|
+
# article](http://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
|
24
|
+
# * Updatable via API
|
25
25
|
#
|
26
26
|
# - url_slug
|
27
27
|
# * Unique string used as a component of the project's URL in the Telerivet web app
|
28
|
-
# *
|
28
|
+
# * Updatable via API
|
29
|
+
#
|
30
|
+
# - default_route_id
|
31
|
+
# * The ID of a basic route or custom route that will be used to send messages by
|
32
|
+
# default (via both the API and web app), unless a particular route ID is specified when
|
33
|
+
# sending the message.
|
34
|
+
# * Updatable via API
|
35
|
+
#
|
36
|
+
# - auto_create_contacts (bool)
|
37
|
+
# * If true, a contact will be automatically created for each unique phone number that a
|
38
|
+
# message is sent to or received from. If false, contacts will not automatically be
|
39
|
+
# created (unless contact information is modified by an automated service). The
|
40
|
+
# Conversations tab in the web app will only show messages that are associated with a
|
41
|
+
# contact.
|
42
|
+
# * Updatable via API
|
29
43
|
#
|
30
44
|
# - vars (Hash)
|
31
45
|
# * Custom variables stored for this project
|
@@ -37,7 +51,7 @@ module Telerivet
|
|
37
51
|
#
|
38
52
|
class Project < Entity
|
39
53
|
#
|
40
|
-
# Sends one message (SMS, MMS, voice call, or USSD request).
|
54
|
+
# Sends one message (SMS, MMS, chat app message, voice call, or USSD request).
|
41
55
|
#
|
42
56
|
# Arguments:
|
43
57
|
# - options (Hash)
|
@@ -46,7 +60,7 @@ class Project < Entity
|
|
46
60
|
# - message_type
|
47
61
|
# * Type of message to send. If `text`, will use the default text message type for the
|
48
62
|
# selected route.
|
49
|
-
# * Allowed values: sms, mms, ussd, call,
|
63
|
+
# * Allowed values: text, sms, mms, ussd, call, chat, service
|
50
64
|
# * Default: text
|
51
65
|
#
|
52
66
|
# - content
|
@@ -72,9 +86,9 @@ class Project < Entity
|
|
72
86
|
# - status_secret
|
73
87
|
# * POST parameter 'secret' passed to status_url
|
74
88
|
#
|
75
|
-
# -
|
89
|
+
# - replace_variables (bool)
|
76
90
|
# * Set to true to evaluate variables like [[contact.name]] in message content. [(See
|
77
|
-
# available variables)](#variables)
|
91
|
+
# available variables)](#variables) (`is_template` parameter also accepted)
|
78
92
|
# * Default: false
|
79
93
|
#
|
80
94
|
# - track_clicks (boolean)
|
@@ -82,11 +96,31 @@ class Project < Entity
|
|
82
96
|
# short URLs.
|
83
97
|
# * Default: false
|
84
98
|
#
|
99
|
+
# - short_link_params (Hash)
|
100
|
+
# *
|
101
|
+
# If `track_clicks` is true, `short_link_params` may be used to specify
|
102
|
+
# custom parameters for each short link in the message. The following parameters are
|
103
|
+
# supported:
|
104
|
+
#
|
105
|
+
# `domain` (string): A custom short domain name to use for the short
|
106
|
+
# links. The domain name must already be registered for your project or organization.
|
107
|
+
#
|
108
|
+
# `expiration_sec` (integer): The number of seconds after the message is
|
109
|
+
# created (queued to send) when the short links will stop forwarding to the
|
110
|
+
# destination URL.
|
111
|
+
# If null, the short links will not expire.
|
112
|
+
#
|
85
113
|
# - media_urls (array)
|
86
114
|
# * URLs of media files to attach to the text message. If `message_type` is `sms`,
|
87
115
|
# short links to each media URL will be appended to the end of the content (separated
|
88
116
|
# by a new line).
|
89
117
|
#
|
118
|
+
# - route_params (Hash)
|
119
|
+
# * Route-specific parameters for the message. The parameters object should have one
|
120
|
+
# or more keys matching the `phone_type` field of a phone (basic route) that may be
|
121
|
+
# used to send the message. The corresponding value should be an object with
|
122
|
+
# route-specific parameters to use if the message is sent by that type of route.
|
123
|
+
#
|
90
124
|
# - label_ids (array)
|
91
125
|
# * List of IDs of labels to add to this message
|
92
126
|
#
|
@@ -154,7 +188,7 @@ class Project < Entity
|
|
154
188
|
# - message_type
|
155
189
|
# * Type of message to send. If `text`, will use the default text message type for the
|
156
190
|
# selected route.
|
157
|
-
# * Allowed values: sms, mms, call,
|
191
|
+
# * Allowed values: text, sms, mms, call, chat, service
|
158
192
|
# * Default: text
|
159
193
|
#
|
160
194
|
# - content
|
@@ -192,9 +226,9 @@ class Project < Entity
|
|
192
226
|
# * Optionally excludes one contact from receiving the message (only when group_id is
|
193
227
|
# set)
|
194
228
|
#
|
195
|
-
# -
|
229
|
+
# - replace_variables (bool)
|
196
230
|
# * Set to true to evaluate variables like [[contact.name]] in message content [(See
|
197
|
-
# available variables)](#variables)
|
231
|
+
# available variables)](#variables) (`is_template` parameter also accepted)
|
198
232
|
# * Default: false
|
199
233
|
#
|
200
234
|
# - track_clicks (boolean)
|
@@ -202,6 +236,20 @@ class Project < Entity
|
|
202
236
|
# short URLs.
|
203
237
|
# * Default: false
|
204
238
|
#
|
239
|
+
# - short_link_params (Hash)
|
240
|
+
# *
|
241
|
+
# If `track_clicks` is true, `short_link_params` may be used to specify
|
242
|
+
# custom parameters for each short link in the message. The following parameters are
|
243
|
+
# supported:
|
244
|
+
#
|
245
|
+
# `domain` (string): A custom short domain name to use for the short
|
246
|
+
# links. The domain name must already be registered for your project or organization.
|
247
|
+
#
|
248
|
+
# `expiration_sec` (integer): The number of seconds after the message is
|
249
|
+
# created (queued to send) when the short links will stop forwarding to the
|
250
|
+
# destination URL.
|
251
|
+
# If null, the short links will not expire.
|
252
|
+
#
|
205
253
|
# - media_urls (array)
|
206
254
|
# * URLs of media files to attach to the text message. If `message_type` is `sms`,
|
207
255
|
# short links to each URL will be appended to the end of the content (separated by a
|
@@ -210,6 +258,12 @@ class Project < Entity
|
|
210
258
|
# - vars (Hash)
|
211
259
|
# * Custom variables to set for each message
|
212
260
|
#
|
261
|
+
# - route_params (Hash)
|
262
|
+
# * Route-specific parameters for the messages in the broadcast. The parameters object
|
263
|
+
# may have keys matching the `phone_type` field of a phone (basic route) that may be
|
264
|
+
# used to send messages in this broadcast. The corresponding value is an object with
|
265
|
+
# route-specific parameters to use when sending messages with that type of route.
|
266
|
+
#
|
213
267
|
# - service_id
|
214
268
|
# * Service to invoke for each recipient (when `message_type` is `call` or `service`)
|
215
269
|
# * Required if message_type is service
|
@@ -262,7 +316,7 @@ class Project < Entity
|
|
262
316
|
# - message_type
|
263
317
|
# * Type of message to send. If `text`, will use the default text message type for the
|
264
318
|
# selected route.
|
265
|
-
# * Allowed values: sms, mms, chat,
|
319
|
+
# * Allowed values: text, sms, mms, call, chat, service
|
266
320
|
# * Default: text
|
267
321
|
#
|
268
322
|
# - route_id
|
@@ -290,16 +344,41 @@ class Project < Entity
|
|
290
344
|
# - label_ids (array)
|
291
345
|
# * Array of IDs of labels to add to each message (maximum 5)
|
292
346
|
#
|
293
|
-
# -
|
347
|
+
# - replace_variables (bool)
|
294
348
|
# * Set to true to evaluate variables like [[contact.name]] in message content [(See
|
295
|
-
# available variables)](#variables)
|
349
|
+
# available variables)](#variables) (`is_template` parameter also accepted)
|
296
350
|
# * Default: false
|
297
351
|
#
|
352
|
+
# - track_clicks (boolean)
|
353
|
+
# * If true, URLs in the message content will automatically be replaced with unique
|
354
|
+
# short URLs.
|
355
|
+
# * Default: false
|
356
|
+
#
|
357
|
+
# - short_link_params (Hash)
|
358
|
+
# *
|
359
|
+
# If `track_clicks` is true, `short_link_params` may be used to specify
|
360
|
+
# custom parameters for each short link in the message. The following parameters are
|
361
|
+
# supported:
|
362
|
+
#
|
363
|
+
# `domain` (string): A custom short domain name to use for the short
|
364
|
+
# links. The domain name must already be registered for your project or organization.
|
365
|
+
#
|
366
|
+
# `expiration_sec` (integer): The number of seconds after the message is
|
367
|
+
# created (queued to send) when the short links will stop forwarding to the
|
368
|
+
# destination URL.
|
369
|
+
# If null, the short links will not expire.
|
370
|
+
#
|
298
371
|
# - media_urls (array)
|
299
372
|
# * URLs of media files to attach to the text message. If `message_type` is `sms`,
|
300
373
|
# short links to each media URL will be appended to the end of the content (separated
|
301
374
|
# by a new line).
|
302
375
|
#
|
376
|
+
# - route_params (Hash)
|
377
|
+
# * Route-specific parameters to apply to all messages. The parameters object may have
|
378
|
+
# keys matching the `phone_type` field of a phone (basic route) that may be used to
|
379
|
+
# send messages. The corresponding value is an object with route-specific parameters
|
380
|
+
# to use when sending messages with that type of route.
|
381
|
+
#
|
303
382
|
# - vars (Hash)
|
304
383
|
# * Custom variables to store with the message
|
305
384
|
#
|
@@ -325,6 +404,10 @@ class Project < Entity
|
|
325
404
|
# (Other properties of the Message object are
|
326
405
|
# omitted in order to reduce the amount of redundant data sent in each API
|
327
406
|
# response.)
|
407
|
+
# If the `messages` parameter in the API request
|
408
|
+
# contains items with `to_number` values that are associated with blocked contacts,
|
409
|
+
# the `id` and `status` properties corresponding to those items will be null, and no
|
410
|
+
# messages will be sent to those numbers.
|
328
411
|
#
|
329
412
|
# - broadcast_id
|
330
413
|
# * ID of broadcast that these messages are associated with, if `broadcast_id` or
|
@@ -372,6 +455,9 @@ class Project < Entity
|
|
372
455
|
# messages approximately once every 15 seconds, so it is not possible to control the exact
|
373
456
|
# second at which a scheduled message is sent.
|
374
457
|
#
|
458
|
+
# Only one of the parameters group_id, to_number, and contact_id
|
459
|
+
# should be provided.
|
460
|
+
#
|
375
461
|
# With `message_type`=`service`, schedules an automated service (such
|
376
462
|
# as a poll) to be invoked for a group or list of phone numbers. Any service that can be
|
377
463
|
# triggered for a contact can be scheduled via this method, whether or not the service
|
@@ -383,20 +469,21 @@ class Project < Entity
|
|
383
469
|
#
|
384
470
|
# - message_type
|
385
471
|
# * Type of message to send
|
386
|
-
# * Allowed values: sms, ussd, call, service
|
387
|
-
# * Default:
|
472
|
+
# * Allowed values: text, sms, mms, ussd, call, chat, service
|
473
|
+
# * Default: text
|
388
474
|
#
|
389
475
|
# - content
|
390
476
|
# * Content of the message to schedule
|
391
|
-
# * Required if sending
|
477
|
+
# * Required if sending text message
|
392
478
|
#
|
393
479
|
# - group_id
|
394
480
|
# * ID of the group to send the message to
|
395
|
-
# * Required if to_number not set
|
396
481
|
#
|
397
482
|
# - to_number (string)
|
398
483
|
# * Phone number to send the message to
|
399
|
-
#
|
484
|
+
#
|
485
|
+
# - contact_id (string)
|
486
|
+
# * ID of the contact to send the message to
|
400
487
|
#
|
401
488
|
# - start_time (UNIX timestamp)
|
402
489
|
# * The time that the message will be sent (or first sent for recurring messages)
|
@@ -447,8 +534,23 @@ class Project < Entity
|
|
447
534
|
# short URLs.
|
448
535
|
# * Default: false
|
449
536
|
#
|
450
|
-
# -
|
537
|
+
# - short_link_params (Hash)
|
538
|
+
# *
|
539
|
+
# If `track_clicks` is true, `short_link_params` may be used to specify
|
540
|
+
# custom parameters for each short link in the message. The following parameters are
|
541
|
+
# supported:
|
542
|
+
#
|
543
|
+
# `domain` (string): A custom short domain name to use for the short
|
544
|
+
# links. The domain name must already be registered for your project or organization.
|
545
|
+
#
|
546
|
+
# `expiration_sec` (integer): The number of seconds after the message is
|
547
|
+
# created (queued to send) when the short links will stop forwarding to the
|
548
|
+
# destination URL.
|
549
|
+
# If null, the short links will not expire.
|
550
|
+
#
|
551
|
+
# - replace_variables (bool)
|
451
552
|
# * Set to true to evaluate variables like [[contact.name]] in message content
|
553
|
+
# (`is_template` parameter also accepted)
|
452
554
|
# * Default: false
|
453
555
|
#
|
454
556
|
# - media_urls (array)
|
@@ -456,14 +558,20 @@ class Project < Entity
|
|
456
558
|
# short links to each media URL will be appended to the end of the content (separated
|
457
559
|
# by a new line).
|
458
560
|
#
|
561
|
+
# - route_params (Hash)
|
562
|
+
# * Route-specific parameters to use when sending the message. The parameters object
|
563
|
+
# may have keys matching the `phone_type` field of a phone (basic route) that may be
|
564
|
+
# used to send the message. The corresponding value is an object with route-specific
|
565
|
+
# parameters to use when sending a message with that type of route.
|
566
|
+
#
|
459
567
|
# - label_ids (array)
|
460
568
|
# * Array of IDs of labels to add to the sent messages (maximum 5). Does not apply
|
461
569
|
# when `message_type`=`service`, since the labels are determined by the service
|
462
570
|
# itself.
|
463
571
|
#
|
464
572
|
# - timezone_id
|
465
|
-
# * TZ database timezone ID; see
|
466
|
-
#
|
573
|
+
# * TZ database timezone ID; see [List of tz database time zones Wikipedia
|
574
|
+
# article](http://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
|
467
575
|
# * Default: project default timezone
|
468
576
|
#
|
469
577
|
# - end_time (UNIX timestamp)
|
@@ -485,6 +593,166 @@ class Project < Entity
|
|
485
593
|
ScheduledMessage.new(@api, @api.do_request("POST", get_base_api_path() + "/scheduled", options))
|
486
594
|
end
|
487
595
|
|
596
|
+
#
|
597
|
+
# Creates a relative scheduled message. This allows scheduling messages on a different date
|
598
|
+
# for each contact, for example on their birthday, a certain number of days before an
|
599
|
+
# appointment, or a certain number of days after enrolling in a campaign.
|
600
|
+
#
|
601
|
+
# Telerivet will automatically create a
|
602
|
+
# [ScheduledMessage](#ScheduledMessage) for each contact matching a RelativeScheduledMessage.
|
603
|
+
#
|
604
|
+
# Relative scheduled messages can be created for a group or an
|
605
|
+
# individual contact, although dynamic groups are not supported. Only one of the parameters
|
606
|
+
# group_id, to_number, and contact_id should be provided.
|
607
|
+
#
|
608
|
+
# With message_type=service, schedules an automated service (such as a
|
609
|
+
# poll). Any service that can be triggered for a contact can be scheduled via this method,
|
610
|
+
# whether or not the service actually sends a message.
|
611
|
+
#
|
612
|
+
# Arguments:
|
613
|
+
# - options (Hash)
|
614
|
+
# * Required
|
615
|
+
#
|
616
|
+
# - message_type
|
617
|
+
# * Type of message to send
|
618
|
+
# * Allowed values: text, sms, mms, call, chat, service
|
619
|
+
# * Default: text
|
620
|
+
#
|
621
|
+
# - content
|
622
|
+
# * Content of the message to schedule
|
623
|
+
# * Required if sending text message
|
624
|
+
#
|
625
|
+
# - group_id
|
626
|
+
# * ID of the group to send the message to. Dynamic groups are not supported.
|
627
|
+
#
|
628
|
+
# - to_number (string)
|
629
|
+
# * Phone number to send the message to
|
630
|
+
#
|
631
|
+
# - contact_id (string)
|
632
|
+
# * ID of the contact to send the message to
|
633
|
+
#
|
634
|
+
# - time_of_day
|
635
|
+
# * Time of day when scheduled messages will be sent in HH:MM format (with hours from
|
636
|
+
# 00 to 23)
|
637
|
+
# * Required
|
638
|
+
#
|
639
|
+
# - timezone_id
|
640
|
+
# * TZ database timezone ID; see [List of tz database time zones Wikipedia
|
641
|
+
# article](http://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
|
642
|
+
# * Default: project default timezone
|
643
|
+
#
|
644
|
+
# - date_variable
|
645
|
+
# * Custom contact variable storing date or date/time values relative to which
|
646
|
+
# messages will be scheduled.
|
647
|
+
# * Required
|
648
|
+
#
|
649
|
+
# - offset_scale
|
650
|
+
# * The type of interval (day/week/month/year) that will be used to adjust the
|
651
|
+
# scheduled date relative to the date stored in the contact's date_variable, when
|
652
|
+
# offset_count is non-zero (D=day, W=week, M=month, Y=year)
|
653
|
+
# * Allowed values: D, W, M, Y
|
654
|
+
# * Default: D
|
655
|
+
#
|
656
|
+
# - offset_count (int)
|
657
|
+
# * The number of days/weeks/months/years to adjust the date of the scheduled message
|
658
|
+
# relative relative to the date stored in the custom contact variable identified by
|
659
|
+
# the date_variable parameter. May be positive, negative, or zero.
|
660
|
+
# * Default: 0
|
661
|
+
#
|
662
|
+
# - rrule
|
663
|
+
# * A recurrence rule describing the how the schedule repeats, e.g. 'FREQ=MONTHLY' or
|
664
|
+
# 'FREQ=WEEKLY;INTERVAL=2'; see <https://tools.ietf.org/html/rfc2445#section-4.3.10>.
|
665
|
+
# (UNTIL is ignored; use end_time parameter instead).
|
666
|
+
# * Default: COUNT=1 (one-time scheduled message, does not repeat)
|
667
|
+
#
|
668
|
+
# - route_id
|
669
|
+
# * ID of the phone or route to send the message from
|
670
|
+
# * Default: default sender route ID
|
671
|
+
#
|
672
|
+
# - service_id
|
673
|
+
# * Service to invoke for each recipient (when `message_type` is `call` or `service`)
|
674
|
+
# * Required if message_type is service
|
675
|
+
#
|
676
|
+
# - audio_url
|
677
|
+
# * The URL of an MP3 file to play when the contact answers the call (when
|
678
|
+
# `message_type` is `call`).
|
679
|
+
#
|
680
|
+
# If `audio_url` is provided, the text-to-speech voice is not used to say
|
681
|
+
# `content`, although you can optionally use `content` to indicate the script for the
|
682
|
+
# audio.
|
683
|
+
#
|
684
|
+
# For best results, use an MP3 file containing only speech. Music is not
|
685
|
+
# recommended because the audio quality will be low when played over a phone line.
|
686
|
+
#
|
687
|
+
# - tts_lang
|
688
|
+
# * The language of the text-to-speech voice (when `message_type` is `call`)
|
689
|
+
# * Allowed values: en-US, en-GB, en-GB-WLS, en-AU, en-IN, da-DK, nl-NL, fr-FR, fr-CA,
|
690
|
+
# de-DE, is-IS, it-IT, pl-PL, pt-BR, pt-PT, ru-RU, es-ES, es-US, sv-SE
|
691
|
+
# * Default: en-US
|
692
|
+
#
|
693
|
+
# - tts_voice
|
694
|
+
# * The name of the text-to-speech voice (when message_type=call)
|
695
|
+
# * Allowed values: female, male
|
696
|
+
# * Default: female
|
697
|
+
#
|
698
|
+
# - track_clicks (boolean)
|
699
|
+
# * If true, URLs in the message content will automatically be replaced with unique
|
700
|
+
# short URLs.
|
701
|
+
# * Default: false
|
702
|
+
#
|
703
|
+
# - short_link_params (Hash)
|
704
|
+
# *
|
705
|
+
# If `track_clicks` is true, `short_link_params` may be used to specify
|
706
|
+
# custom parameters for each short link in the message. The following parameters are
|
707
|
+
# supported:
|
708
|
+
#
|
709
|
+
# `domain` (string): A custom short domain name to use for the short
|
710
|
+
# links. The domain name must already be registered for your project or organization.
|
711
|
+
#
|
712
|
+
# `expiration_sec` (integer): The number of seconds after the message is
|
713
|
+
# created (queued to send) when the short links will stop forwarding to the
|
714
|
+
# destination URL.
|
715
|
+
# If null, the short links will not expire.
|
716
|
+
#
|
717
|
+
# - replace_variables (bool)
|
718
|
+
# * Set to true to evaluate variables like [[contact.name]] in message content
|
719
|
+
# * Default: false
|
720
|
+
#
|
721
|
+
# - media_urls (array)
|
722
|
+
# * URLs of media files to attach to the text message. If `message_type` is `sms`,
|
723
|
+
# short links to each media URL will be appended to the end of the content (separated
|
724
|
+
# by a new line).
|
725
|
+
#
|
726
|
+
# - route_params (Hash)
|
727
|
+
# * Route-specific parameters to use when sending the message. The parameters object
|
728
|
+
# may have keys matching the `phone_type` field of a phone (basic route) that may be
|
729
|
+
# used to send the message. The corresponding value is an object with route-specific
|
730
|
+
# parameters to use when sending a message with that type of route.
|
731
|
+
#
|
732
|
+
# - label_ids (array)
|
733
|
+
# * Array of IDs of labels to add to the sent messages (maximum 5). Does not apply
|
734
|
+
# when `message_type`=`service`, since the labels are determined by the service
|
735
|
+
# itself.
|
736
|
+
#
|
737
|
+
# - end_time (UNIX timestamp)
|
738
|
+
# * Time after which a recurring message will stop (not applicable to non-recurring
|
739
|
+
# scheduled messages)
|
740
|
+
#
|
741
|
+
# - end_time_offset (int)
|
742
|
+
# * Number of seconds from now until the recurring message will stop
|
743
|
+
#
|
744
|
+
# - vars (Hash)
|
745
|
+
# * Custom variables to set for this relative scheduled message, which will be copied
|
746
|
+
# to each message sent from this scheduled message
|
747
|
+
#
|
748
|
+
# Returns:
|
749
|
+
# Telerivet::RelativeScheduledMessage
|
750
|
+
#
|
751
|
+
def create_relative_scheduled_message(options)
|
752
|
+
require_relative 'relativescheduledmessage'
|
753
|
+
RelativeScheduledMessage.new(@api, @api.do_request("POST", get_base_api_path() + "/relative_scheduled", options))
|
754
|
+
end
|
755
|
+
|
488
756
|
#
|
489
757
|
# Add an incoming message to Telerivet. Acts the same as if the message was received by a
|
490
758
|
# phone. Also triggers any automated services that apply to the message.
|
@@ -648,6 +916,9 @@ class Project < Entity
|
|
648
916
|
# Arguments:
|
649
917
|
# - options (Hash)
|
650
918
|
#
|
919
|
+
# - group_id
|
920
|
+
# * Filter contacts within a group
|
921
|
+
#
|
651
922
|
# - name
|
652
923
|
# * Filter contacts by name
|
653
924
|
# * Allowed modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt],
|
@@ -657,28 +928,26 @@ class Project < Entity
|
|
657
928
|
# * Filter contacts by phone number
|
658
929
|
# * Allowed modifiers: phone_number[ne], phone_number[prefix],
|
659
930
|
# phone_number[not_prefix], phone_number[gte], phone_number[gt], phone_number[lt],
|
660
|
-
# phone_number[lte]
|
931
|
+
# phone_number[lte], phone_number[exists]
|
661
932
|
#
|
662
933
|
# - time_created (UNIX timestamp)
|
663
934
|
# * Filter contacts by time created
|
664
|
-
# * Allowed modifiers: time_created[
|
935
|
+
# * Allowed modifiers: time_created[min], time_created[max]
|
665
936
|
#
|
666
937
|
# - last_message_time (UNIX timestamp)
|
667
938
|
# * Filter contacts by last time a message was sent or received
|
668
|
-
# * Allowed modifiers: last_message_time[
|
669
|
-
# last_message_time[
|
939
|
+
# * Allowed modifiers: last_message_time[min], last_message_time[max],
|
940
|
+
# last_message_time[exists]
|
670
941
|
#
|
671
942
|
# - last_incoming_message_time (UNIX timestamp)
|
672
943
|
# * Filter contacts by last time a message was received
|
673
|
-
# * Allowed modifiers: last_incoming_message_time[
|
674
|
-
# last_incoming_message_time[
|
675
|
-
# last_incoming_message_time[max]
|
944
|
+
# * Allowed modifiers: last_incoming_message_time[min],
|
945
|
+
# last_incoming_message_time[max], last_incoming_message_time[exists]
|
676
946
|
#
|
677
947
|
# - last_outgoing_message_time (UNIX timestamp)
|
678
948
|
# * Filter contacts by last time a message was sent
|
679
|
-
# * Allowed modifiers: last_outgoing_message_time[
|
680
|
-
# last_outgoing_message_time[
|
681
|
-
# last_outgoing_message_time[max]
|
949
|
+
# * Allowed modifiers: last_outgoing_message_time[min],
|
950
|
+
# last_outgoing_message_time[max], last_outgoing_message_time[exists]
|
682
951
|
#
|
683
952
|
# - incoming_message_count (int)
|
684
953
|
# * Filter contacts by number of messages received from the contact
|
@@ -695,9 +964,9 @@ class Project < Entity
|
|
695
964
|
#
|
696
965
|
# - vars (Hash)
|
697
966
|
# * Filter contacts by value of a custom variable (e.g. vars[email], vars[foo], etc.)
|
698
|
-
# * Allowed modifiers: vars[foo][
|
699
|
-
# vars[foo][
|
700
|
-
# vars[foo][
|
967
|
+
# * Allowed modifiers: vars[foo][ne], vars[foo][prefix], vars[foo][not_prefix],
|
968
|
+
# vars[foo][gte], vars[foo][gt], vars[foo][lt], vars[foo][lte], vars[foo][min],
|
969
|
+
# vars[foo][max], vars[foo][exists]
|
701
970
|
#
|
702
971
|
# - sort
|
703
972
|
# * Sort the results based on a field
|
@@ -758,7 +1027,7 @@ class Project < Entity
|
|
758
1027
|
end
|
759
1028
|
|
760
1029
|
#
|
761
|
-
# Queries
|
1030
|
+
# Queries basic routes within the given project.
|
762
1031
|
#
|
763
1032
|
# Arguments:
|
764
1033
|
# - options (Hash)
|
@@ -776,8 +1045,8 @@ class Project < Entity
|
|
776
1045
|
#
|
777
1046
|
# - last_active_time (UNIX timestamp)
|
778
1047
|
# * Filter phones by last active time
|
779
|
-
# * Allowed modifiers: last_active_time[
|
780
|
-
# last_active_time[
|
1048
|
+
# * Allowed modifiers: last_active_time[min], last_active_time[max],
|
1049
|
+
# last_active_time[exists]
|
781
1050
|
#
|
782
1051
|
# - sort
|
783
1052
|
# * Sort the results based on a field
|
@@ -806,7 +1075,7 @@ class Project < Entity
|
|
806
1075
|
end
|
807
1076
|
|
808
1077
|
#
|
809
|
-
# Retrieves the
|
1078
|
+
# Retrieves the basic route with the given ID.
|
810
1079
|
#
|
811
1080
|
# Arguments:
|
812
1081
|
# - id
|
@@ -822,7 +1091,7 @@ class Project < Entity
|
|
822
1091
|
end
|
823
1092
|
|
824
1093
|
#
|
825
|
-
# Initializes the
|
1094
|
+
# Initializes the basic route with the given ID without making an API request.
|
826
1095
|
#
|
827
1096
|
# Arguments:
|
828
1097
|
# - id
|
@@ -843,17 +1112,21 @@ class Project < Entity
|
|
843
1112
|
# Arguments:
|
844
1113
|
# - options (Hash)
|
845
1114
|
#
|
1115
|
+
# - label_id
|
1116
|
+
# * Filter messages with a label
|
1117
|
+
#
|
846
1118
|
# - direction
|
847
1119
|
# * Filter messages by direction
|
848
1120
|
# * Allowed values: incoming, outgoing
|
849
1121
|
#
|
850
1122
|
# - message_type
|
851
1123
|
# * Filter messages by message_type
|
852
|
-
# * Allowed values: sms, mms, ussd, call, service
|
1124
|
+
# * Allowed values: sms, mms, ussd, ussd_session, call, chat, service
|
853
1125
|
#
|
854
1126
|
# - source
|
855
1127
|
# * Filter messages by source
|
856
|
-
# * Allowed values: phone, provider, web, api, service, webhook, scheduled
|
1128
|
+
# * Allowed values: phone, provider, web, api, service, webhook, scheduled,
|
1129
|
+
# integration
|
857
1130
|
#
|
858
1131
|
# - starred (bool)
|
859
1132
|
# * Filter messages by starred/unstarred
|
@@ -861,7 +1134,7 @@ class Project < Entity
|
|
861
1134
|
# - status
|
862
1135
|
# * Filter messages by status
|
863
1136
|
# * Allowed values: ignored, processing, received, sent, queued, failed,
|
864
|
-
# failed_queued, cancelled, delivered, not_delivered
|
1137
|
+
# failed_queued, cancelled, delivered, not_delivered, read
|
865
1138
|
#
|
866
1139
|
# - time_created[min] (UNIX timestamp)
|
867
1140
|
# * Filter messages created on or after a particular time
|
@@ -871,18 +1144,26 @@ class Project < Entity
|
|
871
1144
|
#
|
872
1145
|
# - external_id
|
873
1146
|
# * Filter messages by ID from an external provider
|
1147
|
+
# * Allowed modifiers: external_id[ne], external_id[exists]
|
874
1148
|
#
|
875
1149
|
# - contact_id
|
876
1150
|
# * ID of the contact who sent/received the message
|
1151
|
+
# * Allowed modifiers: contact_id[ne], contact_id[exists]
|
877
1152
|
#
|
878
1153
|
# - phone_id
|
879
1154
|
# * ID of the phone (basic route) that sent/received the message
|
880
1155
|
#
|
881
1156
|
# - broadcast_id
|
882
1157
|
# * ID of the broadcast containing the message
|
1158
|
+
# * Allowed modifiers: broadcast_id[ne], broadcast_id[exists]
|
883
1159
|
#
|
884
1160
|
# - scheduled_id
|
885
1161
|
# * ID of the scheduled message that created this message
|
1162
|
+
# * Allowed modifiers: scheduled_id[ne], scheduled_id[exists]
|
1163
|
+
#
|
1164
|
+
# - group_id
|
1165
|
+
# * Filter messages sent or received by contacts in a particular group. The group must
|
1166
|
+
# be a normal group, not a dynamic group.
|
886
1167
|
#
|
887
1168
|
# - sort
|
888
1169
|
# * Sort the results based on a field
|
@@ -1018,6 +1299,292 @@ class Project < Entity
|
|
1018
1299
|
return Broadcast.new(@api, {'project_id' => self.id, 'id' => id}, false)
|
1019
1300
|
end
|
1020
1301
|
|
1302
|
+
#
|
1303
|
+
# Creates and starts an asynchronous task that is applied to all entities matching a filter
|
1304
|
+
# (e.g. contacts, messages, or data rows).
|
1305
|
+
# Tasks are designed to efficiently process a large number of
|
1306
|
+
# entities. When processing a large number of entities,
|
1307
|
+
# tasks are much faster than using the API to query and loop over
|
1308
|
+
# all objects matching a filter.
|
1309
|
+
#
|
1310
|
+
# Several different types of tasks are supported, including
|
1311
|
+
# applying services to contacts, messages, or data rows;
|
1312
|
+
# adding or removing contacts from a group; blocking or unblocking
|
1313
|
+
# sending messages to a contact; updating a custom variable;
|
1314
|
+
# deleting contacts, messages, or data rows; or exporting data to
|
1315
|
+
# CSV.
|
1316
|
+
#
|
1317
|
+
# When using a task to apply a Custom Actions or Cloud Script API
|
1318
|
+
# service (`apply_service_to_contacts`, `apply_service_to_rows`, or
|
1319
|
+
# `apply_service_to_messages`),
|
1320
|
+
# the `task` variable will be available within the service. The
|
1321
|
+
# service can use custom variables on the task object (e.g. `task.vars.example`), such as
|
1322
|
+
# to store aggregate statistics for the rows matching the filter.
|
1323
|
+
#
|
1324
|
+
# Arguments:
|
1325
|
+
# - options (Hash)
|
1326
|
+
# * Required
|
1327
|
+
#
|
1328
|
+
# - task_type
|
1329
|
+
# * Type of task to create. Each `task_type` applies to a certain type of entity (such
|
1330
|
+
# as a contact, message, or data row).
|
1331
|
+
#
|
1332
|
+
# Tasks for contacts:
|
1333
|
+
#
|
1334
|
+
# - update_contact_var
|
1335
|
+
# - add_group_members
|
1336
|
+
# - remove_group_members
|
1337
|
+
# - set_conversation_status
|
1338
|
+
# - set_send_blocked
|
1339
|
+
# - apply_service_to_contacts
|
1340
|
+
# - delete_contacts
|
1341
|
+
# - export_contacts
|
1342
|
+
#
|
1343
|
+
# Tasks for data rows:
|
1344
|
+
#
|
1345
|
+
# - update_row_var
|
1346
|
+
# - apply_service_to_rows
|
1347
|
+
# - delete_rows
|
1348
|
+
# - export_rows
|
1349
|
+
#
|
1350
|
+
# Tasks for messages:
|
1351
|
+
#
|
1352
|
+
# - cancel_messages
|
1353
|
+
# - resend_messages
|
1354
|
+
# - retry_message_services
|
1355
|
+
# - apply_service_to_messages
|
1356
|
+
# - add_label
|
1357
|
+
# - remove_label
|
1358
|
+
# - update_message_var
|
1359
|
+
# - delete_messages
|
1360
|
+
# - export_messages
|
1361
|
+
# * Required
|
1362
|
+
#
|
1363
|
+
# - task_params (Hash)
|
1364
|
+
# * Parameters applied to all matching rows (specific to `task_type`).
|
1365
|
+
#
|
1366
|
+
# **apply_service_to_contacts**,
|
1367
|
+
# **apply_service_to_messages**, **apply_service_to_rows**:
|
1368
|
+
# <table>
|
1369
|
+
# <tr><td> service_id </td> <td> The ID of the service
|
1370
|
+
# to apply (string) </td></tr>
|
1371
|
+
# <tr><td> variables </td> <td> Optional object
|
1372
|
+
# containing up to 25 temporary variable names and their corresponding values to set
|
1373
|
+
# when invoking the service. Values may be strings, numbers, or boolean (true/false).
|
1374
|
+
# String values may be up to 4096 bytes in length. Arrays and objects are not
|
1375
|
+
# supported. Within Custom Actions, each variable can be used like [[$name]] (with a
|
1376
|
+
# leading $ character and surrounded by double square brackets). Within a Cloud Script
|
1377
|
+
# API service or JavaScript action, each variable will be available as a global
|
1378
|
+
# JavaScript variable like $name (with a leading $ character). (object) </td></tr>
|
1379
|
+
# </table>
|
1380
|
+
# <br />
|
1381
|
+
# **update_contact_var**, **update_message_var**,
|
1382
|
+
# **update_row_var**:
|
1383
|
+
# <table>
|
1384
|
+
# <tr><td> variable </td> <td> The custom variable
|
1385
|
+
# name (string) </td></tr>
|
1386
|
+
# <tr><td> value </td> <td> The value to set (string,
|
1387
|
+
# boolean, float, null) </td></tr>
|
1388
|
+
# </table>
|
1389
|
+
# <br />
|
1390
|
+
# **add_group_members**, **remove_group_members**:
|
1391
|
+
# <table>
|
1392
|
+
# <tr><td> group_id </td> <td> The ID of the group
|
1393
|
+
# (string) </td></tr>
|
1394
|
+
# </table>
|
1395
|
+
# <br />
|
1396
|
+
# **add_label**, **remove_label**:
|
1397
|
+
# <table>
|
1398
|
+
# <tr><td> label_id </td> <td> The ID of the label
|
1399
|
+
# (string) </td></tr>
|
1400
|
+
# </table>
|
1401
|
+
# <br />
|
1402
|
+
# **resend_messages**:
|
1403
|
+
# <table>
|
1404
|
+
# <tr><td> route_id </td> <td> ID of the new route to
|
1405
|
+
# use, or null to use the original route (string) </td></tr>
|
1406
|
+
# </table>
|
1407
|
+
# <br />
|
1408
|
+
# **set_send_blocked**:
|
1409
|
+
# <table>
|
1410
|
+
# <tr><td> send_blocked </td> <td> true to block
|
1411
|
+
# sending messages, false to unblock sending messages (boolean) </td></tr>
|
1412
|
+
# </table>
|
1413
|
+
# <br />
|
1414
|
+
# **set_conversation_status**:
|
1415
|
+
# <table>
|
1416
|
+
# <tr><td> conversation_status </td> <td> "active",
|
1417
|
+
# "handled", or "closed" (string) </td></tr>
|
1418
|
+
# </table>
|
1419
|
+
# <br />
|
1420
|
+
# **export_contacts**, **export_messages**,
|
1421
|
+
# **export_rows**:
|
1422
|
+
# <table>
|
1423
|
+
# <tr><td>storage_id </td> <td> ID of a storage
|
1424
|
+
# provider where the CSV file will be saved. (string)
|
1425
|
+
#
|
1426
|
+
# Currently only AWS S3 is supported as a storage
|
1427
|
+
# provider.
|
1428
|
+
# This requires creating a S3 bucket in your own
|
1429
|
+
# AWS account, as well as an IAM user with access key and secret that has permission
|
1430
|
+
# to write to that bucket.
|
1431
|
+
# You can configure your own S3 bucket as a
|
1432
|
+
# storage provider on the <a href="/dashboard/a/storage">Storage Providers</a> page.
|
1433
|
+
#
|
1434
|
+
# Direct downloads are not supported when
|
1435
|
+
# exporting data via the API.
|
1436
|
+
# (string) </td></tr>
|
1437
|
+
# <tr><td>filename </td> <td> Path within the storage
|
1438
|
+
# backend where the CSV file will be saved </td></tr>
|
1439
|
+
# <tr><td>column_ids </td> <td> IDs of columns to save
|
1440
|
+
# in the CSV file. If not provided, all default columns will be saved. (array of
|
1441
|
+
# strings, optional) </td></tr>
|
1442
|
+
# </table>
|
1443
|
+
# <br />
|
1444
|
+
# **delete_contacts**, **delete_messages**,
|
1445
|
+
# **delete_rows**, **cancel_messages**, **retry_message_services**: <br />
|
1446
|
+
# No parameters.
|
1447
|
+
#
|
1448
|
+
# - filter_type
|
1449
|
+
# * Type of filter defining the rows that the task is applied to.
|
1450
|
+
#
|
1451
|
+
# Each `filter_type` queries a certain type of
|
1452
|
+
# entity (such as contacts, messages, or data rows).
|
1453
|
+
#
|
1454
|
+
# In general, the `task_type` and the
|
1455
|
+
# `filter_type` must return the same type of entity; however, tasks applied to
|
1456
|
+
# contacts (other than `export_contacts`) can also be applied
|
1457
|
+
# when the filter returns entities that are
|
1458
|
+
# associated with a contact, such as messages or data rows. (Note that in this case,
|
1459
|
+
# it is possible for the task to be applied multiple times to an individual contact if
|
1460
|
+
# multiple messages or data rows are associated with the same contact.)
|
1461
|
+
# * Allowed values: query_contacts, contact_ids, query_rows, row_ids, query_messages,
|
1462
|
+
# message_ids
|
1463
|
+
# * Required
|
1464
|
+
#
|
1465
|
+
# - filter_params (Hash)
|
1466
|
+
# * Parameters defining the rows that the task is applied to (specific to
|
1467
|
+
# `filter_type`).
|
1468
|
+
#
|
1469
|
+
# **`query_contacts`**: <br />
|
1470
|
+
# The same filter parameters as used by
|
1471
|
+
# [project.queryContacts](#Project.queryContacts). If you want to apply the task to
|
1472
|
+
# all contacts, use the parameters {"all": true}.
|
1473
|
+
#
|
1474
|
+
# **`contact_ids`**:
|
1475
|
+
# <table>
|
1476
|
+
# <tr><td> `contact_ids` </td> <td> IDs of up to 100
|
1477
|
+
# contacts to apply this task to (array of strings) </td></tr>
|
1478
|
+
# </table>
|
1479
|
+
#
|
1480
|
+
# **`query_messages`**: <br />
|
1481
|
+
# The same filter parameters as used by
|
1482
|
+
# [project.queryMessages](#Project.queryMessages). If you want to apply the task to
|
1483
|
+
# all messages, use the parameters {"all": true}.
|
1484
|
+
#
|
1485
|
+
# **`message_ids`**:
|
1486
|
+
# <table>
|
1487
|
+
# <tr><td> `message_ids` </td> <td> IDs of up to 100
|
1488
|
+
# messages to apply this task to (array of strings) </td></tr>
|
1489
|
+
# </table>
|
1490
|
+
#
|
1491
|
+
# **`query_rows`**: <br />
|
1492
|
+
# The same filter parameters as used by
|
1493
|
+
# [table.queryRows](#DataTable.queryRows). If you want to apply the task to all rows
|
1494
|
+
# in the table, use the parameters {"all": true}.
|
1495
|
+
#
|
1496
|
+
# **`row_ids`**:
|
1497
|
+
# <table>
|
1498
|
+
# <tr><td> `row_ids` </td> <td> IDs of up to 100 data
|
1499
|
+
# rows to apply this task to (array of strings) </td></tr>
|
1500
|
+
# </table>
|
1501
|
+
# * Required
|
1502
|
+
#
|
1503
|
+
# - table_id (string, max 34 characters)
|
1504
|
+
# * ID of the data table this task is applied to (if applicable).
|
1505
|
+
#
|
1506
|
+
# Required if filter_type is `query_rows` or `row_ids`.
|
1507
|
+
#
|
1508
|
+
# - vars (Hash)
|
1509
|
+
# * Initial custom variables to set for the task.
|
1510
|
+
#
|
1511
|
+
# If the task applies a service, the service can read
|
1512
|
+
# and write custom variables on the task object (e.g. `task.vars.example`), such as
|
1513
|
+
# to store aggregate statistics for the rows matching
|
1514
|
+
# the filter.
|
1515
|
+
#
|
1516
|
+
# Returns:
|
1517
|
+
# Telerivet::Task
|
1518
|
+
#
|
1519
|
+
def create_task(options)
|
1520
|
+
require_relative 'task'
|
1521
|
+
Task.new(@api, @api.do_request("POST", get_base_api_path() + "/tasks", options))
|
1522
|
+
end
|
1523
|
+
|
1524
|
+
#
|
1525
|
+
# Queries batch tasks within the given project.
|
1526
|
+
#
|
1527
|
+
# Arguments:
|
1528
|
+
# - options (Hash)
|
1529
|
+
#
|
1530
|
+
# - sort
|
1531
|
+
# * Sort the results based on a field
|
1532
|
+
# * Allowed values: default
|
1533
|
+
# * Default: default
|
1534
|
+
#
|
1535
|
+
# - sort_dir
|
1536
|
+
# * Sort the results in ascending or descending order
|
1537
|
+
# * Allowed values: asc, desc
|
1538
|
+
# * Default: asc
|
1539
|
+
#
|
1540
|
+
# - page_size (int)
|
1541
|
+
# * Number of results returned per page (max 500)
|
1542
|
+
# * Default: 50
|
1543
|
+
#
|
1544
|
+
# - offset (int)
|
1545
|
+
# * Number of items to skip from beginning of result set
|
1546
|
+
# * Default: 0
|
1547
|
+
#
|
1548
|
+
# Returns:
|
1549
|
+
# Telerivet::APICursor (of Telerivet::Task)
|
1550
|
+
#
|
1551
|
+
def query_tasks(options = nil)
|
1552
|
+
require_relative 'task'
|
1553
|
+
@api.cursor(Task, get_base_api_path() + "/tasks", options)
|
1554
|
+
end
|
1555
|
+
|
1556
|
+
#
|
1557
|
+
# Retrieves the task with the given ID.
|
1558
|
+
#
|
1559
|
+
# Arguments:
|
1560
|
+
# - id
|
1561
|
+
# * ID of the task
|
1562
|
+
# * Required
|
1563
|
+
#
|
1564
|
+
# Returns:
|
1565
|
+
# Telerivet::Task
|
1566
|
+
#
|
1567
|
+
def get_task_by_id(id)
|
1568
|
+
require_relative 'task'
|
1569
|
+
Task.new(@api, @api.do_request("GET", get_base_api_path() + "/tasks/#{id}"))
|
1570
|
+
end
|
1571
|
+
|
1572
|
+
#
|
1573
|
+
# Initializes the task with the given ID without making an API request.
|
1574
|
+
#
|
1575
|
+
# Arguments:
|
1576
|
+
# - id
|
1577
|
+
# * ID of the task
|
1578
|
+
# * Required
|
1579
|
+
#
|
1580
|
+
# Returns:
|
1581
|
+
# Telerivet::Task
|
1582
|
+
#
|
1583
|
+
def init_task_by_id(id)
|
1584
|
+
require_relative 'task'
|
1585
|
+
return Task.new(@api, {'project_id' => self.id, 'id' => id}, false)
|
1586
|
+
end
|
1587
|
+
|
1021
1588
|
#
|
1022
1589
|
# Queries groups within the given project.
|
1023
1590
|
#
|
@@ -1284,20 +1851,22 @@ class Project < Entity
|
|
1284
1851
|
#
|
1285
1852
|
# - message_type
|
1286
1853
|
# * Filter scheduled messages by message_type
|
1287
|
-
# * Allowed values: sms, mms, ussd, call, service
|
1854
|
+
# * Allowed values: sms, mms, ussd, ussd_session, call, chat, service
|
1288
1855
|
#
|
1289
1856
|
# - time_created (UNIX timestamp)
|
1290
1857
|
# * Filter scheduled messages by time_created
|
1291
|
-
# * Allowed modifiers: time_created[
|
1858
|
+
# * Allowed modifiers: time_created[min], time_created[max]
|
1292
1859
|
#
|
1293
1860
|
# - next_time (UNIX timestamp)
|
1294
1861
|
# * Filter scheduled messages by next_time
|
1295
|
-
# * Allowed modifiers: next_time[
|
1296
|
-
#
|
1862
|
+
# * Allowed modifiers: next_time[min], next_time[max], next_time[exists]
|
1863
|
+
#
|
1864
|
+
# - relative_scheduled_id
|
1865
|
+
# * Filter scheduled messages created for a relative scheduled message
|
1297
1866
|
#
|
1298
1867
|
# - sort
|
1299
1868
|
# * Sort the results based on a field
|
1300
|
-
# * Allowed values: default,
|
1869
|
+
# * Allowed values: default, next_time
|
1301
1870
|
# * Default: default
|
1302
1871
|
#
|
1303
1872
|
# - sort_dir
|
@@ -1321,6 +1890,52 @@ class Project < Entity
|
|
1321
1890
|
@api.cursor(ScheduledMessage, get_base_api_path() + "/scheduled", options)
|
1322
1891
|
end
|
1323
1892
|
|
1893
|
+
#
|
1894
|
+
# Queries relative scheduled messages within the given project.
|
1895
|
+
#
|
1896
|
+
# Arguments:
|
1897
|
+
# - options (Hash)
|
1898
|
+
#
|
1899
|
+
# - message_type
|
1900
|
+
# * Filter relative scheduled messages by message_type
|
1901
|
+
# * Allowed values: sms, mms, ussd, ussd_session, call, chat, service
|
1902
|
+
#
|
1903
|
+
# - time_created (UNIX timestamp)
|
1904
|
+
# * Filter relative scheduled messages by time_created
|
1905
|
+
# * Allowed modifiers: time_created[min], time_created[max]
|
1906
|
+
#
|
1907
|
+
# - group_id
|
1908
|
+
# * Filter relative scheduled messages sent to a group
|
1909
|
+
#
|
1910
|
+
# - contact_id
|
1911
|
+
# * Filter relative scheduled messages sent to an individual contact
|
1912
|
+
#
|
1913
|
+
# - sort
|
1914
|
+
# * Sort the results based on a field
|
1915
|
+
# * Allowed values: default
|
1916
|
+
# * Default: default
|
1917
|
+
#
|
1918
|
+
# - sort_dir
|
1919
|
+
# * Sort the results in ascending or descending order
|
1920
|
+
# * Allowed values: asc, desc
|
1921
|
+
# * Default: asc
|
1922
|
+
#
|
1923
|
+
# - page_size (int)
|
1924
|
+
# * Number of results returned per page (max 500)
|
1925
|
+
# * Default: 50
|
1926
|
+
#
|
1927
|
+
# - offset (int)
|
1928
|
+
# * Number of items to skip from beginning of result set
|
1929
|
+
# * Default: 0
|
1930
|
+
#
|
1931
|
+
# Returns:
|
1932
|
+
# Telerivet::APICursor (of Telerivet::RelativeScheduledMessage)
|
1933
|
+
#
|
1934
|
+
def query_relative_scheduled_messages(options = nil)
|
1935
|
+
require_relative 'relativescheduledmessage'
|
1936
|
+
@api.cursor(RelativeScheduledMessage, get_base_api_path() + "/relative_scheduled", options)
|
1937
|
+
end
|
1938
|
+
|
1324
1939
|
#
|
1325
1940
|
# Retrieves the scheduled message with the given ID.
|
1326
1941
|
#
|
@@ -1353,6 +1968,179 @@ class Project < Entity
|
|
1353
1968
|
return ScheduledMessage.new(@api, {'project_id' => self.id, 'id' => id}, false)
|
1354
1969
|
end
|
1355
1970
|
|
1971
|
+
#
|
1972
|
+
# Retrieves the scheduled message with the given ID.
|
1973
|
+
#
|
1974
|
+
# Arguments:
|
1975
|
+
# - id
|
1976
|
+
# * ID of the relative scheduled message
|
1977
|
+
# * Required
|
1978
|
+
#
|
1979
|
+
# Returns:
|
1980
|
+
# Telerivet::RelativeScheduledMessage
|
1981
|
+
#
|
1982
|
+
def get_relative_scheduled_message_by_id(id)
|
1983
|
+
require_relative 'relativescheduledmessage'
|
1984
|
+
RelativeScheduledMessage.new(@api, @api.do_request("GET", get_base_api_path() + "/relative_scheduled/#{id}"))
|
1985
|
+
end
|
1986
|
+
|
1987
|
+
#
|
1988
|
+
# Initializes the relative scheduled message with the given ID without making an API request.
|
1989
|
+
#
|
1990
|
+
# Arguments:
|
1991
|
+
# - id
|
1992
|
+
# * ID of the relative scheduled message
|
1993
|
+
# * Required
|
1994
|
+
#
|
1995
|
+
# Returns:
|
1996
|
+
# Telerivet::RelativeScheduledMessage
|
1997
|
+
#
|
1998
|
+
def init_relative_scheduled_message_by_id(id)
|
1999
|
+
require_relative 'relativescheduledmessage'
|
2000
|
+
return RelativeScheduledMessage.new(@api, {'project_id' => self.id, 'id' => id}, false)
|
2001
|
+
end
|
2002
|
+
|
2003
|
+
#
|
2004
|
+
# Creates a new automated service.
|
2005
|
+
#
|
2006
|
+
# Only certain types of automated services can be created via the API.
|
2007
|
+
# Other types of services can only be created via the web app.
|
2008
|
+
#
|
2009
|
+
# Although Custom Actions services cannot be created directly via the
|
2010
|
+
# API, they may be converted to a template,
|
2011
|
+
# and then instances of the template can be created via this method
|
2012
|
+
# with `service_type`=`custom_template_instance`. Converting a service
|
2013
|
+
# to a template requires the Service Templates feature to be enabled
|
2014
|
+
# for the organization.
|
2015
|
+
#
|
2016
|
+
# Arguments:
|
2017
|
+
# - options (Hash)
|
2018
|
+
# * Required
|
2019
|
+
#
|
2020
|
+
# - name (string)
|
2021
|
+
# * Name of the service to create, which must be unique in the project. If a name is
|
2022
|
+
# not provided, a unique default name will be generated.
|
2023
|
+
#
|
2024
|
+
# - service_type (string)
|
2025
|
+
# * Type of service to create. The following service types can be created via the
|
2026
|
+
# API:
|
2027
|
+
#
|
2028
|
+
# - incoming_message_webhook
|
2029
|
+
# - incoming_message_script
|
2030
|
+
# - contact_script
|
2031
|
+
# - message_script
|
2032
|
+
# - data_row_script
|
2033
|
+
# - webhook_script
|
2034
|
+
# - voice_script
|
2035
|
+
# - ussd_script
|
2036
|
+
# - project_script
|
2037
|
+
# - custom_template_instance
|
2038
|
+
#
|
2039
|
+
# Other types of services can only be created via the web app.
|
2040
|
+
# * Required
|
2041
|
+
#
|
2042
|
+
# - config (Hash)
|
2043
|
+
# * Configuration specific to the service `type`.
|
2044
|
+
#
|
2045
|
+
# **incoming_message_webhook**:
|
2046
|
+
# <table>
|
2047
|
+
# <tr><td> url </td> <td> The webhook URL that will be
|
2048
|
+
# triggered when an incoming message is received (string) </td></tr>
|
2049
|
+
# <tr><td> secret </td> <td> Optional string that will
|
2050
|
+
# be passed as the `secret` POST parameter to the webhook URL. (object) </td></tr>
|
2051
|
+
# </table>
|
2052
|
+
# <br />
|
2053
|
+
#
|
2054
|
+
# **incoming_message_script, contact_script,
|
2055
|
+
# message_script, data_row_script, webhook_script, voice_script, ussd_script,
|
2056
|
+
# project_script**:
|
2057
|
+
# <table>
|
2058
|
+
# <tr><td> code </td> <td> The JavaScript code to run
|
2059
|
+
# when the service is triggered (max 100 KB). To run code longer than 100 KB, use a
|
2060
|
+
# Cloud Script Module. (string) </td></tr>
|
2061
|
+
# </table>
|
2062
|
+
# <br />
|
2063
|
+
#
|
2064
|
+
# **custom_template_instance**:
|
2065
|
+
# <table>
|
2066
|
+
# <tr><td> template_service_id </td> <td> ID of the
|
2067
|
+
# service template (string). The service template must be available to the current
|
2068
|
+
# project or organization.</td></tr>
|
2069
|
+
# <tr><td> params </td> <td> Key/value pairs for all
|
2070
|
+
# service template parameters (object). If the values satisfy the validation rules
|
2071
|
+
# specified in the service template, they will also be copied to the `vars` property
|
2072
|
+
# of the service. Any values not associated with service template parameters will be
|
2073
|
+
# ignored.
|
2074
|
+
# </td></tr>
|
2075
|
+
# </table>
|
2076
|
+
# <br />
|
2077
|
+
# * Required
|
2078
|
+
#
|
2079
|
+
# - vars
|
2080
|
+
# * Custom variables and values to set for this service
|
2081
|
+
#
|
2082
|
+
# - active (bool)
|
2083
|
+
# * Whether the service is initially active or inactive. Inactive services are not
|
2084
|
+
# automatically triggered and cannot be invoked via the API.
|
2085
|
+
# * Default: 1
|
2086
|
+
#
|
2087
|
+
# - response_table_id
|
2088
|
+
# * ID of a data table where responses will be stored, or null to disable
|
2089
|
+
# automatically storing responses. If the response_table_id parameter is not provided,
|
2090
|
+
# a data table may automatically be created with the same name as the service if the
|
2091
|
+
# service collects responses.
|
2092
|
+
#
|
2093
|
+
# - phone_ids (array)
|
2094
|
+
# * IDs of phones (basic routes) to associate with this service, or null to associate
|
2095
|
+
# this service with all routes. Only applies for service types that handle incoming
|
2096
|
+
# messages, voice calls, or USSD sessions.
|
2097
|
+
#
|
2098
|
+
# - message_types (array)
|
2099
|
+
# * Types of messages that this service should handle. Only applies to services that
|
2100
|
+
# handle incoming messages.
|
2101
|
+
# * Allowed values: text, call, sms, mms, ussd_session, chat
|
2102
|
+
#
|
2103
|
+
# - show_action (bool)
|
2104
|
+
# * Whether to show this service in the Actions menu within the Telerivet web app when
|
2105
|
+
# the service is active. Only applies for service types that are manually triggered.
|
2106
|
+
# * Default: 1
|
2107
|
+
#
|
2108
|
+
# - contact_number_filter
|
2109
|
+
# * If contact_number_filter is `long_number`, this service will only be triggered if
|
2110
|
+
# the contact phone number has at least 7 digits (ignoring messages from shortcodes
|
2111
|
+
# and alphanumeric senders). If contact_number_filter is `all`, the service will be
|
2112
|
+
# triggered for all contact phone numbers. Only applies to services that handle
|
2113
|
+
# incoming messages.
|
2114
|
+
# * Allowed values: long_number, all
|
2115
|
+
# * Default: long_number
|
2116
|
+
#
|
2117
|
+
# - direction
|
2118
|
+
# * Determines whether the service handles incoming voice calls, outgoing voice calls,
|
2119
|
+
# or both. Only applies to services that handle voice calls.
|
2120
|
+
# * Allowed values: incoming, outgoing, both
|
2121
|
+
# * Default: both
|
2122
|
+
#
|
2123
|
+
# - priority (int)
|
2124
|
+
# * A number that determines the order that services are triggered when an event
|
2125
|
+
# occurs (e.g. when an incoming message is received). Smaller numbers are triggered
|
2126
|
+
# first. The priority is ignored for services that are triggered directly.
|
2127
|
+
#
|
2128
|
+
# - apply_mode
|
2129
|
+
# * If apply_mode is `unhandled`, the service will not be triggered if another service
|
2130
|
+
# has already handled the incoming message. If apply_mode is `always`, the service
|
2131
|
+
# will always be triggered regardless of other services. Only applies to services that
|
2132
|
+
# handle incoming messages.
|
2133
|
+
# * Allowed values: always, unhandled
|
2134
|
+
# * Default: unhandled
|
2135
|
+
#
|
2136
|
+
# Returns:
|
2137
|
+
# Telerivet::Service
|
2138
|
+
#
|
2139
|
+
def create_service(options)
|
2140
|
+
require_relative 'service'
|
2141
|
+
Service.new(@api, @api.do_request("POST", get_base_api_path() + "/services", options))
|
2142
|
+
end
|
2143
|
+
|
1356
2144
|
#
|
1357
2145
|
# Queries services within the given project.
|
1358
2146
|
#
|
@@ -1369,7 +2157,7 @@ class Project < Entity
|
|
1369
2157
|
#
|
1370
2158
|
# - context
|
1371
2159
|
# * Filter services that can be invoked in a particular context
|
1372
|
-
# * Allowed values: message, call, contact, project
|
2160
|
+
# * Allowed values: message, call, ussd_session, row, contact, project
|
1373
2161
|
#
|
1374
2162
|
# - sort
|
1375
2163
|
# * Sort the results based on a field
|
@@ -1429,6 +2217,114 @@ class Project < Entity
|
|
1429
2217
|
return Service.new(@api, {'project_id' => self.id, 'id' => id}, false)
|
1430
2218
|
end
|
1431
2219
|
|
2220
|
+
#
|
2221
|
+
# Queries service log entries associated with this project.
|
2222
|
+
#
|
2223
|
+
# Note: Service logs are automatically deleted and no longer available
|
2224
|
+
# via the API after approximately one month.
|
2225
|
+
#
|
2226
|
+
# Arguments:
|
2227
|
+
# - options (Hash)
|
2228
|
+
#
|
2229
|
+
# - service_id
|
2230
|
+
# * Filter logs generated by a particular service
|
2231
|
+
#
|
2232
|
+
# - message_id
|
2233
|
+
# * Filter service logs related to a particular message
|
2234
|
+
#
|
2235
|
+
# - contact_id
|
2236
|
+
# * Filter service logs related to a particular contact. Ignored if using the
|
2237
|
+
# message_id parameter.
|
2238
|
+
#
|
2239
|
+
# - time_created (UNIX timestamp)
|
2240
|
+
# * Filter service logs by the time they were created
|
2241
|
+
# * Allowed modifiers: time_created[min], time_created[max]
|
2242
|
+
#
|
2243
|
+
# - execution_stats (bool)
|
2244
|
+
# * Show detailed execution stats for each log entry, if available.
|
2245
|
+
#
|
2246
|
+
# - sort_dir
|
2247
|
+
# * Sort the results in ascending or descending order
|
2248
|
+
# * Allowed values: asc, desc
|
2249
|
+
# * Default: asc
|
2250
|
+
#
|
2251
|
+
# - page_size (int)
|
2252
|
+
# * Number of results returned per page (max 500)
|
2253
|
+
# * Default: 50
|
2254
|
+
#
|
2255
|
+
# - offset (int)
|
2256
|
+
# * Number of items to skip from beginning of result set
|
2257
|
+
# * Default: 0
|
2258
|
+
#
|
2259
|
+
# Returns:
|
2260
|
+
# Telerivet::APICursor (of Hash)
|
2261
|
+
#
|
2262
|
+
# Returned Item Properties:
|
2263
|
+
# - time_created (UNIX timestamp)
|
2264
|
+
# * The time when the log entry was created
|
2265
|
+
#
|
2266
|
+
# - content
|
2267
|
+
# * The text logged
|
2268
|
+
#
|
2269
|
+
# - elapsed_ms (int)
|
2270
|
+
# * Elapsed time in milliseconds, if available.
|
2271
|
+
#
|
2272
|
+
# - service_id
|
2273
|
+
# * ID of the service associated with this log entry. Not returned when querying log
|
2274
|
+
# entries for a particular service.
|
2275
|
+
#
|
2276
|
+
# - message_id
|
2277
|
+
# * ID of the message associated with this log entry. Not returned when querying log
|
2278
|
+
# entries for a particular message.
|
2279
|
+
#
|
2280
|
+
# - contact_id
|
2281
|
+
# * ID of the contact associated with this log entry. Not returned when querying log
|
2282
|
+
# entries for a particular message or contact.
|
2283
|
+
#
|
2284
|
+
# - api_request_count (int)
|
2285
|
+
# * The total number of API requests triggered via the Cloud Script API. (Only
|
2286
|
+
# provided if execution_stats=true.)
|
2287
|
+
#
|
2288
|
+
# - api_request_ms (int)
|
2289
|
+
# * The total execution time of all API requests triggered via the Cloud Script API.
|
2290
|
+
# (Only provided if execution_stats=true.)
|
2291
|
+
#
|
2292
|
+
# - http_request_count (int)
|
2293
|
+
# * The total number of external HTTP requests triggered via the Cloud Script API.
|
2294
|
+
# (Only provided if execution_stats=true.)
|
2295
|
+
#
|
2296
|
+
# - http_request_ms (int)
|
2297
|
+
# * The total execution time of all external HTTP requests triggered via the Cloud
|
2298
|
+
# Script API. (Only provided if execution_stats=true.)
|
2299
|
+
#
|
2300
|
+
# - webhook_count (int)
|
2301
|
+
# * The total number of Webhook API requests triggered. (Only provided if
|
2302
|
+
# execution_stats=true.)
|
2303
|
+
#
|
2304
|
+
# - requests (array)
|
2305
|
+
# * Details about each API request, external HTTP request, and Cloud Script Module
|
2306
|
+
# loaded via the Cloud Script API. (Only provided if execution_stats=true.)
|
2307
|
+
#
|
2308
|
+
# Each item in the array has the following properties:
|
2309
|
+
#
|
2310
|
+
# - type (string): `api_request`, `http_request`, or
|
2311
|
+
# `module_load`
|
2312
|
+
# - resource (string): A string specific to the type of
|
2313
|
+
# request.
|
2314
|
+
# For module_load, this is the module path. For
|
2315
|
+
# api_request, it contains the HTTP
|
2316
|
+
# method, path, and query string. For http_request, it
|
2317
|
+
# contains the HTTP method and
|
2318
|
+
# URL.
|
2319
|
+
# - elapsed_ms (int): Number of milliseconds elapsed in
|
2320
|
+
# fetching
|
2321
|
+
# this resource
|
2322
|
+
# - status_code (int): Response status code, if available
|
2323
|
+
#
|
2324
|
+
def query_service_logs(options = nil)
|
2325
|
+
@api.cursor(nil, get_base_api_path() + "/service_logs", options)
|
2326
|
+
end
|
2327
|
+
|
1432
2328
|
#
|
1433
2329
|
# Queries custom routes that can be used to send messages (not including Phones).
|
1434
2330
|
#
|
@@ -1510,6 +2406,274 @@ class Project < Entity
|
|
1510
2406
|
return @api.do_request("GET", get_base_api_path() + "/users")
|
1511
2407
|
end
|
1512
2408
|
|
2409
|
+
#
|
2410
|
+
# Returns information about each airtime transaction.
|
2411
|
+
#
|
2412
|
+
# Arguments:
|
2413
|
+
# - options (Hash)
|
2414
|
+
#
|
2415
|
+
# - time_created[min] (UNIX timestamp)
|
2416
|
+
# * Filter transactions created on or after a particular time
|
2417
|
+
#
|
2418
|
+
# - time_created[max] (UNIX timestamp)
|
2419
|
+
# * Filter transactions created before a particular time
|
2420
|
+
#
|
2421
|
+
# - contact_id
|
2422
|
+
# * Filter transactions sent to a particular contact
|
2423
|
+
#
|
2424
|
+
# - to_number
|
2425
|
+
# * Filter transactions sent to a particular phone number
|
2426
|
+
#
|
2427
|
+
# - service_id
|
2428
|
+
# * Filter transactions sent by a particular service
|
2429
|
+
#
|
2430
|
+
# - status
|
2431
|
+
# * Filter transactions by status
|
2432
|
+
# * Allowed values: pending, queued, processing, successful, failed, cancelled,
|
2433
|
+
# pending_payment, pending_approval
|
2434
|
+
#
|
2435
|
+
# - sort_dir
|
2436
|
+
# * Sort the results in ascending or descending order
|
2437
|
+
# * Allowed values: asc, desc
|
2438
|
+
# * Default: asc
|
2439
|
+
#
|
2440
|
+
# - page_size (int)
|
2441
|
+
# * Number of results returned per page (max 500)
|
2442
|
+
# * Default: 50
|
2443
|
+
#
|
2444
|
+
# - offset (int)
|
2445
|
+
# * Number of items to skip from beginning of result set
|
2446
|
+
# * Default: 0
|
2447
|
+
#
|
2448
|
+
# Returns:
|
2449
|
+
# Telerivet::APICursor (of Telerivet::AirtimeTransaction)
|
2450
|
+
#
|
2451
|
+
def query_airtime_transactions(options = nil)
|
2452
|
+
require_relative 'airtimetransaction'
|
2453
|
+
@api.cursor(AirtimeTransaction, get_base_api_path() + "/airtime_transactions", options)
|
2454
|
+
end
|
2455
|
+
|
2456
|
+
#
|
2457
|
+
# Gets an airtime transaction by ID
|
2458
|
+
#
|
2459
|
+
# Arguments:
|
2460
|
+
# - id
|
2461
|
+
# * ID of the airtime transaction
|
2462
|
+
# * Required
|
2463
|
+
#
|
2464
|
+
# Returns:
|
2465
|
+
# Telerivet::AirtimeTransaction
|
2466
|
+
#
|
2467
|
+
def get_airtime_transaction_by_id(id)
|
2468
|
+
require_relative 'airtimetransaction'
|
2469
|
+
AirtimeTransaction.new(@api, @api.do_request("GET", get_base_api_path() + "/airtime_transactions/#{id}"))
|
2470
|
+
end
|
2471
|
+
|
2472
|
+
#
|
2473
|
+
# Initializes an airtime transaction by ID without making an API request.
|
2474
|
+
#
|
2475
|
+
# Arguments:
|
2476
|
+
# - id
|
2477
|
+
# * ID of the airtime transaction
|
2478
|
+
# * Required
|
2479
|
+
#
|
2480
|
+
# Returns:
|
2481
|
+
# Telerivet::AirtimeTransaction
|
2482
|
+
#
|
2483
|
+
def init_airtime_transaction_by_id(id)
|
2484
|
+
require_relative 'airtimetransaction'
|
2485
|
+
return AirtimeTransaction.new(@api, {'project_id' => self.id, 'id' => id}, false)
|
2486
|
+
end
|
2487
|
+
|
2488
|
+
#
|
2489
|
+
# Gets a list of all custom fields defined for contacts in this project. The return value is
|
2490
|
+
# an array of objects with the properties 'name', 'variable', 'type', 'order', 'readonly', and
|
2491
|
+
# 'lookup_key'. (Fields are automatically created any time a Contact's 'vars' property is
|
2492
|
+
# updated.)
|
2493
|
+
#
|
2494
|
+
# Returns:
|
2495
|
+
# array
|
2496
|
+
#
|
2497
|
+
def get_contact_fields()
|
2498
|
+
return @api.do_request("GET", get_base_api_path() + "/contact_fields")
|
2499
|
+
end
|
2500
|
+
|
2501
|
+
#
|
2502
|
+
# Allows customizing how a custom contact field is displayed in the Telerivet web app.
|
2503
|
+
#
|
2504
|
+
# Arguments:
|
2505
|
+
# - variable
|
2506
|
+
# * The variable name of the field to create or update.
|
2507
|
+
# * Required
|
2508
|
+
#
|
2509
|
+
# - options (Hash)
|
2510
|
+
# * Required
|
2511
|
+
#
|
2512
|
+
# - name (string, max 64 characters)
|
2513
|
+
# * Display name for the field
|
2514
|
+
#
|
2515
|
+
# - type (int)
|
2516
|
+
# * Field type
|
2517
|
+
# * Allowed values: text, long_text, secret, phone_number, email, url, audio, date,
|
2518
|
+
# date_time, number, boolean, checkbox, select, radio
|
2519
|
+
#
|
2520
|
+
# - order (int)
|
2521
|
+
# * Order in which to display the field
|
2522
|
+
#
|
2523
|
+
# - items (array)
|
2524
|
+
# * Array of up to 100 objects containing `value` and `label` string properties to
|
2525
|
+
# show in the dropdown list when type is `select`. Each `value` and `label` must be
|
2526
|
+
# between 1 and 256 characters in length.
|
2527
|
+
# * Required if type is `select`
|
2528
|
+
#
|
2529
|
+
# - readonly (bool)
|
2530
|
+
# * Set to true to prevent editing the field in the Telerivet web app
|
2531
|
+
#
|
2532
|
+
# - lookup_key (bool)
|
2533
|
+
# * Set to true to allow using this field as a lookup key when importing contacts via
|
2534
|
+
# the Telerivet web app
|
2535
|
+
#
|
2536
|
+
# - show_on_conversation (bool)
|
2537
|
+
# * Set to true to show field on Conversations tab
|
2538
|
+
#
|
2539
|
+
# Returns:
|
2540
|
+
# object
|
2541
|
+
#
|
2542
|
+
def set_contact_field_metadata(variable, options)
|
2543
|
+
return @api.do_request("POST", get_base_api_path() + "/contact_fields/#{variable}", options)
|
2544
|
+
end
|
2545
|
+
|
2546
|
+
#
|
2547
|
+
# Gets a list of all custom fields defined for messages in this project. The return value is
|
2548
|
+
# an array of objects with the properties 'name', 'variable', 'type', 'order', 'readonly', and
|
2549
|
+
# 'lookup_key'. (Fields are automatically created any time a Contact's 'vars' property is
|
2550
|
+
# updated.)
|
2551
|
+
#
|
2552
|
+
# Returns:
|
2553
|
+
# array
|
2554
|
+
#
|
2555
|
+
def get_message_fields()
|
2556
|
+
return @api.do_request("GET", get_base_api_path() + "/message_fields")
|
2557
|
+
end
|
2558
|
+
|
2559
|
+
#
|
2560
|
+
# Allows customizing how a custom message field is displayed in the Telerivet web app.
|
2561
|
+
#
|
2562
|
+
# Arguments:
|
2563
|
+
# - variable
|
2564
|
+
# * The variable name of the field to create or update.
|
2565
|
+
# * Required
|
2566
|
+
#
|
2567
|
+
# - options (Hash)
|
2568
|
+
# * Required
|
2569
|
+
#
|
2570
|
+
# - name (string, max 64 characters)
|
2571
|
+
# * Display name for the field
|
2572
|
+
#
|
2573
|
+
# - type (string)
|
2574
|
+
# * Field type
|
2575
|
+
# * Allowed values: text, long_text, secret, phone_number, email, url, audio, date,
|
2576
|
+
# date_time, number, boolean, checkbox, select, radio
|
2577
|
+
#
|
2578
|
+
# - order (int)
|
2579
|
+
# * Order in which to display the field
|
2580
|
+
#
|
2581
|
+
# - items (array)
|
2582
|
+
# * Array of up to 100 objects containing `value` and `label` string properties to
|
2583
|
+
# show in the dropdown list when type is `select`. Each `value` and `label` must be
|
2584
|
+
# between 1 and 256 characters in length.
|
2585
|
+
# * Required if type is `select`
|
2586
|
+
#
|
2587
|
+
# - hide_values (bool)
|
2588
|
+
# * Set to true to avoid showing values of this field on the Messages page
|
2589
|
+
#
|
2590
|
+
# Returns:
|
2591
|
+
# object
|
2592
|
+
#
|
2593
|
+
def set_message_field_metadata(variable, options)
|
2594
|
+
return @api.do_request("POST", get_base_api_path() + "/message_fields/#{variable}", options)
|
2595
|
+
end
|
2596
|
+
|
2597
|
+
#
|
2598
|
+
# Retrieves statistics about messages sent or received via Telerivet. This endpoint returns
|
2599
|
+
# historical data that is computed shortly after midnight each day in the project's time zone,
|
2600
|
+
# and does not contain message statistics for the current day.
|
2601
|
+
#
|
2602
|
+
# Arguments:
|
2603
|
+
# - options (Hash)
|
2604
|
+
# * Required
|
2605
|
+
#
|
2606
|
+
# - start_date (string)
|
2607
|
+
# * Start date of message statistics, in YYYY-MM-DD format
|
2608
|
+
# * Required
|
2609
|
+
#
|
2610
|
+
# - end_date (string)
|
2611
|
+
# * End date of message statistics (inclusive), in YYYY-MM-DD format
|
2612
|
+
# * Required
|
2613
|
+
#
|
2614
|
+
# - rollup (string)
|
2615
|
+
# * Date interval to group by
|
2616
|
+
# * Allowed values: day, week, month, year, all
|
2617
|
+
# * Default: day
|
2618
|
+
#
|
2619
|
+
# - properties (string)
|
2620
|
+
# * Comma separated list of properties to group by
|
2621
|
+
# * Allowed values: org_id, org_name, org_industry, project_id, project_name, user_id,
|
2622
|
+
# user_email, user_name, phone_id, phone_name, phone_type, direction, source, status,
|
2623
|
+
# network_code, network_name, message_type, service_id, service_name, simulated, link
|
2624
|
+
#
|
2625
|
+
# - metrics (string)
|
2626
|
+
# * Comma separated list of metrics to return (summed for each distinct value of the
|
2627
|
+
# requested properties)
|
2628
|
+
# * Allowed values: count, num_parts, duration, price
|
2629
|
+
# * Required
|
2630
|
+
#
|
2631
|
+
# - currency (string)
|
2632
|
+
# * Three-letter ISO 4217 currency code used when returning the 'price' field. If the
|
2633
|
+
# original price was in a different currency, it will be converted to the requested
|
2634
|
+
# currency using the approximate current exchange rate.
|
2635
|
+
# * Default: USD
|
2636
|
+
#
|
2637
|
+
# - filters (Hash)
|
2638
|
+
# * Key-value pairs of properties and corresponding values; the returned statistics
|
2639
|
+
# will only include messages where the property matches the provided value. Only the
|
2640
|
+
# following properties are supported for filters: `user_id`, `phone_id`, `direction`,
|
2641
|
+
# `source`, `status`, `service_id`, `simulated`, `message_type`, `network_code`
|
2642
|
+
#
|
2643
|
+
# Returns:
|
2644
|
+
# (associative array)
|
2645
|
+
# - intervals (array)
|
2646
|
+
# * List of objects representing each date interval containing at least one message
|
2647
|
+
# matching the filters.
|
2648
|
+
# Each object has the following properties:
|
2649
|
+
#
|
2650
|
+
# <table>
|
2651
|
+
# <tr><td> start_time </td> <td> The UNIX timestamp of the start
|
2652
|
+
# of the interval (int) </td></tr>
|
2653
|
+
# <tr><td> end_time </td> <td> The UNIX timestamp of the end of
|
2654
|
+
# the interval, exclusive (int) </td></tr>
|
2655
|
+
# <tr><td> start_date </td> <td> The date of the start of the
|
2656
|
+
# interval in YYYY-MM-DD format (string) </td></tr>
|
2657
|
+
# <tr><td> end_date </td> <td> The date of the end of the
|
2658
|
+
# interval in YYYY-MM-DD format, inclusive (string) </td></tr>
|
2659
|
+
# <tr><td> groups </td> <td> Array of groups for each
|
2660
|
+
# combination of requested property values matching the filters (array)
|
2661
|
+
# <br /><br />
|
2662
|
+
# Each object has the following properties:
|
2663
|
+
# <table>
|
2664
|
+
# <tr><td> properties </td> <td> An object of key/value
|
2665
|
+
# pairs for each distinct value of the requested properties (object) </td></tr>
|
2666
|
+
# <tr><td> metrics </td> <td> An object of key/value pairs
|
2667
|
+
# for each requested metric (object) </td></tr>
|
2668
|
+
# </table>
|
2669
|
+
# </td></tr>
|
2670
|
+
# </table>
|
2671
|
+
#
|
2672
|
+
def get_message_stats(options)
|
2673
|
+
data = @api.do_request("GET", get_base_api_path() + "/message_stats", options)
|
2674
|
+
return data
|
2675
|
+
end
|
2676
|
+
|
1513
2677
|
#
|
1514
2678
|
# Saves any fields or custom variables that have changed for the project.
|
1515
2679
|
#
|
@@ -1533,10 +2697,34 @@ class Project < Entity
|
|
1533
2697
|
get('timezone_id')
|
1534
2698
|
end
|
1535
2699
|
|
2700
|
+
def timezone_id=(value)
|
2701
|
+
set('timezone_id', value)
|
2702
|
+
end
|
2703
|
+
|
1536
2704
|
def url_slug
|
1537
2705
|
get('url_slug')
|
1538
2706
|
end
|
1539
2707
|
|
2708
|
+
def url_slug=(value)
|
2709
|
+
set('url_slug', value)
|
2710
|
+
end
|
2711
|
+
|
2712
|
+
def default_route_id
|
2713
|
+
get('default_route_id')
|
2714
|
+
end
|
2715
|
+
|
2716
|
+
def default_route_id=(value)
|
2717
|
+
set('default_route_id', value)
|
2718
|
+
end
|
2719
|
+
|
2720
|
+
def auto_create_contacts
|
2721
|
+
get('auto_create_contacts')
|
2722
|
+
end
|
2723
|
+
|
2724
|
+
def auto_create_contacts=(value)
|
2725
|
+
set('auto_create_contacts', value)
|
2726
|
+
end
|
2727
|
+
|
1540
2728
|
def organization_id
|
1541
2729
|
get('organization_id')
|
1542
2730
|
end
|