telerivet 1.8.2 → 1.9.6

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.
@@ -25,6 +25,7 @@ module Telerivet
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
+ # (required length: 3-18 characters)
28
29
  # * Updatable via API
29
30
  #
30
31
  # - default_route_id
@@ -41,6 +42,17 @@ module Telerivet
41
42
  # contact.
42
43
  # * Updatable via API
43
44
  #
45
+ # - message_retention_days (int)
46
+ # * Number of days to retain messages in this project. Messages older than this will be
47
+ # automatically deleted. If null, messages will be retained forever.
48
+ # * Updatable via API
49
+ #
50
+ # - short_link_scheme (bool)
51
+ # * If true (the default), short links in messages will include the scheme (e.g.,
52
+ # 'https://rvt.me/xxxxxxxxx'). If false, short links will not include the scheme (e.g.,
53
+ # 'rvt.me/xxxxxxxxx').
54
+ # * Updatable via API
55
+ #
44
56
  # - vars (Hash)
45
57
  # * Custom variables stored for this project. Variable names may be up to 32 characters
46
58
  # in length and can contain the characters a-z, A-Z, 0-9, and _.
@@ -53,6 +65,10 @@ module Telerivet
53
65
  # - organization_id (string, max 34 characters)
54
66
  # * ID of the organization this project belongs to
55
67
  # * Read-only
68
+ #
69
+ # - url
70
+ # * URL to this project in the Telerivet web app
71
+ # * Read-only
56
72
  #
57
73
  class Project < Entity
58
74
  #
@@ -93,7 +109,7 @@ class Project < Entity
93
109
  #
94
110
  # - replace_variables (bool)
95
111
  # * Set to true to evaluate variables like [[contact.name]] in message content. [(See
96
- # available variables)](#variables) (`is_template` parameter also accepted)
112
+ # available variables)](#variables)
97
113
  # * Default: false
98
114
  #
99
115
  # - track_clicks (boolean)
@@ -115,18 +131,15 @@ class Project < Entity
115
131
  # destination URL.
116
132
  # If null, the short links will not expire.
117
133
  #
118
- # - media_urls (array)
119
- # * URLs of media files to attach to the text message. If `message_type` is `sms`,
120
- # short links to each URL will be appended to the end of the content (separated by a
121
- # new line).
134
+ # - media (array)
135
+ # * Array of media attachments for the text message.
122
136
  #
137
+ # If sending a type of message that doesn't support attachments (e.g. SMS),
138
+ # short links to each media URL will be appended to the end of the content (separated
139
+ # by a new line).
123
140
  #
124
- # By default, each file must have a https:// or http:// URL, which requires the file
125
- # to be uploaded somewhere that is accessible via the internet. For media files that
126
- # are not already accessible via the internet, the media_urls parameter also supports
127
- # data URIs with the file data encoded via Base64 (e.g. "data:image/png;base64,..."),
128
- # with a maximum file size of 2 MB. To send media via data URIs, contact Telerivet to
129
- # request enabling the data URIs feature for your project.
141
+ # Alternatively, you can use the `media_urls` parameter with an array of URL
142
+ # strings.
130
143
  #
131
144
  # - route_params (Hash)
132
145
  # * Route-specific parameters for the message.
@@ -243,8 +256,8 @@ class Project < Entity
243
256
  # set)
244
257
  #
245
258
  # - replace_variables (bool)
246
- # * Set to true to evaluate variables like [[contact.name]] in message content [(See
247
- # available variables)](#variables) (`is_template` parameter also accepted)
259
+ # * Set to true to evaluate variables like [[contact.name]] in message content. [(See
260
+ # available variables)](#variables)
248
261
  # * Default: false
249
262
  #
250
263
  # - track_clicks (boolean)
@@ -266,18 +279,15 @@ class Project < Entity
266
279
  # destination URL.
267
280
  # If null, the short links will not expire.
268
281
  #
269
- # - media_urls (array)
270
- # * URLs of media files to attach to the text message. If `message_type` is `sms`,
271
- # short links to each URL will be appended to the end of the content (separated by a
272
- # new line).
282
+ # - media (array)
283
+ # * Array of media attachments for the text message.
273
284
  #
285
+ # If sending a type of message that doesn't support attachments (e.g. SMS),
286
+ # short links to each media URL will be appended to the end of the content (separated
287
+ # by a new line).
274
288
  #
275
- # By default, each file must have a https:// or http:// URL, which requires the file
276
- # to be uploaded somewhere that is accessible via the internet. For media files that
277
- # are not already accessible via the internet, the media_urls parameter also supports
278
- # data URIs with the file data encoded via Base64 (e.g. "data:image/png;base64,..."),
279
- # with a maximum file size of 2 MB. To send media via data URIs, contact Telerivet to
280
- # request enabling the data URIs feature for your project.
289
+ # Alternatively, you can use the `media_urls` parameter with an array of URL
290
+ # strings.
281
291
  #
282
292
  # - vars (Hash)
283
293
  # * Custom variables to set for each message
@@ -372,8 +382,8 @@ class Project < Entity
372
382
  # * Array of IDs of labels to add to each message (maximum 5)
373
383
  #
374
384
  # - replace_variables (bool)
375
- # * Set to true to evaluate variables like [[contact.name]] in message content [(See
376
- # available variables)](#variables) (`is_template` parameter also accepted)
385
+ # * Set to true to evaluate variables like [[contact.name]] in message content. [(See
386
+ # available variables)](#variables)
377
387
  # * Default: false
378
388
  #
379
389
  # - track_clicks (boolean)
@@ -395,18 +405,15 @@ class Project < Entity
395
405
  # destination URL.
396
406
  # If null, the short links will not expire.
397
407
  #
398
- # - media_urls (array)
399
- # * URLs of media files to attach to the text message. If `message_type` is `sms`,
400
- # short links to each URL will be appended to the end of the content (separated by a
401
- # new line).
408
+ # - media (array)
409
+ # * Array of media attachments for the text message.
402
410
  #
411
+ # If sending a type of message that doesn't support attachments (e.g. SMS),
412
+ # short links to each media URL will be appended to the end of the content (separated
413
+ # by a new line).
403
414
  #
404
- # By default, each file must have a https:// or http:// URL, which requires the file
405
- # to be uploaded somewhere that is accessible via the internet. For media files that
406
- # are not already accessible via the internet, the media_urls parameter also supports
407
- # data URIs with the file data encoded via Base64 (e.g. "data:image/png;base64,..."),
408
- # with a maximum file size of 2 MB. To send media via data URIs, contact Telerivet to
409
- # request enabling the data URIs feature for your project.
415
+ # Alternatively, you can use the `media_urls` parameter with an array of URL
416
+ # strings.
410
417
  #
411
418
  # - route_params (Hash)
412
419
  # * Route-specific parameters to apply to all messages.
@@ -497,7 +504,7 @@ class Project < Entity
497
504
  # should be provided.
498
505
  #
499
506
  # With `message_type`=`service`, schedules an automated service (such
500
- # as a poll) to be invoked for a group or list of phone numbers. Any service that can be
507
+ # as a poll) to be invoked for a group or an individual contact. Any service that can be
501
508
  # triggered for a contact can be scheduled via this method, whether or not the service
502
509
  # actually sends a message.
503
510
  #
@@ -587,22 +594,19 @@ class Project < Entity
587
594
  # If null, the short links will not expire.
588
595
  #
589
596
  # - replace_variables (bool)
590
- # * Set to true to evaluate variables like [[contact.name]] in message content
591
- # (`is_template` parameter also accepted)
597
+ # * Set to true to evaluate variables like [[contact.name]] in message content. [(See
598
+ # available variables)](#variables)
592
599
  # * Default: false
593
600
  #
594
- # - media_urls (array)
595
- # * URLs of media files to attach to the text message. If `message_type` is `sms`,
596
- # short links to each URL will be appended to the end of the content (separated by a
597
- # new line).
601
+ # - media (array)
602
+ # * Array of media attachments for the text message.
598
603
  #
604
+ # If sending a type of message that doesn't support attachments (e.g. SMS),
605
+ # short links to each media URL will be appended to the end of the content (separated
606
+ # by a new line).
599
607
  #
600
- # By default, each file must have a https:// or http:// URL, which requires the file
601
- # to be uploaded somewhere that is accessible via the internet. For media files that
602
- # are not already accessible via the internet, the media_urls parameter also supports
603
- # data URIs with the file data encoded via Base64 (e.g. "data:image/png;base64,..."),
604
- # with a maximum file size of 2 MB. To send media via data URIs, contact Telerivet to
605
- # request enabling the data URIs feature for your project.
608
+ # Alternatively, you can use the `media_urls` parameter with an array of URL
609
+ # strings.
606
610
  #
607
611
  # - route_params (Hash)
608
612
  # * Route-specific parameters to use when sending the message.
@@ -696,10 +700,10 @@ class Project < Entity
696
700
  # * Required
697
701
  #
698
702
  # - offset_scale
699
- # * The type of interval (day/week/month/year) that will be used to adjust the
700
- # scheduled date relative to the date stored in the contact's date_variable, when
701
- # offset_count is non-zero (D=day, W=week, M=month, Y=year)
702
- # * Allowed values: D, W, M, Y
703
+ # * The type of interval that will be used to adjust the scheduled date relative to
704
+ # the date stored in the contact's date_variable, when offset_count is non-zero
705
+ # (I=minutes, D=day, W=week, M=month, Y=year)
706
+ # * Allowed values: I, D, W, M, Y
703
707
  # * Default: D
704
708
  #
705
709
  # - offset_count (int)
@@ -764,21 +768,19 @@ class Project < Entity
764
768
  # If null, the short links will not expire.
765
769
  #
766
770
  # - replace_variables (bool)
767
- # * Set to true to evaluate variables like [[contact.name]] in message content
771
+ # * Set to true to evaluate variables like [[contact.name]] in message content. [(See
772
+ # available variables)](#variables)
768
773
  # * Default: false
769
774
  #
770
- # - media_urls (array)
771
- # * URLs of media files to attach to the text message. If `message_type` is `sms`,
772
- # short links to each URL will be appended to the end of the content (separated by a
773
- # new line).
775
+ # - media (array)
776
+ # * Array of media attachments for the text message.
774
777
  #
