telerivet 1.3.0 → 1.4.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
  SHA1:
3
- metadata.gz: f29fae453430b0721c120ed759f6471eb6353a5a
4
- data.tar.gz: 20efe5389264b4ff2ba936b23a77ff1ade66aec5
3
+ metadata.gz: 2d2fced513f7484cd8ea41bc16c1e95a20dbe18d
4
+ data.tar.gz: e4fc99c1924272a9872262ece7f291c6f92060b4
5
5
  SHA512:
6
- metadata.gz: 0caee23855bbca0c7bc86ac0c5c4e057ab11470999871542d884d7c1c381713203f7d2f136653208833a4f5528a40e63965b9a20ea6c8b0fcde6553d2a605ab2
7
- data.tar.gz: 39e7a0403bba946173d14ecbe1e02016cf4b160b7e81b06efdd6df18a01178340f015e3b89a93eb5191aa061a04ed30e854cbc31794e8a1cf58007e0fe112d4b
6
+ metadata.gz: f027ddecadb6e32b3dded7c0ee27b4d7afeede434d02848bc2a23f69186765e2bc77ec0dac6cc4bde926d0959b889e29bf76490037bb24ce19cb772874c21c82
7
+ data.tar.gz: 82ccab2d76a1b30183d39945d958901fe85ab575003fa1341aca0d5087d3b3a277cd19d0f96126d9a4ad1e01e9de8252556c20e3b0ab8d48b504005d6f869790
@@ -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.3.0'
12
+ @@client_version = '1.4.0'
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
- request.body = JSON.dump(params)
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
 
@@ -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
- # - recipients_str
29
- # * A string with a human readable description of the first few recipients (possibly
30
- # truncated)
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)
@@ -114,7 +122,7 @@ module Telerivet
114
122
  # * Read-only
115
123
  #
116
124
  # - vars (Hash)
117
- # * Custom variables stored for this message
125
+ # * Custom variables stored for this broadcast
118
126
  # * Read-only
119
127
  #
120
128
  # - price (number)
@@ -170,8 +178,8 @@ class Broadcast < Entity
170
178
  get('recipients')
171
179
  end
172
180
 
173
- def recipients_str
174
- get('recipients_str')
181
+ def title
182
+ get('title')
175
183
  end
176
184
 
177
185
  def time_created
@@ -152,7 +152,10 @@ class Contact < Entity
152
152
  # * ID of the contact who sent/received the message
153
153
  #
154
154
  # - phone_id
155
- # * ID of the phone that sent/received the message
155
+ # * ID of the phone (basic route) that sent/received the message
156
+ #
157
+ # - broadcast_id
158
+ # * ID of the broadcast containing the message
156
159
  #
157
160
  # - sort
158
161
  # * Sort the results based on a field
@@ -66,7 +66,10 @@ class Label < Entity
66
66
  # * ID of the contact who sent/received the message
67
67
  #
68
68
  # - phone_id
69
- # * ID of the phone that sent/received the message
69
+ # * ID of the phone (basic route) that sent/received the message
70
+ #
71
+ # - broadcast_id
72
+ # * ID of the broadcast containing the message
70
73
  #
71
74
  # - sort
72
75
  # * Sort the results based on a field
@@ -128,7 +128,7 @@ module Telerivet
128
128
  # * Read-only
129
129
  #
130
130
  # - phone_id (string, max 34 characters)
131
- # * ID of the phone that sent or received the message
131
+ # * ID of the phone (basic route) that sent or received the message
132
132
  # * Read-only
133
133
  #
134
134
  # - contact_id (string, max 34 characters)
@@ -136,7 +136,7 @@ module Telerivet
136
136
  # * Read-only
137
137
  #
138
138
  # - route_id (string, max 34 characters)
139
- # * ID of the route that sent the message (if applicable)
139
+ # * ID of the custom route that sent the message (if applicable)
140
140
  # * Read-only
141
141
  #
142
142
  # - broadcast_id (string, max 34 characters)
@@ -4,6 +4,10 @@ module Telerivet
4
4
  #
5
5
  # Represents a phone or gateway that you use to send/receive messages via Telerivet.
6
6
  #
7
+ # Basic Routes were formerly referred to as "Phones" within Telerivet. API
8
+ # methods, parameters, and properties related to Basic Routes continue to use the term "Phone"
9
+ # to maintain backwards compatibility.
10
+ #
7
11
  # Fields:
8
12
  #
9
13
  # - id (string, max 34 characters)
@@ -15,11 +19,11 @@ module Telerivet
15
19
  # * Updatable via API
