telerivet 1.1.7 → 1.2.1

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.
@@ -1,6 +1,6 @@
1
-
2
- module Telerivet
3
-
1
+
2
+ module Telerivet
3
+
4
4
  #
5
5
  # Represents a row in a custom data table.
6
6
  #
@@ -47,7 +47,7 @@ module Telerivet
47
47
  # * ID of the project this data row belongs to
48
48
  # * Read-only
49
49
  #
50
- class DataRow < Entity
50
+ class DataRow < Entity
51
51
  #
52
52
  # Saves any fields or custom variables that have changed for this data row.
53
53
  #
@@ -102,6 +102,6 @@ class DataRow < Entity
102
102
  "/projects/#{get('project_id')}/tables/#{get('table_id')}/rows/#{get('id')}"
103
103
  end
104
104
 
105
- end
106
-
107
- end
105
+ end
106
+
107
+ end
@@ -1,11 +1,10 @@
1
-
2
- module Telerivet
3
-
1
+
2
+ module Telerivet
3
+
4
4
  #
5
5
  # Represents a custom data table that can store arbitrary rows.
6
6
  #
7
- # For example, poll services use data tables to store a row for each
8
- # response.
7
+ # For example, poll services use data tables to store a row for each response.
9
8
  #
10
9
  # DataTables are schemaless -- each row simply stores custom variables. Each
11
10
  # variable name is equivalent to a different "column" of the data table.
@@ -34,7 +33,7 @@ module Telerivet
34
33
  # * ID of the project this data table belongs to
35
34
  # * Read-only
36
35
  #
37
- class DataTable < Entity
36
+ class DataTable < Entity
38
37
  #
39
38
  # Queries rows in this data table.
40
39
  #
@@ -203,6 +202,6 @@ class DataTable < Entity
203
202
  "/projects/#{get('project_id')}/tables/#{get('id')}"
204
203
  end
205
204
 
206
- end
207
-
208
- end
205
+ end
206
+
207
+ end
@@ -1,6 +1,6 @@
1
-
2
- module Telerivet
3
-
1
+
2
+ module Telerivet
3
+
4
4
  #
5
5
  # Represents a group used to organize contacts within Telerivet.
6
6
  #
@@ -34,7 +34,7 @@ module Telerivet
34
34
  # * ID of the project this group belongs to
35
35
  # * Read-only
36
36
  #
37
- class Group < Entity
37
+ class Group < Entity
38
38
  #
39
39
  # Queries contacts that are members of the given group.
40
40
  #
@@ -209,6 +209,6 @@ class Group < Entity
209
209
  "/projects/#{get('project_id')}/groups/#{get('id')}"
210
210
  end
211
211
 
212
- end
213
-
214
- end
212
+ end
213
+
214
+ end
@@ -1,6 +1,6 @@
1
-
2
- module Telerivet
3
-
1
+
2
+ module Telerivet
3
+
4
4
  #
5
5
  # Represents a label used to organize messages within Telerivet.
6
6
  #
@@ -26,7 +26,7 @@ module Telerivet
26
26
  # * ID of the project this label belongs to
27
27
  # * Read-only
28
28
  #
29
- class Label < Entity
29
+ class Label < Entity
30
30
  #
31
31
  # Queries messages with the given label.
32
32
  #
@@ -59,6 +59,9 @@ class Label < Entity
59
59
  # - time_created[max] (UNIX timestamp)
60
60
  # * Filter messages created before a particular time
61
61
  #
62
+ # - external_id
63
+ # * Filter messages by ID from an external provider
64
+ #
62
65
  # - contact_id
63
66
  # * ID of the contact who sent/received the message
64
67
  #
@@ -129,6 +132,6 @@ class Label < Entity
129
132
  "/projects/#{get('project_id')}/labels/#{get('id')}"
130
133
  end
131
134
 
132
- end
133
-
134
- end
135
+ end
136
+
137
+ end
@@ -59,7 +59,7 @@ module Telerivet
59
59
  # * Updatable via API
60
60
  #
61
61
  # - simulated (bool)
62
- # * Whether this message is was simulated within Telerivet for testing (and not actually
62
+ # * Whether this message was simulated within Telerivet for testing (and not actually
63
63
  # sent to or received by a real phone)
64
64
  # * Read-only
65
65
  #
@@ -98,6 +98,21 @@ module Telerivet
98
98
  # known.
99
99
  # * Read-only
100
100
  #
