telerivet 1.4.6 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b442bc6d2aab45f4be47acc976f991bbd399de9a68ac092ec6dd2d717c3373e9
4
- data.tar.gz: 7c629053a6f168be87bb4e705e6cad78c9e7ec3aebe34cbb7553843dcf0cb02b
3
+ metadata.gz: 4e063e2ce507f6d45b86d12c584475887c050c3d439863d91d545b0ba331e823
4
+ data.tar.gz: d8040eb663854c7df190aa8f49984d9854687238532b6278af53dea6ebc77250
5
5
  SHA512:
6
- metadata.gz: b2585a9e281177331fe9615cbf02d91169f5f6bb178ebe228cd81b4def87576a7486b4e5457261b324f6fe1b958bace906e2e3a28d5b9bef8cb7c77f09bc9586
7
- data.tar.gz: 35cb63dc5fbcdb5400808a8f3c4db85e4e5b07d85bd273c01d4693975ae10682e758a67e92797b7e771ccaba6fcd573e3629389aed7696346eff142da6186ef7
6
+ metadata.gz: da5e09e1c639a5e1bd3b704214c4a276d62469e6ae0853d71cbe4b9dc2a2aacbb1f58d5e5bcbf1093e5cbf24a7a99abcf30d029883aca055d4b41ae9f3a7f8ff
7
+ data.tar.gz: 4ad80ced036f9d8810e3e7f693443247740791ed4097b26ce179c2c2ef0ca06986b41942fde40401ea8989df19591f84834439efb74900f9bb57ec7f939d8f25
data/lib/telerivet.rb CHANGED
@@ -9,7 +9,7 @@ module Telerivet
9
9
  class API
10
10
  attr_reader :num_requests
11
11
 
12
- @@client_version = '1.4.6'
12
+ @@client_version = '1.5.0'
13
13
 
14
14
  #
15
15
  # Initializes a client handle to the Telerivet REST API.
@@ -65,6 +65,10 @@ module Telerivet
65
65
  # * ID of the project that the airtime transaction belongs to
66
66
  # * Read-only
67
67
  #
68
+ # - external_id
69
+ # * The ID of this transaction from an external airtime gateway provider, if available.
70
+ # * Read-only
71
+ #
68
72
  # - vars (Hash)
69
73
  # * Custom variables stored for this transaction
70
74
  # * Updatable via API
@@ -122,6 +126,10 @@ class AirtimeTransaction < Entity
122
126
  get('project_id')
123
127
  end
124
128
 
129
+ def external_id
130
+ get('external_id')
131
+ end
132
+
125
133
  def get_base_api_path()
126
134
  "/projects/#{get('project_id')}/airtime_transactions/#{get('id')}"
127
135
  end
@@ -253,8 +253,8 @@ class Contact < Entity
253
253
  #
254
254
  # - next_time (UNIX timestamp)
255
255
  # * Filter scheduled messages by next_time
256
- # * Allowed modifiers: next_time[exists], next_time[ne], next_time[min],
257
- # next_time[max]
256
+ # * Allowed modifiers: next_time[ne], next_time[min], next_time[max],
257
+ # next_time[exists]
258
258
  #
259
259
  # - sort
260
260
  # * Sort the results based on a field
@@ -331,9 +331,9 @@ class Contact < Entity
331
331
  #
332
332
  # - vars (Hash)
333
333
  # * Filter states by value of a custom variable (e.g. vars[email], vars[foo], etc.)
334
- # * Allowed modifiers: vars[foo][exists], vars[foo][ne], vars[foo][prefix],
335
- # vars[foo][not_prefix], vars[foo][gte], vars[foo][gt], vars[foo][lt], vars[foo][lte],
336
- # vars[foo][min], vars[foo][max]
334
+ # * Allowed modifiers: vars[foo][ne], vars[foo][prefix], vars[foo][not_prefix],
335
+ # vars[foo][gte], vars[foo][gt], vars[foo][lt], vars[foo][lte], vars[foo][min],
336
+ # vars[foo][max], vars[foo][exists]
337
337
  #
338
338
  # - sort
339
339
  # * Sort the results based on a field
@@ -22,7 +22,8 @@ module Telerivet
22
22
  # * Updatable via API
23
23
  #
24
24
  # - num_rows (int)
