telerivet 1.3.0 → 1.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/telerivet.rb +12 -4
- data/lib/telerivet/airtimetransaction.rb +131 -0
- data/lib/telerivet/broadcast.rb +56 -8
- data/lib/telerivet/contact.rb +37 -9
- data/lib/telerivet/datatable.rb +71 -3
- data/lib/telerivet/group.rb +3 -3
- data/lib/telerivet/label.rb +11 -4
- data/lib/telerivet/message.rb +74 -4
- data/lib/telerivet/organization.rb +1 -1
- data/lib/telerivet/phone.rb +17 -6
- data/lib/telerivet/project.rb +365 -147
- data/lib/telerivet/route.rb +8 -2
- data/lib/telerivet/scheduledmessage.rb +22 -1
- data/lib/telerivet/service.rb +31 -5
- metadata +4 -5
- data/lib/telerivet/mobilemoneyreceipt.rb +0 -187
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b442bc6d2aab45f4be47acc976f991bbd399de9a68ac092ec6dd2d717c3373e9
|
4
|
+
data.tar.gz: 7c629053a6f168be87bb4e705e6cad78c9e7ec3aebe34cbb7553843dcf0cb02b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2585a9e281177331fe9615cbf02d91169f5f6bb178ebe228cd81b4def87576a7486b4e5457261b324f6fe1b958bace906e2e3a28d5b9bef8cb7c77f09bc9586
|
7
|
+
data.tar.gz: 35cb63dc5fbcdb5400808a8f3c4db85e4e5b07d85bd273c01d4693975ae10682e758a67e92797b7e771ccaba6fcd573e3629389aed7696346eff142da6186ef7
|
data/lib/telerivet.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'json'
|
3
|
+
require 'zlib'
|
3
4
|
require_relative 'telerivet/entity'
|
4
5
|
require_relative 'telerivet/apicursor'
|
5
6
|
|
@@ -8,7 +9,7 @@ module Telerivet
|
|
8
9
|
class API
|
9
10
|
attr_reader :num_requests
|
10
11
|
|
11
|
-
@@client_version = '1.
|
12
|
+
@@client_version = '1.4.6'
|
12
13
|
|
13
14
|
#
|
14
15
|
# Initializes a client handle to the Telerivet REST API.
|
@@ -61,7 +62,14 @@ class API
|
|
61
62
|
if has_post_data
|
62
63
|
request.set_content_type("application/json")
|
63
64
|
if params != nil
|
64
|
-
|
65
|
+
data = JSON.dump(params)
|
66
|
+
|
67
|
+
if data.length >= 400
|
68
|
+
request['Content-Encoding'] = 'gzip'
|
69
|
+
data = Zlib::Deflate.new(nil, 31).deflate(data, Zlib::FINISH)
|
70
|
+
end
|
71
|
+
|
72
|
+
request.body = data
|
65
73
|
end
|
66
74
|
end
|
67
75
|
|
@@ -145,7 +153,7 @@ class API
|
|
145
153
|
# * Default: asc
|
146
154
|
#
|
147
155
|
# - page_size (int)
|
148
|
-
# * Number of results returned per page (max
|
156
|
+
# * Number of results returned per page (max 500)
|
149
157
|
# * Default: 50
|
150
158
|
#
|
151
159
|
# - offset (int)
|
@@ -214,7 +222,7 @@ class API
|
|
214
222
|
# * Default: asc
|
215
223
|
#
|
216
224
|
# - page_size (int)
|
217
|
-
# * Number of results returned per page (max
|
225
|
+
# * Number of results returned per page (max 500)
|
218
226
|
# * Default: 50
|
219
227
|
#
|
220
228
|
# - offset (int)
|
@@ -0,0 +1,131 @@
|
|
1
|
+
|
2
|
+
module Telerivet
|
3
|
+
|
4
|
+
#
|
5
|
+
# Represents a transaction where airtime is sent to a mobile phone number.
|
6
|
+
#
|
7
|
+
# To send airtime, first [create a Custom Actions service to send a particular amount of
|
8
|
+
# airtime](/dashboard/add_service?subtype_id=main.service.rules.contact&action_id=main.rule.sendairtime),
|
9
|
+
# then trigger the service using [service.invoke](#Service.invoke),
|
10
|
+
# [project.sendBroadcast](#Project.sendBroadcast), or
|
11
|
+
# [project.scheduleMessage](#Project.scheduleMessage).
|
12
|
+
#
|
13
|
+
# Fields:
|
14
|
+
#
|
15
|
+
# - id
|
16
|
+
# * ID of the airtime transaction
|
17
|
+
# * Read-only
|
18
|
+
#
|
19
|
+
# - to_number
|
20
|
+
# * Destination phone number in international format (no leading +)
|
21
|
+
# * Read-only
|
22
|
+
#
|
23
|
+
# - operator_name
|
24
|
+
# * Operator name
|
25
|
+
# * Read-only
|
26
|
+
#
|
27
|
+
# - country
|
28
|
+
# * Country code
|
29
|
+
# * Read-only
|
30
|
+
#
|
31
|
+
# - status
|
32
|
+
# * Current status of airtime transaction (`successful`, `failed`, `cancelled`,
|
33
|
+
# `queued`, `pending_approval`, or `pending_payment`)
|
34
|
+
# * Read-only
|
35
|
+
#
|
36
|
+
# - status_text
|
37
|
+
# * Error or success message returned by airtime provider, if available
|
38
|
+
# * Read-only
|
39
|
+
#
|
40
|
+
# - value
|
41
|
+
# * Value of airtime sent to destination phone number, in units of value_currency
|
42
|
+
# * Read-only
|
43
|
+
#
|
44
|
+
# - value_currency
|
45
|
+
# * Currency code of price
|
46
|
+
# * Read-only
|
47
|
+
#
|
48
|
+
# - price
|
49
|
+
# * Price charged for airtime transaction, in units of price_currency
|
50
|
+
# * Read-only
|
51
|
+
#
|
52
|
+
# - price_currency
|
53
|
+
# * Currency code of price
|
54
|
+
# * Read-only
|
55
|
+
#
|
56
|
+
# - contact_id
|
57
|
+
# * ID of the contact the airtime was sent to
|
58
|
+
# * Read-only
|
59
|
+
#
|
60
|
+
# - service_id
|
61
|
+
# * ID of the service that sent the airtime
|
62
|
+
# * Read-only
|
63
|
+
#
|
64
|
+
# - project_id
|
65
|
+
# * ID of the project that the airtime transaction belongs to
|
66
|
+
# * Read-only
|
67
|
+
#
|
68
|
+
# - vars (Hash)
|
69
|
+
# * Custom variables stored for this transaction
|
70
|
+
# * Updatable via API
|
71
|
+
#
|
72
|
+
class AirtimeTransaction < Entity
|
73
|
+
def id
|
74
|
+
get('id')
|
75
|
+
end
|
76
|
+
|
77
|
+
def to_number
|
78
|
+
get('to_number')
|
79
|
+
end
|
80
|
+
|
81
|
+
def operator_name
|
82
|
+
get('operator_name')
|
83
|
+
end
|
84
|
+
|
85
|
+
def country
|
86
|
+
get('country')
|
87
|
+
end
|
88
|
+
|
89
|
+
def status
|
90
|
+
get('status')
|
91
|
+
end
|
92
|
+
|
93
|
+
def status_text
|
94
|
+
get('status_text')
|
95
|
+
end
|
96
|
+
|
97
|
+
def value
|
98
|
+
get('value')
|
99
|
+
end
|
100
|
+
|
101
|
+
def value_currency
|
102
|
+
get('value_currency')
|
103
|
+
end
|
104
|
+
|
105
|
+
def price
|
106
|
+
get('price')
|
107
|
+
end
|
108
|
+
|
109
|
+
def price_currency
|
110
|
+
get('price_currency')
|
111
|
+
end
|
112
|
+
|
113
|
+
def contact_id
|
114
|
+
get('contact_id')
|
115
|
+
end
|
116
|
+
|
117
|
+
def service_id
|
118
|
+
get('service_id')
|
119
|
+
end
|
120
|
+
|
121
|
+
def project_id
|
122
|
+
get('project_id')
|
123
|
+
end
|
124
|
+
|
125
|
+
def get_base_api_path()
|
126
|
+
"/projects/#{get('project_id')}/airtime_transactions/#{get('id')}"
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
data/lib/telerivet/broadcast.rb
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
module Telerivet
|
3
3
|
|
4
4
|
#
|
5
|
+
# Represents a collection of related outgoing messages.
|
6
|
+
# Typically, messages in a broadcast have the same content template and were
|
7
|
+
# sent at the same time; however, a broadcast can also contain messages with unrelated content
|
8
|
+
# and messages that were sent at different times.
|
9
|
+
# A broadcast is automatically created when sending a message to a group of
|
10
|
+
# contacts.
|
11
|
+
#
|
5
12
|
# Fields:
|
6
13
|
#
|
7
14
|
# - id (string, max 34 characters)
|
@@ -25,9 +32,10 @@ module Telerivet
|
|
25
32
|
# `filter_params` properties, as they may change without notice.)
|
26
33
|
# * Read-only
|
27
34
|
#
|
28
|
-
# -
|
29
|
-
# *
|
30
|
-
#
|
35
|
+
# - title
|
36
|
+
# * Title of the broadcast. If a title was not provided when the broadcast was sent, it
|
37
|
+
# is automatically set to a human readable description of the first few recipients
|
38
|
+
# (possibly truncated)
|
31
39
|
# * Read-only
|
32
40
|
#
|
33
41
|
# - time_created (UNIX timestamp)
|
@@ -67,7 +75,7 @@ module Telerivet
|
|
67
75
|
#
|
68
76
|
# - message_type
|
69
77
|
# * Type of message sent from this broadcast
|
70
|
-
# * Allowed values: sms, mms, ussd, call
|
78
|
+
# * Allowed values: sms, mms, ussd, call, service
|
71
79
|
# * Read-only
|
72
80
|
#
|
73
81
|
# - content (string)
|
@@ -101,7 +109,7 @@ module Telerivet
|
|
101
109
|
#
|
102
110
|
# - source
|
103
111
|
# * How the message originated within Telerivet
|
104
|
-
# * Allowed values: phone, provider, web, api, service, webhook, scheduled
|
112
|
+
# * Allowed values: phone, provider, web, api, service, webhook, scheduled, integration
|
105
113
|
# * Read-only
|
106
114
|
#
|
107
115
|
# - simulated (bool)
|
@@ -109,12 +117,31 @@ module Telerivet
|
|
109
117
|
# sent to or received by a real phone)
|
110
118
|
# * Read-only
|
111
119
|
#
|
120
|
+
# - track_clicks (boolean)
|
121
|
+
# * If true, URLs in the message content will automatically be replaced with unique
|
122
|
+
# short URLs.
|
123
|
+
# * Read-only
|
124
|
+
#
|
125
|
+
# - clicked_count (int)
|
126
|
+
# * The number of messages in this broadcast containing short links that were clicked.
|
127
|
+
# At most one click per message is counted. If track_clicks is false, this property will
|
128
|
+
# be null.
|
129
|
+
# * Read-only
|
130
|
+
#
|
112
131
|
# - label_ids (array)
|
113
132
|
# * List of IDs of labels applied to all messages in the broadcast
|
114
133
|
# * Read-only
|
115
134
|
#
|
135
|
+
# - media (array)
|
136
|
+
# * For text messages containing media files, this is an array of objects with the
|
137
|
+
# properties `url`, `type` (MIME type), `filename`, and `size` (file size in bytes).
|
138
|
+
# Unknown properties are null. This property is undefined for messages that do not
|
139
|
+
# contain media files. Note: For files uploaded via the Telerivet web app, the URL is
|
140
|
+
# temporary and may not be valid for more than 1 day.
|
141
|
+
# * Read-only
|
142
|
+
#
|
116
143
|
# - vars (Hash)
|
117
|
-
# * Custom variables stored for this
|
144
|
+
# * Custom variables stored for this broadcast
|
118
145
|
# * Read-only
|
119
146
|
#
|
120
147
|
# - price (number)
|
@@ -139,6 +166,11 @@ module Telerivet
|
|
139
166
|
# * ID of the phone or route used to send the broadcast (if applicable)
|
140
167
|
# * Read-only
|
141
168
|
#
|
169
|
+
# - service_id (string, max 34 characters)
|
170
|
+
# * The service associated with this broadcast (for voice calls, the service defines the
|
171
|
+
# call flow)
|
172
|
+
# * Read-only
|
173
|
+
#
|
142
174
|
# - user_id (string, max 34 characters)
|
143
175
|
# * ID of the Telerivet user who sent the broadcast (if applicable)
|
144
176
|
# * Read-only
|
@@ -170,8 +202,8 @@ class Broadcast < Entity
|
|
170
202
|
get('recipients')
|
171
203
|
end
|
172
204
|
|
173
|
-
def
|
174
|
-
get('
|
205
|
+
def title
|
206
|
+
get('title')
|
175
207
|
end
|
176
208
|
|
177
209
|
def time_created
|
@@ -234,10 +266,22 @@ class Broadcast < Entity
|
|
234
266
|
get('simulated')
|
235
267
|
end
|
236
268
|
|
269
|
+
def track_clicks
|
270
|
+
get('track_clicks')
|
271
|
+
end
|
272
|
+
|
273
|
+
def clicked_count
|
274
|
+
get('clicked_count')
|
275
|
+
end
|
276
|
+
|
237
277
|
def label_ids
|
238
278
|
get('label_ids')
|
239
279
|
end
|
240
280
|
|
281
|
+
def media
|
282
|
+
get('media')
|
283
|
+
end
|
284
|
+
|
241
285
|
def price
|
242
286
|
get('price')
|
243
287
|
end
|
@@ -258,6 +302,10 @@ class Broadcast < Entity
|
|
258
302
|
get('route_id')
|
259
303
|
end
|
260
304
|
|
305
|
+
def service_id
|
306
|
+
get('service_id')
|
307
|
+
end
|
308
|
+
|
261
309
|
def user_id
|
262
310
|
get('user_id')
|
263
311
|
end
|
data/lib/telerivet/contact.rb
CHANGED
@@ -19,10 +19,19 @@ module Telerivet
|
|
19
19
|
# * Time the contact was added in Telerivet
|
20
20
|
# * Read-only
|
21
21
|
#
|
22
|
+
# - time_updated (UNIX timestamp)
|
23
|
+
# * Time the contact was last updated in Telerivet
|
24
|
+
# * Read-only
|
25
|
+
#
|
22
26
|
# - send_blocked (bool)
|
23
27
|
# * True if Telerivet is blocked from sending messages to this contact
|
24
28
|
# * Updatable via API
|
25
29
|
#
|
30
|
+
# - conversation_status
|
31
|
+
# * Current status of the conversation with this contact
|
32
|
+
# * Allowed values: closed, active, handled
|
33
|
+
# * Updatable via API
|
34
|
+
#
|
26
35
|
# - last_message_time (UNIX timestamp)
|
27
36
|
# * Last time the contact sent or received a message (null if no messages have been sent
|
28
37
|
# or received)
|
@@ -125,11 +134,12 @@ class Contact < Entity
|
|
125
134
|
#
|
126
135
|
# - message_type
|
127
136
|
# * Filter messages by message_type
|
128
|
-
# * Allowed values: sms, mms, ussd, call
|
137
|
+
# * Allowed values: sms, mms, ussd, call, service
|
129
138
|
#
|
130
139
|
# - source
|
131
140
|
# * Filter messages by source
|
132
|
-
# * Allowed values: phone, provider, web, api, service, webhook, scheduled
|
141
|
+
# * Allowed values: phone, provider, web, api, service, webhook, scheduled,
|
142
|
+
# integration
|
133
143
|
#
|
134
144
|
# - starred (bool)
|
135
145
|
# * Filter messages by starred/unstarred
|
@@ -152,7 +162,13 @@ class Contact < Entity
|
|
152
162
|
# * ID of the contact who sent/received the message
|
153
163
|
#
|
154
164
|
# - phone_id
|
155
|
-
# * ID of the phone that sent/received the message
|
165
|
+
# * ID of the phone (basic route) that sent/received the message
|
166
|
+
#
|
167
|
+
# - broadcast_id
|
168
|
+
# * ID of the broadcast containing the message
|
169
|
+
#
|
170
|
+
# - scheduled_id
|
171
|
+
# * ID of the scheduled message that created this message
|
156
172
|
#
|
157
173
|
# - sort
|
158
174
|
# * Sort the results based on a field
|
@@ -165,7 +181,7 @@ class Contact < Entity
|
|
165
181
|
# * Default: asc
|
166
182
|
#
|
167
183
|
# - page_size (int)
|
168
|
-
# * Number of results returned per page (max
|
184
|
+
# * Number of results returned per page (max 500)
|
169
185
|
# * Default: 50
|
170
186
|
#
|
171
187
|
# - offset (int)
|
@@ -205,7 +221,7 @@ class Contact < Entity
|
|
205
221
|
# * Default: asc
|
206
222
|
#
|
207
223
|
# - page_size (int)
|
208
|
-
# * Number of results returned per page (max
|
224
|
+
# * Number of results returned per page (max 500)
|
209
225
|
# * Default: 50
|
210
226
|
#
|
211
227
|
# - offset (int)
|
@@ -229,7 +245,7 @@ class Contact < Entity
|
|
229
245
|
#
|
230
246
|
# - message_type
|
231
247
|
# * Filter scheduled messages by message_type
|
232
|
-
# * Allowed values: sms, mms, ussd, call
|
248
|
+
# * Allowed values: sms, mms, ussd, call, service
|
233
249
|
#
|
234
250
|
# - time_created (UNIX timestamp)
|
235
251
|
# * Filter scheduled messages by time_created
|
@@ -251,7 +267,7 @@ class Contact < Entity
|
|
251
267
|
# * Default: asc
|
252
268
|
#
|
253
269
|
# - page_size (int)
|
254
|
-
# * Number of results returned per page (max
|
270
|
+
# * Number of results returned per page (max 500)
|
255
271
|
# * Default: 50
|
256
272
|
#
|
257
273
|
# - offset (int)
|
@@ -287,7 +303,7 @@ class Contact < Entity
|
|
287
303
|
# * Default: asc
|
288
304
|
#
|
289
305
|
# - page_size (int)
|
290
|
-
# * Number of results returned per page (max
|
306
|
+
# * Number of results returned per page (max 500)
|
291
307
|
# * Default: 50
|
292
308
|
#
|
293
309
|
# - offset (int)
|
@@ -330,7 +346,7 @@ class Contact < Entity
|
|
330
346
|
# * Default: asc
|
331
347
|
#
|
332
348
|
# - page_size (int)
|
333
|
-
# * Number of results returned per page (max
|
349
|
+
# * Number of results returned per page (max 500)
|
334
350
|
# * Default: 50
|
335
351
|
#
|
336
352
|
# - offset (int)
|
@@ -383,6 +399,10 @@ class Contact < Entity
|
|
383
399
|
get('time_created')
|
384
400
|
end
|
385
401
|
|
402
|
+
def time_updated
|
403
|
+
get('time_updated')
|
404
|
+
end
|
405
|
+
|
386
406
|
def send_blocked
|
387
407
|
get('send_blocked')
|
388
408
|
end
|
@@ -391,6 +411,14 @@ class Contact < Entity
|
|
391
411
|
set('send_blocked', value)
|
392
412
|
end
|
393
413
|
|
414
|
+
def conversation_status
|
415
|
+
get('conversation_status')
|
416
|
+
end
|
417
|
+
|
418
|
+
def conversation_status=(value)
|
419
|
+
set('conversation_status', value)
|
420
|
+
end
|
421
|
+
|
394
422
|
def last_message_time
|
395
423
|
get('last_message_time')
|
396
424
|
end
|