telerivet 1.2.1 → 1.3.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: 956df92c7601623b5f4cca141712a7f4efa82074
4
- data.tar.gz: b6fb090b8d492b7ea8a68ee394793dbfc5f6c890
3
+ metadata.gz: f29fae453430b0721c120ed759f6471eb6353a5a
4
+ data.tar.gz: 20efe5389264b4ff2ba936b23a77ff1ade66aec5
5
5
  SHA512:
6
- metadata.gz: dead19b8d3452ea46c0a3bc819899e59fc6a726df88cf023277031e58ff72f34c3a5b46a17c415afb699a07376a2f41f50833c9e3edc6a19f86464de9fc2c952
7
- data.tar.gz: 3132ac8c08c783f6ba7d48cd06416967818bb416292341b472902e45f3bc19280b23d8e39639b7314d805c6dd41436ad89fd5794da242f8d000e4c9b04aa180c
6
+ metadata.gz: 0caee23855bbca0c7bc86ac0c5c4e057ab11470999871542d884d7c1c381713203f7d2f136653208833a4f5528a40e63965b9a20ea6c8b0fcde6553d2a605ab2
7
+ data.tar.gz: 39e7a0403bba946173d14ecbe1e02016cf4b160b7e81b06efdd6df18a01178340f015e3b89a93eb5191aa061a04ed30e854cbc31794e8a1cf58007e0fe112d4b
@@ -8,7 +8,7 @@ module Telerivet
8
8
  class API
9
9
  attr_reader :num_requests
10
10
 
11
- @@client_version = '1.2.1'
11
+ @@client_version = '1.3.0'
12
12
 
13
13
  #
14
14
  # Initializes a client handle to the Telerivet REST API.
@@ -160,6 +160,75 @@ class API
160
160
  self.cursor(Project, get_base_api_path() + "/projects", options)
161
161
  end
162
162
 
163
+ #
164
+ # Retrieves the Telerivet organization with the given ID.
165
+ #
166
+ # Arguments:
167
+ # - id
168
+ # * ID of the organization -- see <https://telerivet.com/dashboard/api>
169
+ # * Required
170
+ #
171
+ # Returns:
172
+ # Telerivet::Organization
173
+ #
174
+ def get_organization_by_id(id)
175
+ require_relative 'telerivet/organization'
176
+ Organization.new(self, self.do_request("GET", get_base_api_path() + "/organizations/#{id}"))
177
+ end
178
+
179
+ #
180
+ # Initializes the Telerivet organization with the given ID without making an API request.
181
+ #
182
+ # Arguments:
183
+ # - id
184
+ # * ID of the organization -- see <https://telerivet.com/dashboard/api>
185
+ # * Required
186
+ #
187
+ # Returns:
188
+ # Telerivet::Organization
189
+ #
190
+ def init_organization_by_id(id)
191
+ require_relative 'telerivet/organization'
192
+ return Organization.new(self, {'id' => id}, false)
193
+ end
194
+
195
+ #
196
+ # Queries organizations accessible to the current user account.
197
+ #
198
+ # Arguments:
199
+ # - options (Hash)
200
+ #
201
+ # - name
202
+ # * Filter organizations by name
203
+ # * Allowed modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt],
204
+ # name[lt], name[lte]
205
+ #
206
+ # - sort
207
+ # * Sort the results based on a field
208
+ # * Allowed values: default, name
209
+ # * Default: default
210
+ #
211
+ # - sort_dir
212
+ # * Sort the results in ascending or descending order
213
+ # * Allowed values: asc, desc
214
+ # * Default: asc
215
+ #
216
+ # - page_size (int)
217
+ # * Number of results returned per page (max 200)
218
+ # * Default: 50
219
+ #
220
+ # - offset (int)
221
+ # * Number of items to skip from beginning of result set
222
+ # * Default: 0
223
+ #
224
+ # Returns:
225
+ # Telerivet::APICursor (of Telerivet::Organization)
226
+ #
227
+ def query_organizations(options = nil)
228
+ require_relative 'telerivet/organization'
229
+ self.cursor(Organization, get_base_api_path() + "/organizations", options)
230
+ end
231
+
163
232
  def get_base_api_path()
