telerivet 1.8.2 → 1.8.5

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.
@@ -41,6 +41,17 @@ module Telerivet
41
41
  # contact.
42
42
  # * Updatable via API
43
43
  #
44
+ # - message_retention_days (int)
45
+ # * Number of days to retain messages in this project. Messages older than this will be
46
+ # automatically deleted. If null, messages will be retained forever.
47
+ # * Updatable via API
48
+ #
49
+ # - short_link_scheme (bool)
50
+ # * If true (the default), short links in messages will include the scheme (e.g.,
51
+ # 'https://rvt.me/xxxxxxxxx'). If false, short links will not include the scheme (e.g.,
52
+ # 'rvt.me/xxxxxxxxx').
53
+ # * Updatable via API
54
+ #
44
55
  # - vars (Hash)
45
56
  # * Custom variables stored for this project. Variable names may be up to 32 characters
46
57
  # in length and can contain the characters a-z, A-Z, 0-9, and _.
@@ -93,7 +104,9 @@ class Project < Entity
93
104
  #
94
105
  # - replace_variables (bool)
95
106
  # * Set to true to evaluate variables like [[contact.name]] in message content. [(See
96
- # available variables)](#variables) (`is_template` parameter also accepted)
107
+ # available variables)](#variables) (`is_template` parameter also accepted). The
108
+ # double square brackets may also include [filters](/api/rules_engine#filters) to
109
+ # transform variables, such as to set a default value.
97
110
  # * Default: false
98
111
  #
99
112
  # - track_clicks (boolean)
@@ -115,7 +128,7 @@ class Project < Entity
115
128
  # destination URL.
116
129
  # If null, the short links will not expire.
117
130
  #
118
- # - media_urls (array)
131
+ # - media_urls (array of strings)
119
132
  # * URLs of media files to attach to the text message. If `message_type` is `sms`,
120
133
  # short links to each URL will be appended to the end of the content (separated by a
121
134
  # new line).
@@ -266,7 +279,7 @@ class Project < Entity
266
279
  # destination URL.
267
280
  # If null, the short links will not expire.
268
281
  #
269
- # - media_urls (array)
282
+ # - media_urls (array of strings)
270
283
  # * URLs of media files to attach to the text message. If `message_type` is `sms`,
271
284
  # short links to each URL will be appended to the end of the content (separated by a
272
285
  # new line).
@@ -395,7 +408,7 @@ class Project < Entity
395
408
  # destination URL.
396
409
  # If null, the short links will not expire.
397
410
  #
398
- # - media_urls (array)
411
+ # - media_urls (array of strings)
399
412
  # * URLs of media files to attach to the text message. If `message_type` is `sms`,
400
413
  # short links to each URL will be appended to the end of the content (separated by a
401
414
  # new line).
@@ -497,7 +510,7 @@ class Project < Entity
497
510
  # should be provided.
498
511
  #
499
512
  # 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
513
+ # as a poll) to be invoked for a group or an individual contact. Any service that can be
501
514
  # triggered for a contact can be scheduled via this method, whether or not the service
502
515
  # actually sends a message.
503
516
  #
@@ -591,7 +604,7 @@ class Project < Entity
591
604
  # (`is_template` parameter also accepted)
592
605
  # * Default: false
593
606
  #
594
- # - media_urls (array)
607
+ # - media_urls (array of strings)
595
608
  # * URLs of media files to attach to the text message. If `message_type` is `sms`,
596
609
  # short links to each URL will be appended to the end of the content (separated by a
597
610
  # new line).
@@ -767,7 +780,7 @@ class Project < Entity
767
780
  # * Set to true to evaluate variables like [[contact.name]] in message content
768
781
  # * Default: false
769
782
  #
770
- # - media_urls (array)
783
+ # - media_urls (array of strings)
771
784
  # * URLs of media files to attach to the text message. If `message_type` is `sms`,
772
785
  # short links to each URL will be appended to the end of the content (separated by a
773
786
  # new line).
@@ -1171,6 +1184,204 @@ class Project < Entity
1171
1184
  return Phone.new(@api, {'project_id' => self.id, 'id' => id}, false)
1172
1185
  end
1173
1186
 