101
+ # - audio_url
102
+ # * For voice calls, the URL of an MP3 file to play when the contact answers the call
103
+ # * Read-only
104
+ #
105
+ # - tts_lang
106
+ # * For voice calls, the language of the text-to-speech voice
107
+ # * Allowed values: en-US, en-GB, en-GB-WLS, en-AU, en-IN, da-DK, nl-NL, fr-FR, fr-CA,
108
+ # de-DE, is-IS, it-IT, pl-PL, pt-BR, pt-PT, ru-RU, es-ES, es-US, sv-SE
109
+ # * Read-only
110
+ #
111
+ # - tts_voice
112
+ # * For voice calls, the text-to-speech voice
113
+ # * Allowed values: female, male
114
+ # * Read-only
115
+ #
101
116
  # - mms_parts (array)
102
117
  # * A list of parts in the MMS message, the same as returned by the
103
118
  # [getMMSParts](#Message.getMMSParts) method.
@@ -124,6 +139,10 @@ module Telerivet
124
139
  # * ID of the route that sent the message (if applicable)
125
140
  # * Read-only
126
141
  #
142
+ # - broadcast_id (string, max 34 characters)
143
+ # * ID of the broadcast that this message is part of (if applicable)
144
+ # * Read-only
145
+ #
127
146
  # - user_id (string, max 34 characters)
128
147
  # * ID of the Telerivet user who sent the message (if applicable)
129
148
  # * Read-only
@@ -327,6 +346,18 @@ class Message < Entity
327
346
  get('ring_time')
328
347
  end
329
348
 
349
+ def audio_url
350
+ get('audio_url')
351
+ end
352
+
353
+ def tts_lang
354
+ get('tts_lang')
355
+ end
356
+
357
+ def tts_voice
358
+ get('tts_voice')
359
+ end
360
+
330
361
  def mms_parts
331
362
  get('mms_parts')
332
363
  end
@@ -347,6 +378,10 @@ class Message < Entity
347
378
  get('route_id')
348
379
  end
349
380
 
381
+ def broadcast_id
382
+ get('broadcast_id')
383
+ end
384
+
350
385
  def user_id
351
386
  get('user_id')
352
387
  end
@@ -1,6 +1,6 @@
1
-
2
- module Telerivet
3
-
1
+
2
+ module Telerivet
3
+
4
4
  #
5
5
  # Represents a receipt received from a mobile money system such as Safaricom M-Pesa (Kenya),
6
6
  # Vodacom M-Pesa (Tanzania), or Tigo Pesa (Tanzania).
@@ -91,7 +91,7 @@ module Telerivet
91
91
  # * ID of the project this receipt belongs to
92
92
  # * Read-only
93
93
  #
94
- class MobileMoneyReceipt < Entity
94
+ class MobileMoneyReceipt < Entity
95
95
  #
96
96
  # Saves any fields or custom variables that have changed for this mobile money receipt.
97
97
  #
@@ -182,6 +182,6 @@ class MobileMoneyReceipt < Entity
182
182
  "/projects/#{get('project_id')}/receipts/#{get('id')}"
183
183
  end
184
184
 
185
- end
186
-
187
- end
185
+ end
186
+
187
+ end
@@ -1,6 +1,6 @@
1
-
2
- module Telerivet
3
-
1
+
2
+ module Telerivet
3
+
4
4
  #
5
5
  # Represents a phone or gateway that you use to send/receive messages via Telerivet.
6
6
  #
@@ -94,7 +94,7 @@ module Telerivet
94
94
  # (only present for Android phones)
95
95
  # * Read-only
96
96
  #
97
- class Phone < Entity
97
+ class Phone < Entity
98
98
  #
99
99
  # Queries messages sent or received by this phone.
100
100
  #
@@ -127,6 +127,9 @@ class Phone < Entity
127
127
  # - time_created[max] (UNIX timestamp)
128
128
  # * Filter messages created before a particular time
129
129
  #
130
+ # - external_id
131
+ # * Filter messages by ID from an external provider
132
+ #
130
133
  # - contact_id
131
134
  # * ID of the contact who sent/received the message
132
135
  #
@@ -254,6 +257,6 @@ class Phone < Entity
254
257
  "/projects/#{get('project_id')}/phones/#{get('id')}"
255
258
  end
256
259
 
257
- end
258
-
259
- end
260
+ end
261
+
262
+ end
@@ -1,6 +1,6 @@
1
-
2
- module Telerivet
3
-
1
+
2
+ module Telerivet
3
+
4
4
  #