164
233
  ""
165
234
  end
@@ -0,0 +1,164 @@
1
+
2
+ module Telerivet
3
+
4
+ #
5
+ # Represents a Telerivet organization.
6
+ #
7
+ # Fields:
8
+ #
9
+ # - id (string, max 34 characters)
10
+ # * ID of the organization
11
+ # * Read-only
12
+ #
13
+ # - name
14
+ # * Name of the organization
15
+ # * Updatable via API
16
+ #
17
+ # - timezone_id
18
+ # * Billing quota time zone ID; see
19
+ # <http://en.wikipedia.org/wiki/List_of_tz_database_time_zones>
20
+ # * Updatable via API
21
+ #
22
+ class Organization < Entity
23
+ #
24
+ # Saves any fields that have changed for this organization.
25
+ #
26
+ def save()
27
+ super
28
+ end
29
+
30
+ #
31
+ # Retrieves information about the organization's service plan and account balance.
32
+ #
33
+ # Returns:
34
+ # (associative array)
35
+ # - balance (string)
36
+ # * Prepaid account balance
37
+ #
38
+ # - balance_currency (string)
39
+ # * Currency of prepaid account balance
40
+ #
41
+ # - plan_name (string)
42
+ # * Name of service plan
43
+ #
44
+ # - plan_price (string)
45
+ # * Price of service plan
46
+ #
47
+ # - plan_currency (string)
48
+ # * Currency of service plan price
49
+ #
50
+ # - plan_rrule (string)
51
+ # * Service plan recurrence rule (e.g. FREQ=MONTHLY or FREQ=YEARLY)
52
+ #
53
+ # - plan_paid (boolean)
54
+ # * true if the service plan has been paid for the current billing interval; false
55
+ # if it is unpaid (free plans are considered paid)
56
+ #
57
+ # - plan_start_time (UNIX timestamp)
58
+ # * Time when the current billing interval started
59
+ #
60
+ # - plan_end_time (UNIX timestamp)
61
+ # * Time when the current billing interval ends
62
+ #
63
+ # - plan_suspend_time (UNIX timestamp)
64
+ # * Time when the account will be suspended, if the plan remains unpaid after
65
+ # `plan_end_time` (may be null)
66
+ #
67
+ # - plan_limits (Hash)
68
+ # * Object describing the limits associated with the current service plan. The
69
+ # object contains the following keys: `phones`, `projects`, `active_services`,
70
+ # `users`, `contacts`, `messages_day`, `stored_messages`, `data_rows`,
71
+ # `api_requests_day`. The values corresponding to each key are integers, or null.
72
+ #
73
+ # - recurring_billing_enabled (boolean)
74
+ # * True if recurring billing is enabled, false otherwise
75
+ #
76
+ # - auto_refill_enabled (boolean)
77
+ # * True if auto-refill is enabled, false otherwise
78
+ #
79
+ def get_billing_details()
80
+ data = @api.do_request("GET", get_base_api_path() + "/billing")
81
+ return data
82
+ end
83
+
84
+ #
85
+ # Retrieves the current usage count associated with a particular service plan limit. Available
86
+ # usage types are `phones`, `projects`, `users`, `contacts`, `messages_day`,
87
+ # `stored_messages`, `data_rows`, and `api_requests_day`.
88
+ #
89
+ # Arguments:
90
+ # - usage_type
91
+ # * Usage type.
92
+ # * Required
93
+ #
94
+ # Returns:
95
+ # int
96
+ #
97
+ def get_usage(usage_type)
98
+ return @api.do_request("GET", get_base_api_path() + "/usage/#{usage_type}")
99
+ end
100
+
101
+ #
102
+ # Queries projects in this organization.
103
+ #
104
+ # Arguments:
105
+ # - options (Hash)
106
+ #
107
+ # - name
108
+ # * Filter projects by name
109
+ # * Allowed modifiers: name[ne], name[prefix], name[not_prefix], name[gte], name[gt],
110
+ # name[lt], name[lte]
111
+ #
112
+ # - sort
113
+ # * Sort the results based on a field
114
+ # * Allowed values: default, name
115
+ # * Default: default
116
+ #
117
+ # - sort_dir
118
+ # * Sort the results in ascending or descending order
119
+ # * Allowed values: asc, desc
120
+ # * Default: asc
121
+ #
122
+ # - page_size (int)
123
+ # * Number of results returned per page (max 200)
124
+ # * Default: 50
125
+ #
126
+ # - offset (int)
127
+ # * Number of items to skip from beginning of result set
128
+ # * Default: 0
129
+ #
130
+ # Returns:
131
+ # Telerivet::APICursor (of Telerivet::Project)
132
+ #
133
+ def query_projects(options = nil)
134
+ require_relative 'project'
135
+ @api.cursor(Project, get_base_api_path() + "/projects", options)
136
+ end
137
+
138
+ def id
139
+ get('id')
140
+ end
141
+
142
+ def name
143
+ get('name')
144
+ end
145
+
146
+ def name=(value)
147
+ set('name', value)
148
+ end
149
+
150
+ def timezone_id
151
+ get('timezone_id')
152
+ end
153
+
154
+ def timezone_id=(value)
155
+ set('timezone_id', value)
156
+ end
157
+
158
+ def get_base_api_path()
159
+ "/organizations/#{get('id')}"
160
+ end
161
+
162
+ end
163
+
164
+ end
@@ -90,8 +90,8 @@ module Telerivet
90
90
  #