1187
+ #
1188
+ # Creates a new basic route (phone) with external API credentials.
1189
+ #
1190
+ # For some external API providers, this method automatically updates webhook URLs configured
1191
+ # with the external provider so that incoming messages/calls and call status events are routed
1192
+ # to Telerivet. In this case, if you have already configured a webhook URL with the external
1193
+ # provider, it will be overwritten. For other external API providers, webhook URLs may require
1194
+ # manual configuration in order for the route to be fully functional.
1195
+ #
1196
+ # Note: This API can only create routes that connect to external gateway APIs using your own
1197
+ # account credentials. To add Android phones, WhatsApp routes, or routes with
1198
+ # Telerivet-managed billing, use the web app instead.
1199
+ #
1200
+ # Credentials are passed via the `external_account_id`, `external_id`, `external_secret`, and
1201
+ # `external_config` parameters. The meaning of these parameters for each phone type is as
1202
+ # follows:
1203
+ #
1204
+ # **Twilio Virtual Number** (`phone_type`: twilio):
1205
+ #
1206
+ # - `external_id` (optional): The SID of your Twilio phone number (starts with 'PN'); if not
1207
+ # provided, it will be looked up by the phone_number parameter
1208
+ # - `external_account_id` (required): Your Twilio Account SID (starts with 'AC')
1209
+ # - `external_secret` (required): Your Twilio Auth Token
1210
+ #
1211
+ # **Twilio Messaging Service** (`phone_type`: twilio_messaging_service):
1212
+ #
1213
+ # - `external_id` (required): The SID of your Twilio messaging service (starts with 'MG')
1214
+ # - `external_account_id` (required): Your Twilio Account SID (starts with 'AC')
1215
+ # - `external_secret` (required): Your Twilio Auth Token
1216
+ #
1217
+ # **Twilio Shortcode** (`phone_type`: twilio_shortcode):
1218
+ #
1219
+ # - `external_id` (optional): The SID of your Twilio shortcode (starts with 'SC'); if not
1220
+ # provided, it will be looked up by the phone_number parameter
1221
+ # - `external_account_id` (required): Your Twilio Account SID (starts with 'AC')
1222
+ # - `external_secret` (required): Your Twilio Auth Token
1223
+ #
1224
+ # **Twilio Caller ID** (`phone_type`: twilio_caller_id):
1225
+ #
1226
+ # - `external_account_id` (required): Your Twilio Account SID (starts with 'AC')
1227
+ # - `external_secret` (required): Your Twilio Auth Token
1228
+ #
1229
+ # **Vonage Virtual Number or Vonage Sender ID** (`phone_type`: nexmo or nexmo_sender_id):
1230
+ #
1231
+ # - `external_account_id` (required): Your Vonage API Key
1232
+ # - `external_secret` (required): Your Vonage API Secret
1233
+ #
1234
+ # **Telesign SMS** (`phone_type`: telesign):
1235
+ #
1236
+ # - `external_account_id` (required): Your Telesign Customer ID
1237
+ # - `external_secret` (required): Your Telesign API Key
1238
+ # - `external_config.message_type`: `ARN`, `MKT`, or `OTP`
1239
+ # - `external_config.sender_type`: `one_way` (default) or `two_way`
1240
+ #
1241
+ # **Infobip SMS** (`phone_type`: infobip):
1242
+ #
1243
+ # - `external_account_id` (required): Your Infobip username
1244
+ # - `external_secret` (required): Your Infobip API key
1245
+ # - `external_config.sender_type`: `one_way` (default) or `two_way`
1246
+ # - `external_config.india_dlt_principal_entity_id`: India DLT Principal Entity ID (only
1247
+ # needed if sending to India)
1248
+ #
1249
+ # **Infobip USSD** (`phone_type`: infobip_ussd):
1250
+ #
1251
+ # - No external credentials required
1252
+ #
1253
+ # **Africa's Talking SMS** (`phone_type`: africas_talking):
1254
+ #
1255
+ # - `external_account_id` (required): Your Africa's Talking username
1256
+ # - `external_secret` (required): Your Africa's Talking API key
1257
+ # - `external_config.sender_type`: `one_way` (default) or `two_way`
1258
+ #
1259
+ # **Africa's Talking USSD** (`phone_type`: africas_talking_ussd):
1260
+ #
1261
+ # - No external credentials required
1262
+ #
1263
+ # **Simulated Phone** (`phone_type`: simulated):
1264
+ #
1265
+ # - No external credentials required
1266
+ # - Messages are simulated locally and not sent to any external provider
1267
+ # - Useful for testing
1268
+ #
1269
+ # #### Webhook URL Setup
1270
+ #
1271
+ # Some route types require manual configuration of callback URLs in the external provider's
1272
+ # dashboard. When the Phone response includes an `external_setup` object, you will need to
1273
+ # configure the webhook URLs in your provider's account settings.
1274
+ #
1275
+ # The following phone types require manual webhook setup:
1276
+ #
1277
+ # - `africas_talking`: `message_status_url` (always), `incoming_message_url` (if two_way)
1278
+ # - `africas_talking_ussd`: `incoming_call_url`
1279
+ # - `infobip_ussd`: `incoming_call_url`
1280
+ # - `twilio_messaging_service`: `incoming_message_url`
1281
+ # - `telesign` (two_way only): `incoming_message_url`
1282
+ #
1283
+ # Telerivet automatically configures webhooks for the following phone types as follows:
1284
+ #
1285
+ # - `twilio` - automatically updates incoming SMS and voice configuration for the Twilio
1286
+ # virtual number associated with the phone_number or external_id parameter
1287
+ # - `twilio_shortcode` - automatically updates incoming SMS configuration for the Twilio short
1288
+ # code associated with the phone_number or external_id parameter
1289
+ # - `nexmo` - automatically updates incoming SMS and voice configuration for the Vonage
1290
+ # virtual number matching the phone_number parameter
1291
+ # - `infobip` - automatically updates incoming SMS configuration for the Infobip virtual
1292
+ # number matching the phone_number parameter or external_id parameter
1293
+ #
1294
+ # Arguments:
1295
+ # - options (Hash)
1296
+ # * Required
1297
+ #
1298
+ # - name (string)
1299
+ # * Name of the basic route to create
1300
+ #
1301
+ # - phone_number (string)
1302
+ # * Phone number or sender ID
1303
+ # * Required
1304
+ #
1305
+ # - phone_type (string)
1306
+ # * Type of basic route to create. Supported values: twilio, twilio_messaging_service,
1307
+ # twilio_shortcode, twilio_caller_id, nexmo, infobip, africas_talking,
1308
+ # africas_talking_ussd, infobip_ussd, telesign, simulated. Other types of basic routes
1309
+ # can only be created via the web app.
1310
+ # * Required
1311
+ #
1312
+ # - external_account_id (string)
1313
+ # * Account ID for the external API (e.g. Twilio Account SID, Vonage API Key). See the
1314
+ # description above for the meaning of this parameter for each phone type.
1315
+ #
1316
+ # - external_id (string)
1317
+ # * External phone/resource ID within the external API account (if applicable). For
1318
+ # `twilio` and `twilio_shortcode` routes, this is optional and will be looked up
1319
+ # automatically from the phone_number if not provided.
1320
+ #
1321
+ # - external_secret (string)
1322
+ # * Secret/API key for the external API (e.g. Twilio Auth Token, Vonage API Secret).
1323
+ # This value is required when creating a new route but is never returned in API
1324
+ # responses. See the description above for the meaning of this parameter for each
1325
+ # phone type.
1326
+ #
1327
+ # - external_config (Hash)
1328
+ # * Additional configuration settings specific to the phone_type. See the description
1329
+ # above for available settings for each phone type.
1330
+ #
1331
+ # - country
1332
+ # * 2-letter country code (ISO 3166-1 alpha-2) where phone is from. This country code
1333
+ # is used to automatically convert phone numbers in local format to international
1334
+ # format. If not provided, will be set to the organization's country by default.
1335
+ #
1336
+ # - send_paused (bool)
1337
+ # * True if sending messages should initially be paused, false otherwise
1338
+ # * Default:
1339
+ #
1340
+ # - timezone_id (string)
1341
+ # * A string specifying the time zone used when sending messages; see [List of tz
1342
+ # database time zones Wikipedia
1343
+ # article](http://en.wikipedia.org/wiki/List_of_tz_database_time_zones). When not
1344
+ # provided, the project's default time zone is used.
1345
+ #
1346
+ # - validate_recipient_numbers (bool)
1347
+ # * Set to true to validate recipient phone numbers before sending. Messages to
1348
+ # invalid numbers will fail without being sent.
1349
+ # * Default:
1350
+ #
1351
+ # - allowed_recipient_countries (array of strings)
1352
+ # * Array of 2-letter country codes (ISO 3166-1 alpha-2) to which this phone is
1353
+ # allowed to send messages. If not provided, there is no restriction.
1354
+ #
1355
+ # - send_delay (number)
1356
+ # * Number of seconds to wait after sending each message, to avoid exceeding carrier
1357
+ # rate limits.
1358
+ #
1359
+ # - quiet_mode (string)
1360
+ # * Controls behavior during quiet hours. Possible values: 'off' (disabled), 'delay'
1361
+ # (messages delayed until quiet hours end), 'confirm' (requires manual confirmation;
1362
+ # worker-based routes only).
1363
+ # * Allowed values: off, delay, confirm
1364
+ # * Default: off
1365
+ #
1366
+ # - quiet_start (string)
1367
+ # * Time when quiet hours begin, in HH:MM format (24-hour time). Only applicable when
1368
+ # quiet_mode is not 'off'.
1369
+ #
1370
+ # - quiet_end (string)
1371
+ # * Time when quiet hours end, in HH:MM format (24-hour time). Only applicable when
1372
+ # quiet_mode is not 'off'.
1373
+ #
1374
+ # - vars
1375
+ # * Custom variables and values to set for this basic route
1376
+ #
1377
+ # Returns:
1378
+ # Telerivet::Phone
1379
+ #
1380
+ def create_phone(options)
1381
+ require_relative 'phone'
1382
+ Phone.new(@api, @api.do_request("POST", get_base_api_path() + "/phones", options))
1383
+ end
1384
+
1174
1385
  #