778
+ # If sending a type of message that doesn't support attachments (e.g. SMS),
779
+ # short links to each media URL will be appended to the end of the content (separated
780
+ # by a new line).
775
781
  #
776
- # By default, each file must have a https:// or http:// URL, which requires the file
777
- # to be uploaded somewhere that is accessible via the internet. For media files that
778
- # are not already accessible via the internet, the media_urls parameter also supports
779
- # data URIs with the file data encoded via Base64 (e.g. "data:image/png;base64,..."),
780
- # with a maximum file size of 2 MB. To send media via data URIs, contact Telerivet to
781
- # request enabling the data URIs feature for your project.
782
+ # Alternatively, you can use the `media_urls` parameter with an array of URL
783
+ # strings.
782
784
  #
783
785
  # - route_params (Hash)
784
786
  # * Route-specific parameters to use when sending the message.
@@ -1171,6 +1173,209 @@ class Project < Entity
1171
1173
  return Phone.new(@api, {'project_id' => self.id, 'id' => id}, false)
1172
1174
  end
1173
1175
 
1176
+ #
1177
+ # Creates a new basic route (phone) with external API credentials.
1178
+ #
1179
+ # For some external API providers, this method automatically updates webhook URLs configured
1180
+ # with the external provider so that incoming messages/calls and call status events are routed
1181
+ # to Telerivet. In this case, if you have already configured a webhook URL with the external
1182
+ # provider, it will be overwritten. For other external API providers, webhook URLs may require
1183
+ # manual configuration in order for the route to be fully functional.
1184
+ #
1185
+ # Note: This API can only create routes that connect to external gateway APIs using your own
1186
+ # account credentials. To add Android phones, WhatsApp routes, or routes with
1187
+ # Telerivet-managed billing, use the web app instead.
1188
+ #
1189
+ # Credentials are passed via the `external_account_id`, `external_id`, `external_secret`, and
1190
+ # `external_config` parameters. The meaning of these parameters for each phone type is as
1191
+ # follows:
1192
+ #
1193
+ # **Twilio Virtual Number** (`phone_type`: twilio):
1194
+ #
1195
+ # - external_id (optional): Twilio phone number SID (starts with 'PN'); looked up by
1196
+ # phone_number if not provided
1197
+ # - external_account_id (required): Twilio Account SID (starts with 'AC')
1198
+ # - external_secret (required): Twilio Auth Token
1199
+ #
1200
+ # **Twilio Messaging Service** (`phone_type`: twilio_messaging_service):
1201
+ #
1202
+ # - external_id (required): Twilio messaging service SID (starts with 'MG')
1203
+ # - external_account_id (required): Twilio Account SID (starts with 'AC')
1204
+ # - external_secret (required): Twilio Auth Token
1205
+ #
1206
+ # **Twilio Shortcode** (`phone_type`: twilio_shortcode):
1207
+ #
1208
+ # - external_id (optional): Twilio shortcode SID (starts with 'SC'); looked up by phone_number
1209
+ # if not provided
1210
+ # - external_account_id (required): Twilio Account SID (starts with 'AC')
1211
+ # - external_secret (required): Twilio Auth Token
1212
+ #
1213
+ # **Twilio Caller ID** (`phone_type`: twilio_caller_id):
1214
+ #
1215
+ # - external_account_id (required): Twilio Account SID (starts with 'AC')
1216
+ # - external_secret (required): Twilio Auth Token
1217
+ #
1218
+ # **Vonage Virtual Number** (`phone_type`: nexmo):
1219
+ #
1220
+ # - external_account_id (required): Vonage API Key
1221
+ # - external_secret (required): Vonage API Secret
1222
+ #
1223
+ # **Vonage Sender ID** (`phone_type`: nexmo_sender_id):
1224
+ #
1225
+ # - external_account_id (required): Vonage API Key
1226
+ # - external_secret (required): Vonage API Secret
1227
+ #
1228
+ # **Telesign SMS** (`phone_type`: telesign):
1229
+ #
1230
+ # - external_account_id (required): Telesign Customer ID
1231
+ # - external_secret (required): Telesign API Key
1232
+ # - external_config.message_type: ARN, MKT, or OTP
1233
+ # - external_config.sender_type: one_way (default) or two_way
1234
+ #
1235
+ # **Infobip SMS** (`phone_type`: infobip):
1236
+ #
1237
+ # - external_account_id (required): Infobip username
1238
+ # - external_secret (required): Infobip API key
1239
+ # - external_config.sender_type: one_way (default) or two_way
1240
+ # - external_config.india_dlt_principal_entity_id: India DLT Principal Entity ID (only for
1241
+ # India)
1242
+ #
1243
+ # **Infobip USSD** (`phone_type`: infobip_ussd):
1244
+ #
1245
+ # - No external credentials required
1246
+ #
1247
+ # **Africa's Talking SMS** (`phone_type`: africas_talking):
1248
+ #
1249
+ # - external_account_id (required): Africa's Talking username
1250
+ # - external_secret (required): Africa's Talking API key
1251
+ # - external_config.sender_type: one_way (default) or two_way
1252
+ #
1253
+ # **Africa's Talking USSD** (`phone_type`: africas_talking_ussd):
1254
+ #
1255
+ # - No external credentials required
1256
+ #
1257
+ # **Simulated Phone** (`phone_type`: simulated):
1258
+ #
1259
+ # - No external credentials required
1260
+ # - Messages are simulated locally and not sent to any external provider
1261
+ # - Useful for testing
1262
+ #
1263
+ # #### Webhook URL Setup
1264
+ #
1265
+ # Some route types require manual configuration of callback URLs in the external provider's
1266
+ # dashboard. When the Phone response includes an `external_setup` object, you will need to
1267
+ # configure the webhook URLs in your provider's account settings.
1268
+ #
1269
+ # The following phone types require manual webhook setup:
1270
+ #
1271
+ # - `africas_talking`: `message_status_url` (always), `incoming_message_url` (if two_way)
1272
+ # - `africas_talking_ussd`: `incoming_call_url`
1273
+ # - `infobip_ussd`: `incoming_call_url`
1274
+ # - `twilio_messaging_service`: `incoming_message_url`
1275
+ # - `telesign` (two_way only): `incoming_message_url`
1276
+ #
1277
+ # Telerivet automatically configures webhooks for the following phone types as follows:
1278
+ #
1279
+ # - `twilio` - automatically updates incoming SMS and voice configuration for the Twilio
1280
+ # virtual number associated with the phone_number or external_id parameter
1281
+ # - `twilio_shortcode` - automatically updates incoming SMS configuration for the Twilio short
1282
+ # code associated with the phone_number or external_id parameter
1283
+ # - `nexmo` - automatically updates incoming SMS and voice configuration for the Vonage
1284
+ # virtual number matching the phone_number parameter
1285
+ # - `infobip` - automatically updates incoming SMS configuration for the Infobip virtual
1286
+ # number matching the phone_number parameter or external_id parameter
1287
+ #
1288
+ # Arguments:
1289
+ # - options (Hash)
1290
+ # * Required
1291
+ #
1292
+ # - name (string)
1293
+ # * Name of the basic route to create
1294
+ #
1295
+ # - phone_number (string)
1296
+ # * Phone number or sender ID
1297
+ # * Required
1298
+ #
1299
+ # - phone_type (string)
1300
+ # * Type of basic route to create. Supported values: twilio, twilio_messaging_service,
1301
+ # twilio_shortcode, twilio_caller_id, nexmo, infobip, africas_talking,
1302
+ # africas_talking_ussd, infobip_ussd, telesign, simulated. Other types of basic routes
1303
+ # can only be created via the web app.
1304
+ # * Required
1305
+ #
1306
+ # - external_account_id (string)
1307
+ # * Account ID for the external API (e.g. Twilio Account SID, Vonage API Key). See the
1308
+ # description above for the meaning of this parameter for each phone type.
1309
+ #
1310
+ # - external_id (string)
1311
+ # * External phone/resource ID within the external API account (if applicable). For
1312
+ # `twilio` and `twilio_shortcode` routes, this is optional and will be looked up
1313
+ # automatically from the phone_number if not provided.
1314
+ #
1315
+ # - external_secret (string)
1316
+ # * Secret/API key for the external API (e.g. Twilio Auth Token, Vonage API Secret).
1317
+ # This value is required when creating a new route but is never returned in API
1318
+ # responses. See the description above for the meaning of this parameter for each
1319
+ # phone type.
1320
+ #
1321
+ # - external_config (Hash)
1322
+ # * Additional configuration settings specific to the phone_type. See the description
1323
+ # above for available settings for each phone type.
1324
+ #
1325
+ # - country
1326
+ # * 2-letter country code (ISO 3166-1 alpha-2) where phone is from. This country code
1327
+ # is used to automatically convert phone numbers in local format to international
1328
+ # format. If not provided, will be set to the organization's country by default.
1329
+ #
1330
+ # - send_paused (bool)
1331
+ # * True if sending messages should initially be paused, false otherwise
1332
+ # * Default:
1333
+ #
1334
+ # - timezone_id (string)
1335
+ # * A string specifying the time zone used when sending messages; see [List of tz
1336
+ # database time zones Wikipedia
1337
+ # article](http://en.wikipedia.org/wiki/List_of_tz_database_time_zones). When not
1338
+ # provided, the project's default time zone is used.
1339
+ #
1340
+ # - validate_recipient_numbers (bool)
1341
+ # * Set to true to validate recipient phone numbers before sending. Messages to
1342
+ # invalid numbers will fail without being sent.
1343
+ # * Default:
1344
+ #
1345
+ # - allowed_recipient_countries (array of strings)
1346
+ # * Array of 2-letter country codes (ISO 3166-1 alpha-2) to which this phone is
1347
+ # allowed to send messages. If not provided, there is no restriction.
1348
+ #
1349
+ # - send_delay (number)
1350
+ # * Number of seconds to wait after sending each message, to avoid exceeding carrier
1351
+ # rate limits.
1352
+ #
1353
+ # - quiet_mode (string)
1354
+ # * Controls behavior during quiet hours. Possible values: 'off' (disabled), 'delay'
1355
+ # (messages delayed until quiet hours end), 'confirm' (requires manual confirmation;
1356
+ # worker-based routes only).
1357
+ # * Allowed values: off, delay, confirm
1358
+ # * Default: off
1359
+ #
1360
+ # - quiet_start (string)
1361
+ # * Time when quiet hours begin, in HH:MM format (24-hour time). Only applicable when
1362
+ # quiet_mode is not 'off'.
1363
+ #
1364
+ # - quiet_end (string)
1365
+ # * Time when quiet hours end, in HH:MM format (24-hour time). Only applicable when
1366
+ # quiet_mode is not 'off'.
1367
+ #
1368
+ # - vars
1369
+ # * Custom variables and values to set for this basic route
1370
+ #
1371
+ # Returns:
1372
+ # Telerivet::Phone
1373
+ #
1374
+ def create_phone(options)
1375
+ require_relative 'phone'
1376
+ Phone.new(@api, @api.do_request("POST", get_base_api_path() + "/phones", options))
1377
+ end
1378
+
1174
1379
  #