25
- # * Number of rows in the table
25
+ # * Number of rows in the table. For performance reasons, this number may sometimes be
26
+ # out-of-date.
26
27
  # * Read-only
27
28
  #
28
29
  # - show_add_row (bool)
@@ -61,9 +62,9 @@ class DataTable < Entity
61
62
  #
62
63
  # - vars (Hash)
63
64
  # * Filter data rows by value of a custom variable (e.g. vars[q1], vars[foo], etc.)
64
- # * Allowed modifiers: vars[foo][exists], vars[foo][ne], vars[foo][prefix],
65
- # vars[foo][not_prefix], vars[foo][gte], vars[foo][gt], vars[foo][lt], vars[foo][lte],
66
- # vars[foo][min], vars[foo][max]
65
+ # * Allowed modifiers: vars[foo][ne], vars[foo][prefix], vars[foo][not_prefix],
66
+ # vars[foo][gte], vars[foo][gt], vars[foo][lt], vars[foo][lte], vars[foo][min],
67
+ # vars[foo][max], vars[foo][exists]
67
68
  #
68
69
  # - sort
69
70
  # * Sort the results based on a field
@@ -175,7 +176,7 @@ class DataTable < Entity
175
176
  # - type (string)
176
177
  # * Field type
177
178
  # * Allowed values: text, long_text, number, boolean, email, url, audio, phone_number,
178
- # date, date_time, groups, route, select, buttons
179
+ # date, date_time, groups, route, select, buttons, contact
179
180
  #
180
181
  # - order (int)
181
182
  # * Order in which to display the field
@@ -50,7 +50,7 @@ class Group < Entity
50
50
  # * Filter contacts by phone number
51
51
  # * Allowed modifiers: phone_number[ne], phone_number[prefix],
52
52
  # phone_number[not_prefix], phone_number[gte], phone_number[gt], phone_number[lt],
53
- # phone_number[lte]
53
+ # phone_number[lte], phone_number[exists]
54
54
  #
55
55
  # - time_created (UNIX timestamp)
56
56
  # * Filter contacts by time created
@@ -58,20 +58,20 @@ class Group < Entity
58
58
  #
59
59
  # - last_message_time (UNIX timestamp)
60
60
  # * Filter contacts by last time a message was sent or received
61
- # * Allowed modifiers: last_message_time[exists], last_message_time[ne],
62
- # last_message_time[min], last_message_time[max]
61
+ # * Allowed modifiers: last_message_time[ne], last_message_time[min],
62
+ # last_message_time[max], last_message_time[exists]
63
63
  #
64
64
  # - last_incoming_message_time (UNIX timestamp)
65
65
  # * Filter contacts by last time a message was received
66
- # * Allowed modifiers: last_incoming_message_time[exists],
67
- # last_incoming_message_time[ne], last_incoming_message_time[min],
68
- # last_incoming_message_time[max]
66
+ # * Allowed modifiers: last_incoming_message_time[ne],
67
+ # last_incoming_message_time[min], last_incoming_message_time[max],
68
+ # last_incoming_message_time[exists]
69
69
  #
70
70
  # - last_outgoing_message_time (UNIX timestamp)
71
71
  # * Filter contacts by last time a message was sent
72
- # * Allowed modifiers: last_outgoing_message_time[exists],
73
- # last_outgoing_message_time[ne], last_outgoing_message_time[min],
74
- # last_outgoing_message_time[max]
72
+ # * Allowed modifiers: last_outgoing_message_time[ne],
73
+ # last_outgoing_message_time[min], last_outgoing_message_time[max],
74
+ # last_outgoing_message_time[exists]
75
75
  #
76
76
  # - incoming_message_count (int)
77
77
  # * Filter contacts by number of messages received from the contact
@@ -88,9 +88,9 @@ class Group < Entity
88
88
  #
89
89
  # - vars (Hash)
90
90
  # * Filter contacts by value of a custom variable (e.g. vars[email], vars[foo], etc.)
91
- # * Allowed modifiers: vars[foo][exists], vars[foo][ne], vars[foo][prefix],
92
- # vars[foo][not_prefix], vars[foo][gte], vars[foo][gt], vars[foo][lt], vars[foo][lte],
93
- # vars[foo][min], vars[foo][max]
91
+ # * Allowed modifiers: vars[foo][ne], vars[foo][prefix], vars[foo][not_prefix],
92
+ # vars[foo][gte], vars[foo][gt], vars[foo][lt], vars[foo][lte], vars[foo][min],
93
+ # vars[foo][max], vars[foo][exists]
94
94
  #