1175
1386
  # Queries messages within the given project.
1176
1387
  #
@@ -1823,6 +2034,122 @@ class Project < Entity
1823
2034
  return Label.new(@api, {'project_id' => self.id, 'id' => id}, false)
1824
2035
  end
1825
2036
 
2037
+ #
2038
+ # Queries message templates within the given project.
2039
+ #
2040
+ # Arguments:
2041
+ # - options (Hash)
2042
+ #
2043
+ # - name
2044
+ # * Filter templates by name
2045
+ # * Allowed modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt],
2046
+ # name[lt], name[lte]
2047
+ #
2048
+ # - waba_id
2049
+ # * Filter templates by WhatsApp Business Account ID
2050
+ #
2051
+ # - sort
2052
+ # * Sort the results based on a field
2053
+ # * Allowed values: default, name
2054
+ # * Default: default
2055
+ #
2056
+ # - sort_dir
2057
+ # * Sort the results in ascending or descending order
2058
+ # * Allowed values: asc, desc
2059
+ # * Default: asc
2060
+ #
2061
+ # - page_size (int)
2062
+ # * Number of results returned per page (max 500)
2063
+ # * Default: 50
2064
+ #
2065
+ # - offset (int)
2066
+ # * Number of items to skip from beginning of result set
2067
+ # * Default: 0
2068
+ #
2069
+ # Returns:
2070
+ # Telerivet::APICursor (of Telerivet::MessageTemplate)
2071
+ #
2072
+ def query_message_templates(options = nil)
2073
+ require_relative 'messagetemplate'
2074
+ @api.cursor(MessageTemplate, get_base_api_path() + "/message_templates", options)
2075
+ end
2076
+
2077
+ #
2078
+ # Creates a new message template that can be used when composing or scheduling messages.
2079
+ #
2080
+ # Arguments:
2081
+ # - options (Hash)
2082
+ # * Required
2083
+ #
2084
+ # - name (string)
2085
+ # * Name of the template (max 127 characters)
2086
+ # * Required
2087
+ #
2088
+ # - content (string)
2089
+ # * Content of the message template (max 2000 characters)
2090
+ # * Required
2091
+ #
2092
+ # - track_clicks (bool)
2093
+ # * If true, URLs in the content will be replaced with short links that track clicks.
2094
+ # Requires a plan with click tracking enabled.
2095
+ # * Default:
2096
+ #
2097
+ # - short_link_params (Hash)
2098
+ # * If `track_clicks` is true, `short_link_params` may be used to specify custom
2099
+ # parameters for each short link.
2100
+ #
2101
+ # - attachments (array)
2102
+ # * List of attachment objects with file URLs to include with the template
2103
+ #
2104
+ # - route_params (Hash)
2105
+ # * Route-specific parameters to use when sending messages with this template.
2106
+ #
2107
+ # When sending messages via chat apps such as WhatsApp, the route_params
2108
+ # parameter can be used to send messages with app-specific features such as quick
2109
+ # replies and link buttons.
2110
+ #
2111
+ # For more details, see [Route-Specific Parameters](#route_params).
2112
+ #
2113
+ # Returns:
2114
+ # Telerivet::MessageTemplate
2115
+ #
2116
+ def create_message_template(options)
2117
+ require_relative 'messagetemplate'
2118
+ MessageTemplate.new(@api, @api.do_request("POST", get_base_api_path() + "/message_templates", options))
2119
+ end
2120
+
2121
+ #
2122
+ # Retrieves the message template with the given ID.
2123
+ #
2124
+ # Arguments:
2125
+ # - id
2126
+ # * ID of the message template
2127
+ # * Required
2128
+ #
2129
+ # Returns:
2130
+ # Telerivet::MessageTemplate
2131
+ #
2132
+ def get_message_template_by_id(id)
2133
+ require_relative 'messagetemplate'
2134
+ MessageTemplate.new(@api, @api.do_request("GET", get_base_api_path() + "/message_templates/#{id}"))
2135
+ end
2136
+
2137
+ #
2138
+ # Initializes the message template with the given ID without making an API request.
2139
+ #
2140
+ # Arguments:
2141
+ # - id
2142
+ # * ID of the message template
2143
+ # * Required
2144
+ #
2145
+ # Returns:
2146
+ # Telerivet::MessageTemplate
2147
+ #
2148
+ def init_message_template_by_id(id)
2149
+ require_relative 'messagetemplate'
2150
+ return MessageTemplate.new(@api, {'project_id' => self.id, 'id' => id}, false)
2151
+ end
2152
+
1826
2153
  #