16
20
  #
17
21
  # - phone_number (string)
18
- # * Phone number of the phone
22
+ # * Phone number or sender ID
19
23
  # * Updatable via API
20
24
  #
21
25
  # - phone_type
22
- # * Type of this phone/gateway (e.g. android, twilio, nexmo, etc)
26
+ # * Type of this phone/route (e.g. android, twilio, nexmo, etc)
23
27
  # * Read-only
24
28
  #
25
29
  # - country
@@ -134,7 +138,10 @@ class Phone < Entity
134
138
  # * ID of the contact who sent/received the message
135
139
  #
136
140
  # - phone_id
137
- # * ID of the phone that sent/received the message
141
+ # * ID of the phone (basic route) that sent/received the message
142
+ #
143
+ # - broadcast_id
144
+ # * ID of the broadcast containing the message
138
145
  #
139
146
  # - sort
140
147
  # * Sort the results based on a field
@@ -63,7 +63,7 @@ class Project < Entity
63
63
  #
64
64
  # - route_id
65
65
  # * ID of the phone or route to send the message from
66
- # * Default: default sender phone ID for your project
66
+ # * Default: default sender route ID for your project
67
67
  #
68
68
  # - service_id
69
69
  # * Service that defines the call flow of the voice call (when `message_type` is
@@ -113,14 +113,6 @@ class Project < Entity
113
113
  # will attempt to send messages with higher priority numbers first (for example, so
114
114
  # you can prioritize an auto-reply ahead of a bulk message to a large group).
115
115
  # * Default: 1
116
- #
117
- # - user_id
118
- # * ID of the Telerivet user account that sent the message (use
119
- # [project.getUsers](#Project.getUsers) to look up user IDs). In order to use this
120
- # parameter, the user account associated with the API key must have administrator
121
- # permissions for the project, and the user account associated with the user_id
122
- # parameter must have access to the project.
123
- # * Default: User account associated with the API key
124
116
  #
125
117
  # Returns:
126
118
  # Telerivet::Message
@@ -131,7 +123,7 @@ class Project < Entity
131
123
  end
132
124
 
133
125
  #
134
- # Sends an SMS message (optionally with mail-merge templates) or voice call to a group or a
126
+ # Sends a text message (optionally with mail-merge templates) or voice call to a group or a
135
127
  # list of up to 500 phone numbers
136
128
  #
137
129
  # Arguments:
@@ -157,7 +149,11 @@ class Project < Entity
157
149
  #
158
150
  # - route_id
159
151
  # * ID of the phone or route to send the message from
160
- # * Default: default sender phone ID
152
+ # * Default: default sender route ID
153
+ #
154
+ # - title (string)
155
+ # * Title of the broadcast. If a title is not provided, a title will automatically be
156
+ # generated from the recipient group name or phone numbers.
161
157
  #
162
158
  # - service_id
163
159
  # * Service that defines the call flow of the voice call (when `message_type` is
@@ -207,13 +203,106 @@ class Project < Entity
207
203
  # * Custom variables to set for each message
208
204
  #
209
205
  # Returns:
206
+ # Telerivet::Broadcast
207
+ #
208
+ def send_broadcast(options)
209
+ require_relative 'broadcast'
210
+ Broadcast.new(@api, @api.do_request("POST", get_base_api_path() + "/send_broadcast", options))
211
+ end
212
+
213
+ #
214
+ # Sends up to 100 different messages in a single API request. This method is significantly
215
+ # faster than sending a separate API request for each message.
216
+ #
217
+ # Arguments:
218
+ # - options (Hash)
219
+ # * Required
220
+ #
221
+ # - messages (array)
222
+ # * Array of up to 100 objects with `content` and `to_number` properties
223
+ # * Required
224
+ #
225
+ # - message_type
226
+ # * Type of message to send
227
+ # * Allowed values: sms
228
+ # * Default: sms
229
+ #
230
+ # - route_id
231
+ # * ID of the phone or route to send the messages from
232
+ # * Default: default sender route ID
233
+ #
234
+ # - broadcast_id (string)
235
+ # * ID of an existing broadcast to associate the messages with
236
+ #
237
+ # - broadcast_title (string)
238
+ # * Title of broadcast to create (when `broadcast_id` is not provided).
239
+ # When sending more than 100 messages over multiple API
240
+ # requests, you can associate all messages with the same broadcast by providing a
241
+ # `broadcast_title` parameter in the first
242
+ # API request, then retrieving the `broadcast_id` property
243
+ # from the API response, and passing it as the `broadcast_id` parameter in subsequent
244
+ # API requests.
245
+ #
246
+ # - status_url
247
+ # * Webhook callback URL to be notified when message status changes
248
+ #
249
+ # - status_secret
250
+ # * POST parameter 'secret' passed to status_url
251
+ #
252
+ # - label_ids (array)
253
+ # * Array of IDs of labels to add to each message (maximum 5)
254
+ #
255
+ # - is_template (bool)
256
+ # * Set to true to evaluate variables like [[contact.name]] in message content [(See
257
+ # available variables)](#variables)
258
+ # * Default: false
259
+ #
260
+ # Returns:
261
+ # (associative array)
262
+ # - messages (array)
263
+ # * List of objects representing each newly created message, with the same length
264
+ # and order as provided in the `messages` parameter in the API request.
265
+ # Each object has the `id` and `status` properties,
266
+ # and may have the property `error_message`.
267
+ # (Other properties of the Message object are
268
+ # omitted in order to reduce the amount of redundant data sent in each API
269
+ # response.)
270
+ #
271
+ # - broadcast_id
272
+ # * ID of broadcast that these messages are associated with, if `broadcast_id` or
273
+ # `broadcast_title` parameter is provided in the API request.
274
+ #
275
+ def send_multi(options)
276
+ data = @api.do_request("POST", get_base_api_path() + "/send_multi", options)
277
+ return data
278
+ end
279
+
280
+ #
281
+ # (Deprecated) Send a message a to group or a list of phone numbers.
282
+ # This method is only needed to maintain backward compatibility with
283
+ # code developed using previous versions of the client library.
284
+ # Use `sendBroadcast` or `sendMulti` instead.
285
+ #
286
+ # Arguments:
287
+ # - options (Hash)
288
+ # * Required
289
+ #
290
+ # - message_type
291
+ #
292
+ # - content
293
+ # * Required
294
+ #
295
+ # - group_id
296
+ #
297
+ # - to_numbers
298
+ #
299
+ # Returns:
210
300
  # (associative array)
211
301
  # - count_queued (int)
212
302
  # * Number of messages queued to send
213
303
  #
214
304
  # - broadcast_id
215
- # * ID of broadcast created for this message batch. If `count_queued` is 0 or 1, a
216
- # broadcast will not be created, and the `broadcast_id` property will be null.
305
+ # * ID of broadcast created for this message batch.
217
306
  #
218
307
  def send_messages(options)
219
308
  data = @api.do_request("POST", get_base_api_path() + "/messages/send_batch", options)
@@ -262,7 +351,7 @@ class Project < Entity
262
351
  #
263
352
  # - route_id
264
353
  # * ID of the phone or route to send the message from
265
- # * Default: default sender phone ID
354
+ # * Default: default sender route ID
266
355
  #
267
356
  # - service_id
268
357
  # * Service that defines the call flow of the voice call (when `message_type` is
@@ -339,7 +428,7 @@ class Project < Entity
339
428
  # * Required
340
429
  #
341
430
  # - phone_id
342
- # * ID of the phone that received the message
431
+ # * ID of the phone (basic route) that received the message
343
432
  # * Required
344
433
  #
345
434
  # - to_number
@@ -657,7 +746,10 @@ class Project < Entity
657
746
  # * ID of the contact who sent/received the message
658
747
  #
659
748
  # - phone_id
660
- # * ID of the phone that sent/received the message
749
+ # * ID of the phone (basic route) that sent/received the message
750
+ #
751
+ # - broadcast_id
752
+ # * ID of the broadcast containing the message
661
753
  #
662
754
  # - sort
663
755
  # * Sort the results based on a field
@@ -1204,93 +1296,6 @@ class Project < Entity
1204
1296
  return Service.new(@api, {'project_id' => self.id, 'id' => id}, false)
1205
1297
  end
1206
1298
 