95
95
  # - sort
96
96
  # * Sort the results based on a field
@@ -134,8 +134,8 @@ class Group < Entity
134
134
  #
135
135
  # - next_time (UNIX timestamp)
136
136
  # * Filter scheduled messages by next_time
137
- # * Allowed modifiers: next_time[exists], next_time[ne], next_time[min],
138
- # next_time[max]
137
+ # * Allowed modifiers: next_time[ne], next_time[min], next_time[max],
138
+ # next_time[exists]
139
139
  #
140
140
  # - sort
141
141
  # * Sort the results based on a field
@@ -648,6 +648,9 @@ class Project < Entity
648
648
  # Arguments:
649
649
  # - options (Hash)
650
650
  #
651
+ # - group_id
652
+ # * Filter contacts within a group
653
+ #
651
654
  # - name
652
655
  # * Filter contacts by name
653
656
  # * Allowed modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt],
@@ -657,7 +660,7 @@ class Project < Entity
657
660
  # * Filter contacts by phone number
658
661
  # * Allowed modifiers: phone_number[ne], phone_number[prefix],
659
662
  # phone_number[not_prefix], phone_number[gte], phone_number[gt], phone_number[lt],
660
- # phone_number[lte]
663
+ # phone_number[lte], phone_number[exists]
661
664
  #
662
665
  # - time_created (UNIX timestamp)
663
666
  # * Filter contacts by time created
@@ -665,20 +668,20 @@ class Project < Entity
665
668
  #
666
669
  # - last_message_time (UNIX timestamp)
667
670
  # * Filter contacts by last time a message was sent or received
668
- # * Allowed modifiers: last_message_time[exists], last_message_time[ne],
669
- # last_message_time[min], last_message_time[max]
671
+ # * Allowed modifiers: last_message_time[ne], last_message_time[min],
672
+ # last_message_time[max], last_message_time[exists]
670
673
  #
671
674
  # - last_incoming_message_time (UNIX timestamp)
672
675
  # * Filter contacts by last time a message was received
673
- # * Allowed modifiers: last_incoming_message_time[exists],
674
- # last_incoming_message_time[ne], last_incoming_message_time[min],
675
- # last_incoming_message_time[max]
676
+ # * Allowed modifiers: last_incoming_message_time[ne],
677
+ # last_incoming_message_time[min], last_incoming_message_time[max],
678
+ # last_incoming_message_time[exists]
676
679
  #
677
680
  # - last_outgoing_message_time (UNIX timestamp)
678
681
  # * Filter contacts by last time a message was sent
679
- # * Allowed modifiers: last_outgoing_message_time[exists],
680
- # last_outgoing_message_time[ne], last_outgoing_message_time[min],
681
- # last_outgoing_message_time[max]
682
+ # * Allowed modifiers: last_outgoing_message_time[ne],
683
+ # last_outgoing_message_time[min], last_outgoing_message_time[max],
684
+ # last_outgoing_message_time[exists]
682
685
  #
683
686
  # - incoming_message_count (int)
684
687
  # * Filter contacts by number of messages received from the contact
@@ -695,9 +698,9 @@ class Project < Entity
695
698
  #
696
699
  # - vars (Hash)
697
700
  # * Filter contacts by value of a custom variable (e.g. vars[email], vars[foo], etc.)
698
- # * Allowed modifiers: vars[foo][exists], vars[foo][ne], vars[foo][prefix],
699
- # vars[foo][not_prefix], vars[foo][gte], vars[foo][gt], vars[foo][lt], vars[foo][lte],
700
- # vars[foo][min], vars[foo][max]
701
+ # * Allowed modifiers: vars[foo][ne], vars[foo][prefix], vars[foo][not_prefix],
702
+ # vars[foo][gte], vars[foo][gt], vars[foo][lt], vars[foo][lte], vars[foo][min],
703
+ # vars[foo][max], vars[foo][exists]
701
704
  #
702
705
  # - sort
703
706
  # * Sort the results based on a field
@@ -776,8 +779,8 @@ class Project < Entity
776
779
  #
777
780
  # - last_active_time (UNIX timestamp)
778
781
  # * Filter phones by last active time