91
91
  # - send_limit (int)
92
92
  # * Maximum number of SMS messages per hour that can be sent by this Android phone. To
93
- # increase this limit, install additional SMS expansion packs in the Telerivet app.
94
- # (only present for Android phones)
93
+ # increase this limit, install additional SMS expansion packs in the Telerivet Gateway
94
+ # app. (only present for Android phones)
95
95
  # * Read-only
96
96
  #
97
97
  class Phone < Entity
@@ -30,6 +30,10 @@ module Telerivet
30
30
  # - vars (Hash)
31
31
  # * Custom variables stored for this project
32
32
  # * Updatable via API
33
+ #
34
+ # - organization_id (string, max 34 characters)
35
+ # * ID of the organization this project belongs to
36
+ # * Read-only
33
37
  #
34
38
  class Project < Entity
35
39
  #
@@ -45,8 +49,8 @@ class Project < Entity
45
49
  # * Default: sms
46
50
  #
47
51
  # - content
48
- # * Content of the message to send (if message_type=call, the text will be spoken
49
- # during a text-to-speech call)
52
+ # * Content of the message to send (if `message_type` is `call`, the text will be
53
+ # spoken during a text-to-speech call)
50
54
  # * Required if sending SMS message
51
55
  #
52
56
  # - to_number (string)
@@ -62,13 +66,14 @@ class Project < Entity
62
66
  # * Default: default sender phone ID for your project
63
67
  #
64
68
  # - service_id
65
- # * Service that defines the call flow of the voice call (when message_type=call)
69
+ # * Service that defines the call flow of the voice call (when `message_type` is
70
+ # `call`)
66
71
  #
67
72
  # - audio_url
68
73
  # * The URL of an MP3 file to play when the contact answers the call (when
69
- # message_type=call).
74
+ # `message_type` is `call`).
70
75
  #
71
- # If audio_url is provided, the text-to-speech voice is not used to say
76
+ # If `audio_url` is provided, the text-to-speech voice is not used to say
72
77
  # `content`, although you can optionally use `content` to indicate the script for the
