telerivet 1.6.1 → 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 +16 -0
- data/lib/telerivet/apicursor.rb +26 -22
- data/lib/telerivet/broadcast.rb +4 -4
- data/lib/telerivet/contact.rb +7 -4
- data/lib/telerivet/datatable.rb +2 -2
- data/lib/telerivet/group.rb +4 -1
- data/lib/telerivet/label.rb +1 -1
- data/lib/telerivet/message.rb +25 -3
- data/lib/telerivet/organization.rb +44 -2
- data/lib/telerivet/phone.rb +10 -8
- data/lib/telerivet/project.rb +616 -89
- data/lib/telerivet/relativescheduledmessage.rb +361 -0
- data/lib/telerivet/route.rb +1 -1
- data/lib/telerivet/scheduledmessage.rb +102 -23
- data/lib/telerivet/service.rb +131 -32
- data/lib/telerivet.rb +1 -1
- metadata +3 -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)
|
@@ -174,7 +188,7 @@ class Project < Entity
|
|
174
188
|
# - message_type
|
175
189
|
# * Type of message to send. If `text`, will use the default text message type for the
|
176
190
|
# selected route.
|
177
|
-
# * Allowed values: sms, mms, call,
|
191
|
+
# * Allowed values: text, sms, mms, call, chat, service
|
178
192
|
# * Default: text
|
179
193
|
#
|
180
194
|
# - content
|
@@ -212,9 +226,9 @@ class Project < Entity
|
|
212
226
|
# * Optionally excludes one contact from receiving the message (only when group_id is
|
213
227
|
# set)
|
214
228
|
#
|
215
|
-
# -
|
229
|
+
# - replace_variables (bool)
|
216
230
|
# * Set to true to evaluate variables like [[contact.name]] in message content [(See
|
217
|
-
# available variables)](#variables)
|
231
|
+
# available variables)](#variables) (`is_template` parameter also accepted)
|
218
232
|
# * Default: false
|
219
233
|
#
|
220
234
|
# - track_clicks (boolean)
|
@@ -302,7 +316,7 @@ class Project < Entity
|
|
302
316
|
# - message_type
|
303
317
|
# * Type of message to send. If `text`, will use the default text message type for the
|
304
318
|
# selected route.
|
305
|
-
# * Allowed values: sms, mms, chat,
|
319
|
+
# * Allowed values: text, sms, mms, call, chat, service
|
306
320
|
# * Default: text
|
307
321
|
#
|
308
322
|
# - route_id
|
@@ -330,9 +344,9 @@ class Project < Entity
|
|
330
344
|
# - label_ids (array)
|
331
345
|
# * Array of IDs of labels to add to each message (maximum 5)
|
332
346
|
#
|
333
|
-
# -
|
347
|
+
# - replace_variables (bool)
|
334
348
|
# * Set to true to evaluate variables like [[contact.name]] in message content [(See
|
335
|
-
# available variables)](#variables)
|
349
|
+
# available variables)](#variables) (`is_template` parameter also accepted)
|
336
350
|
# * Default: false
|
337
351
|
#
|
338
352
|
# - track_clicks (boolean)
|
@@ -441,6 +455,9 @@ class Project < Entity
|
|
441
455
|
# messages approximately once every 15 seconds, so it is not possible to control the exact
|
442
456
|
# second at which a scheduled message is sent.
|
443
457
|
#
|
458
|
+
# Only one of the parameters group_id, to_number, and contact_id
|
459
|
+
# should be provided.
|
460
|
+
#
|
444
461
|
# With `message_type`=`service`, schedules an automated service (such
|
445
462
|
# as a poll) to be invoked for a group or list of phone numbers. Any service that can be
|
446
463
|
# triggered for a contact can be scheduled via this method, whether or not the service
|
@@ -452,20 +469,21 @@ class Project < Entity
|
|
452
469
|
#
|
453
470
|
# - message_type
|
454
471
|
# * Type of message to send
|
455
|
-
# * Allowed values: sms, ussd, call, service
|
456
|
-
# * Default:
|
472
|
+
# * Allowed values: text, sms, mms, ussd, call, chat, service
|
473
|
+
# * Default: text
|
457
474
|
#
|
458
475
|
# - content
|
459
476
|
# * Content of the message to schedule
|
460
|
-
# * Required if sending
|
477
|
+
# * Required if sending text message
|
461
478
|
#
|
462
479
|
# - group_id
|
463
480
|
# * ID of the group to send the message to
|
464
|
-
# * Required if to_number not set
|
465
481
|
#
|
466
482
|
# - to_number (string)
|
467
483
|
# * Phone number to send the message to
|
468
|
-
#
|
484
|
+
#
|
485
|
+
# - contact_id (string)
|
486
|
+
# * ID of the contact to send the message to
|
469
487
|
#
|
470
488
|
# - start_time (UNIX timestamp)
|
471
489
|
# * The time that the message will be sent (or first sent for recurring messages)
|
@@ -530,8 +548,9 @@ class Project < Entity
|
|
530
548
|
# destination URL.
|
531
549
|
# If null, the short links will not expire.
|
532
550
|
#
|
533
|
-
# -
|
551
|
+
# - replace_variables (bool)
|
534
552
|
# * Set to true to evaluate variables like [[contact.name]] in message content
|
553
|
+
# (`is_template` parameter also accepted)
|
535
554
|
# * Default: false
|
536
555
|
#
|
537
556
|
# - media_urls (array)
|
@@ -551,8 +570,8 @@ class Project < Entity
|
|
551
570
|
# itself.
|
552
571
|
#
|
553
572
|
# - timezone_id
|
554
|
-
# * TZ database timezone ID; see
|
555
|
-
#
|
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).
|
556
575
|
# * Default: project default timezone
|
557
576
|
#
|
558
577
|
# - end_time (UNIX timestamp)
|
@@ -574,6 +593,166 @@ class Project < Entity
|
|
574
593
|
ScheduledMessage.new(@api, @api.do_request("POST", get_base_api_path() + "/scheduled", options))
|
575
594
|
end
|
576
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
|
+
|
577
756
|
#
|
578
757
|
# Add an incoming message to Telerivet. Acts the same as if the message was received by a
|
579
758
|
# phone. Also triggers any automated services that apply to the message.
|
@@ -848,7 +1027,7 @@ class Project < Entity
|
|
848
1027
|
end
|
849
1028
|
|
850
1029
|
#
|
851
|
-
# Queries
|
1030
|
+
# Queries basic routes within the given project.
|
852
1031
|
#
|
853
1032
|
# Arguments:
|
854
1033
|
# - options (Hash)
|
@@ -896,7 +1075,7 @@ class Project < Entity
|
|
896
1075
|
end
|
897
1076
|
|
898
1077
|
#
|
899
|
-
# Retrieves the
|
1078
|
+
# Retrieves the basic route with the given ID.
|
900
1079
|
#
|
901
1080
|
# Arguments:
|
902
1081
|
# - id
|
@@ -912,7 +1091,7 @@ class Project < Entity
|
|
912
1091
|
end
|
913
1092
|
|
914
1093
|
#
|
915
|
-
# Initializes the
|
1094
|
+
# Initializes the basic route with the given ID without making an API request.
|
916
1095
|
#
|
917
1096
|
# Arguments:
|
918
1097
|
# - id
|
@@ -942,7 +1121,7 @@ class Project < Entity
|
|
942
1121
|
#
|
943
1122
|
# - message_type
|
944
1123
|
# * Filter messages by message_type
|
945
|
-
# * Allowed values: sms, mms, ussd, call, service
|
1124
|
+
# * Allowed values: sms, mms, ussd, ussd_session, call, chat, service
|
946
1125
|
#
|
947
1126
|
# - source
|
948
1127
|
# * Filter messages by source
|
@@ -1152,50 +1331,44 @@ class Project < Entity
|
|
1152
1331
|
#
|
1153
1332
|
# Tasks for contacts:
|
1154
1333
|
#
|
1155
|
-
# -
|
1156
|
-
# -
|
1157
|
-
# -
|
1158
|
-
# -
|
1159
|
-
# -
|
1160
|
-
# -
|
1161
|
-
# -
|
1162
|
-
# -
|
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
|
1163
1342
|
#
|
1164
1343
|
# Tasks for data rows:
|
1165
1344
|
#
|
1166
|
-
# -
|
1167
|
-
# -
|
1168
|
-
# -
|
1169
|
-
# -
|
1345
|
+
# - update_row_var
|
1346
|
+
# - apply_service_to_rows
|
1347
|
+
# - delete_rows
|
1348
|
+
# - export_rows
|
1170
1349
|
#
|
1171
1350
|
# Tasks for messages:
|
1172
1351
|
#
|
1173
|
-
# -
|
1174
|
-
# -
|
1175
|
-
# -
|
1176
|
-
# -
|
1177
|
-
# -
|
1178
|
-
# -
|
1179
|
-
# -
|
1180
|
-
# -
|
1181
|
-
# -
|
1182
|
-
# * Allowed values: update_contact_var, delete_contacts, add_group_members,
|
1183
|
-
# remove_group_members, set_conversation_status, set_send_blocked,
|
1184
|
-
# apply_service_to_contacts, update_row_var, delete_rows, apply_service_to_rows,
|
1185
|
-
# delete_messages, cancel_messages, resend_messages, retry_message_services,
|
1186
|
-
# apply_service_to_messages, add_label, remove_label, update_message_var,
|
1187
|
-
# export_messages, export_contacts, export_rows
|
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
|
1188
1361
|
# * Required
|
1189
1362
|
#
|
1190
1363
|
# - task_params (Hash)
|
1191
1364
|
# * Parameters applied to all matching rows (specific to `task_type`).
|
1192
1365
|
#
|
1193
|
-
#
|
1194
|
-
#
|
1366
|
+
# **apply_service_to_contacts**,
|
1367
|
+
# **apply_service_to_messages**, **apply_service_to_rows**:
|
1195
1368
|
# <table>
|
1196
|
-
# <tr><td>
|
1197
|
-
#
|
1198
|
-
# <tr><td>
|
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
|
1199
1372
|
# containing up to 25 temporary variable names and their corresponding values to set
|
1200
1373
|
# when invoking the service. Values may be strings, numbers, or boolean (true/false).
|
1201
1374
|
# String values may be up to 4096 bytes in length. Arrays and objects are not
|
@@ -1205,49 +1378,49 @@ class Project < Entity
|
|
1205
1378
|
# JavaScript variable like $name (with a leading $ character). (object) </td></tr>
|
1206
1379
|
# </table>
|
1207
1380
|
# <br />
|
1208
|
-
#
|
1209
|
-
#
|
1381
|
+
# **update_contact_var**, **update_message_var**,
|
1382
|
+
# **update_row_var**:
|
1210
1383
|
# <table>
|
1211
|
-
# <tr><td>
|
1384
|
+
# <tr><td> variable </td> <td> The custom variable
|
1212
1385
|
# name (string) </td></tr>
|
1213
|
-
# <tr><td>
|
1214
|
-
#
|
1386
|
+
# <tr><td> value </td> <td> The value to set (string,
|
1387
|
+
# boolean, float, null) </td></tr>
|
1215
1388
|
# </table>
|
1216
1389
|
# <br />
|
1217
|
-
#
|
1390
|
+
# **add_group_members**, **remove_group_members**:
|
1218
1391
|
# <table>
|
1219
|
-
# <tr><td>
|
1392
|
+
# <tr><td> group_id </td> <td> The ID of the group
|
1220
1393
|
# (string) </td></tr>
|
1221
1394
|
# </table>
|
1222
1395
|
# <br />
|
1223
|
-
#
|
1396
|
+
# **add_label**, **remove_label**:
|
1224
1397
|
# <table>
|
1225
|
-
# <tr><td>
|
1398
|
+
# <tr><td> label_id </td> <td> The ID of the label
|
1226
1399
|
# (string) </td></tr>
|
1227
1400
|
# </table>
|
1228
1401
|
# <br />
|
1229
|
-
#
|
1402
|
+
# **resend_messages**:
|
1230
1403
|
# <table>
|
1231
|
-
# <tr><td>
|
1232
|
-
#
|
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>
|
1233
1406
|
# </table>
|
1234
1407
|
# <br />
|
1235
|
-
#
|
1408
|
+
# **set_send_blocked**:
|
1236
1409
|
# <table>
|
1237
|
-
# <tr><td>
|
1238
|
-
# sending messages,
|
1410
|
+
# <tr><td> send_blocked </td> <td> true to block
|
1411
|
+
# sending messages, false to unblock sending messages (boolean) </td></tr>
|
1239
1412
|
# </table>
|
1240
1413
|
# <br />
|
1241
|
-
#
|
1414
|
+
# **set_conversation_status**:
|
1242
1415
|
# <table>
|
1243
|
-
# <tr><td>
|
1416
|
+
# <tr><td> conversation_status </td> <td> "active",
|
1244
1417
|
# "handled", or "closed" (string) </td></tr>
|
1245
1418
|
# </table>
|
1246
1419
|
# <br />
|
1247
|
-
#
|
1248
|
-
#
|
1420
|
+
# **export_contacts**, **export_messages**,
|
1421
|
+
# **export_rows**:
|
1249
1422
|
# <table>
|
1250
|
-
# <tr><td
|
1423
|
+
# <tr><td>storage_id </td> <td> ID of a storage
|
1251
1424
|
# provider where the CSV file will be saved. (string)
|
1252
1425
|
#
|
1253
1426
|
# Currently only AWS S3 is supported as a storage
|
@@ -1261,15 +1434,15 @@ class Project < Entity
|
|
1261
1434
|
# Direct downloads are not supported when
|
1262
1435
|
# exporting data via the API.
|
1263
1436
|
# (string) </td></tr>
|
1264
|
-
# <tr><td
|
1265
|
-
#
|
1266
|
-
# <tr><td
|
1267
|
-
#
|
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
|
1268
1441
|
# strings, optional) </td></tr>
|
1269
1442
|
# </table>
|
1270
1443
|
# <br />
|
1271
|
-
#
|
1272
|
-
#
|
1444
|
+
# **delete_contacts**, **delete_messages**,
|
1445
|
+
# **delete_rows**, **cancel_messages**, **retry_message_services**: <br />
|
1273
1446
|
# No parameters.
|
1274
1447
|
#
|
1275
1448
|
# - filter_type
|
@@ -1678,7 +1851,7 @@ class Project < Entity
|
|
1678
1851
|
#
|
1679
1852
|
# - message_type
|
1680
1853
|
# * Filter scheduled messages by message_type
|
1681
|
-
# * Allowed values: sms, mms, ussd, call, service
|
1854
|
+
# * Allowed values: sms, mms, ussd, ussd_session, call, chat, service
|
1682
1855
|
#
|
1683
1856
|
# - time_created (UNIX timestamp)
|
1684
1857
|
# * Filter scheduled messages by time_created
|
@@ -1688,6 +1861,9 @@ class Project < Entity
|
|
1688
1861
|
# * Filter scheduled messages by next_time
|
1689
1862
|
# * Allowed modifiers: next_time[min], next_time[max], next_time[exists]
|
1690
1863
|
#
|
1864
|
+
# - relative_scheduled_id
|
1865
|
+
# * Filter scheduled messages created for a relative scheduled message
|
1866
|
+
#
|
1691
1867
|
# - sort
|
1692
1868
|
# * Sort the results based on a field
|
1693
1869
|
# * Allowed values: default, next_time
|
@@ -1714,6 +1890,52 @@ class Project < Entity
|
|
1714
1890
|
@api.cursor(ScheduledMessage, get_base_api_path() + "/scheduled", options)
|
1715
1891
|
end
|
1716
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
|
+
|
1717
1939
|
#
|
1718
1940
|
# Retrieves the scheduled message with the given ID.
|
1719
1941
|
#
|
@@ -1746,6 +1968,179 @@ class Project < Entity
|
|
1746
1968
|
return ScheduledMessage.new(@api, {'project_id' => self.id, 'id' => id}, false)
|
1747
1969
|
end
|
1748
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
|
+
|
1749
2144
|
#
|
1750
2145
|
# Queries services within the given project.
|
1751
2146
|
#
|
@@ -1822,6 +2217,114 @@ class Project < Entity
|
|
1822
2217
|
return Service.new(@api, {'project_id' => self.id, 'id' => id}, false)
|
1823
2218
|
end
|
1824
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
|
+
|
1825
2328
|
#
|
1826
2329
|
# Queries custom routes that can be used to send messages (not including Phones).
|
1827
2330
|
#
|
@@ -2011,8 +2514,8 @@ class Project < Entity
|
|
2011
2514
|
#
|
2012
2515
|
# - type (int)
|
2013
2516
|
# * Field type
|
2014
|
-
# * Allowed values: text, long_text, phone_number, email, url, audio, date,
|
2015
|
-
# number, boolean, select
|
2517
|
+
# * Allowed values: text, long_text, secret, phone_number, email, url, audio, date,
|
2518
|
+
# date_time, number, boolean, checkbox, select, radio
|
2016
2519
|
#
|
2017
2520
|
# - order (int)
|
2018
2521
|
# * Order in which to display the field
|
@@ -2069,8 +2572,8 @@ class Project < Entity
|
|
2069
2572
|
#
|
2070
2573
|
# - type (string)
|
2071
2574
|
# * Field type
|
2072
|
-
# * Allowed values: text, long_text, phone_number, email, url, audio, date,
|
2073
|
-
# number, boolean, select
|
2575
|
+
# * Allowed values: text, long_text, secret, phone_number, email, url, audio, date,
|
2576
|
+
# date_time, number, boolean, checkbox, select, radio
|
2074
2577
|
#
|
2075
2578
|
# - order (int)
|
2076
2579
|
# * Order in which to display the field
|
@@ -2194,10 +2697,34 @@ class Project < Entity
|
|
2194
2697
|
get('timezone_id')
|
2195
2698
|
end
|
2196
2699
|
|
2700
|
+
def timezone_id=(value)
|
2701
|
+
set('timezone_id', value)
|
2702
|
+
end
|
2703
|
+
|
2197
2704
|
def url_slug
|
2198
2705
|
get('url_slug')
|
2199
2706
|
end
|
2200
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
|
+
|
2201
2728
|
def organization_id
|
2202
2729
|
get('organization_id')
|
2203
2730
|
end
|