779
- # * Allowed modifiers: last_active_time[exists], last_active_time[ne],
780
- # last_active_time[min], last_active_time[max]
782
+ # * Allowed modifiers: last_active_time[ne], last_active_time[min],
783
+ # last_active_time[max], last_active_time[exists]
781
784
  #
782
785
  # - sort
783
786
  # * Sort the results based on a field
@@ -843,6 +846,9 @@ class Project < Entity
843
846
  # Arguments:
844
847
  # - options (Hash)
845
848
  #
849
+ # - label_id
850
+ # * Filter messages with a label
851
+ #
846
852
  # - direction
847
853
  # * Filter messages by direction
848
854
  # * Allowed values: incoming, outgoing
@@ -1019,6 +1025,290 @@ class Project < Entity
1019
1025
  return Broadcast.new(@api, {'project_id' => self.id, 'id' => id}, false)
1020
1026
  end
1021
1027
 
1028
+ #
1029
+ # Creates and starts an asynchronous task that is applied to all entities matching a filter
1030
+ # (e.g. contacts, messages, or data rows).
1031
+ # Tasks are designed to efficiently process a large number of
1032
+ # entities. When processing a large number of entities,
1033
+ # tasks are much faster than using the API to query and loop over
1034
+ # all objects matching a filter.
1035
+ #
1036
+ # Several different types of tasks are supported, including
1037
+ # applying services to contacts, messages, or data rows;
1038
+ # adding or removing contacts from a group; blocking or unblocking
1039
+ # sending messages to a contact; updating a custom variable;
1040
+ # deleting contacts, messages, or data rows; or exporting data to
1041
+ # CSV.
1042
+ #
1043
+ # When using a task to apply a Custom Actions or Cloud Script API
1044
+ # service (`apply_service_to_contacts`, `apply_service_to_rows`, or
1045
+ # `apply_service_to_messages`),
1046
+ # the `task` variable will be available within the service. The
1047
+ # service can use custom variables on the task object (e.g. `task.vars.example`), such as
1048
+ # to store aggregate statistics for the rows matching the filter.
1049
+ #
1050
+ # Arguments:
1051
+ # - options (Hash)
1052
+ # * Required
1053
+ #
1054
+ # - task_type
1055
+ # * Type of task to create. Each `task_type` applies to a certain type of entity (such
1056
+ # as a contact, message, or data row).
1057
+ #
1058
+ # Tasks for contacts:
1059
+ #
1060
+ # - `update_contact_var`
1061
+ # - `add_group_members`
1062
+ # - `remove_group_members`
1063
+ # - `set_conversation_status`
1064
+ # - `set_send_blocked`
1065
+ # - `apply_service_to_contacts`
1066
+ # - `delete_contacts`
1067
+ # - `export_contacts`
1068
+ #
1069
+ # Tasks for data rows:
1070
+ #
1071
+ # - `update_row_var`
1072
+ # - `apply_service_to_rows`
1073
+ # - `delete_rows`
1074
+ # - `export_rows`
1075
+ #
1076
+ # Tasks for messages:
1077
+ #
1078
+ # - `cancel_messages`
1079
+ # - `resend_messages`
1080
+ # - `retry_message_services`
1081
+ # - `apply_service_to_messages`
1082
+ # - `add_label`
1083
+ # - `remove_label`
1084
+ # - `update_message_var`
1085
+ # - `delete_messages`
1086
+ # - `export_messages`
1087
+ # * Allowed values: update_contact_var, delete_contacts, add_group_members,
1088
+ # remove_group_members, set_conversation_status, set_send_blocked,
1089
+ # apply_service_to_contacts, update_row_var, delete_rows, apply_service_to_rows,
1090
+ # delete_messages, cancel_messages, resend_messages, retry_message_services,
1091
+ # apply_service_to_messages, add_label, remove_label, update_message_var,
1092
+ # export_messages, export_contacts, export_rows
1093
+ # * Required
1094
+ #
1095
+ # - task_params (Hash)
1096
+ # * Parameters applied to all matching rows (specific to `task_type`).
1097
+ #
1098
+ # **`apply_service_to_contacts`**,
1099
+ # **`apply_service_to_messages`**, **`apply_service_to_rows`**:
1100
+ # <table>
1101
+ # <tr><td> `service_id` </td> <td> The ID of the
1102
+ # service to apply (string) </td></tr>
1103
+ # </table>
1104
+ #
1105
+ # **`update_contact_var`**, **`update_message_var`**,
1106
+ # **`update_row_var`**:
1107
+ # <table>
1108
+ # <tr><td> `variable` </td> <td> The custom variable
1109
+ # name (string) </td></tr>
1110
+ # <tr><td> `value` </td> <td> The value to set
1111
+ # (string, boolean, float, null) </td></tr>
1112
+ # </table>
1113
+ #
1114
+ # **`add_group_members`**, **`remove_group_members`**:
1115
+ # <table>
1116
+ # <tr><td> `group_id` </td> <td> The ID of the group
1117
+ # (string) </td></tr>
1118
+ # </table>
1119
+ #
1120
+ # **`add_label`**, **`remove_label`**:
1121
+ # <table>
1122
+ # <tr><td> `label_id` </td> <td> The ID of the label
1123
+ # (string) </td></tr>
1124
+ # </table>
1125
+ #
1126
+ # **`resend_messages`**:
1127
+ # <table>
1128
+ # <tr><td> `route_id` </td> <td> ID of the new route
1129
+ # to use, or null to use the original route (string) </td></tr>
1130
+ # </table>
1131
+ #
1132
+ # **`set_send_blocked`**:
1133
+ # <table>
1134
+ # <tr><td> `send_blocked` </td> <td> `true` to block
1135
+ # sending messages, `false` to unblock sending messages (boolean) </td></tr>
1136
+ # </table>
1137
+ #
1138
+ # **`set_conversation_status`**:
1139
+ # <table>
1140
+ # <tr><td> `conversation_status` </td> <td> "active",
1141
+ # "handled", or "closed" (string) </td></tr>
1142
+ # </table>
1143
+ #
1144
+ # **`export_contacts`**, **`export_messages`**,
1145
+ # **`export_rows`**:
1146
+ # <table>
1147
+ # <tr><td>`storage_id` </td> <td> ID of a storage
1148
+ # backend where the CSV file will be saved. (string)
1149
+ #
1150
+ # Currently only AWS S3 is supported as a storage
1151
+ # backend.
1152
+ # This requires creating a S3 bucket in your own
1153
+ # AWS account, as well as an IAM user with access key and secret that has permission
1154
+ # to write to that bucket.
1155
+ # To configure your own S3 bucket as a storage
1156
+ # backend, contact support.
1157
+ #
1158
+ # Direct downloads are not supported when
1159
+ # exporting data via the API.
1160
+ # (string) </td></tr>
1161
+ # <tr><td>`filename` </td> <td> Path within the
1162
+ # storage backend where the CSV file will be saved </td></tr>
1163
+ # <tr><td>`column_ids` </td> <td> IDs of columns to
1164
+ # save in the CSV file. If not provided, all default columns will be saved. (array of
1165
+ # strings, optional) </td></tr>
1166
+ # </table>
1167
+ #
1168
+ # **`delete_contacts`**, **`delete_messages`**,
1169
+ # **`delete_rows`**, **`cancel_messages`**, **`retry_message_services`**: <br />
1170
+ # No parameters.
1171
+ #
1172
+ # - filter_type
1173
+ # * Type of filter defining the rows that the task is applied to.
1174
+ #
1175
+ # Each `filter_type` queries a certain type of
1176
+ # entity (such as contacts, messages, or data rows).
1177
+ #
1178
+ # In general, the `task_type` and the
1179
+ # `filter_type` must return the same type of entity; however, tasks applied to
1180
+ # contacts (other than `export_contacts`) can also be applied
1181
+ # when the filter returns entities that are
1182
+ # associated with a contact, such as messages or data rows. (Note that in this case,
1183
+ # it is possible for the task to be applied multiple times to an individual contact if
1184
+ # multiple messages or data rows are associated with the same contact.)
1185
+ # * Allowed values: query_contacts, contact_ids, query_rows, row_ids, query_messages,
1186
+ # message_ids
1187
+ # * Required
1188
+ #
1189
+ # - filter_params (Hash)
1190
+ # * Parameters defining the rows that the task is applied to (specific to
1191
+ # `filter_type`).
1192
+ #
1193
+ # **`query_contacts`**: <br />
1194
+ # The same filter parameters as used by
1195
+ # [project.queryContacts](#Project.queryContacts). If you want to apply the task to
1196
+ # all contacts, use the parameters {"all": true}.
1197
+ #
1198
+ # **`contact_ids`**:
1199
+ # <table>
1200
+ # <tr><td> `contact_ids` </td> <td> IDs of up to 100
1201
+ # contacts to apply this task to (array of strings) </td></tr>
1202
+ # </table>
1203
+ #
1204
+ # **`query_messages`**: <br />
1205
+ # The same filter parameters as used by
1206
+ # [project.queryMessages](#Project.queryMessages). If you want to apply the task to
1207
+ # all messages, use the parameters {"all": true}.
1208
+ #
1209
+ # **`message_ids`**:
1210
+ # <table>
1211
+ # <tr><td> `message_ids` </td> <td> IDs of up to 100
1212
+ # messages to apply this task to (array of strings) </td></tr>
1213
+ # </table>
1214
+ #
1215
+ # **`query_rows`**: <br />
1216
+ # The same filter parameters as used by
1217
+ # [table.queryRows](#DataTable.queryRows). If you want to apply the task to all rows
1218
+ # in the table, use the parameters {"all": true}.
1219
+ #
1220
+ # **`row_ids`**:
1221
+ # <table>
1222
+ # <tr><td> `row_ids` </td> <td> IDs of up to 100 data
1223
+ # rows to apply this task to (array of strings) </td></tr>
1224
+ # </table>
1225
+ # * Required
1226
+ #
1227
+ # - table_id (string, max 34 characters)
1228
+ # * ID of the data table this task is applied to (if applicable).
1229
+ #
1230
+ # Required if filter_type is `query_rows` or `row_ids`.
1231
+ #
1232
+ # - vars (Hash)
1233
+ # * Initial custom variables to set for the task.
1234
+ #
1235
+ # If the task applies a service, the service can read
1236
+ # and write custom variables on the task object (e.g. `task.vars.example`), such as
1237
+ # to store aggregate statistics for the rows matching
1238
+ # the filter.
1239
+ #
1240
+ # Returns:
1241
+ # Telerivet::Task
1242
+ #
1243
+ def create_task(options)
1244
+ require_relative 'task'
1245
+ Task.new(@api, @api.do_request("POST", get_base_api_path() + "/tasks", options))
1246
+ end
1247
+
1248
+ #
1249
+ # Queries batch tasks within the given project.
1250
+ #
1251
+ # Arguments:
1252
+ # - options (Hash)
1253
+ #
1254
+ # - sort
1255
+ # * Sort the results based on a field
1256
+ # * Allowed values: default
1257
+ # * Default: default
1258
+ #
1259
+ # - sort_dir
1260
+ # * Sort the results in ascending or descending order
1261
+ # * Allowed values: asc, desc
1262
+ # * Default: asc
1263
+ #
1264
+ # - page_size (int)
1265
+ # * Number of results returned per page (max 500)
1266
+ # * Default: 50
1267
+ #
1268
+ # - offset (int)
1269
+ # * Number of items to skip from beginning of result set
1270
+ # * Default: 0
1271
+ #
1272
+ # Returns:
1273
+ # Telerivet::APICursor (of Telerivet::Task)
1274
+ #
1275
+ def query_tasks(options = nil)
1276
+ require_relative 'task'
1277
+ @api.cursor(Task, get_base_api_path() + "/tasks", options)
1278
+ end
1279
+
1280
+ #
1281
+ # Retrieves the task with the given ID.
1282
+ #
1283
+ # Arguments:
1284
+ # - id
1285
+ # * ID of the task
1286
+ # * Required
1287
+ #
1288
+ # Returns:
1289
+ # Telerivet::Task
1290
+ #
1291
+ def get_task_by_id(id)
1292
+ require_relative 'task'
1293
+ Task.new(@api, @api.do_request("GET", get_base_api_path() + "/tasks/#{id}"))
1294
+ end
1295
+
1296
+ #
1297
+ # Initializes the task with the given ID without making an API request.
1298
+ #
1299
+ # Arguments:
1300
+ # - id
1301
+ # * ID of the task
1302
+ # * Required
1303
+ #
1304
+ # Returns:
1305
+ # Telerivet::Task
1306
+ #
1307
+ def init_task_by_id(id)
1308
+ require_relative 'task'
1309
+ return Task.new(@api, {'project_id' => self.id, 'id' => id}, false)
1310
+ end
1311
+
1022
1312
  #