1207
- #
1208
- # Queries mobile money receipts within the given project.
1209
- #
1210
- # Arguments:
1211
- # - options (Hash)
1212
- #
1213
- # - tx_id
1214
- # * Filter receipts by transaction ID
1215
- #
1216
- # - tx_type
1217
- # * Filter receipts by transaction type
1218
- # * Allowed values: receive_money, send_money, pay_bill, deposit, withdrawal,
1219
- # airtime_purchase, balance_inquiry, reversal
1220
- #
1221
- # - tx_time (UNIX timestamp)
1222
- # * Filter receipts by transaction time
1223
- # * Allowed modifiers: tx_time[ne], tx_time[min], tx_time[max]
1224
- #
1225
- # - name
1226
- # * Filter receipts by other person's name
1227
- # * Allowed modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt],
1228
- # name[lt], name[lte]
1229
- #
1230
- # - phone_number
1231
- # * Filter receipts by other person's phone number
1232
- # * Allowed modifiers: phone_number[ne], phone_number[prefix],
1233
- # phone_number[not_prefix], phone_number[gte], phone_number[gt], phone_number[lt],
1234
- # phone_number[lte]
1235
- #
1236
- # - sort
1237
- # * Sort the results based on a field
1238
- # * Allowed values: default
1239
- # * Default: default
1240
- #
1241
- # - sort_dir
1242
- # * Sort the results in ascending or descending order
1243
- # * Allowed values: asc, desc
1244
- # * Default: asc
1245
- #
1246
- # - page_size (int)
1247
- # * Number of results returned per page (max 200)
1248
- # * Default: 50
1249
- #
1250
- # - offset (int)
1251
- # * Number of items to skip from beginning of result set
1252
- # * Default: 0
1253
- #
1254
- # Returns:
1255
- # Telerivet::APICursor (of Telerivet::MobileMoneyReceipt)
1256
- #
1257
- def query_receipts(options = nil)
1258
- require_relative 'mobilemoneyreceipt'
1259
- @api.cursor(MobileMoneyReceipt, get_base_api_path() + "/receipts", options)
1260
- end
1261
-
1262
- #
1263
- # Retrieves the mobile money receipt with the given ID.
1264
- #
1265
- # Arguments:
1266
- # - id
1267
- # * ID of the mobile money receipt
1268
- # * Required
1269
- #
1270
- # Returns:
1271
- # Telerivet::MobileMoneyReceipt
1272
- #
1273
- def get_receipt_by_id(id)
1274
- require_relative 'mobilemoneyreceipt'
1275
- MobileMoneyReceipt.new(@api, @api.do_request("GET", get_base_api_path() + "/receipts/#{id}"))
1276
- end
1277
-
1278
- #
1279
- # Initializes the mobile money receipt with the given ID without making an API request.
1280
- #
1281
- # Arguments:
1282
- # - id
1283
- # * ID of the mobile money receipt
1284
- # * Required
1285
- #
1286
- # Returns:
1287
- # Telerivet::MobileMoneyReceipt
1288
- #
1289
- def init_receipt_by_id(id)
1290
- require_relative 'mobilemoneyreceipt'
1291
- return MobileMoneyReceipt.new(@api, {'project_id' => self.id, 'id' => id}, false)
1292
- end
1293
-
1294
1299
  #
1295
1300
  # Queries custom routes that can be used to send messages (not including Phones).
1296
1301
  #
@@ -2,9 +2,15 @@
2
2
  module Telerivet
3
3
 
4
4
  #
5
- # Represents a custom route that can be used to send messages via one or more Phones.
5
+ # Represents a custom route that can be used to send messages via one or more basic routes
6
+ # (phones).
6
7
  #
7
- # Note: Routing rules can currently only be configured via Telerivet's web UI.
8
+ # Custom Routes were formerly referred to simply as "Routes" within Telerivet. API methods,
9
+ # parameters, and properties related to Custom Routes continue to use the term "Route" to
10
+ # maintain backwards compatibility.
11
+ #
12
+ # Custom routing rules can currently only be configured via Telerivet's web
13
+ # UI.
8
14
  #
9
15
  # Fields:
10
16
  #
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.3.0
4
+ version: 1.4.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: 2018-04-26 00:00:00.000000000 Z
11
+ date: 2018-06-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby client library for Telerivet REST API
14
14
  email: support@telerivet.com
@@ -28,7 +28,6 @@ files:
28
28
  - lib/telerivet/group.rb
29
29
  - lib/telerivet/label.rb
30
30
  - lib/telerivet/message.rb
31
- - lib/telerivet/mobilemoneyreceipt.rb
32
31
  - lib/telerivet/organization.rb
33
32
  - lib/telerivet/phone.rb
34
33
  - lib/telerivet/project.rb