5
5
  # Represents a Telerivet project.
6
6
  #
@@ -23,11 +23,15 @@ module Telerivet
23
23
  # <http://en.wikipedia.org/wiki/List_of_tz_database_time_zones>
24
24
  # * Read-only
25
25
  #
26
+ # - url_slug
27
+ # * Unique string used as a component of the project's URL in the Telerivet web app
28
+ # * Read-only
29
+ #
26
30
  # - vars (Hash)
27
31
  # * Custom variables stored for this project
28
32
  # * Updatable via API
29
33
  #
30
- class Project < Entity
34
+ class Project < Entity
31
35
  #
32
36
  # Sends one message (SMS, voice call, or USSD request).
33
37
  #
@@ -35,8 +39,14 @@ class Project < Entity
35
39
  # - options (Hash)
36
40
  # * Required
37
41
  #
42
+ # - message_type
43
+ # * Type of message to send
44
+ # * Allowed values: sms, ussd, call
45
+ # * Default: sms
46
+ #
38
47
  # - content
39
- # * Content of the message to send
48
+ # * Content of the message to send (if message_type=call, the text will be spoken
49
+ # during a text-to-speech call)
40
50
  # * Required if sending SMS message
41
51
  #
42
52
  # - to_number (string)
@@ -52,8 +62,29 @@ class Project < Entity
52
62
  # * Default: default sender phone ID for your project
53
63
  #
54
64
  # - service_id
55
- # * Service that defines the call flow of the voice call
56
- # * Required if sending voice call
65
+ # * Service that defines the call flow of the voice call (when message_type=call)
66
+ #
67
+ # - audio_url
68
+ # * The URL of an MP3 file to play when the contact answers the call (when
69
+ # message_type=call).
70
+ #
71
+ # If audio_url is provided, the text-to-speech voice is not used to say
72
+ # `content`, although you can optionally use `content` to indicate the script for the
73
+ # audio.
74
+ #
75
+ # For best results, use an MP3 file containing only speech. Music is not
76
+ # recommended because the audio quality will be low when played over a phone line.
77
+ #
78
+ # - tts_lang
79
+ # * The language of the text-to-speech voice (when message_type=call)
80
+ # * Allowed values: en-US, en-GB, en-GB-WLS, en-AU, en-IN, da-DK, nl-NL, fr-FR, fr-CA,
81
+ # de-DE, is-IS, it-IT, pl-PL, pt-BR, pt-PT, ru-RU, es-ES, es-US, sv-SE
82
+ # * Default: en-US
83
+ #
84
+ # - tts_voice
85
+ # * The name of the text-to-speech voice (when message_type=call)
86
+ # * Allowed values: female, male
87
+ # * Default: female
57
88
  #
58
89
  # - status_url
59
90
  # * Webhook callback URL to be notified when message status changes
@@ -69,11 +100,6 @@ class Project < Entity
69
100
  # - label_ids (array)
70
101
  # * List of IDs of labels to add to this message
71
102
  #
72
- # - message_type
73
- # * Type of message to send
74
- # * Allowed values: sms, ussd, call
75
- # * Default: sms
76
- #
77
103
  # - vars (Hash)
78
104
  # * Custom variables to store with the message
79
105
  #
@@ -82,6 +108,14 @@ class Project < Entity
82
108
  # will attempt to send messages with higher priority numbers first (for example, so
83
109
  # you can prioritize an auto-reply ahead of a bulk message to a large group).
84
110
  # * Default: 1
111
+ #
112
+ # - user_id
113
+ # * ID of the Telerivet user account that sent the message (use
114
+ # [project.getUsers](#Project.getUsers) to look up user IDs). In order to use this
115
+ # parameter, the user account associated with the API key must have administrator
116
+ # permissions for the project, and the user account associated with the user_id
117
+ # parameter must have access to the project.
118
+ # * Default: User account associated with the API key
85
119
  #
86
120
  # Returns:
87
121
  # Telerivet::Message
@@ -99,6 +133,11 @@ class Project < Entity
99
133
  # - options (Hash)
100
134
  # * Required
101
135
  #
136
+ # - message_type
137
+ # * Type of message to send
138
+ # * Allowed values: sms, call
139
+ # * Default: sms
140
+ #
102
141
  # - content
103
142
  # * Content of the message to send
104
143
  # * Required if sending SMS message