73
78
  # audio.
74
79
  #
@@ -76,7 +81,7 @@ class Project < Entity
76
81
  # recommended because the audio quality will be low when played over a phone line.
77
82
  #
78
83
  # - tts_lang
79
- # * The language of the text-to-speech voice (when message_type=call)
84
+ # * The language of the text-to-speech voice (when `message_type` is `call`)
80
85
  # * Allowed values: en-US, en-GB, en-GB-WLS, en-AU, en-IN, da-DK, nl-NL, fr-FR, fr-CA,
81
86
  # de-DE, is-IS, it-IT, pl-PL, pt-BR, pt-PT, ru-RU, es-ES, es-US, sv-SE
82
87
  # * Default: en-US
@@ -155,13 +160,14 @@ class Project < Entity
155
160
  # * Default: default sender phone ID
156
161
  #
157
162
  # - service_id
158
- # * Service that defines the call flow of the voice call (when message_type=call)
163
+ # * Service that defines the call flow of the voice call (when `message_type` is
164
+ # `call`)
159
165
  #
160
166
  # - audio_url
161
167
  # * The URL of an MP3 file to play when the contact answers the call (when
162
- # message_type=call).
168
+ # `message_type` is `call`).
163
169
  #
164
- # If audio_url is provided, the text-to-speech voice is not used to say
170
+ # If `audio_url` is provided, the text-to-speech voice is not used to say
165
171
  # `content`, although you can optionally use `content` to indicate the script for the
166
172
  # audio.
167
173
  #
@@ -169,7 +175,7 @@ class Project < Entity
169
175
  # recommended because the audio quality will be low when played over a phone line.
170
176
  #
171
177
  # - tts_lang
172
- # * The language of the text-to-speech voice (when message_type=call)
178
+ # * The language of the text-to-speech voice (when `message_type` is `call`)
173
179
  # * Allowed values: en-US, en-GB, en-GB-WLS, en-AU, en-IN, da-DK, nl-NL, fr-FR, fr-CA,
174
180
  # de-DE, is-IS, it-IT, pl-PL, pt-BR, pt-PT, ru-RU, es-ES, es-US, sv-SE
175
181
  # * Default: en-US
@@ -206,8 +212,8 @@ class Project < Entity
206
212
  # * Number of messages queued to send
207
213
  #
208
214
  # - 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.
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.
211
217
  #
212
218
  def send_messages(options)
213
219
  data = @api.do_request("POST", get_base_api_path() + "/messages/send_batch", options)
@@ -215,8 +221,8 @@ class Project < Entity
215
221
  end
216
222
 
217
223
  #
218
- # Schedules an SMS message to a group or single contact. Note that Telerivet only sends
219
- # scheduled messages approximately once per minute, so it is not possible to control the exact
224
+ # Schedules a message to a group or single contact. Note that Telerivet only sends scheduled
225
+ # messages approximately once every 15 seconds, so it is not possible to control the exact
220
226
  # second at which a scheduled message is sent.
221
227
  #
222
228
  # Arguments:
@@ -225,7 +231,7 @@ class Project < Entity
225
231
  #
226
232
  # - message_type
227
233
  # * Type of message to send
228
- # * Allowed values: sms, ussd
234
+ # * Allowed values: sms, ussd, call
229
235
  # * Default: sms
230
236
  #
231
237
  # - content
@@ -259,13 +265,14 @@ class Project < Entity
259
265
  # * Default: default sender phone ID
260
266
  #
261
267
  # - service_id
262
- # * Service that defines the call flow of the voice call (when message_type=call)
268
+ # * Service that defines the call flow of the voice call (when `message_type` is
269
+ # `call`)
263
270
  #
264
271
  # - audio_url
265
272
  # * The URL of an MP3 file to play when the contact answers the call (when
266
- # message_type=call).
273
+ # `message_type` is `call`).
267
274
  #