@@ -1,187 +0,0 @@
1
-
2
- module Telerivet
3
-
4
- #
5
- # Represents a receipt received from a mobile money system such as Safaricom M-Pesa (Kenya),
6
- # Vodacom M-Pesa (Tanzania), or Tigo Pesa (Tanzania).
7
- #
8
- # When your Android phone receives a SMS receipt from a supported mobile money
9
- # service that Telerivet can understand, Telerivet will automatically parse it and create a
10
- # MobileMoneyReceipt object.
11
- #
12
- # Fields:
13
- #
14
- # - id (string, max 34 characters)
15
- # * Telerivet's internal ID for the receipt
16
- # * Read-only
17
- #
18
- # - tx_id
19
- # * Transaction ID from the receipt
20
- # * Read-only
21
- #
22
- # - tx_type
23
- # * Type of mobile money transaction
24
- # * Allowed values: receive_money, send_money, pay_bill, deposit, withdrawal,
25
- # airtime_purchase, balance_inquiry, reversal
26
- # * Read-only
27
- #
28
- # - currency
29
- # * [ISO 4217 Currency code](http://en.wikipedia.org/wiki/ISO_4217) for the transaction,
30
- # e.g. KES or TZS. Amount, balance, and fee are expressed in units of this currency.
31
- # * Read-only
32
- #
33
- # - amount (number)
34
- # * Amount of this transaction; positive numbers indicate money added to your account,
35
- # negative numbers indicate money removed from your account
36
- # * Read-only
37
- #
38
- # - balance (number)
39
- # * The current balance of your mobile money account (null if not available)
40
- # * Read-only
41
- #
42
- # - fee (number)
43
- # * The transaction fee charged by the mobile money system (null if not available)
44
- # * Read-only
45
- #
46
- # - name
47
- # * The name of the other person in the transaction (null if not available)
48
- # * Read-only
49
- #
50
- # - phone_number
51
- # * The phone number of the other person in the transaction (null if not available)
52
- # * Read-only
53
- #
54
- # - time_created (UNIX timestamp)
55
- # * The time this receipt was created in Telerivet
56
- # * Read-only
57
- #
58
- # - other_tx_id
59
- # * The other transaction ID listed in the receipt (e.g. the transaction ID for a
60
- # reversed transaction)
61
- # * Read-only
62
- #
63
- # - content
64
- # * The raw content of the mobile money receipt
65
- # * Read-only
66
- #
67
- # - provider_id
68
- # * Telerivet's internal ID for the mobile money provider
69
- # * Read-only
70
- #
71
- # - vars (Hash)
72
- # * Custom variables stored for this mobile money receipt
73
- # * Updatable via API
74
- #
75
- # - contact_id
76
- # * ID of the contact associated with the name/phone number on the receipt. Note that
77
- # some mobile money systems do not provide the other person's phone number, so it's
78
- # possible Telerivet may not automatically assign a contact_id, or may assign it to a
79
- # different contact with the same name.
80
- # * Updatable via API
81
- #
82
- # - phone_id
83
- # * ID of the phone that received the receipt
84
- # * Read-only
85
- #
86
- # - message_id
87
- # * ID of the message corresponding to the receipt
88
- # * Read-only
89
- #
90
- # - project_id
91
- # * ID of the project this receipt belongs to
92
- # * Read-only
93
- #
94
- class MobileMoneyReceipt < Entity
95
- #
96
- # Saves any fields or custom variables that have changed for this mobile money receipt.
97
- #
98
- def save()
99
- super
100
- end
101
-
102
- #
103
- # Deletes this receipt.
104
- #
105
- def delete()
106
- @api.do_request("DELETE", get_base_api_path())
107
- end
108
-
109
- def id
110
- get('id')
111
- end
112
-
113
- def tx_id
114
- get('tx_id')
115
- end
116
-
117
- def tx_type
118
- get('tx_type')
119
- end
120
-
121
- def currency
122
- get('currency')
123
- end
124
-
125
- def amount
126
- get('amount')
127
- end
128
-
129
- def balance
130
- get('balance')
131
- end
132
-
133
- def fee
134
- get('fee')
135
- end
136
-
137
- def name
138
- get('name')
139
- end
140
-
141
- def phone_number
142
- get('phone_number')
143
- end
144
-
145
- def time_created
146
- get('time_created')
147
- end
148
-
149
- def other_tx_id
150
- get('other_tx_id')
151
- end
152
-
153
- def content
154
- get('content')
155
- end
156
-
157
- def provider_id
158
- get('provider_id')
159
- end
160
-
161
- def contact_id
162
- get('contact_id')
163
- end
164
-
165
- def contact_id=(value)
166
- set('contact_id', value)
167
- end
168
-
169
- def phone_id
170
- get('phone_id')
171
- end
172
-
173
- def message_id
174
- get('message_id')
175
- end
176
-
177
- def project_id
178
- get('project_id')
179
- end
180
-
181
- def get_base_api_path()
182
- "/projects/#{get('project_id')}/receipts/#{get('id')}"
183
- end
184
-
185
- end
186
-
187
- end