1175
1380
  # Queries messages within the given project.
1176
1381
  #
@@ -1191,7 +1396,7 @@ class Project < Entity
1191
1396
  # - source
1192
1397
  # * Filter messages by source
1193
1398
  # * Allowed values: phone, provider, web, api, service, webhook, scheduled,
1194
- # integration
1399
+ # integration, mcp
1195
1400
  #
1196
1401
  # - starred (bool)
1197
1402
  # * Filter messages by starred/unstarred
@@ -1364,6 +1569,213 @@ class Project < Entity
1364
1569
  return Broadcast.new(@api, {'project_id' => self.id, 'id' => id}, false)
1365
1570
  end
1366
1571
 
1572
+ #
1573
+ # Queries campaigns within the given project.
1574
+ #
1575
+ # Arguments:
1576
+ # - options (Hash)
1577
+ #
1578
+ # - name
1579
+ # * Filter campaigns by name
1580
+ # * Allowed modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt],
1581
+ # name[lt], name[lte]
1582
+ #
1583
+ # - status
1584
+ # * Filter campaigns by status
1585
+ # * Allowed values: draft, scheduled, sent, pending_review
1586
+ #
1587
+ # - campaign_type
1588
+ # * Filter campaigns by type
1589
+ # * Allowed values: broadcast_text, broadcast_call, broadcast_svc, relative,
1590
+ # anniversary
1591
+ #
1592
+ # - group_id
1593
+ # * Filter campaigns by the recipient group
1594
+ #
1595
+ # - label_id
1596
+ # * Filter campaigns by an associated label
1597
+ #
1598
+ # - time_created[min] (UNIX timestamp)
1599
+ # * Filter campaigns created on or after a particular time
1600
+ #
1601
+ # - time_created[max] (UNIX timestamp)
1602
+ # * Filter campaigns created before a particular time
1603
+ #
1604
+ # - schedule_time[min] (UNIX timestamp)
1605
+ # * Filter broadcast campaigns scheduled on or after a particular time
1606
+ #
1607
+ # - schedule_time[max] (UNIX timestamp)
1608
+ # * Filter broadcast campaigns scheduled before a particular time
1609
+ #
1610
+ # - sort
1611
+ # * Sort the results based on a field
1612
+ # * Allowed values: default, name, schedule_time
1613
+ # * Default: default
1614
+ #
1615
+ # - sort_dir
1616
+ # * Sort the results in ascending or descending order
1617
+ # * Allowed values: asc, desc
1618
+ # * Default: asc
1619
+ #
1620
+ # - page_size (int)
1621
+ # * Number of results returned per page (max 500)
1622
+ # * Default: 50
1623
+ #
1624
+ # - offset (int)
1625
+ # * Number of items to skip from beginning of result set
1626
+ # * Default: 0
1627
+ #
1628
+ # Returns:
1629
+ # Telerivet::APICursor (of Telerivet::Campaign)
1630
+ #
1631
+ def query_campaigns(options = nil)
1632
+ require_relative 'campaign'
1633
+ @api.cursor(Campaign, get_base_api_path() + "/campaigns", options)
1634
+ end
1635
+
1636
+ #
1637
+ # Retrieves the campaign with the given ID.
1638
+ #
1639
+ # Arguments:
1640
+ # - id
1641
+ # * ID of the campaign
1642
+ # * Required
1643
+ #
1644
+ # Returns:
1645
+ # Telerivet::Campaign
1646
+ #
1647
+ def get_campaign_by_id(id)
1648
+ require_relative 'campaign'
1649
+ Campaign.new(@api, @api.do_request("GET", get_base_api_path() + "/campaigns/#{id}"))
1650
+ end
1651
+
1652
+ #
1653
+ # Initializes the Telerivet campaign with the given ID without making an API request.
1654
+ #
1655
+ # Arguments:
1656
+ # - id
1657
+ # * ID of the campaign
1658
+ # * Required
1659
+ #
1660
+ # Returns:
1661
+ # Telerivet::Campaign
1662
+ #
1663
+ def init_campaign_by_id(id)
1664
+ require_relative 'campaign'
1665
+ return Campaign.new(@api, {'project_id' => self.id, 'id' => id}, false)
1666
+ end
1667
+
1668
+ #
1669
+ # Creates a new draft campaign, without sending it.
1670
+ #
1671
+ # Arguments:
1672
+ # - options (Hash)
1673
+ # * Required
1674
+ #
1675
+ # - campaign_type
1676
+ # * Type of campaign to create
1677
+ # * Allowed values: broadcast_text, broadcast_call, broadcast_svc, relative,
1678
+ # anniversary
1679
+ # * Required
1680
+ #
1681
+ # - name
1682
+ # * Name of the campaign
1683
+ #
1684
+ # - group_id
1685
+ # * ID of the group of contacts to send the campaign to
1686
+ #
1687
+ # - exclude_group_id
1688
+ # * ID of a group of contacts to exclude from this campaign
1689
+ #
1690
+ # - route_id
1691
+ # * ID of the phone or route to send the campaign from
1692
+ #
1693
+ # - timezone_id
1694
+ # * ID of the timezone to use for scheduling
1695
+ #
1696
+ # - label_ids (array)
1697
+ # * IDs of labels to apply to messages sent by this campaign
1698
+ #
1699
+ # - respondent_group_id
1700
+ # * ID of the group to add contacts to after they respond
1701
+ #
1702
+ # - clicked_group_id
1703
+ # * ID of the group to add contacts to after they click a link
1704
+ #
1705
+ # - schedule_mode
1706
+ # * Indicates whether the campaign should be sent immediately or at a future time
1707
+ # (broadcast campaigns only). If `schedule_time` is set, `schedule_mode` is
1708
+ # automatically set to `at_time`. If `schedule_mode` is set to `immediate` or `null`,
1709
+ # `schedule_time` is automatically cleared.
1710
+ #
1711
+ # Note that the campaign will not actually be sent or
1712
+ # scheduled until the API method is called to [send the campaign](#Campaign.send).
1713
+ # * Allowed values: immediate, at_time
1714
+ #
1715
+ # - schedule_time (UNIX timestamp)
1716
+ # * When the campaign is scheduled to be sent, as a UNIX timestamp (broadcast
1717
+ # campaigns only). Setting this to a non-null value automatically sets `schedule_mode`
1718
+ # to `at_time`.
1719
+ #
1720
+ # Note that the campaign will not actually be scheduled
1721
+ # until the API method is called to [schedule the campaign](#Campaign.send).
1722
+ #
1723
+ # - content
1724
+ # * Text content of the message (`broadcast_text` campaigns), or the text-to-speech
1725
+ # text for voice calls (`broadcast_call` campaigns). May contain variables like
1726
+ # `[[contact.name]]`.
1727
+ #
1728
+ # [(See available variables)](#variables)
1729
+ #
1730
+ # - media (array)
1731
+ # * Array of media attachments (`broadcast_text` campaigns only).
1732
+ #
1733
+ # - route_params (Hash)
1734
+ # * Route-specific parameters for the message (`broadcast_text` campaigns only). See
1735
+ # [Route-Specific Parameters](#route_params).
1736
+ #
1737
+ # - track_clicks (boolean)
1738
+ # * Whether to shorten links and track link clicks (`broadcast_text` campaigns only).
1739
+ #
1740
+ # - short_link_params (Hash)
1741
+ # * Parameters for short links when `track_clicks` is enabled (`broadcast_text`
1742
+ # campaigns only).
1743
+ #
1744
+ # - audio_url
1745
+ # * URL of an MP3 file to play for voice calls (`broadcast_call` campaigns only).
1746
+ #
1747
+ # - tts_lang
1748
+ # * Language for text-to-speech voice calls (`broadcast_call` campaigns only).
1749
+ # * Allowed values: en-US, en-GB, en-GB-WLS, en-AU, en-IN, da-DK, nl-NL, fr-FR, fr-CA,
1750
+ # de-DE, is-IS, it-IT, pl-PL, pt-BR, pt-PT, ru-RU, es-ES, es-US, sv-SE
1751
+ #
1752
+ # - tts_voice
1753
+ # * Voice for text-to-speech voice calls (`broadcast_call` campaigns only).
1754
+ # * Allowed values: female, male
1755
+ #
1756
+ # - date_variable
1757
+ # * Custom contact variable storing date or date/time values relative to which
1758
+ # messages will be scheduled (`relative` and `anniversary` campaigns only)
1759
+ #
1760
+ # - items (array)
1761
+ # * Array of campaign items (`relative` and `anniversary` campaigns only).
1762
+ #
1763
+ # - vars (Hash)
1764
+ # * Custom variables and values to set for this campaign. Variable names may be up to
1765
+ # 32 characters in length and can contain the characters a-z, A-Z, 0-9, and _.
1766
+ # Values may be strings, numbers, or boolean (true/false).
1767
+ # String values may be up to 4096 bytes in length when encoded as UTF-8.
1768
+ # Up to 100 variables are supported per object.
1769
+ # Setting a variable to null will delete the variable.
1770
+ #
1771
+ # Returns:
1772
+ # Telerivet::Campaign
1773
+ #
1774
+ def create_campaign(options)
1775
+ require_relative 'campaign'
1776
+ Campaign.new(@api, @api.do_request("POST", get_base_api_path() + "/campaigns", options))
1777
+ end
1778
+
1367
1779
  #
