telerivet 1.5.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/telerivet/airtimetransaction.rb +16 -0
- data/lib/telerivet/apicursor.rb +26 -22
- data/lib/telerivet/broadcast.rb +15 -4
- data/lib/telerivet/contact.rb +20 -10
- data/lib/telerivet/datatable.rb +15 -4
- data/lib/telerivet/group.rb +14 -14
- data/lib/telerivet/label.rb +10 -2
- data/lib/telerivet/message.rb +76 -34
- data/lib/telerivet/organization.rb +124 -2
- data/lib/telerivet/phone.rb +19 -9
- data/lib/telerivet/project.rb +930 -112
- 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 +140 -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)
|
@@ -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)
|
350
|
+
# * Default: false
|
351
|
+
#
|
352
|
+
# - track_clicks (boolean)
|
353
|
+
# * If true, URLs in the message content will automatically be replaced with unique
|
354
|
+
# short URLs.
|
296
355
|
# * Default: false
|
297
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.
|
@@ -664,24 +932,22 @@ class Project < Entity
|
|
664
932
|
#
|
665
933
|
# - time_created (UNIX timestamp)
|
666
934
|
# * Filter contacts by time created
|
667
|
-
# * Allowed modifiers: time_created[
|
935
|
+
# * Allowed modifiers: time_created[min], time_created[max]
|
668
936
|
#
|
669
937
|
# - last_message_time (UNIX timestamp)
|
670
938
|
# * Filter contacts by last time a message was sent or received
|
671
|
-
# * Allowed modifiers: last_message_time[
|
672
|
-
# last_message_time[
|
939
|
+
# * Allowed modifiers: last_message_time[min], last_message_time[max],
|
940
|
+
# last_message_time[exists]
|
673
941
|
#
|
674
942
|
# - last_incoming_message_time (UNIX timestamp)
|
675
943
|
# * Filter contacts by last time a message was received
|
676
|
-
# * Allowed modifiers: last_incoming_message_time[
|
677
|
-
# last_incoming_message_time[
|
678
|
-
# last_incoming_message_time[exists]
|
944
|
+
# * Allowed modifiers: last_incoming_message_time[min],
|
945
|
+
# last_incoming_message_time[max], last_incoming_message_time[exists]
|
679
946
|
#
|
680
947
|
# - last_outgoing_message_time (UNIX timestamp)
|
681
948
|
# * Filter contacts by last time a message was sent
|
682
|
-
# * Allowed modifiers: last_outgoing_message_time[
|
683
|
-
# last_outgoing_message_time[
|
684
|
-
# last_outgoing_message_time[exists]
|
949
|
+
# * Allowed modifiers: last_outgoing_message_time[min],
|
950
|
+
# last_outgoing_message_time[max], last_outgoing_message_time[exists]
|
685
951
|
#
|
686
952
|
# - incoming_message_count (int)
|
687
953
|
# * Filter contacts by number of messages received from the contact
|
@@ -761,7 +1027,7 @@ class Project < Entity
|
|
761
1027
|
end
|
762
1028
|
|
763
1029
|
#
|
764
|
-
# Queries
|
1030
|
+
# Queries basic routes within the given project.
|
765
1031
|
#
|
766
1032
|
# Arguments:
|
767
1033
|
# - options (Hash)
|
@@ -779,8 +1045,8 @@ class Project < Entity
|
|
779
1045
|
#
|
780
1046
|
# - last_active_time (UNIX timestamp)
|
781
1047
|
# * Filter phones by last active time
|
782
|
-
# * Allowed modifiers: last_active_time[
|
783
|
-
# last_active_time[
|
1048
|
+
# * Allowed modifiers: last_active_time[min], last_active_time[max],
|
1049
|
+
# last_active_time[exists]
|
784
1050
|
#
|
785
1051
|
# - sort
|
786
1052
|
# * Sort the results based on a field
|
@@ -809,7 +1075,7 @@ class Project < Entity
|
|
809
1075
|
end
|
810
1076
|
|
811
1077
|
#
|
812
|
-
# Retrieves the
|
1078
|
+
# Retrieves the basic route with the given ID.
|
813
1079
|
#
|
814
1080
|
# Arguments:
|
815
1081
|
# - id
|
@@ -825,7 +1091,7 @@ class Project < Entity
|
|
825
1091
|
end
|
826
1092
|
|
827
1093
|
#
|
828
|
-
# Initializes the
|
1094
|
+
# Initializes the basic route with the given ID without making an API request.
|
829
1095
|
#
|
830
1096
|
# Arguments:
|
831
1097
|
# - id
|
@@ -855,7 +1121,7 @@ class Project < Entity
|
|
855
1121
|
#
|
856
1122
|
# - message_type
|
857
1123
|
# * Filter messages by message_type
|
858
|
-
# * Allowed values: sms, mms, ussd, call, service
|
1124
|
+
# * Allowed values: sms, mms, ussd, ussd_session, call, chat, service
|
859
1125
|
#
|
860
1126
|
# - source
|
861
1127
|
# * Filter messages by source
|
@@ -868,7 +1134,7 @@ class Project < Entity
|
|
868
1134
|
# - status
|
869
1135
|
# * Filter messages by status
|
870
1136
|
# * Allowed values: ignored, processing, received, sent, queued, failed,
|
871
|
-
# failed_queued, cancelled, delivered, not_delivered
|
1137
|
+
# failed_queued, cancelled, delivered, not_delivered, read
|
872
1138
|
#
|
873
1139
|
# - time_created[min] (UNIX timestamp)
|
874
1140
|
# * Filter messages created on or after a particular time
|
@@ -878,18 +1144,26 @@ class Project < Entity
|
|
878
1144
|
#
|
879
1145
|
# - external_id
|
880
1146
|
# * Filter messages by ID from an external provider
|
1147
|
+
# * Allowed modifiers: external_id[ne], external_id[exists]
|
881
1148
|
#
|
882
1149
|
# - contact_id
|
883
1150
|
# * ID of the contact who sent/received the message
|
1151
|
+
# * Allowed modifiers: contact_id[ne], contact_id[exists]
|
884
1152
|
#
|
885
1153
|
# - phone_id
|
886
1154
|
# * ID of the phone (basic route) that sent/received the message
|
887
1155
|
#
|
888
1156
|
# - broadcast_id
|
889
1157
|
# * ID of the broadcast containing the message
|
1158
|
+
# * Allowed modifiers: broadcast_id[ne], broadcast_id[exists]
|
890
1159
|
#
|
891
1160
|
# - scheduled_id
|
892
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.
|
893
1167
|
#
|
894
1168
|
# - sort
|
895
1169
|
# * Sort the results based on a field
|
@@ -1057,116 +1331,118 @@ class Project < Entity
|
|
1057
1331
|
#
|
1058
1332
|
# Tasks for contacts:
|
1059
1333
|
#
|
1060
|
-
# -
|
1061
|
-
# -
|
1062
|
-
# -
|
1063
|
-
# -
|
1064
|
-
# -
|
1065
|
-
# -
|
1066
|
-
# -
|
1067
|
-
# -
|
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
|
1068
1342
|
#
|
1069
1343
|
# Tasks for data rows:
|
1070
1344
|
#
|
1071
|
-
# -
|
1072
|
-
# -
|
1073
|
-
# -
|
1074
|
-
# -
|
1345
|
+
# - update_row_var
|
1346
|
+
# - apply_service_to_rows
|
1347
|
+
# - delete_rows
|
1348
|
+
# - export_rows
|
1075
1349
|
#
|
1076
1350
|
# Tasks for messages:
|
1077
1351
|
#
|
1078
|
-
# -
|
1079
|
-
# -
|
1080
|
-
# -
|
1081
|
-
# -
|
1082
|
-
# -
|
1083
|
-
# -
|
1084
|
-
# -
|
1085
|
-
# -
|
1086
|
-
# -
|
1087
|
-
# * Allowed values: update_contact_var, delete_contacts, add_group_members,
|
1088
|
-
# remove_group_members, set_conversation_status, set_send_blocked,
|
1089
|
-
# apply_service_to_contacts, update_row_var, delete_rows, apply_service_to_rows,
|
1090
|
-
# delete_messages, cancel_messages, resend_messages, retry_message_services,
|
1091
|
-
# apply_service_to_messages, add_label, remove_label, update_message_var,
|
1092
|
-
# export_messages, export_contacts, export_rows
|
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
|
1093
1361
|
# * Required
|
1094
1362
|
#
|
1095
1363
|
# - task_params (Hash)
|
1096
1364
|
# * Parameters applied to all matching rows (specific to `task_type`).
|
1097
1365
|
#
|
1098
|
-
#
|
1099
|
-
#
|
1366
|
+
# **apply_service_to_contacts**,
|
1367
|
+
# **apply_service_to_messages**, **apply_service_to_rows**:
|
1100
1368
|
# <table>
|
1101
|
-
# <tr><td>
|
1102
|
-
#
|
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>
|
1103
1379
|
# </table>
|
1104
|
-
#
|
1105
|
-
#
|
1106
|
-
#
|
1380
|
+
# <br />
|
1381
|
+
# **update_contact_var**, **update_message_var**,
|
1382
|
+
# **update_row_var**:
|
1107
1383
|
# <table>
|
1108
|
-
# <tr><td>
|
1384
|
+
# <tr><td> variable </td> <td> The custom variable
|
1109
1385
|
# name (string) </td></tr>
|
1110
|
-
# <tr><td>
|
1111
|
-
#
|
1386
|
+
# <tr><td> value </td> <td> The value to set (string,
|
1387
|
+
# boolean, float, null) </td></tr>
|
1112
1388
|
# </table>
|
1113
|
-
#
|
1114
|
-
#
|
1389
|
+
# <br />
|
1390
|
+
# **add_group_members**, **remove_group_members**:
|
1115
1391
|
# <table>
|
1116
|
-
# <tr><td>
|
1392
|
+
# <tr><td> group_id </td> <td> The ID of the group
|
1117
1393
|
# (string) </td></tr>
|
1118
1394
|
# </table>
|
1119
|
-
#
|
1120
|
-
#
|
1395
|
+
# <br />
|
1396
|
+
# **add_label**, **remove_label**:
|
1121
1397
|
# <table>
|
1122
|
-
# <tr><td>
|
1398
|
+
# <tr><td> label_id </td> <td> The ID of the label
|
1123
1399
|
# (string) </td></tr>
|
1124
1400
|
# </table>
|
1125
|
-
#
|
1126
|
-
#
|
1401
|
+
# <br />
|
1402
|
+
# **resend_messages**:
|
1127
1403
|
# <table>
|
1128
|
-
# <tr><td>
|
1129
|
-
#
|
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>
|
1130
1406
|
# </table>
|
1131
|
-
#
|
1132
|
-
#
|
1407
|
+
# <br />
|
1408
|
+
# **set_send_blocked**:
|
1133
1409
|
# <table>
|
1134
|
-
# <tr><td>
|
1135
|
-
# sending messages,
|
1410
|
+
# <tr><td> send_blocked </td> <td> true to block
|
1411
|
+
# sending messages, false to unblock sending messages (boolean) </td></tr>
|
1136
1412
|
# </table>
|
1137
|
-
#
|
1138
|
-
#
|
1413
|
+
# <br />
|
1414
|
+
# **set_conversation_status**:
|
1139
1415
|
# <table>
|
1140
|
-
# <tr><td>
|
1416
|
+
# <tr><td> conversation_status </td> <td> "active",
|
1141
1417
|
# "handled", or "closed" (string) </td></tr>
|
1142
1418
|
# </table>
|
1143
|
-
#
|
1144
|
-
#
|
1145
|
-
#
|
1419
|
+
# <br />
|
1420
|
+
# **export_contacts**, **export_messages**,
|
1421
|
+
# **export_rows**:
|
1146
1422
|
# <table>
|
1147
|
-
# <tr><td
|
1148
|
-
#
|
1423
|
+
# <tr><td>storage_id </td> <td> ID of a storage
|
1424
|
+
# provider where the CSV file will be saved. (string)
|
1149
1425
|
#
|
1150
1426
|
# Currently only AWS S3 is supported as a storage
|
1151
|
-
#
|
1427
|
+
# provider.
|
1152
1428
|
# This requires creating a S3 bucket in your own
|
1153
1429
|
# AWS account, as well as an IAM user with access key and secret that has permission
|
1154
1430
|
# to write to that bucket.
|
1155
|
-
#
|
1156
|
-
#
|
1431
|
+
# You can configure your own S3 bucket as a
|
1432
|
+
# storage provider on the <a href="/dashboard/a/storage">Storage Providers</a> page.
|
1157
1433
|
#
|
1158
1434
|
# Direct downloads are not supported when
|
1159
1435
|
# exporting data via the API.
|
1160
1436
|
# (string) </td></tr>
|
1161
|
-
# <tr><td
|
1162
|
-
#
|
1163
|
-
# <tr><td
|
1164
|
-
#
|
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
|
1165
1441
|
# strings, optional) </td></tr>
|
1166
1442
|
# </table>
|
1167
|
-
#
|
1168
|
-
#
|
1169
|
-
#
|
1443
|
+
# <br />
|
1444
|
+
# **delete_contacts**, **delete_messages**,
|
1445
|
+
# **delete_rows**, **cancel_messages**, **retry_message_services**: <br />
|
1170
1446
|
# No parameters.
|
1171
1447
|
#
|
1172
1448
|
# - filter_type
|
@@ -1575,20 +1851,22 @@ class Project < Entity
|
|
1575
1851
|
#
|
1576
1852
|
# - message_type
|
1577
1853
|
# * Filter scheduled messages by message_type
|
1578
|
-
# * Allowed values: sms, mms, ussd, call, service
|
1854
|
+
# * Allowed values: sms, mms, ussd, ussd_session, call, chat, service
|
1579
1855
|
#
|
1580
1856
|
# - time_created (UNIX timestamp)
|
1581
1857
|
# * Filter scheduled messages by time_created
|
1582
|
-
# * Allowed modifiers: time_created[
|
1858
|
+
# * Allowed modifiers: time_created[min], time_created[max]
|
1583
1859
|
#
|
1584
1860
|
# - next_time (UNIX timestamp)
|
1585
1861
|
# * Filter scheduled messages by next_time
|
1586
|
-
# * Allowed modifiers: next_time[
|
1587
|
-
#
|
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
|
1588
1866
|
#
|
1589
1867
|
# - sort
|
1590
1868
|
# * Sort the results based on a field
|
1591
|
-
# * Allowed values: default,
|
1869
|
+
# * Allowed values: default, next_time
|
1592
1870
|
# * Default: default
|
1593
1871
|
#
|
1594
1872
|
# - sort_dir
|
@@ -1612,6 +1890,52 @@ class Project < Entity
|
|
1612
1890
|
@api.cursor(ScheduledMessage, get_base_api_path() + "/scheduled", options)
|
1613
1891
|
end
|
1614
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
|
+
|
1615
1939
|
#
|
1616
1940
|
# Retrieves the scheduled message with the given ID.
|
1617
1941
|
#
|
@@ -1644,6 +1968,179 @@ class Project < Entity
|
|
1644
1968
|
return ScheduledMessage.new(@api, {'project_id' => self.id, 'id' => id}, false)
|
1645
1969
|
end
|
1646
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
|
+
|
1647
2144
|
#
|
1648
2145
|
# Queries services within the given project.
|
1649
2146
|
#
|
@@ -1720,6 +2217,114 @@ class Project < Entity
|
|
1720
2217
|
return Service.new(@api, {'project_id' => self.id, 'id' => id}, false)
|
1721
2218
|
end
|
1722
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
|
+
|
1723
2328
|
#
|
1724
2329
|
# Queries custom routes that can be used to send messages (not including Phones).
|
1725
2330
|
#
|
@@ -1880,6 +2485,195 @@ class Project < Entity
|
|
1880
2485
|
return AirtimeTransaction.new(@api, {'project_id' => self.id, 'id' => id}, false)
|
1881
2486
|
end
|
1882
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
|
+
|
1883
2677
|
#
|
1884
2678
|
# Saves any fields or custom variables that have changed for the project.
|
1885
2679
|
#
|
@@ -1903,10 +2697,34 @@ class Project < Entity
|
|
1903
2697
|
get('timezone_id')
|
1904
2698
|
end
|
1905
2699
|
|
2700
|
+
def timezone_id=(value)
|
2701
|
+
set('timezone_id', value)
|
2702
|
+
end
|
2703
|
+
|
1906
2704
|
def url_slug
|
1907
2705
|
get('url_slug')
|
1908
2706
|
end
|
1909
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
|
+
|
1910
2728
|
def organization_id
|
1911
2729
|
get('organization_id')
|
1912
2730
|
end
|