268
- # If audio_url is provided, the text-to-speech voice is not used to say
275
+ # If `audio_url` is provided, the text-to-speech voice is not used to say
269
276
  # `content`, although you can optionally use `content` to indicate the script for the
270
277
  # audio.
271
278
  #
@@ -273,7 +280,7 @@ class Project < Entity
273
280
  # recommended because the audio quality will be low when played over a phone line.
274
281
  #
275
282
  # - tts_lang
276
- # * The language of the text-to-speech voice (when message_type=call)
283
+ # * The language of the text-to-speech voice (when `message_type` is `call`)
277
284
  # * Allowed values: en-US, en-GB, en-GB-WLS, en-AU, en-IN, da-DK, nl-NL, fr-FR, fr-CA,
278
285
  # de-DE, is-IS, it-IT, pl-PL, pt-BR, pt-PT, ru-RU, es-ES, es-US, sv-SE
279
286
  # * Default: en-US
@@ -320,7 +327,7 @@ class Project < Entity
320
327
  #
321
328
  # - content
322
329
  # * Content of the incoming message
323
- # * Required unless message_type is call
330
+ # * Required unless `message_type` is `call`
324
331
  #
325
332
  # - message_type
326
333
  # * Type of message
@@ -366,14 +373,14 @@ class Project < Entity
366
373
  # an existing contact with that phone number (including suffix matches to allow finding
367
374
  # contacts with phone numbers in a different format). If a phone number is not provided but a
368
375
  # name is provided, Telerivet will search for a contact with that exact name (case
369
- # insensitive). This behavior can be modified by setting the lookup_key parameter to look up a
370
- # contact by another field, including a custom variable.
376
+ # insensitive). This behavior can be modified by setting the `lookup_key` parameter to look up
377
+ # a contact by another field, including a custom variable.
371
378
  #
372
379
  # If no existing contact is found, a new contact will be created.
373
380
  #
374
381
  # Then that contact will be updated with any parameters provided
375
- # (name, phone_number, vars, default\_route\_id, send\_blocked, add\_group\_ids,
376
- # remove\_group\_ids).
382
+ # (`name`, `phone_number`, `vars`, `default_route_id`, `send_blocked`, `add_group_ids`,
383
+ # `remove_group_ids`).
377
384
  #
378
385
  # Arguments:
379
386
  # - options (Hash)
@@ -400,7 +407,7 @@ class Project < Entity
400
407
  # * ID of one or more groups to add this contact as a member (max 20)
401
408
  #
402
409
  # - id
403
- # * ID of an existing contact (only used if lookup_key is 'id')
410
+ # * ID of an existing contact (only used if `lookup_key` is 'id')
404
411
  #
405
412
  # - remove_group_ids (array)
406
413
  # * ID of one or more groups to remove this contact as a member (max 20)
@@ -1392,6 +1399,10 @@ class Project < Entity
1392
1399
  get('url_slug')
1393
1400
  end
1394
1401
 
1402
+ def organization_id
1403
+ get('organization_id')
1404
+ end
1405
+
1395
1406
  def get_base_api_path()
1396
1407
  "/projects/#{get('id')}"
1397
1408
  end
@@ -24,16 +24,41 @@ module Telerivet
24
24
  # <http://en.wikipedia.org/wiki/List_of_tz_database_time_zones>
25
25
  # * Read-only
26
26
  #
27
+ # - recipients (array of objects)
28
+ # * List of recipients. Each recipient is an object with a string `type` property, which
29
+ # may be `"phone_number"`, `"group"`, or `"filter"`.
30
+ #
31
+ # If the type is `"phone_number"`, the `phone_number` property will
32
+ # be set to the recipient's phone number.
33
+ #
34
+ # If the type is `"group"`, the `group_id` property will be set to
35
+ # the ID of the group, and the `group_name` property will be set to the name of the
36
+ # group.
37
+ #
38
+ # If the type is `"filter"`, the `filter_type` property (string) and
39
+ # `filter_params` property (object) describe the filter used to send the broadcast. (API
40
+ # clients should not rely on a particular value or format of the `filter_type` or
41
+ # `filter_params` properties, as they may change without notice.)
42
+ # * Read-only
43
+ #
44
+ # - recipients_str
45
+ # * A string with a human readable description of the first few recipients (possibly
46
+ # truncated)
47
+ # * Read-only
48
+ #
27
49
  # - group_id