1368
1780
  # Creates and starts an asynchronous task that is applied to all entities matching a filter
1369
1781
  # (e.g. contacts, messages, or data rows).
@@ -1691,7 +2103,9 @@ class Project < Entity
1691
2103
  end
1692
2104
 
1693
2105
  #
1694
- # Retrieves or creates a group by name.
2106
+ # Retrieves or creates a group by name. If a group with that name does not exist, a new normal
2107
+ # group will be created, initially empty. (To create a dynamic group, use
2108
+ # [project.createGroup](#Project.createGroup).)
1695
2109
  #
1696
2110
  # Arguments:
1697
2111
  # - name
@@ -1706,6 +2120,66 @@ class Project < Entity
1706
2120
  Group.new(@api, @api.do_request("POST", get_base_api_path() + "/groups", {'name' => name}))
1707
2121
  end
1708
2122
 
2123
+ #
2124
+ # Creates a new group.
2125
+ #
2126
+ # If the `filters` parameter is provided, the group will be a dynamic
2127
+ # group whose members are determined by the filter conditions. Otherwise, it will be a normal
2128
+ # group, initially empty, with the ability to manually add members via
2129
+ # [contact.addToGroup](#Contact.addToGroup) and remove members via
2130
+ # [contact.removeFromGroup](#Contact.removeFromGroup).
2131
+ #
2132
+ # Dynamic group filter conditions can later be updated via the
2133
+ # `filters` property of the Group object; a group cannot be converted between a normal group
2134
+ # and a dynamic group after it is created.
2135
+ #
2136
+ # Arguments:
2137
+ # - options (Hash)
2138
+ # * Required
2139
+ #
2140
+ # - name (string)
2141
+ # * Name of the group (must be unique within the project)
2142
+ # * Required
2143
+ #
2144
+ # - filters (Hash)
2145
+ # * Key-value pairs of conditions that contacts must match to be members of a dynamic
2146
+ # group. To filter by a custom variable, precede the variable name with 'vars.'
2147
+ # (conditions on custom variables may also be provided as a nested object under a
2148
+ # `vars` key, e.g. `{"vars": {"city": "Manila"}}`); other supported keys are `id`,
2149
+ # `name`, `phone_number`, `time_created`, `time_updated`, `incoming_message_count`,
2150
+ # `outgoing_message_count`, `last_incoming_message_time`,
2151
+ # `last_outgoing_message_time`, `conversation_status`, `send_blocked`, `group` (ID of
2152
+ # a normal group whose members should be included), `not_group` (ID of a normal group
2153
+ # whose members should be excluded), and `q` (full-text search query matching contacts
2154
+ # like the search box in the web app). Each value is either a value to match exactly,
2155
+ # or an object with an operator such as `ne`, `prefix`, `gte`, `lt`, `exists`, or
2156
+ # `not_exists` as the key (e.g. `{"gte": 10}`).
2157
+ #
2158
+ # - allow_sending (bool)
2159
+ # * True if messages can be sent to this group, false otherwise.
2160
+ # * Default: 1
2161
+ #
2162
+ # - add_time_variable (string)
2163
+ # * Variable name of a custom contact field that will automatically be set to the
2164
+ # current date/time on any contact that is added to the group. This variable will only
2165
+ # be set if the contact does not already have a value for this variable.
2166
+ #
2167
+ # - vars (Hash)
2168
+ # * Custom variables and values to set for this group. Variable names may be up to 32
2169
+ # characters in length and can contain the characters a-z, A-Z, 0-9, and _.
2170
+ # Values may be strings, numbers, or boolean (true/false).
2171
+ # String values may be up to 4096 bytes in length when encoded as UTF-8.
2172
+ # Up to 100 variables are supported per object.
2173
+ # Setting a variable to null will delete the variable.
2174
+ #
2175
+ # Returns:
2176
+ # Telerivet::Group
2177
+ #
2178
+ def create_group(options)
2179
+ require_relative 'group'
2180
+ Group.new(@api, @api.do_request("POST", get_base_api_path() + "/create_group", options))
2181
+ end
2182
+
1709
2183
  #
1710
2184
  # Retrieves the group with the given ID.
1711
2185
  #
@@ -1824,16 +2298,19 @@ class Project < Entity
1824
2298
  end
1825
2299
 
1826
2300
  #
1827
- # Queries data tables within the given project.
2301
+ # Queries message templates within the given project.
1828
2302
  #
1829
2303
  # Arguments:
1830
2304
  # - options (Hash)
1831
2305
  #
1832
2306
  # - name
1833
- # * Filter data tables by name
2307
+ # * Filter templates by name
1834
2308
  # * Allowed modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt],
1835
2309
  # name[lt], name[lte]
1836
2310
  #
2311
+ # - waba_id
2312
+ # * Filter templates by WhatsApp Business Account ID
2313
+ #
1837
2314
  # - sort
1838
2315
  # * Sort the results based on a field
1839
2316
  # * Allowed values: default, name
@@ -1853,57 +2330,315 @@ class Project < Entity
1853
2330
  # * Default: 0
1854
2331
  #
1855
2332
  # Returns:
1856
- # Telerivet::APICursor (of Telerivet::DataTable)
2333
+ # Telerivet::APICursor (of Telerivet::MessageTemplate)
1857
2334
  #
1858
- def query_data_tables(options = nil)
1859
- require_relative 'datatable'
1860
- @api.cursor(DataTable, get_base_api_path() + "/tables", options)
2335
+ def query_message_templates(options = nil)
2336
+ require_relative 'messagetemplate'
2337
+ @api.cursor(MessageTemplate, get_base_api_path() + "/message_templates", options)
1861
2338
  end
1862
2339
 
1863
2340
  #
1864
- # Gets or creates a data table by name.
2341
+ # Creates a new message template that can be used when composing or scheduling messages.
1865
2342
  #
1866
2343
  # Arguments:
1867
- # - name
1868
- # * Name of the data table
2344
+ # - options (Hash)
1869
2345
  # * Required
2346
+ #
2347
+ # - name (string)
2348
+ # * Name of the template (max 127 characters)
2349
+ # * Required
2350
+ #
2351
+ # - content (string)
2352
+ # * Content of the message template (max 2000 characters)
2353
+ # * Required
2354
+ #
2355
+ # - track_clicks (bool)
2356
+ # * If true, URLs in the content will be replaced with short links that track clicks.
2357
+ # Requires a plan with click tracking enabled.
2358
+ # * Default:
2359
+ #
2360
+ # - short_link_params (Hash)
2361
+ # * If `track_clicks` is true, `short_link_params` may be used to specify custom
2362
+ # parameters for each short link.
2363
+ #
2364
+ # - attachments (array)
2365
+ # * List of attachment objects with file URLs to include with the template
2366
+ #
2367
+ # - route_params (Hash)
2368
+ # * Route-specific parameters to use when sending messages with this template.
2369
+ #
2370
+ # When sending messages via chat apps such as WhatsApp, the route_params
2371
+ # parameter can be used to send messages with app-specific features such as quick
2372
+ # replies and link buttons.
2373
+ #
2374
+ # For more details, see [Route-Specific Parameters](#route_params).
1870
2375
  #
1871
2376
  # Returns:
1872
- # Telerivet::DataTable
2377
+ # Telerivet::MessageTemplate
1873
2378
  #
1874
- def get_or_create_data_table(name)
1875
- require_relative 'datatable'
1876
- DataTable.new(@api, @api.do_request("POST", get_base_api_path() + "/tables", {'name' => name}))
2379
+ def create_message_template(options)
2380
+ require_relative 'messagetemplate'
2381
+ MessageTemplate.new(@api, @api.do_request("POST", get_base_api_path() + "/message_templates", options))
1877
2382
  end
1878
2383
 
1879
2384
  #
1880
- # Retrieves the data table with the given ID.
2385
+ # Retrieves the message template with the given ID.
1881
2386
  #
1882
2387
  # Arguments:
1883
2388
  # - id
1884
- # * ID of the data table
2389
+ # * ID of the message template
1885
2390
  # * Required
1886
2391
  #
1887
2392
  # Returns:
1888
- # Telerivet::DataTable
2393
+ # Telerivet::MessageTemplate
1889
2394
  #
1890
- def get_data_table_by_id(id)
1891
- require_relative 'datatable'
1892
- DataTable.new(@api, @api.do_request("GET", get_base_api_path() + "/tables/#{id}"))
2395
+ def get_message_template_by_id(id)
2396
+ require_relative 'messagetemplate'
2397
+ MessageTemplate.new(@api, @api.do_request("GET", get_base_api_path() + "/message_templates/#{id}"))
1893
2398
  end
1894
2399
 
1895
2400
  #
1896
- # Initializes the data table with the given ID without making an API request.
2401
+ # Initializes the message template with the given ID without making an API request.
1897
2402
  #
1898
2403
  # Arguments:
1899
2404
  # - id
1900
- # * ID of the data table
2405
+ # * ID of the message template
1901
2406
  # * Required
1902
2407
  #
1903
2408
  # Returns:
1904
- # Telerivet::DataTable
2409
+ # Telerivet::MessageTemplate
1905
2410
  #