1023
1313
  # Queries groups within the given project.
1024
1314
  #
@@ -1293,8 +1583,8 @@ class Project < Entity
1293
1583
  #
1294
1584
  # - next_time (UNIX timestamp)
1295
1585
  # * Filter scheduled messages by next_time
1296
- # * Allowed modifiers: next_time[exists], next_time[ne], next_time[min],
1297
- # next_time[max]
1586
+ # * Allowed modifiers: next_time[ne], next_time[min], next_time[max],
1587
+ # next_time[exists]
1298
1588
  #
1299
1589
  # - sort
1300
1590
  # * Sort the results based on a field
@@ -1370,7 +1660,7 @@ class Project < Entity
1370
1660
  #
1371
1661
  # - context
1372
1662
  # * Filter services that can be invoked in a particular context
1373
- # * Allowed values: message, call, contact, project
1663
+ # * Allowed values: message, call, ussd_session, row, contact, project
1374
1664
  #
1375
1665
  # - sort
1376
1666
  # * Sort the results based on a field
@@ -97,7 +97,7 @@ class Service < Entity
97
97
  #
98
98
  # - context
99
99
  # * The name of the context in which this service is invoked
100
- # * Allowed values: message, call, contact, project
100
+ # * Allowed values: message, call, ussd_session, row, contact, project
101
101
  # * Required