1827
2154
  # Queries data tables within the given project.
1828
2155
  #
@@ -2065,19 +2392,144 @@ class Project < Entity
2065
2392
  return RelativeScheduledMessage.new(@api, {'project_id' => self.id, 'id' => id}, false)
2066
2393
  end
2067
2394
 
2395
+ #
2396
+ # Queries scheduled services within the given project.
2397
+ #
2398
+ # Arguments:
2399
+ # - options (Hash)
2400
+ #
2401
+ # - service_id
2402
+ # * Filter scheduled services by the service ID
2403
+ #
2404
+ # - time_created (UNIX timestamp)
2405
+ # * Filter scheduled services by time_created
2406
+ # * Allowed modifiers: time_created[min], time_created[max]
2407
+ #
2408
+ # - next_time (UNIX timestamp)
2409
+ # * Filter scheduled services by next_time
2410
+ # * Allowed modifiers: next_time[min], next_time[max]
2411
+ #
2412
+ # - sort
2413
+ # * Sort the results based on a field
2414
+ # * Allowed values: default, next_time
2415
+ # * Default: default
2416
+ #
2417
+ # - sort_dir
2418
+ # * Sort the results in ascending or descending order
2419
+ # * Allowed values: asc, desc
2420
+ # * Default: asc
2421
+ #
2422
+ # - page_size (int)
2423
+ # * Number of results returned per page (max 500)
2424
+ # * Default: 50
2425
+ #
2426
+ # - offset (int)
2427
+ # * Number of items to skip from beginning of result set
2428
+ # * Default: 0
2429
+ #
2430
+ # Returns:
2431
+ # Telerivet::APICursor (of Telerivet::ScheduledService)
2432
+ #
2433
+ def query_scheduled_services(options = nil)
2434
+ require_relative 'scheduledservice'
2435
+ @api.cursor(ScheduledService, get_base_api_path() + "/scheduled_services", options)
2436
+ end
2437
+
2438
+ #
2439
+ # Schedules a service to be triggered at a specified time.
2440
+ #
2441
+ # Only services that can be triggered for the project context and
2442
+ # handle the default event can be scheduled. This includes services with types
2443
+ # `scheduled_actions`, `scheduled_script`, and other service types that support project-level
2444
+ # triggering.
2445
+ #
2446
+ # (Note: To schedule services that are triggered for a contact,
2447
+ # [project.scheduleMessage](#Project.scheduleMessage) should be used instead with
2448
+ # `message_type`=`service`.)
2449
+ #
2450
+ # Arguments:
2451
+ # - options (Hash)
2452
+ # * Required
2453
+ #
2454
+ # - service_id
2455
+ # * ID of the service to schedule
2456
+ # * Required
2457
+ #
2458
+ # - start_time (UNIX timestamp)
2459
+ # * The time that the service will be triggered (or first triggered for recurring
2460
+ # scheduled services)
2461
+ # * Required if start_time_offset not set
2462
+ #
2463
+ # - start_time_offset (int)
2464
+ # * Number of seconds from now to trigger the service
2465
+ #
2466
+ # - rrule
2467
+ # * A recurrence rule describing how the schedule repeats, e.g. 'FREQ=MONTHLY' or
2468
+ # 'FREQ=WEEKLY;INTERVAL=2'; see <https://tools.ietf.org/html/rfc2445#section-4.3.10>.
2469
+ # (UNTIL is ignored; use end_time parameter instead).
2470
+ # * Default: COUNT=1 (one-time scheduled service, does not repeat)
2471
+ #
2472
+ # - timezone_id
2473
+ # * TZ database timezone ID; see [List of tz database time zones Wikipedia
2474
+ # article](http://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
2475
+ # * Default: project default timezone
2476
+ #
2477
+ # - end_time (UNIX timestamp)
2478
+ # * Time after which a recurring scheduled service will stop (not applicable to
2479
+ # non-recurring scheduled services)
2480
+ #
2481
+ # - end_time_offset (int)
2482
+ # * Number of seconds from now until the recurring scheduled service will stop
2483
+ #
2484
+ # - vars (Hash)
2485
+ # * Custom variables to store for this scheduled service
2486
+ #
2487
+ # Returns:
2488
+ # Telerivet::ScheduledService
2489
+ #
2490
+ def schedule_service(options)
2491
+ require_relative 'scheduledservice'
2492
+ ScheduledService.new(@api, @api.do_request("POST", get_base_api_path() + "/scheduled_services", options))
2493
+ end
2494
+
2495
+ #
2496
+ # Retrieves the scheduled service with the given ID.
2497
+ #
2498
+ # Arguments:
2499
+ # - id
2500
+ # * ID of the scheduled service
2501
+ # * Required
2502
+ #
2503
+ # Returns:
2504
+ # Telerivet::ScheduledService
2505
+ #
2506
+ def get_scheduled_service_by_id(id)
2507
+ require_relative 'scheduledservice'
2508
+ ScheduledService.new(@api, @api.do_request("GET", get_base_api_path() + "/scheduled_services/#{id}"))
2509
+ end
2510
+
2511
+ #
2512
+ # Initializes the scheduled service with the given ID without making an API request.
2513
+ #
2514
+ # Arguments:
2515
+ # - id
2516
+ # * ID of the scheduled service
2517
+ # * Required
2518
+ #
2519
+ # Returns:
2520
+ # Telerivet::ScheduledService
2521
+ #
2522
+ def init_scheduled_service_by_id(id)
2523
+ require_relative 'scheduledservice'
2524
+ return ScheduledService.new(@api, {'project_id' => self.id, 'id' => id}, false)
2525
+ end
2526
+
2068
2527
  #