1906
- def init_data_table_by_id(id)
2411
+ def init_message_template_by_id(id)
2412
+ require_relative 'messagetemplate'
2413
+ return MessageTemplate.new(@api, {'project_id' => self.id, 'id' => id}, false)
2414
+ end
2415
+
2416
+ #
2417
+ # Queries files stored within the given project.
2418
+ #
2419
+ # Arguments:
2420
+ # - options (Hash)
2421
+ #
2422
+ # - filename
2423
+ # * Filter files by filename
2424
+ # * Allowed modifiers: filename[ne], filename[prefix], filename[not_prefix],
2425
+ # filename[gte], filename[gt], filename[lt], filename[lte]
2426
+ #
2427
+ # - type
2428
+ # * Filter files by MIME type. A type ending in `/*` matches any subtype (e.g.
2429
+ # `image/*`).
2430
+ #
2431
+ # - category
2432
+ # * Filter files by category
2433
+ # * Allowed values: outgoing_media, incoming_media, call_audio, test_recording,
2434
+ # script_module, icon
2435
+ #
2436
+ # - source
2437
+ # * Filter files by how they were created
2438
+ # * Allowed values: upload, recording, message, api
2439
+ #
2440
+ # - size (int)
2441
+ # * Filter files by size in bytes
2442
+ # * Allowed modifiers: size[min], size[max]
2443
+ #
2444
+ # - time_created (UNIX timestamp)
2445
+ # * Filter files by time_created
2446
+ # * Allowed modifiers: time_created[min], time_created[max]
2447
+ #
2448
+ # - message_id
2449
+ # * Filter files associated with a particular message
2450
+ #
2451
+ # - sha256
2452
+ # * Filter files by the SHA-256 hash of the file content (lowercase hex), e.g. to
2453
+ # check whether a particular file has already been uploaded
2454
+ #
2455
+ # - sort
2456
+ # * Sort the results based on a field
2457
+ # * Allowed values: default, filename, size, time_created
2458
+ # * Default: default
2459
+ #
2460
+ # - sort_dir
2461
+ # * Sort the results in ascending or descending order
2462
+ # * Allowed values: asc, desc
2463
+ # * Default: asc
2464
+ #
2465
+ # - page_size (int)
2466
+ # * Number of results returned per page (max 500)
2467
+ # * Default: 50
2468
+ #
2469
+ # - offset (int)
2470
+ # * Number of items to skip from beginning of result set
2471
+ # * Default: 0
2472
+ #
2473
+ # Returns:
2474
+ # Telerivet::APICursor (of Telerivet::StoredFile)
2475
+ #
2476
+ def query_files(options = nil)
2477
+ require_relative 'storedfile'
2478
+ @api.cursor(StoredFile, get_base_api_path() + "/files", options)
2479
+ end
2480
+
2481
+ #
2482
+ # Uploads a file to be stored by Telerivet.
2483
+ #
2484
+ # After uploading a file, it can be attached to an outgoing message by
2485
+ # passing its ID as a `file_id` item in the `media` parameter of
2486
+ # [project.sendMessage](#Project.sendMessage),
2487
+ # [project.sendBroadcast](#Project.sendBroadcast), or [project.sendMulti](#Project.sendMulti).
2488
+ # This makes it possible to upload a media file once and attach it to many messages, instead
2489
+ # of including the file content in every API request.
2490
+ #
2491
+ # The file content is provided inline via the `data` parameter,
2492
+ # encoded via Base64, with a maximum decoded file size of 5 MB. Image, video, audio, PDF, and
2493
+ # vCard files are supported.
2494
+ #
2495
+ # Files are deduplicated by content: if a file previously uploaded via
2496
+ # the API in the same project has the same content and MIME type, the existing stored file is
2497
+ # returned instead of creating a duplicate.
2498
+ #
2499
+ # Arguments:
2500
+ # - options (Hash)
2501
+ # * Required
2502
+ #
2503
+ # - data (string)
2504
+ # * Base64-encoded file content (max 5 MB decoded). Alternatively, a Base64 data URI
2505
+ # such as `data:image/jpeg;base64,...`, in which case the `type` parameter may be
2506
+ # omitted.
2507
+ # * Required
2508
+ #
2509
+ # - filename (string, max 127 characters)
2510
+ # * Filename of the stored file. If not provided, the filename is generated
2511
+ # automatically.
2512
+ #
2513
+ # - type (string)
2514
+ # * MIME type of the file, e.g. `image/jpeg`. If `data` is a data URI, the type may be
2515
+ # omitted, but must match the MIME type of the data URI if provided.
2516
+ # * Required unless `data` is a data URI
2517
+ #
2518
+ # - description (string, max 1000 characters)
2519
+ # * Description of the file
2520
+ #
2521
+ # Returns:
2522
+ # Telerivet::StoredFile
2523
+ #
2524
+ def upload_file(options)
2525
+ require_relative 'storedfile'
2526
+ StoredFile.new(@api, @api.do_request("POST", get_base_api_path() + "/files", options))
2527
+ end
2528
+
2529
+ #
2530
+ # Retrieves the stored file with the given ID.
2531
+ #
2532
+ # Arguments:
2533
+ # - id
2534
+ # * ID of the stored file
2535
+ # * Required
2536
+ #
2537
+ # Returns:
2538
+ # Telerivet::StoredFile
2539
+ #
2540
+ def get_file_by_id(id)
2541
+ require_relative 'storedfile'
2542
+ StoredFile.new(@api, @api.do_request("GET", get_base_api_path() + "/files/#{id}"))
2543
+ end
2544
+
2545
+ #
2546
+ # Initializes the stored file with the given ID without making an API request.
2547
+ #
2548
+ # Arguments:
2549
+ # - id
2550
+ # * ID of the stored file
2551
+ # * Required
2552
+ #
2553
+ # Returns:
2554
+ # Telerivet::StoredFile
2555
+ #
2556
+ def init_file_by_id(id)
2557
+ require_relative 'storedfile'
2558
+ return StoredFile.new(@api, {'project_id' => self.id, 'id' => id}, false)
2559
+ end
2560
+
2561
+ #
2562
+ # Queries data tables within the given project.
2563
+ #
2564
+ # Arguments:
2565
+ # - options (Hash)
2566
+ #
2567
+ # - name
2568
+ # * Filter data tables by name
2569
+ # * Allowed modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt],
2570
+ # name[lt], name[lte]
2571
+ #
2572
+ # - sort
2573
+ # * Sort the results based on a field
2574
+ # * Allowed values: default, name
2575
+ # * Default: default
2576
+ #
2577
+ # - sort_dir
2578
+ # * Sort the results in ascending or descending order
2579
+ # * Allowed values: asc, desc
2580
+ # * Default: asc
2581
+ #
2582
+ # - page_size (int)
2583
+ # * Number of results returned per page (max 500)
2584
+ # * Default: 50
2585
+ #
2586
+ # - offset (int)
2587
+ # * Number of items to skip from beginning of result set
2588
+ # * Default: 0
2589
+ #
2590
+ # Returns:
2591
+ # Telerivet::APICursor (of Telerivet::DataTable)
2592
+ #
2593
+ def query_data_tables(options = nil)
2594
+ require_relative 'datatable'
2595
+ @api.cursor(DataTable, get_base_api_path() + "/tables", options)
2596
+ end
2597
+
2598
+ #
2599
+ # Gets or creates a data table by name.
2600
+ #
2601
+ # Arguments:
2602
+ # - name
2603
+ # * Name of the data table
2604
+ # * Required
2605
+ #
2606
+ # Returns:
2607
+ # Telerivet::DataTable
2608
+ #
2609
+ def get_or_create_data_table(name)
2610
+ require_relative 'datatable'
2611
+ DataTable.new(@api, @api.do_request("POST", get_base_api_path() + "/tables", {'name' => name}))
2612
+ end
2613
+
2614
+ #
2615
+ # Retrieves the data table with the given ID.
2616
+ #
2617
+ # Arguments:
2618
+ # - id
2619
+ # * ID of the data table
2620
+ # * Required
2621
+ #
2622
+ # Returns:
2623
+ # Telerivet::DataTable
2624
+ #
2625
+ def get_data_table_by_id(id)
2626
+ require_relative 'datatable'
2627
+ DataTable.new(@api, @api.do_request("GET", get_base_api_path() + "/tables/#{id}"))
2628
+ end
2629
+
2630
+ #
2631
+ # Initializes the data table with the given ID without making an API request.
2632
+ #
2633
+ # Arguments:
2634
+ # - id
2635
+ # * ID of the data table
2636
+ # * Required
2637
+ #
2638
+ # Returns:
2639
+ # Telerivet::DataTable
2640
+ #
2641
+ def init_data_table_by_id(id)
1907
2642
  require_relative 'datatable'
1908
2643
  return DataTable.new(@api, {'project_id' => self.id, 'id' => id}, false)
1909
2644
  end
@@ -2065,19 +2800,144 @@ class Project < Entity
2065
2800
  return RelativeScheduledMessage.new(@api, {'project_id' => self.id, 'id' => id}, false)
2066
2801
  end
2067
2802
 