@@ -116,8 +155,29 @@ class Project < Entity
116
155
  # * Default: default sender phone ID
117
156
  #
118
157
  # - service_id
119
- # * Service that defines the call flow of the voice call
120
- # * Required if sending voice call
158
+ # * Service that defines the call flow of the voice call (when message_type=call)
159
+ #
160
+ # - audio_url
161
+ # * The URL of an MP3 file to play when the contact answers the call (when
162
+ # message_type=call).
163
+ #
164
+ # If audio_url is provided, the text-to-speech voice is not used to say
165
+ # `content`, although you can optionally use `content` to indicate the script for the
166
+ # audio.
167
+ #
168
+ # For best results, use an MP3 file containing only speech. Music is not
169
+ # recommended because the audio quality will be low when played over a phone line.
170
+ #
171
+ # - tts_lang
172
+ # * The language of the text-to-speech voice (when message_type=call)
173
+ # * Allowed values: en-US, en-GB, en-GB-WLS, en-AU, en-IN, da-DK, nl-NL, fr-FR, fr-CA,
174
+ # de-DE, is-IS, it-IT, pl-PL, pt-BR, pt-PT, ru-RU, es-ES, es-US, sv-SE
175
+ # * Default: en-US
176
+ #
177
+ # - tts_voice
178
+ # * The name of the text-to-speech voice (when message_type=call)
179
+ # * Allowed values: female, male
180
+ # * Default: female
121
181
  #
122
182
  # - status_url
123
183
  # * Webhook callback URL to be notified when message status changes
@@ -132,11 +192,6 @@ class Project < Entity
132
192
  # * Optionally excludes one contact from receiving the message (only when group_id is
133
193
  # set)
134
194
  #
135
- # - message_type
136
- # * Type of message to send
137
- # * Allowed values: sms, call
138
- # * Default: sms
139
- #
140
195
  # - is_template (bool)
141
196
  # * Set to true to evaluate variables like [[contact.name]] in message content [(See
142
197
  # available variables)](#variables)
@@ -149,9 +204,14 @@ class Project < Entity
149
204
  # (associative array)
150
205
  # - count_queued (int)
151
206
  # * Number of messages queued to send
207
+ #
208
+ # - broadcast_id
209
+ # * ID of broadcast created for this message batch. If count\_queued is 0 or 1, a
210
+ # broadcast will not be created, and the broadcast\_id property will be null.
152
211
  #
153
212
  def send_messages(options)
154
- return @api.do_request("POST", get_base_api_path() + "/messages/send_batch", options)
213
+ data = @api.do_request("POST", get_base_api_path() + "/messages/send_batch", options)
214
+ return data
155
215
  end
156
216
 
157
217
  #
@@ -163,6 +223,11 @@ class Project < Entity
163
223
  # - options (Hash)
164
224
  # * Required
165
225
  #
226
+ # - message_type
227
+ # * Type of message to send
228
+ # * Allowed values: sms, ussd
229
+ # * Default: sms
230
+ #
166
231
  # - content
167
232
  # * Content of the message to schedule
168
233
  # * Required if sending SMS message
@@ -194,13 +259,29 @@ class Project < Entity
194
259
  # * Default: default sender phone ID
195
260
  #
196
261
  # - service_id
197
- # * Service that defines the call flow of the voice call
198
- # * Required if sending voice call
199
- #
200
- # - message_type
201
- # * Type of message to send
202
- # * Allowed values: sms, ussd
203
- # * Default: sms
262
+ # * Service that defines the call flow of the voice call (when message_type=call)
263
+ #
264
+ # - audio_url
265
+ # * The URL of an MP3 file to play when the contact answers the call (when
266
+ # message_type=call).
267
+ #
268
+ # If audio_url is provided, the text-to-speech voice is not used to say
269
+ # `content`, although you can optionally use `content` to indicate the script for the
270
+ # audio.
271
+ #
272
+ # For best results, use an MP3 file containing only speech. Music is not
273
+ # recommended because the audio quality will be low when played over a phone line.
274
+ #
275
+ # - tts_lang
276
+ # * The language of the text-to-speech voice (when message_type=call)
277
+ # * Allowed values: en-US, en-GB, en-GB-WLS, en-AU, en-IN, da-DK, nl-NL, fr-FR, fr-CA,
278
+ # de-DE, is-IS, it-IT, pl-PL, pt-BR, pt-PT, ru-RU, es-ES, es-US, sv-SE
279
+ # * Default: en-US
280
+ #
281
+ # - tts_voice
282
+ # * The name of the text-to-speech voice (when message_type=call)
283
+ # * Allowed values: female, male
284
+ # * Default: female
204
285
  #