102
102
  #
103
103
  # - event
@@ -120,24 +120,29 @@ class Service < Entity
120
120
  # - route_id
121
121
  # * The ID of the phone or route that the service will use for sending messages by
122
122
  # default
123
+ #
124
+ # - async (bool)
125
+ # * If set to true, the service will be invoked asynchronously. By default, queued
126
+ # services will be invoked one at a time for each project.
123
127
  #
124
128
  # Returns:
125
129
  # (associative array)
126
130
  # - return_value (any)
127
131
  # * Return value of the service. May be any JSON type (boolean, number, string,
128
- # array, object, or null).
132
+ # array, object, or null). (Undefined if async=true.)
129
133
  #
130
134
  # - log_entries (array)
131
- # * Array of log entry strings generated by the service
135
+ # * Array of log entry strings generated by the service. (Undefined if async=true.)
132
136
  #
133
137
  # - errors (array)
134
- # * Array of error message strings generated by the service
138
+ # * Array of error message strings generated by the service. (Undefined if
139
+ # async=true.)
135
140
  #
136
141
  # - sent_messages (array of objects)
137
- # * Array of messages sent by the service
142
+ # * Array of messages sent by the service (Undefined if async=true.)
138
143
  #
139
144
  # - airtime_transactions (array of objects)
