telerivet 1.8.5 → 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.
- checksums.yaml +4 -4
- data/lib/telerivet/airtimetransaction.rb +2 -1
- data/lib/telerivet/broadcast.rb +12 -6
- data/lib/telerivet/campaign.rb +481 -0
- data/lib/telerivet/contact.rb +20 -1
- data/lib/telerivet/contactservicestate.rb +4 -2
- data/lib/telerivet/datatable.rb +174 -0
- data/lib/telerivet/dataview.rb +132 -0
- data/lib/telerivet/group.rb +32 -0
- data/lib/telerivet/label.rb +1 -1
- data/lib/telerivet/message.rb +28 -6
- data/lib/telerivet/organization.rb +299 -22
- data/lib/telerivet/phone.rb +49 -1
- data/lib/telerivet/project.rb +734 -104
- data/lib/telerivet/relativescheduledmessage.rb +11 -10
- data/lib/telerivet/route.rb +8 -0
- data/lib/telerivet/scheduledmessage.rb +7 -6
- data/lib/telerivet/service.rb +21 -3
- data/lib/telerivet/storedfile.rb +167 -0
- data/lib/telerivet.rb +1 -1
- metadata +5 -2
data/lib/telerivet/project.rb
CHANGED
|
@@ -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
|
|
@@ -64,6 +65,10 @@ module Telerivet
|
|
|
64
65
|
# - organization_id (string, max 34 characters)
|
|
65
66
|
# * ID of the organization this project belongs to
|
|
66
67
|
# * Read-only
|
|
68
|
+
#
|
|
69
|
+
# - url
|
|
70
|
+
# * URL to this project in the Telerivet web app
|
|
71
|
+
# * Read-only
|
|
67
72
|
#
|
|
68
73
|
class Project < Entity
|
|
69
74
|
#
|
|
@@ -104,9 +109,7 @@ class Project < Entity
|
|
|
104
109
|
#
|
|
105
110
|
# - replace_variables (bool)
|
|
106
111
|
# * Set to true to evaluate variables like [[contact.name]] in message content. [(See
|
|
107
|
-
# available variables)](#variables)
|
|
108
|
-
# double square brackets may also include [filters](/api/rules_engine#filters) to
|
|
109
|
-
# transform variables, such as to set a default value.
|
|
112
|
+
# available variables)](#variables)
|
|
110
113
|
# * Default: false
|
|
111
114
|
#
|
|
112
115
|
# - track_clicks (boolean)
|
|
@@ -128,18 +131,15 @@ class Project < Entity
|
|
|
128
131
|
# destination URL.
|
|
129
132
|
# If null, the short links will not expire.
|
|
130
133
|
#
|
|
131
|
-
# -
|
|
132
|
-
# *
|
|
133
|
-
# short links to each URL will be appended to the end of the content (separated by a
|
|
134
|
-
# new line).
|
|
134
|
+
# - media (array)
|
|
135
|
+
# * Array of media attachments for the text message.
|
|
135
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).
|
|
136
140
|
#
|
|
137
|
-
#
|
|
138
|
-
#
|
|
139
|
-
# are not already accessible via the internet, the media_urls parameter also supports
|
|
140
|
-
# data URIs with the file data encoded via Base64 (e.g. "data:image/png;base64,..."),
|
|
141
|
-
# with a maximum file size of 2 MB. To send media via data URIs, contact Telerivet to
|
|
142
|
-
# 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.
|
|
143
143
|
#
|
|
144
144
|
# - route_params (Hash)
|
|
145
145
|
# * Route-specific parameters for the message.
|
|
@@ -256,8 +256,8 @@ class Project < Entity
|
|
|
256
256
|
# set)
|
|
257
257
|
#
|
|
258
258
|
# - replace_variables (bool)
|
|
259
|
-
# * Set to true to evaluate variables like [[contact.name]] in message content [(See
|
|
260
|
-
# available variables)](#variables)
|
|
259
|
+
# * Set to true to evaluate variables like [[contact.name]] in message content. [(See
|
|
260
|
+
# available variables)](#variables)
|
|
261
261
|
# * Default: false
|
|
262
262
|
#
|
|
263
263
|
# - track_clicks (boolean)
|
|
@@ -279,18 +279,15 @@ class Project < Entity
|
|
|
279
279
|
# destination URL.
|
|
280
280
|
# If null, the short links will not expire.
|
|
281
281
|
#
|
|
282
|
-
# -
|
|
283
|
-
# *
|
|
284
|
-
# short links to each URL will be appended to the end of the content (separated by a
|
|
285
|
-
# new line).
|
|
282
|
+
# - media (array)
|
|
283
|
+
# * Array of media attachments for the text message.
|
|
286
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).
|
|
287
288
|
#
|
|
288
|
-
#
|
|
289
|
-
#
|
|
290
|
-
# are not already accessible via the internet, the media_urls parameter also supports
|
|
291
|
-
# data URIs with the file data encoded via Base64 (e.g. "data:image/png;base64,..."),
|
|
292
|
-
# with a maximum file size of 2 MB. To send media via data URIs, contact Telerivet to
|
|
293
|
-
# 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.
|
|
294
291
|
#
|
|
295
292
|
# - vars (Hash)
|
|
296
293
|
# * Custom variables to set for each message
|
|
@@ -385,8 +382,8 @@ class Project < Entity
|
|
|
385
382
|
# * Array of IDs of labels to add to each message (maximum 5)
|
|
386
383
|
#
|
|
387
384
|
# - replace_variables (bool)
|
|
388
|
-
# * Set to true to evaluate variables like [[contact.name]] in message content [(See
|
|
389
|
-
# available variables)](#variables)
|
|
385
|
+
# * Set to true to evaluate variables like [[contact.name]] in message content. [(See
|
|
386
|
+
# available variables)](#variables)
|
|
390
387
|
# * Default: false
|
|
391
388
|
#
|
|
392
389
|
# - track_clicks (boolean)
|
|
@@ -408,18 +405,15 @@ class Project < Entity
|
|
|
408
405
|
# destination URL.
|
|
409
406
|
# If null, the short links will not expire.
|
|
410
407
|
#
|
|
411
|
-
# -
|
|
412
|
-
# *
|
|
413
|
-
# short links to each URL will be appended to the end of the content (separated by a
|
|
414
|
-
# new line).
|
|
408
|
+
# - media (array)
|
|
409
|
+
# * Array of media attachments for the text message.
|
|
415
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).
|
|
416
414
|
#
|
|
417
|
-
#
|
|
418
|
-
#
|
|
419
|
-
# are not already accessible via the internet, the media_urls parameter also supports
|
|
420
|
-
# data URIs with the file data encoded via Base64 (e.g. "data:image/png;base64,..."),
|
|
421
|
-
# with a maximum file size of 2 MB. To send media via data URIs, contact Telerivet to
|
|
422
|
-
# 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.
|
|
423
417
|
#
|
|
424
418
|
# - route_params (Hash)
|
|
425
419
|
# * Route-specific parameters to apply to all messages.
|
|
@@ -600,22 +594,19 @@ class Project < Entity
|
|
|
600
594
|
# If null, the short links will not expire.
|
|
601
595
|
#
|
|
602
596
|
# - replace_variables (bool)
|
|
603
|
-
# * Set to true to evaluate variables like [[contact.name]] in message content
|
|
604
|
-
#
|
|
597
|
+
# * Set to true to evaluate variables like [[contact.name]] in message content. [(See
|
|
598
|
+
# available variables)](#variables)
|
|
605
599
|
# * Default: false
|
|
606
600
|
#
|
|
607
|
-
# -
|
|
608
|
-
# *
|
|
609
|
-
# short links to each URL will be appended to the end of the content (separated by a
|
|
610
|
-
# new line).
|
|
601
|
+
# - media (array)
|
|
602
|
+
# * Array of media attachments for the text message.
|
|
611
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).
|
|
612
607
|
#
|
|
613
|
-
#
|
|
614
|
-
#
|
|
615
|
-
# are not already accessible via the internet, the media_urls parameter also supports
|
|
616
|
-
# data URIs with the file data encoded via Base64 (e.g. "data:image/png;base64,..."),
|
|
617
|
-
# with a maximum file size of 2 MB. To send media via data URIs, contact Telerivet to
|
|
618
|
-
# 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.
|
|
619
610
|
#
|
|
620
611
|
# - route_params (Hash)
|
|
621
612
|
# * Route-specific parameters to use when sending the message.
|
|
@@ -709,10 +700,10 @@ class Project < Entity
|
|
|
709
700
|
# * Required
|
|
710
701
|
#
|
|
711
702
|
# - offset_scale
|
|
712
|
-
# * The type of interval
|
|
713
|
-
#
|
|
714
|
-
#
|
|
715
|
-
# * 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
|
|
716
707
|
# * Default: D
|
|
717
708
|
#
|
|
718
709
|
# - offset_count (int)
|
|
@@ -777,21 +768,19 @@ class Project < Entity
|
|
|
777
768
|
# If null, the short links will not expire.
|
|
778
769
|
#
|
|
779
770
|
# - replace_variables (bool)
|
|
780
|
-
# * 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)
|
|
781
773
|
# * Default: false
|
|
782
774
|
#
|
|
783
|
-
# -
|
|
784
|
-
# *
|
|
785
|
-
# short links to each URL will be appended to the end of the content (separated by a
|
|
786
|
-
# new line).
|
|
775
|
+
# - media (array)
|
|
776
|
+
# * Array of media attachments for the text message.
|
|
787
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).
|
|
788
781
|
#
|
|
789
|
-
#
|
|
790
|
-
#
|
|
791
|
-
# are not already accessible via the internet, the media_urls parameter also supports
|
|
792
|
-
# data URIs with the file data encoded via Base64 (e.g. "data:image/png;base64,..."),
|
|
793
|
-
# with a maximum file size of 2 MB. To send media via data URIs, contact Telerivet to
|
|
794
|
-
# 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.
|
|
795
784
|
#
|
|
796
785
|
# - route_params (Hash)
|
|
797
786
|
# * Route-specific parameters to use when sending the message.
|
|
@@ -1203,48 +1192,53 @@ class Project < Entity
|
|
|
1203
1192
|
#
|
|
1204
1193
|
# **Twilio Virtual Number** (`phone_type`: twilio):
|
|
1205
1194
|
#
|
|
1206
|
-
# -
|
|
1207
|
-
#
|
|
1208
|
-
# -
|
|
1209
|
-
# -
|
|
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
|
|
1210
1199
|
#
|
|
1211
1200
|
# **Twilio Messaging Service** (`phone_type`: twilio_messaging_service):
|
|
1212
1201
|
#
|
|
1213
|
-
# -
|
|
1214
|
-
# -
|
|
1215
|
-
# -
|
|
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
|
|
1216
1205
|
#
|
|
1217
1206
|
# **Twilio Shortcode** (`phone_type`: twilio_shortcode):
|
|
1218
1207
|
#
|
|
1219
|
-
# -
|
|
1220
|
-
#
|
|
1221
|
-
# -
|
|
1222
|
-
# -
|
|
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
|
|
1223
1212
|
#
|
|
1224
1213
|
# **Twilio Caller ID** (`phone_type`: twilio_caller_id):
|
|
1225
1214
|
#
|
|
1226
|
-
# -
|
|
1227
|
-
# -
|
|
1215
|
+
# - external_account_id (required): Twilio Account SID (starts with 'AC')
|
|
1216
|
+
# - external_secret (required): Twilio Auth Token
|
|
1228
1217
|
#
|
|
1229
|
-
# **Vonage Virtual Number
|
|
1218
|
+
# **Vonage Virtual Number** (`phone_type`: nexmo):
|
|
1230
1219
|
#
|
|
1231
|
-
# -
|
|
1232
|
-
# -
|
|
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
|
|
1233
1227
|
#
|
|
1234
1228
|
# **Telesign SMS** (`phone_type`: telesign):
|
|
1235
1229
|
#
|
|
1236
|
-
# -
|
|
1237
|
-
# -
|
|
1238
|
-
# -
|
|
1239
|
-
# -
|
|
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
|
|
1240
1234
|
#
|
|
1241
1235
|
# **Infobip SMS** (`phone_type`: infobip):
|
|
1242
1236
|
#
|
|
1243
|
-
# -
|
|
1244
|
-
# -
|
|
1245
|
-
# -
|
|
1246
|
-
# -
|
|
1247
|
-
#
|
|
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)
|
|
1248
1242
|
#
|
|
1249
1243
|
# **Infobip USSD** (`phone_type`: infobip_ussd):
|
|
1250
1244
|
#
|
|
@@ -1252,9 +1246,9 @@ class Project < Entity
|
|
|
1252
1246
|
#
|
|
1253
1247
|
# **Africa's Talking SMS** (`phone_type`: africas_talking):
|
|
1254
1248
|
#
|
|
1255
|
-
# -
|
|
1256
|
-
# -
|
|
1257
|
-
# -
|
|
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
|
|
1258
1252
|
#
|
|
1259
1253
|
# **Africa's Talking USSD** (`phone_type`: africas_talking_ussd):
|
|
1260
1254
|
#
|
|
@@ -1402,7 +1396,7 @@ class Project < Entity
|
|
|
1402
1396
|
# - source
|
|
1403
1397
|
# * Filter messages by source
|
|
1404
1398
|
# * Allowed values: phone, provider, web, api, service, webhook, scheduled,
|
|
1405
|
-
# integration
|
|
1399
|
+
# integration, mcp
|
|
1406
1400
|
#
|
|
1407
1401
|
# - starred (bool)
|
|
1408
1402
|
# * Filter messages by starred/unstarred
|
|
@@ -1575,6 +1569,213 @@ class Project < Entity
|
|
|
1575
1569
|
return Broadcast.new(@api, {'project_id' => self.id, 'id' => id}, false)
|
|
1576
1570
|
end
|
|
1577
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
|
+
|
|
1578
1779
|
#
|
|
1579
1780
|
# Creates and starts an asynchronous task that is applied to all entities matching a filter
|
|
1580
1781
|
# (e.g. contacts, messages, or data rows).
|
|
@@ -1902,7 +2103,9 @@ class Project < Entity
|
|
|
1902
2103
|
end
|
|
1903
2104
|
|
|
1904
2105
|
#
|
|
1905
|
-
# 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).)
|
|
1906
2109
|
#
|
|
1907
2110
|
# Arguments:
|
|
1908
2111
|
# - name
|
|
@@ -1917,6 +2120,66 @@ class Project < Entity
|
|
|
1917
2120
|
Group.new(@api, @api.do_request("POST", get_base_api_path() + "/groups", {'name' => name}))
|
|
1918
2121
|
end
|
|
1919
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
|
+
|
|
1920
2183
|
#
|
|
1921
2184
|
# Retrieves the group with the given ID.
|
|
1922
2185
|
#
|
|
@@ -2150,6 +2413,151 @@ class Project < Entity
|
|
|
2150
2413
|
return MessageTemplate.new(@api, {'project_id' => self.id, 'id' => id}, false)
|
|
2151
2414
|
end
|
|
2152
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
|
+
|
|
2153
2561
|
#
|
|
2154
2562
|
# Queries data tables within the given project.
|
|
2155
2563
|
#
|
|
@@ -2551,8 +2959,13 @@ class Project < Entity
|
|
|
2551
2959
|
# - ussd_actions
|
|
2552
2960
|
# - data_row_actions
|
|
2553
2961
|
# - incoming_message_webhook
|
|
2962
|
+
# - optin_optout
|
|
2963
|
+
# - keyword_auto_reply
|
|
2554
2964
|
# - messaging_poll
|
|
2965
|
+
# - voice_poll
|
|
2555
2966
|
# - scheduled_actions
|
|
2967
|
+
# - auto_reply
|
|
2968
|
+
# - call_auto_reply
|
|
2556
2969
|
# - incoming_message_script
|
|
2557
2970
|
# - contact_script
|
|
2558
2971
|
# - message_script
|
|
@@ -2571,8 +2984,9 @@ class Project < Entity
|
|
|
2571
2984
|
#
|
|
2572
2985
|
# - config (Hash)
|
|
2573
2986
|
# * Configuration specific to the `service_type`. See [Service Configuration
|
|
2574
|
-
# Reference](#service_config)
|
|
2575
|
-
# for
|
|
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.
|
|
2576
2990
|
# * Required
|
|
2577
2991
|
#
|
|
2578
2992
|
# - vars
|
|
@@ -2881,6 +3295,17 @@ class Project < Entity
|
|
|
2881
3295
|
@api.cursor(Route, get_base_api_path() + "/routes", options)
|
|
2882
3296
|
end
|
|
2883
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
|
+
|
|
2884
3309
|
#
|
|
2885
3310
|
# Creates a new custom route that can be used to send messages via one or more basic routes
|
|
2886
3311
|
# (phones).
|
|
@@ -3096,6 +3521,31 @@ class Project < Entity
|
|
|
3096
3521
|
return @api.do_request("POST", get_base_api_path() + "/contact_fields/#{variable}", options)
|
|
3097
3522
|
end
|
|
3098
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
|
+
|
|
3099
3549
|
#
|
|
3100
3550
|
# Gets a list of all custom fields defined for messages in this project. The return value is
|
|
3101
3551
|
# an array of objects with the properties 'name', 'variable', 'type', 'order', and
|
|
@@ -3150,6 +3600,31 @@ class Project < Entity
|
|
|
3150
3600
|
return @api.do_request("POST", get_base_api_path() + "/message_fields/#{variable}", options)
|
|
3151
3601
|
end
|
|
3152
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
|
+
|
|
3153
3628
|
#
|
|
3154
3629
|
# Retrieves statistics about messages sent or received via Telerivet. This endpoint returns
|
|
3155
3630
|
# historical data that is computed shortly after midnight each day in the project's time zone.
|
|
@@ -3181,16 +3656,14 @@ class Project < Entity
|
|
|
3181
3656
|
#
|
|
3182
3657
|
# - metrics (string)
|
|
3183
3658
|
# * Comma separated list of metrics to return (summed for each distinct value of the
|
|
3184
|
-
# requested properties)
|
|
3185
|
-
#
|
|
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.
|
|
3186
3665
|
# * Required
|
|
3187
3666
|
#
|
|
3188
|
-
# - currency (string)
|
|
3189
|
-
# * Three-letter ISO 4217 currency code used when returning the 'price' field. If the
|
|
3190
|
-
# original price was in a different currency, it will be converted to the requested
|
|
3191
|
-
# currency using the approximate current exchange rate.
|
|
3192
|
-
# * Default: USD
|
|
3193
|
-
#
|
|
3194
3667
|
# - filters (Hash)
|
|
3195
3668
|
# * Key-value pairs of properties and corresponding values; the returned statistics
|
|
3196
3669
|
# will only include messages where the property matches the provided value. Only the
|
|
@@ -3208,6 +3681,159 @@ class Project < Entity
|
|
|
3208
3681
|
return data
|
|
3209
3682
|
end
|
|
3210
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
|
+
|
|
3211
3837
|
#
|
|
3212
3838
|
# Queries webhooks within the given project.
|
|
3213
3839
|
#
|
|
@@ -3377,6 +4003,10 @@ class Project < Entity
|
|
|
3377
4003
|
get('organization_id')
|
|
3378
4004
|
end
|
|
3379
4005
|
|
|
4006
|
+
def url
|
|
4007
|
+
get('url')
|
|
4008
|
+
end
|
|
4009
|
+
|
|
3380
4010
|
def get_base_api_path()
|
|
3381
4011
|
"/projects/#{get('id')}"
|
|
3382
4012
|
end
|