2803
+ #
2804
+ # Queries scheduled services within the given project.
2805
+ #
2806
+ # Arguments:
2807
+ # - options (Hash)
2808
+ #
2809
+ # - service_id
2810
+ # * Filter scheduled services by the service ID
2811
+ #
2812
+ # - time_created (UNIX timestamp)
2813
+ # * Filter scheduled services by time_created
2814
+ # * Allowed modifiers: time_created[min], time_created[max]
2815
+ #
2816
+ # - next_time (UNIX timestamp)
2817
+ # * Filter scheduled services by next_time
2818
+ # * Allowed modifiers: next_time[min], next_time[max]
2819
+ #
2820
+ # - sort
2821
+ # * Sort the results based on a field
2822
+ # * Allowed values: default, next_time
2823
+ # * Default: default
2824
+ #
2825
+ # - sort_dir
2826
+ # * Sort the results in ascending or descending order
2827
+ # * Allowed values: asc, desc
2828
+ # * Default: asc
2829
+ #
2830
+ # - page_size (int)
2831
+ # * Number of results returned per page (max 500)
2832
+ # * Default: 50
2833
+ #
2834
+ # - offset (int)
2835
+ # * Number of items to skip from beginning of result set
2836
+ # * Default: 0
2837
+ #
2838
+ # Returns:
2839
+ # Telerivet::APICursor (of Telerivet::ScheduledService)
2840
+ #
2841
+ def query_scheduled_services(options = nil)
2842
+ require_relative 'scheduledservice'
2843
+ @api.cursor(ScheduledService, get_base_api_path() + "/scheduled_services", options)
2844
+ end
2845
+
2846
+ #
2847
+ # Schedules a service to be triggered at a specified time.
2848
+ #
2849
+ # Only services that can be triggered for the project context and
2850
+ # handle the default event can be scheduled. This includes services with types
2851
+ # `scheduled_actions`, `scheduled_script`, and other service types that support project-level
2852
+ # triggering.
2853
+ #
2854
+ # (Note: To schedule services that are triggered for a contact,
2855
+ # [project.scheduleMessage](#Project.scheduleMessage) should be used instead with
2856
+ # `message_type`=`service`.)
2857
+ #
2858
+ # Arguments:
2859
+ # - options (Hash)
2860
+ # * Required
2861
+ #
2862
+ # - service_id
2863
+ # * ID of the service to schedule
2864
+ # * Required
2865
+ #
2866
+ # - start_time (UNIX timestamp)
2867
+ # * The time that the service will be triggered (or first triggered for recurring
2868
+ # scheduled services)
2869
+ # * Required if start_time_offset not set
2870
+ #
2871
+ # - start_time_offset (int)
2872
+ # * Number of seconds from now to trigger the service
2873
+ #
2874
+ # - rrule
2875
+ # * A recurrence rule describing how the schedule repeats, e.g. 'FREQ=MONTHLY' or
2876
+ # 'FREQ=WEEKLY;INTERVAL=2'; see <https://tools.ietf.org/html/rfc2445#section-4.3.10>.
2877
+ # (UNTIL is ignored; use end_time parameter instead).
2878
+ # * Default: COUNT=1 (one-time scheduled service, does not repeat)
2879
+ #
2880
+ # - timezone_id
2881
+ # * TZ database timezone ID; see [List of tz database time zones Wikipedia
2882
+ # article](http://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
2883
+ # * Default: project default timezone
2884
+ #
2885
+ # - end_time (UNIX timestamp)
2886
+ # * Time after which a recurring scheduled service will stop (not applicable to
2887
+ # non-recurring scheduled services)
2888
+ #
2889
+ # - end_time_offset (int)
2890
+ # * Number of seconds from now until the recurring scheduled service will stop
2891
+ #
2892
+ # - vars (Hash)
2893
+ # * Custom variables to store for this scheduled service
2894
+ #
2895
+ # Returns:
2896
+ # Telerivet::ScheduledService
2897
+ #
2898
+ def schedule_service(options)
2899
+ require_relative 'scheduledservice'
2900
+ ScheduledService.new(@api, @api.do_request("POST", get_base_api_path() + "/scheduled_services", options))
2901
+ end
2902
+
2903
+ #
2904
+ # Retrieves the scheduled service with the given ID.
2905
+ #
2906
+ # Arguments:
2907
+ # - id
2908
+ # * ID of the scheduled service
2909
+ # * Required
2910
+ #
2911
+ # Returns:
2912
+ # Telerivet::ScheduledService
2913
+ #
2914
+ def get_scheduled_service_by_id(id)
2915
+ require_relative 'scheduledservice'
2916
+ ScheduledService.new(@api, @api.do_request("GET", get_base_api_path() + "/scheduled_services/#{id}"))
2917
+ end
2918
+
2919
+ #
2920
+ # Initializes the scheduled service with the given ID without making an API request.
2921
+ #
2922
+ # Arguments:
2923
+ # - id
2924
+ # * ID of the scheduled service
2925
+ # * Required
2926
+ #
2927
+ # Returns:
2928
+ # Telerivet::ScheduledService
2929
+ #
2930
+ def init_scheduled_service_by_id(id)
2931
+ require_relative 'scheduledservice'
2932
+ return ScheduledService.new(@api, {'project_id' => self.id, 'id' => id}, false)
2933
+ end
2934
+
2068
2935
  #
2069
2936
  # Creates a new automated service.
2070
2937
  #
2071
2938
  # Only certain types of automated services can be created via the API.
2072
2939
  # Other types of services can only be created via the web app.
2073
2940
  #
2074
- # Although Custom Actions services cannot be created directly via the
2075
- # API, they may be converted to a template,
2076
- # and then instances of the template can be created via this method
2077
- # with `service_type`=`custom_template_instance`. Converting a service
2078
- # to a template requires the Service Templates feature to be enabled
2079
- # for the organization.
2080
- #
2081
2941
  # Arguments:
2082
2942
  # - options (Hash)
2083
2943
  # * Required
@@ -2090,63 +2950,43 @@ class Project < Entity
2090
2950
  # * Type of service to create. The following service types can be created via the
2091
2951
  # API:
2092
2952
  #
2953
+ # - incoming_message_actions
2954
+ # - contact_actions
2955
+ # - message_actions
2956
+ # - project_actions
2957
+ # - message_status_actions
2958
+ # - voice_actions
2959
+ # - ussd_actions
2960
+ # - data_row_actions
2093
2961
  # - incoming_message_webhook
2962
+ # - optin_optout
2963
+ # - keyword_auto_reply
2094
2964
  # - messaging_poll
2965
+ # - voice_poll
2966
+ # - scheduled_actions
2967
+ # - auto_reply
2968
+ # - call_auto_reply
2095
2969
  # - incoming_message_script
2096
2970
  # - contact_script
2097
2971
  # - message_script
2098
2972
  # - data_row_script
2973
+ # - scheduled_script
2099
2974
  # - webhook_script
2100
2975
  # - voice_script
2101
2976
  # - ussd_script
2102
2977
  # - project_script
2978
+ # - opt_out_page
2979
+ # - button_page
2103
2980
  # - custom_template_instance
2104
2981
  #
2105
2982
  # Other types of services can only be created via the web app.
2106
2983
  # * Required
2107
2984
  #
2108
2985
  # - config (Hash)
2109
- # * Configuration specific to the service `type`.
2110
- #
2111
- # **incoming_message_webhook**:
2112
- # <table>
2113
- # <tr><td> url </td> <td> The webhook URL that will be
2114
- # triggered when an incoming message is received (string) </td></tr>
2115
- # <tr><td> secret </td> <td> Optional string that will
2116
- # be passed as the `secret` POST parameter to the webhook URL. (object) </td></tr>
2117
- # </table>
2118
- # <br />
2119
- #
2120
- # **incoming_message_script, contact_script,
2121
- # message_script, data_row_script, webhook_script, voice_script, ussd_script,
2122
- # project_script**:
2123
- # <table>
2124
- # <tr><td> code </td> <td> The JavaScript code to run
2125
- # when the service is triggered (max 100 KB). To run code longer than 100 KB, use a
2126
- # Cloud Script Module. (string) </td></tr>
2127
- # </table>
2128
- # <br />
2129
- #
2130
- # **custom_template_instance**:
2131
- # <table>
2132
- # <tr><td> template_service_id </td> <td> ID of the
2133
- # service template (string). The service template must be available to the current
2134
- # project or organization.</td></tr>
2135
- # <tr><td> params </td> <td> Key/value pairs for all
2136
- # service template parameters (object). If the values satisfy the validation rules
2137
- # specified in the service template, they will also be copied to the `vars` property
2138
- # of the service. Any values not associated with service template parameters will be
2139
- # ignored.
2140
- # </td></tr>
2141
- # </table>
2142
- # <br />
2143
- #
2144
- # **messaging_poll**:
2145
- # <br />
2146
- # The configuration parameters for poll services are
2147
- # not yet documented, but can be determined by creating a poll via the web app and
2148
- # then retrieving the configuration via [service.getConfig](#Service.getConfig).
2149
- # <br />
2986
+ # * Configuration specific to the `service_type`. See [Service Configuration
2987
+ # Reference](#service_config) or the machine-readable [OpenAPI
2988
+ # specification](https://api.telerivet.com/openapi.json) for complete documentation of
2989
+ # configuration parameters for each service type.
2150
2990
  # * Required
2151
2991
  #
2152
2992
  # - vars
@@ -2176,7 +3016,21 @@ class Project < Entity
2176
3016
  # - message_types (array)
2177
3017
  # * Types of messages that this service should handle. Only applies to services that
2178
3018
  # handle incoming messages.
2179
- # * Allowed values: text, call, sms, mms, ussd_session, chat
3019
+ # * Allowed values: text, call, ussd
3020
+ #
3021
+ # - table_ids (array)
3022
+ # * IDs of data tables that this service applies to, or null to apply to all data
3023
+ # tables. Only applies to data row services (`data_row_script` and
3024
+ # `data_row_actions`).
3025
+ #
3026
+ # - message_statuses (array of strings)
3027
+ # * Message statuses that this service should handle. Only applies to
3028
+ # `message_status_actions` services.
3029
+ # * Allowed values: sent, delivered, failed, failed_queued, not_delivered
3030
+ #
3031
+ # - tags (array of strings)
3032
+ # * Tags used to organize this service. Each tag can be up to 32 characters in length,
3033
+ # and up to 10 tags are allowed.
2180
3034
  #
2181
3035
  # - show_action (bool)
2182
3036
  # * Whether to show this service in the Actions menu within the Telerivet web app when
@@ -2235,7 +3089,8 @@ class Project < Entity
2235
3089
  #
2236
3090
  # - context
2237
3091
  # * Filter services that can be invoked in a particular context
2238
- # * Allowed values: message, call, ussd_session, row, contact, project
3092
+ # * Allowed values: message, call, ussd_session, row, contact, project,
3093
+ # airtime_transaction
2239
3094
  #
2240
3095
  # - sort
2241
3096
  # * Sort the results based on a field
@@ -2440,6 +3295,48 @@ class Project < Entity
2440
3295
  @api.cursor(Route, get_base_api_path() + "/routes", options)
2441
3296
  end
2442
3297
 
3298
+ #
3299
+ # Returns a list of all available routes for sending messages in a project, including both
3300
+ # basic routes (phones) and custom routes.
3301
+ #
3302
+ # Returns:
3303
+ # array
3304
+ #
3305
+ def get_route_list()
3306
+ return @api.do_request("GET", get_base_api_path() + "/route_list")
3307
+ end
3308
+
3309
+ #
3310
+ # Creates a new custom route that can be used to send messages via one or more basic routes
3311
+ # (phones).
3312
+ #
3313
+ # The `actions` array defines the routing rules.
3314
+ #
3315
+ # Arguments:
3316
+ # - options (Hash)
3317
+ # * Required
3318
+ #
3319
+ # - name (string)
3320
+ # * Name of the custom route to create
3321
+ # * Required
3322
+ #
3323
+ # - actions (array of RoutingAction)
3324
+ # * Array of routing action objects. Allowed action types: `use_phone` (select basic
3325
+ # routes to send messages), `condition` (conditionally execute actions based on
3326
+ # criteria).
3327
+ # * Required
3328
+ #
3329
+ # - vars
3330
+ # * Custom variables and values to set for this route
3331
+ #
3332
+ # Returns:
3333
+ # Telerivet::Route
3334
+ #
3335
+ def create_route(options)
3336
+ require_relative 'route'
3337
+ Route.new(@api, @api.do_request("POST", get_base_api_path() + "/routes", options))
3338
+ end
3339
+
2443
3340
  #