140
- # * Array of airtime transactions sent by the service
145
+ # * Array of airtime transactions sent by the service (Undefined if async=true.)
141
146
  #
142
147
  def invoke(options)
143
148
  invoke_result = @api.do_request('POST', get_base_api_path() + '/invoke', options)
@@ -234,9 +239,9 @@ class Service < Entity
234
239
  #
235
240
  # - vars (Hash)
236
241
  # * Filter states by value of a custom variable (e.g. vars[email], vars[foo], etc.)
237
- # * Allowed modifiers: vars[foo][exists], vars[foo][ne], vars[foo][prefix],
238
- # vars[foo][not_prefix], vars[foo][gte], vars[foo][gt], vars[foo][lt], vars[foo][lte],
239
- # vars[foo][min], vars[foo][max]
242
+ # * Allowed modifiers: vars[foo][ne], vars[foo][prefix], vars[foo][not_prefix],
243
+ # vars[foo][gte], vars[foo][gt], vars[foo][lt], vars[foo][lte], vars[foo][min],
244
+ # vars[foo][max], vars[foo][exists]
240
245
  #
241
246
  # - sort
242
247
  # * Sort the results based on a field
@@ -0,0 +1,151 @@
1
+
2
+ module Telerivet
3
+
4
+ #
5
+ # Represents an asynchronous task that is applied to all entities matching a filter.
6
+ #
7
+ # Tasks include services applied to contacts, messages, or data rows; adding
8
+ # or removing contacts from a group; blocking or unblocking sending messages to a contact;
9
+ # updating a custom variable; deleting contacts, messages, or data rows; or
10
+ # exporting data to CSV.
11
+ #
12
+ # Fields:
13
+ #
14
+ # - id (string, max 34 characters)
15
+ # * ID of the task
16
+ # * Read-only
17
+ #
18
+ # - task_type (string)
19
+ # * The task type
20
+ # * Read-only
21
+ #
22
+ # - task_params (Hash)
23
+ # * Parameters applied to all matching rows (specific to `task_type`). See
24
+ # [project.createTask](#Project.createTask).
25
+ # * Read-only
26
+ #
27
+ # - filter_type
28
+ # * Type of filter defining the rows that the task is applied to
29
+ # * Read-only
30
+ #
31
+ # - filter_params (Hash)
32
+ # * Parameters defining the rows that the task is applied to (specific to
33
+ # `filter_type`). See [project.createTask](#Project.createTask).
34
+ # * Read-only
35
+ #
36
+ # - time_created (UNIX timestamp)
37
+ # * Time the task was created in Telerivet
38
+ # * Read-only
39
+ #
40
+ # - time_active (UNIX timestamp)
41
+ # * Time Telerivet started executing the task
42
+ # * Read-only
43
+ #
44
+ # - time_complete (UNIX timestamp)
45
+ # * Time Telerivet finished executing the task
46
+ # * Read-only
47
+ #
48
+ # - total_rows (int)
49
+ # * The total number of rows matching the filter (null if not known)
50
+ # * Read-only
51
+ #
52
+ # - current_row (int)
53
+ # * The number of rows that have been processed so far
54
+ # * Read-only
55
+ #
56
+ # - status (string)
57
+ # * The current status of the task
58
+ # * Allowed values: created, queued, active, complete, failed, cancelled
59
+ # * Read-only
60
+ #
61
+ # - vars (Hash)
62
+ # * Custom variables stored for this task
63
+ # * Read-only
64
+ #
65
+ # - table_id (string, max 34 characters)
66
+ # * ID of the data table this task is applied to (if applicable)
67
+ # * Read-only
68
+ #
69
+ # - user_id (string, max 34 characters)
70
+ # * ID of the Telerivet user who created the task (if applicable)
71
+ # * Read-only
72
+ #
73
+ # - project_id
74
+ # * ID of the project this task belongs to
75
+ # * Read-only
76
+ #
77
+ class Task < Entity
78
+ #
79
+ # Cancels a task that is not yet complete.
80
+ #
81
+ # Returns:
82
+ # Telerivet::Task
83
+ #
84
+ def cancel()
85
+ require_relative 'task'
86
+ Task.new(@api, @api.do_request("POST", get_base_api_path() + "/cancel"))
87
+ end
88
+
89
+ def id
90
+ get('id')
91
+ end
92
+
93
+ def task_type
94
+ get('task_type')
95
+ end
96
+
97
+ def task_params
98
+ get('task_params')
99
+ end
100
+
101
+ def filter_type
102
+ get('filter_type')
103
+ end
104
+
105
+ def filter_params
106
+ get('filter_params')
107
+ end
108
+
109
+ def time_created
110
+ get('time_created')
111
+ end
112
+
113
+ def time_active
114
+ get('time_active')
115
+ end
116
+
117
+ def time_complete
118
+ get('time_complete')
119
+ end
120
+
121
+ def total_rows
122
+ get('total_rows')
123
+ end
124
+
125
+ def current_row
126
+ get('current_row')
127
+ end
128
+
129
+ def status
130
+ get('status')
131
+ end
132
+
133
+ def table_id
134
+ get('table_id')
135
+ end
136
+
137
+ def user_id
138
+ get('user_id')
139
+ end
140
+
141
+ def project_id
142
+ get('project_id')
143
+ end
144
+
145
+ def get_base_api_path()
146
+ "/projects/#{get('project_id')}/tasks/#{get('id')}"
147
+ end
148
+
149
+ end
150
+
151
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telerivet
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.6
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Young
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-14 00:00:00.000000000 Z
11
+ date: 2021-03-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby client library for Telerivet REST API
14
14
  email: support@telerivet.com
@@ -35,6 +35,7 @@ files:
35
35
  - lib/telerivet/route.rb
36
36
  - lib/telerivet/scheduledmessage.rb
37
37
  - lib/telerivet/service.rb
38
+ - lib/telerivet/task.rb
38
39
  homepage: http://telerivet.com
39
40
  licenses:
40
41
  - MIT