2069
2528
  # Creates a new automated service.
2070
2529
  #
2071
2530
  # Only certain types of automated services can be created via the API.
2072
2531
  # Other types of services can only be created via the web app.
2073
2532
  #
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
2533
  # Arguments:
2082
2534
  # - options (Hash)
2083
2535
  # * Required
@@ -2090,63 +2542,37 @@ class Project < Entity
2090
2542
  # * Type of service to create. The following service types can be created via the
2091
2543
  # API:
2092
2544
  #
2545
+ # - incoming_message_actions
2546
+ # - contact_actions
2547
+ # - message_actions
2548
+ # - project_actions
2549
+ # - message_status_actions
2550
+ # - voice_actions
2551
+ # - ussd_actions
2552
+ # - data_row_actions
2093
2553
  # - incoming_message_webhook
2094
2554
  # - messaging_poll
2555
+ # - scheduled_actions
2095
2556
  # - incoming_message_script
2096
2557
  # - contact_script
2097
2558
  # - message_script
2098
2559
  # - data_row_script
2560
+ # - scheduled_script
2099
2561
  # - webhook_script
2100
2562
  # - voice_script
2101
2563
  # - ussd_script
2102
2564
  # - project_script
2565
+ # - opt_out_page
2566
+ # - button_page
2103
2567
  # - custom_template_instance