2444
3341
  # Gets a custom route by ID
2445
3342
  #
@@ -2565,9 +3462,9 @@ class Project < Entity
2565
3462
 
2566
3463
  #
2567
3464
  # Gets a list of all custom fields defined for contacts in this project. The return value is
2568
- # an array of objects with the properties 'name', 'variable', 'type', 'order', 'readonly', and
2569
- # 'lookup_key'. (Fields are automatically created any time a Contact's 'vars' property is
2570
- # updated.)
3465
+ # an array of objects with the properties 'name', 'variable', 'type', 'order', 'readonly',
3466
+ # 'lookup_key', and 'show_on_conversation'. (Fields are automatically created any time a
3467
+ # Contact's 'vars' property is updated.)
2571
3468
  #
2572
3469
  # Returns:
2573
3470
  # array
@@ -2603,9 +3500,9 @@ class Project < Entity
2603
3500
  #
2604
3501
  # - items (array)
2605
3502
  # * Array of up to 100 objects containing `value` and `label` string properties to
2606
- # show in the dropdown list when type is `select`. Each `value` and `label` must be
2607
- # between 1 and 256 characters in length.
2608
- # * Required if type is `select`
3503
+ # show when type is `select` or `radio`. Each `value` and `label` must be between 1
3504
+ # and 256 characters in length.
3505
+ # * Required if type is `select` or `radio`
2609
3506
  #
2610
3507
  # - readonly (bool)
2611
3508
  # * Set to true to prevent editing the field in the Telerivet web app
@@ -2624,10 +3521,35 @@ class Project < Entity
2624
3521
  return @api.do_request("POST", get_base_api_path() + "/contact_fields/#{variable}", options)
2625
3522
  end
2626
3523
 
3524
+ #
3525
+ # Updates metadata for one or more custom contact fields. Only the specified fields are
3526
+ # updated; other fields are not affected.
3527
+ #
3528
+ # To delete a field, include an object with the `variable` and
3529
+ # `delete` properties set (e.g. `{"variable": "my_field", "delete": true}`). Deleting a field
3530
+ # will also clear the corresponding variable on all contacts in the project.
3531
+ #
3532
+ # Arguments:
3533
+ # - options (Hash)
3534
+ # * Required
3535
+ #
3536
+ # - metadata (array)
3537
+ # * Array of up to 100 objects describing the fields to create, update, or delete.
3538
+ # Each object must contain a `variable` property. Only the properties provided for
3539
+ # each field will be updated.
3540
+ # * Required
3541
+ #
3542
+ # Returns:
3543
+ # array
3544
+ #
3545
+ def update_contact_fields(options)
3546
+ return @api.do_request("POST", get_base_api_path() + "/contact_fields", options)
3547
+ end
3548
+
2627
3549
  #
2628
3550
  # Gets a list of all custom fields defined for messages in this project. The return value is
2629
- # an array of objects with the properties 'name', 'variable', 'type', 'order', 'readonly', and
2630
- # 'lookup_key'. (Fields are automatically created any time a Contact's 'vars' property is
3551
+ # an array of objects with the properties 'name', 'variable', 'type', 'order', and
3552
+ # 'hide_values'. (Fields are automatically created any time a Message's 'vars' property is
2631
3553
  # updated.)
2632
3554
  #
2633
3555
  # Returns:
@@ -2664,9 +3586,9 @@ class Project < Entity
2664
3586
  #
2665
3587
  # - items (array)
2666
3588
  # * Array of up to 100 objects containing `value` and `label` string properties to
2667
- # show in the dropdown list when type is `select`. Each `value` and `label` must be
2668
- # between 1 and 256 characters in length.
2669
- # * Required if type is `select`
3589
+ # show when type is `select` or `radio`. Each `value` and `label` must be between 1
3590
+ # and 256 characters in length.
3591
+ # * Required if type is `select` or `radio`
2670
3592
  #
2671
3593
  # - hide_values (bool)
2672
3594
  # * Set to true to avoid showing values of this field on the Messages page
@@ -2678,10 +3600,36 @@ class Project < Entity
2678
3600
  return @api.do_request("POST", get_base_api_path() + "/message_fields/#{variable}", options)
2679
3601
  end
2680
3602
 
3603
+ #
3604
+ # Updates metadata for one or more custom message fields. Only the specified fields are
3605
+ # updated; other fields are not affected.
3606
+ #
3607
+ # To delete a field, include an object with the `variable` and
3608
+ # `delete` properties set (e.g. `{"variable": "my_field", "delete": true}`). Deleting a field
3609
+ # removes the metadata only; values stored on individual messages are not affected.
3610
+ #
3611
+ # Arguments:
3612
+ # - options (Hash)
3613
+ # * Required
3614
+ #
3615
+ # - metadata (array)
3616
+ # * Array of up to 100 objects describing the fields to create, update, or delete.
3617
+ # Each object must contain a `variable` property. Only the properties provided for
3618
+ # each field will be updated.
3619
+ # * Required
3620
+ #
3621
+ # Returns:
3622
+ # array
3623
+ #
3624
+ def update_message_fields(options)
3625
+ return @api.do_request("POST", get_base_api_path() + "/message_fields", options)
3626
+ end
3627
+
2681
3628
  #
2682
3629
  # Retrieves statistics about messages sent or received via Telerivet. This endpoint returns
2683
- # historical data that is computed shortly after midnight each day in the project's time zone,
2684
- # and does not contain message statistics for the current day.
3630
+ # historical data that is computed shortly after midnight each day in the project's time zone.
3631
+ # If the date range includes the current day, it will include statistics for the current day
3632
+ # so far.
2685
3633
  #
2686
3634
  # Arguments:
2687
3635
  # - options (Hash)
@@ -2708,16 +3656,14 @@ class Project < Entity
2708
3656
  #
2709
3657
  # - metrics (string)
2710
3658
  # * Comma separated list of metrics to return (summed for each distinct value of the
2711
- # requested properties)
2712
- # * Allowed values: count, num_parts, duration, price
3659
+ # requested properties). Supported metrics are `count` (the number of messages),
3660
+ # `num_parts` (the number of SMS parts), `duration` (the total duration of calls, in
3661
+ # seconds), and `price.<currency>` (the total price of messages priced in the
3662
+ # specified ISO 4217 currency, e.g. `price.USD`). Amounts are not converted between
3663
+ # currencies: each `price.<currency>` metric only includes messages priced in the
3664
+ # specified currency.
2713
3665
  # * Required
2714
3666
  #
2715
- # - currency (string)
2716
- # * Three-letter ISO 4217 currency code used when returning the 'price' field. If the
2717
- # original price was in a different currency, it will be converted to the requested
2718
- # currency using the approximate current exchange rate.
2719
- # * Default: USD
2720
- #
2721
3667
  # - filters (Hash)
2722
3668
  # * Key-value pairs of properties and corresponding values; the returned statistics
2723
3669
  # will only include messages where the property matches the provided value. Only the
@@ -2729,35 +3675,263 @@ class Project < Entity
2729
3675
  # - intervals (array)
2730
3676
  # * List of objects representing each date interval containing at least one message
2731
3677
  # matching the filters.
2732
- # Each object has the following properties:
2733
- #
2734
- # <table>
2735
- # <tr><td> start_time </td> <td> The UNIX timestamp of the start
2736
- # of the interval (int) </td></tr>
2737
- # <tr><td> end_time </td> <td> The UNIX timestamp of the end of
2738
- # the interval, exclusive (int) </td></tr>
2739
- # <tr><td> start_date </td> <td> The date of the start of the
2740
- # interval in YYYY-MM-DD format (string) </td></tr>
2741
- # <tr><td> end_date </td> <td> The date of the end of the
2742
- # interval in YYYY-MM-DD format, inclusive (string) </td></tr>
2743
- # <tr><td> groups </td> <td> Array of groups for each
2744
- # combination of requested property values matching the filters (array)
2745
- # <br /><br />
2746
- # Each object has the following properties:
2747
- # <table>
2748
- # <tr><td> properties </td> <td> An object of key/value
2749
- # pairs for each distinct value of the requested properties (object) </td></tr>
2750
- # <tr><td> metrics </td> <td> An object of key/value pairs
2751
- # for each requested metric (object) </td></tr>
2752
- # </table>
2753
- # </td></tr>
2754
- # </table>
2755
3678
  #
2756
3679
  def get_message_stats(options)
2757
3680
  data = @api.do_request("GET", get_base_api_path() + "/message_stats", options)
2758
3681
  return data
2759
3682
  end
2760
3683
 