205
286
  # - is_template (bool)
206
287
  # * Set to true to evaluate variables like [[contact.name]] in message content
@@ -562,6 +643,9 @@ class Project < Entity
562
643
  # - time_created[max] (UNIX timestamp)
563
644
  # * Filter messages created before a particular time
564
645
  #
646
+ # - external_id
647
+ # * Filter messages by ID from an external provider
648
+ #
565
649
  # - contact_id
566
650
  # * ID of the contact who sent/received the message
567
651
  #
@@ -626,6 +710,82 @@ class Project < Entity
626
710
  return Message.new(@api, {'project_id' => self.id, 'id' => id}, false)
627
711
  end
628
712
 
713
+ #
714
+ # Queries broadcasts within the given project.
715
+ #
716
+ # Arguments:
717
+ # - options (Hash)
718
+ #
719
+ # - time_created[min] (UNIX timestamp)
720
+ # * Filter broadcasts created on or after a particular time
721
+ #
722
+ # - time_created[max] (UNIX timestamp)
723
+ # * Filter broadcasts created before a particular time
724
+ #
725
+ # - last_message_time[min] (UNIX timestamp)
726
+ # * Filter broadcasts with most recent message on or after a particular time
727
+ #
728
+ # - last_message_time[max] (UNIX timestamp)
729
+ # * Filter broadcasts with most recent message before a particular time
730
+ #
731
+ # - sort
732
+ # * Sort the results based on a field
733
+ # * Allowed values: default, last_message_time
734
+ # * Default: default
735
+ #
736
+ # - sort_dir
737
+ # * Sort the results in ascending or descending order
738
+ # * Allowed values: asc, desc
739
+ # * Default: asc
740
+ #
741
+ # - page_size (int)
742
+ # * Number of results returned per page (max 200)
743
+ # * Default: 50
744
+ #
745
+ # - offset (int)
746
+ # * Number of items to skip from beginning of result set
747
+ # * Default: 0
748
+ #
749
+ # Returns:
750
+ # Telerivet::APICursor (of Telerivet::Broadcast)
751
+ #
752
+ def query_broadcasts(options = nil)
753
+ require_relative 'broadcast'
754
+ @api.cursor(Broadcast, get_base_api_path() + "/broadcasts", options)
755
+ end
756
+
757
+ #
758
+ # Retrieves the broadcast with the given ID.
759
+ #
760
+ # Arguments:
761
+ # - id
762
+ # * ID of the broadcast
763
+ # * Required
764
+ #
765
+ # Returns:
766
+ # Telerivet::Broadcast
767
+ #
768
+ def get_broadcast_by_id(id)
769
+ require_relative 'broadcast'
770
+ Broadcast.new(@api, @api.do_request("GET", get_base_api_path() + "/broadcasts/#{id}"))
771
+ end
772
+
773
+ #
774
+ # Initializes the Telerivet broadcast with the given ID without making an API request.
775
+ #
776
+ # Arguments:
777
+ # - id
778
+ # * ID of the broadcast
779
+ # * Required
780
+ #
781
+ # Returns:
782
+ # Telerivet::Broadcast
783
+ #
784
+ def init_broadcast_by_id(id)
785
+ require_relative 'broadcast'
786
+ return Broadcast.new(@api, {'project_id' => self.id, 'id' => id}, false)
787
+ end
788
+
629
789
  #
630
790
  # Queries groups within the given project.
631
791
  #
@@ -977,7 +1137,7 @@ class Project < Entity
977
1137
  #
978
1138
  # - context
979
1139
  # * Filter services that can be invoked in a particular context
980
- # * Allowed values: message, contact, project
1140
+ # * Allowed values: message, call, contact, project
981
1141
  #
982
1142
  # - sort
983
1143
  # * Sort the results based on a field
@@ -1228,10 +1388,14 @@ class Project < Entity
1228
1388
  get('timezone_id')
1229
1389
  end
1230
1390
 
1391
+ def url_slug
1392
+ get('url_slug')
1393
+ end
1394
+
1231
1395
  def get_base_api_path()
1232
1396
  "/projects/#{get('id')}"
1233
1397
  end
1234
1398
 
1235
- end
1236
-
1237
- end
1399
+ end
1400
+
1401
+ end