2104
2568
  #
2105
2569
  # Other types of services can only be created via the web app.
2106
2570
  # * Required
2107
2571
  #
2108
2572
  # - 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 />
2573
+ # * Configuration specific to the `service_type`. See [Service Configuration
2574
+ # Reference](#service_config) for complete documentation of configuration parameters
2575
+ # for each service type.
2150
2576
  # * Required
2151
2577
  #
2152
2578
  # - vars
@@ -2176,7 +2602,21 @@ class Project < Entity
2176
2602
  # - message_types (array)
2177
2603
  # * Types of messages that this service should handle. Only applies to services that
2178
2604
  # handle incoming messages.
2179
- # * Allowed values: text, call, sms, mms, ussd_session, chat
2605
+ # * Allowed values: text, call, ussd
2606
+ #
2607
+ # - table_ids (array)
2608
+ # * IDs of data tables that this service applies to, or null to apply to all data
2609
+ # tables. Only applies to data row services (`data_row_script` and
2610
+ # `data_row_actions`).
2611
+ #
2612
+ # - message_statuses (array of strings)
2613
+ # * Message statuses that this service should handle. Only applies to
2614
+ # `message_status_actions` services.
2615
+ # * Allowed values: sent, delivered, failed, failed_queued, not_delivered
2616
+ #
2617
+ # - tags (array of strings)
2618
+ # * Tags used to organize this service. Each tag can be up to 32 characters in length,
2619
+ # and up to 10 tags are allowed.
2180
2620
  #