3684
+ #
3685
+ # Retrieves statistics about the number of contacts in the project (total or in particular
3686
+ # groups) over a date range. This endpoint returns historical data that is computed shortly
3687
+ # after midnight each day in the project's time zone. If the date range includes the current
3688
+ # day, it will include the current number of contacts.
3689
+ #
3690
+ # To get historical statistics for the number of contacts matching a
3691
+ # filter, use [project.createGroup](#Project.createGroup) to create a dynamic group for each
3692
+ # filter you want to track. However, the statistics will only be available for dates after the
3693
+ # dynamic group was created.
3694
+ #
3695
+ # Arguments:
3696
+ # - options (Hash)
3697
+ # * Required
3698
+ #
3699
+ # - start_date (string)
3700
+ # * Start date of contact statistics, in YYYY-MM-DD format
3701
+ # * Required
3702
+ #
3703
+ # - end_date (string)
3704
+ # * End date of contact statistics (inclusive), in YYYY-MM-DD format
3705
+ # * Required
3706
+ #
3707
+ # - rollup (string)
3708
+ # * Date interval to group by
3709
+ # * Allowed values: day, week, month, year
3710
+ # * Default: day
3711
+ #
3712
+ # - cumulative (bool)
3713
+ # * If true, each interval contains the total number of contacts at the end of the
3714
+ # interval; if false, each interval contains the change in the number of contacts
3715
+ # during the interval.
3716
+ # * Default: 1
3717
+ #
3718
+ # - series (string)
3719
+ # * Comma separated list of up to 10 data series to return, corresponding to the keys
3720
+ # of the `values` object in the response. Each item is either `total` (the total
3721
+ # number of contacts in the project) or a group ID (the number of contacts in that
3722
+ # group).
3723
+ # * Default: total
3724
+ #
3725
+ # Returns:
3726
+ # (associative array)
3727
+ # - intervals (array)
3728
+ # * List of objects representing each date interval.
3729
+ #
3730
+ def get_contact_stats(options)
3731
+ data = @api.do_request("GET", get_base_api_path() + "/contact_stats", options)
3732
+ return data
3733
+ end
3734
+
3735
+ #
3736
+ # Retrieves statistics about the number of rows in particular data tables or data table views
3737
+ # over a date range. This endpoint returns historical data that is computed shortly after
3738
+ # midnight each day in the project's time zone. If the date range includes the current day, it
3739
+ # will include the current number of rows.
3740
+ #
3741
+ # Arguments:
3742
+ # - options (Hash)
3743
+ # * Required
3744
+ #
3745
+ # - start_date (string)
3746
+ # * Start date of data table statistics, in YYYY-MM-DD format
3747
+ # * Required
3748
+ #
3749
+ # - end_date (string)
3750
+ # * End date of data table statistics (inclusive), in YYYY-MM-DD format
3751
+ # * Required
3752
+ #
3753
+ # - rollup (string)
3754
+ # * Date interval to group by
3755
+ # * Allowed values: day, week, month, year
3756
+ # * Default: day
3757
+ #
3758
+ # - cumulative (bool)
3759
+ # * If true, each interval contains the number of rows in each data table at the end
3760
+ # of the interval; if false, each interval contains the change in the number of rows
3761
+ # during the interval.
3762
+ # * Default: 1
3763
+ #
3764
+ # - series (string)
3765
+ # * Comma separated list of up to 10 data table IDs and/or data table view IDs,
3766
+ # corresponding to the keys of the `values` object in the response.
3767
+ # * Required
3768
+ #
3769
+ # Returns:
3770
+ # (associative array)
3771
+ # - intervals (array)
3772
+ # * List of objects representing each date interval.
3773
+ #
3774
+ def get_data_table_stats(options)
3775
+ data = @api.do_request("GET", get_base_api_path() + "/data_table_stats", options)
3776
+ return data
3777
+ end
3778
+
3779
+ #
3780
+ # Retrieves statistics about airtime transactions sent via Telerivet. This endpoint returns
3781
+ # historical data for successful transactions that is computed shortly after midnight each day
3782
+ # in the project's time zone. If the date range includes the current day, it will include
3783
+ # statistics for the current day so far.
3784
+ #
3785
+ # Arguments:
3786
+ # - options (Hash)
3787
+ # * Required
3788
+ #
3789
+ # - start_date (string)
3790
+ # * Start date of airtime statistics, in YYYY-MM-DD format
3791
+ # * Required
3792
+ #
3793
+ # - end_date (string)
3794
+ # * End date of airtime statistics (inclusive), in YYYY-MM-DD format
3795
+ # * Required
3796
+ #
3797
+ # - rollup (string)
3798
+ # * Date interval to group by
3799
+ # * Allowed values: day, week, month, year, all
3800
+ # * Default: day
3801
+ #
3802
+ # - properties (string)
3803
+ # * Comma separated list of properties to group by. The `provider_category` property
3804
+ # combines the provider type and category ID (e.g. `main.airtime.dtone/1`); also group
3805
+ # by `category_name` to return the category's display name.
3806
+ # * Allowed values: country, operator_name, product_id, provider_id,
3807
+ # provider_category, category_name
3808
+ #
3809
+ # - metrics (string)
3810
+ # * Comma separated list of metrics to return (summed for each distinct value of the
3811
+ # requested properties). Supported metrics are `count` (the number of successful
3812
+ # transactions), `value.<currency>` (the face value of the airtime received by the
3813
+ # recipients, e.g. `value.KES`), and `price.<currency>` (the amount charged for the
3814
+ # transactions, e.g. `price.USD`). Amounts are not converted between currencies: each
3815
+ # `value`/`price` metric only includes transactions denominated in the specified ISO
3816
+ # 4217 currency, and transactions without a numeric currency value (such as bundles)
3817
+ # are not included in any `value` metric.
3818
+ # * Required
3819
+ #
3820
+ # - filters (Hash)
3821
+ # * Key-value pairs of properties and corresponding values; the returned statistics
3822
+ # will only include successful airtime transactions where the property matches the
3823
+ # provided value. Only the following properties are supported for filters: `country`,
3824
+ # `operator_name`, `product_id`, `provider_id`, `provider_category`
3825
+ #
3826
+ # Returns:
3827
+ # (associative array)
3828
+ # - intervals (array)
3829
+ # * List of objects representing each date interval containing at least one
3830
+ # successful airtime transaction matching the filters.
3831
+ #
3832
+ def get_airtime_stats(options)
3833
+ data = @api.do_request("GET", get_base_api_path() + "/airtime_stats", options)
3834
+ return data
3835
+ end
3836
+
3837
+ #
3838
+ # Queries webhooks within the given project.
3839
+ #
3840
+ # Arguments:
3841
+ # - options (Hash)
3842
+ #
3843
+ # - sort
3844
+ # * Sort the results based on a field
3845
+ # * Allowed values: default
3846
+ # * Default: default
3847
+ #
3848
+ # - sort_dir
3849
+ # * Sort the results in ascending or descending order
3850
+ # * Allowed values: asc, desc
3851
+ # * Default: asc
3852
+ #
3853
+ # - page_size (int)
3854
+ # * Number of results returned per page (max 500)
3855
+ # * Default: 50
3856
+ #
3857
+ # - offset (int)
3858
+ # * Number of items to skip from beginning of result set
3859
+ # * Default: 0
3860
+ #
3861
+ # Returns:
3862
+ # Telerivet::APICursor (of Telerivet::Webhook)
3863
+ #
3864
+ def query_webhooks(options = nil)
3865
+ require_relative 'webhook'
3866
+ @api.cursor(Webhook, get_base_api_path() + "/webhooks", options)
3867
+ end
3868
+
3869
+ #
3870
+ # Creates a new webhook that will be triggered when specific events occur within the project.
3871
+ #
3872
+ # Note: The Webhook object is not used for notifying your server when
3873
+ # incoming messages are received. To notify a URL when incoming messages are received, you can
3874
+ # configure a webhook by [creating a Service](#Project.createService) with type
3875
+ # incoming_message_webhook.
3876
+ #
3877
+ # Arguments:
3878
+ # - options (Hash)
3879
+ # * Required
3880
+ #
3881
+ # - url
3882
+ # * URL to send webhook requests to. Must start with https:// or http://.
3883
+ # * Required
3884
+ #
3885
+ # - secret
3886
+ # * Secret to include when sending webhook requests (up to 200 characters). Telerivet
3887
+ # will send the secret in the password field of HTTP basic auth (with username
3888
+ # 'telerivet').
3889
+ #
3890
+ # - events (array of strings)
3891
+ # * Array of event types to trigger this webhook. Valid event types are: `send_status`
3892
+ # (message status updates), `send_broadcast` (broadcast sent), `contact_update`
3893
+ # (contact added/updated/deleted), `message_metadata` (message metadata updated).
3894
+ #
3895
+ # Returns:
3896
+ # Telerivet::Webhook
3897
+ #
3898
+ def create_webhook(options)
3899
+ require_relative 'webhook'
3900
+ Webhook.new(@api, @api.do_request("POST", get_base_api_path() + "/webhooks", options))
3901
+ end
3902
+
3903
+ #
3904
+ # Retrieves the webhook with the given ID.
3905
+ #
3906
+ # Arguments:
3907
+ # - id
3908
+ # * ID of the webhook
3909
+ # * Required
3910
+ #
3911
+ # Returns:
3912
+ # Telerivet::Webhook
3913
+ #
3914
+ def get_webhook_by_id(id)
3915
+ require_relative 'webhook'
3916
+ Webhook.new(@api, @api.do_request("GET", get_base_api_path() + "/webhooks/#{id}"))
3917
+ end
3918
+
3919
+ #
3920
+ # Initializes the webhook with the given ID without making an API request.
3921
+ #
3922
+ # Arguments:
3923
+ # - id
3924
+ # * ID of the webhook
3925
+ # * Required
3926
+ #
3927
+ # Returns:
3928
+ # Telerivet::Webhook
3929
+ #
3930
+ def init_webhook_by_id(id)
3931
+ require_relative 'webhook'
3932
+ return Webhook.new(@api, {'project_id' => self.id, 'id' => id}, false)
3933
+ end
3934
+
2761
3935
  #
2762
3936
  # Saves any fields or custom variables that have changed for the project.
2763
3937
  #
@@ -2809,10 +3983,30 @@ class Project < Entity
2809
3983
  set('auto_create_contacts', value)
2810
3984
  end
2811
3985
 
3986
+ def message_retention_days
3987
+ get('message_retention_days')
3988
+ end
3989
+
3990
+ def message_retention_days=(value)
3991
+ set('message_retention_days', value)
3992
+ end
3993
+
3994
+ def short_link_scheme
3995
+ get('short_link_scheme')
3996
+ end
3997
+
3998
+ def short_link_scheme=(value)
3999
+ set('short_link_scheme', value)
4000
+ end
4001
+
2812
4002
  def organization_id
2813
4003
  get('organization_id')
2814
4004
  end
2815
4005
 
4006
+ def url
4007
+ get('url')
4008
+ end
4009
+
2816
4010
  def get_base_api_path()
2817
4011
  "/projects/#{get('id')}"
2818
4012
  end