28
- # * ID of the group to send the message to (null if scheduled to an individual contact)
50
+ # * ID of the group to send the message to (null if the recipient is an individual
51
+ # contact, or if there are multiple recipients)
29
52
  # * Read-only
30
53
  #
31
54
  # - contact_id
32
- # * ID of the contact to send the message to (null if scheduled to a group)
55
+ # * ID of the contact to send the message to (null if the recipient is a group, or if
56
+ # there are multiple recipients)
33
57
  # * Read-only
34
58
  #
35
59
  # - to_number
36
- # * Phone number to send the message to (null if scheduled to a group)
60
+ # * Phone number to send the message to (null if the recipient is a group, or if there
61
+ # are multiple recipients)
37
62
  # * Read-only
38
63
  #
39
64
  # - route_id
@@ -140,6 +165,14 @@ class ScheduledMessage < Entity
140
165
  get('timezone_id')
141
166
  end
142
167
 
168
+ def recipients
169
+ get('recipients')
170
+ end
171
+
172
+ def recipients_str
173
+ get('recipients_str')
174
+ end
175
+
143
176
  def group_id
144
177
  get('group_id')
145
178
  end
@@ -70,8 +70,9 @@ module Telerivet
70
70
  #
71
71
  # - questions (array)
72
72
  # * Array of objects describing each question in a poll (only used for polls). Each
73
- # object has the properties "id" (the question ID), "content" (the text of the
74
- # question), and "question_type" (either "multiple_choice", "missed_call", or "open").
73
+ # object has the properties `"id"` (the question ID), `"content"` (the text of the
74
+ # question), and `"question_type"` (either `"multiple_choice"`, `"missed_call"`, or
75
+ # `"open"`).
75
76
  # * Read-only
76
77
  #
77
78
  class Service < Entity
@@ -80,13 +81,13 @@ class Service < Entity
80
81
  # Manually invoke this service in a particular context.
81
82
  #
82
83
  # For example, to send a poll to a particular contact (or resend the
83
- # current question), you can invoke the poll service with context=contact, and contact_id as
84
+ # current question), you can invoke the poll service with context=contact, and `contact_id` as
84
85
  # the ID of the contact to send the poll to.
85
86
  #
86
87
  # Or, to manually apply a service for an incoming message, you can
87
- # invoke the service with context=message, event=incoming\_message, and message_id as the ID
88
- # of the incoming message. (This is normally not necessary, but could be used if you want to
89
- # override Telerivet's standard priority-ordering of services.)
88
+ # invoke the service with `context`=`message`, `event`=`incoming_message`, and `message_id` as
89
+ # the ID of the incoming message. (This is normally not necessary, but could be used if you
90
+ # want to override Telerivet's standard priority-ordering of services.)
90
91
  #
91
92
  # Arguments:
92
93
  # - options (Hash)
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.2.1
4
+ version: 1.3.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: 2017-04-25 00:00:00.000000000 Z
11
+ date: 2018-04-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby client library for Telerivet REST API
14
14
  email: support@telerivet.com
@@ -29,6 +29,7 @@ files:
29
29
  - lib/telerivet/label.rb
30
30
  - lib/telerivet/message.rb
31
31
  - lib/telerivet/mobilemoneyreceipt.rb
32
+ - lib/telerivet/organization.rb
32
33
  - lib/telerivet/phone.rb
33
34
  - lib/telerivet/project.rb
34
35
  - lib/telerivet/route.rb