2181
2621
  # - show_action (bool)
2182
2622
  # * Whether to show this service in the Actions menu within the Telerivet web app when
@@ -2235,7 +2675,8 @@ class Project < Entity
2235
2675
  #
2236
2676
  # - context
2237
2677
  # * Filter services that can be invoked in a particular context
2238
- # * Allowed values: message, call, ussd_session, row, contact, project
2678
+ # * Allowed values: message, call, ussd_session, row, contact, project,
2679
+ # airtime_transaction
2239
2680
  #
2240
2681
  # - sort
2241
2682
  # * Sort the results based on a field
@@ -2440,6 +2881,37 @@ class Project < Entity
2440
2881
  @api.cursor(Route, get_base_api_path() + "/routes", options)
2441
2882
  end
2442
2883
 
2884
+ #
2885
+ # Creates a new custom route that can be used to send messages via one or more basic routes
2886
+ # (phones).
2887
+ #
2888
+ # The `actions` array defines the routing rules.
2889
+ #
2890
+ # Arguments:
2891
+ # - options (Hash)
2892
+ # * Required
2893
+ #
2894
+ # - name (string)
2895
+ # * Name of the custom route to create
2896
+ # * Required
2897
+ #
2898
+ # - actions (array of RoutingAction)
2899
+ # * Array of routing action objects. Allowed action types: `use_phone` (select basic
2900
+ # routes to send messages), `condition` (conditionally execute actions based on
2901
+ # criteria).
2902
+ # * Required
2903
+ #
2904
+ # - vars
2905
+ # * Custom variables and values to set for this route
2906
+ #
2907
+ # Returns:
2908
+ # Telerivet::Route
2909
+ #
2910
+ def create_route(options)
2911
+ require_relative 'route'
2912
+ Route.new(@api, @api.do_request("POST", get_base_api_path() + "/routes", options))
2913
+ end
2914
+
2443
2915
  #
2444
2916
  # Gets a custom route by ID
2445
2917
  #
@@ -2565,9 +3037,9 @@ class Project < Entity
2565
3037
 
2566
3038
  #
2567
3039
  # 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.)
3040
+ # an array of objects with the properties 'name', 'variable', 'type', 'order', 'readonly',
3041
+ # 'lookup_key', and 'show_on_conversation'. (Fields are automatically created any time a
3042
+ # Contact's 'vars' property is updated.)
2571
3043
  #
2572
3044
  # Returns:
2573
3045
  # array
@@ -2603,9 +3075,9 @@ class Project < Entity
2603
3075
  #
2604
3076
  # - items (array)
2605
3077
  # * 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`
3078
+ # show when type is `select` or `radio`. Each `value` and `label` must be between 1
3079
+ # and 256 characters in length.
3080
+ # * Required if type is `select` or `radio`
2609
3081
  #
2610
3082
  # - readonly (bool)
2611
3083
  # * Set to true to prevent editing the field in the Telerivet web app
@@ -2626,8 +3098,8 @@ class Project < Entity
2626
3098
 
2627
3099
  #
2628
3100
  # 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
3101
+ # an array of objects with the properties 'name', 'variable', 'type', 'order', and
3102
+ # 'hide_values'. (Fields are automatically created any time a Message's 'vars' property is
2631
3103
  # updated.)
2632
3104
  #
2633
3105
  # Returns:
@@ -2664,9 +3136,9 @@ class Project < Entity
2664
3136
  #
2665
3137
  # - items (array)
2666
3138
  # * 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`
3139
+ # show when type is `select` or `radio`. Each `value` and `label` must be between 1
3140
+ # and 256 characters in length.
3141
+ # * Required if type is `select` or `radio`
2670
3142
  #
2671
3143
  # - hide_values (bool)
2672
3144
  # * Set to true to avoid showing values of this field on the Messages page
@@ -2680,8 +3152,9 @@ class Project < Entity
2680
3152
 
2681
3153
  #
2682
3154
  # 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.
3155
+ # historical data that is computed shortly after midnight each day in the project's time zone.
3156
+ # If the date range includes the current day, it will include statistics for the current day
3157
+ # so far.
2685
3158
  #
2686
3159
  # Arguments:
2687
3160
  # - options (Hash)
@@ -2729,35 +3202,110 @@ class Project < Entity
2729
3202
  # - intervals (array)
2730
3203
  # * List of objects representing each date interval containing at least one message
2731
3204
  # 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
3205
  #
2756
3206
  def get_message_stats(options)
2757
3207
  data = @api.do_request("GET", get_base_api_path() + "/message_stats", options)
2758
3208
  return data
2759
3209
  end
2760
3210
 
3211
+ #
3212
+ # Queries webhooks within the given project.
3213
+ #
3214
+ # Arguments:
3215
+ # - options (Hash)
3216
+ #
3217
+ # - sort
3218
+ # * Sort the results based on a field
3219
+ # * Allowed values: default
3220
+ # * Default: default
3221
+ #
3222
+ # - sort_dir
3223
+ # * Sort the results in ascending or descending order
3224
+ # * Allowed values: asc, desc
3225
+ # * Default: asc
3226
+ #
3227
+ # - page_size (int)
3228
+ # * Number of results returned per page (max 500)
3229
+ # * Default: 50
3230
+ #
3231
+ # - offset (int)
3232
+ # * Number of items to skip from beginning of result set
3233
+ # * Default: 0
3234
+ #
3235
+ # Returns:
3236
+ # Telerivet::APICursor (of Telerivet::Webhook)
3237
+ #
3238
+ def query_webhooks(options = nil)
3239
+ require_relative 'webhook'
3240
+ @api.cursor(Webhook, get_base_api_path() + "/webhooks", options)
3241
+ end
3242
+
3243
+ #
3244
+ # Creates a new webhook that will be triggered when specific events occur within the project.
3245
+ #
3246
+ # Note: The Webhook object is not used for notifying your server when
3247
+ # incoming messages are received. To notify a URL when incoming messages are received, you can
3248
+ # configure a webhook by [creating a Service](#Project.createService) with type
3249
+ # incoming_message_webhook.
3250
+ #
3251
+ # Arguments:
3252
+ # - options (Hash)
3253
+ # * Required
3254
+ #
3255
+ # - url
3256
+ # * URL to send webhook requests to. Must start with https:// or http://.
3257
+ # * Required
3258
+ #
3259
+ # - secret
3260
+ # * Secret to include when sending webhook requests (up to 200 characters). Telerivet
3261
+ # will send the secret in the password field of HTTP basic auth (with username
3262
+ # 'telerivet').
3263
+ #
3264
+ # - events (array of strings)
3265
+ # * Array of event types to trigger this webhook. Valid event types are: `send_status`
3266
+ # (message status updates), `send_broadcast` (broadcast sent), `contact_update`
3267
+ # (contact added/updated/deleted), `message_metadata` (message metadata updated).
3268
+ #
3269
+ # Returns:
3270
+ # Telerivet::Webhook
3271
+ #
3272
+ def create_webhook(options)
3273
+ require_relative 'webhook'
3274
+ Webhook.new(@api, @api.do_request("POST", get_base_api_path() + "/webhooks", options))
3275
+ end
3276
+
3277
+ #
3278
+ # Retrieves the webhook with the given ID.
3279
+ #
3280
+ # Arguments:
3281
+ # - id
3282
+ # * ID of the webhook
3283
+ # * Required
3284
+ #
3285
+ # Returns:
3286
+ # Telerivet::Webhook
3287
+ #
3288
+ def get_webhook_by_id(id)
3289
+ require_relative 'webhook'
3290
+ Webhook.new(@api, @api.do_request("GET", get_base_api_path() + "/webhooks/#{id}"))
3291
+ end
3292
+
3293
+ #
3294
+ # Initializes the webhook with the given ID without making an API request.
3295
+ #
3296
+ # Arguments:
3297
+ # - id
3298
+ # * ID of the webhook
3299
+ # * Required
3300
+ #
3301
+ # Returns:
3302
+ # Telerivet::Webhook
3303
+ #
3304
+ def init_webhook_by_id(id)
3305
+ require_relative 'webhook'
3306
+ return Webhook.new(@api, {'project_id' => self.id, 'id' => id}, false)
3307
+ end
3308
+
2761
3309
  #
2762
3310
  # Saves any fields or custom variables that have changed for the project.
2763
3311
  #
@@ -2809,6 +3357,22 @@ class Project < Entity
2809
3357
  set('auto_create_contacts', value)
2810
3358
  end
2811
3359
 
3360
+ def message_retention_days
3361
+ get('message_retention_days')
3362
+ end
3363
+
3364
+ def message_retention_days=(value)
3365
+ set('message_retention_days', value)
3366
+ end
3367
+
3368
+ def short_link_scheme
3369
+ get('short_link_scheme')
3370
+ end
3371
+
3372
+ def short_link_scheme=(value)
3373
+ set('short_link_scheme', value)
3374
+ end
3375
+
2812
3376
  def organization_id
2813
3377
  get('organization_id')
2814
3378
  end