telerivet 1.8.5 → 1.9.6
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.
- checksums.yaml +4 -4
- data/lib/telerivet/airtimetransaction.rb +2 -1
- data/lib/telerivet/broadcast.rb +12 -6
- data/lib/telerivet/campaign.rb +481 -0
- data/lib/telerivet/contact.rb +20 -1
- data/lib/telerivet/contactservicestate.rb +4 -2
- data/lib/telerivet/datatable.rb +174 -0
- data/lib/telerivet/dataview.rb +132 -0
- data/lib/telerivet/group.rb +32 -0
- data/lib/telerivet/label.rb +1 -1
- data/lib/telerivet/message.rb +28 -6
- data/lib/telerivet/organization.rb +299 -22
- data/lib/telerivet/phone.rb +49 -1
- data/lib/telerivet/project.rb +734 -104
- data/lib/telerivet/relativescheduledmessage.rb +11 -10
- data/lib/telerivet/route.rb +8 -0
- data/lib/telerivet/scheduledmessage.rb +7 -6
- data/lib/telerivet/service.rb +21 -3
- data/lib/telerivet/storedfile.rb +167 -0
- data/lib/telerivet.rb +1 -1
- metadata +5 -2
|
@@ -40,8 +40,9 @@ class Organization < Entity
|
|
|
40
40
|
# is used when computing statistics by date.
|
|
41
41
|
#
|
|
42
42
|
# - url_slug
|
|
43
|
-
# * Unique string used as a component of the project's URL in the Telerivet web app
|
|
44
|
-
# If not provided, a URL slug will be generated
|
|
43
|
+
# * Unique string used as a component of the project's URL in the Telerivet web app
|
|
44
|
+
# (required length: 3-18 characters). If not provided, a URL slug will be generated
|
|
45
|
+
# automatically.
|
|
45
46
|
#
|
|
46
47
|
# - auto_create_contacts (bool)
|
|
47
48
|
# * If true, a contact will be automatically created for each unique phone number that
|
|
@@ -81,8 +82,34 @@ class Organization < Entity
|
|
|
81
82
|
end
|
|
82
83
|
|
|
83
84
|
#
|
|
84
|
-
# Retrieves information about the organization's service plan
|
|
85
|
+
# Retrieves information about the organization's service plan, including pricing, billing
|
|
86
|
+
# period, current limits, enabled features, overage rates, and any minimum usage fees, as well
|
|
87
|
+
# as the current account balance and payment status.
|
|
85
88
|
#
|
|
89
|
+
# The `plan_limits` object specifies the maximum allowed usage per
|
|
90
|
+
# metric (e.g. messages per day, contacts, API requests per day) that is included as part of
|
|
91
|
+
# the `plan_price`. Unless otherwise specified, each limit is the total across all projects in
|
|
92
|
+
# the organization (except for `custom_actions`).
|
|
93
|
+
#
|
|
94
|
+
# When usage reaches a limit, what happens depends on the metric
|
|
95
|
+
# and whether the `soft_limits` feature is enabled in `plan_features`. For some limits,
|
|
96
|
+
# additional usage is allowed and is billed based on `overage_rates` when the `soft_limits`
|
|
97
|
+
# feature is enabled. For other limits, additional usage is blocked until the plan is upgraded
|
|
98
|
+
# to increase the limits.
|
|
99
|
+
#
|
|
100
|
+
# Additional details about how service plan limits are defined,
|
|
101
|
+
# including what happens when the limits are reached, can be found in the [User
|
|
102
|
+
# Guide](https://guide.telerivet.com/hc/en-us/articles/360038959631-Service-Plan-Limits).
|
|
103
|
+
#
|
|
104
|
+
# Arguments:
|
|
105
|
+
# - options (Hash)
|
|
106
|
+
#
|
|
107
|
+
# - usage (bool)
|
|
108
|
+
# * If true, the response also includes a `usage` object with the current usage count
|
|
109
|
+
# for every key in `plan_limits` — equivalent to calling `getUsage` once per key but
|
|
110
|
+
# in the same round-trip. Omit (or pass false) to skip the usage counters.
|
|
111
|
+
# * Default:
|
|
112
|
+
#
|
|
86
113
|
# Returns:
|
|
87
114
|
# (associative array)
|
|
88
115
|
# - balance (string)
|
|
@@ -119,31 +146,222 @@ class Organization < Entity
|
|
|
119
146
|
#
|
|
120
147
|
# - plan_limits (Hash)
|
|
121
148
|
# * Object describing the limits associated with the current service plan. The
|
|
122
|
-
#
|
|
123
|
-
# `
|
|
124
|
-
#
|
|
149
|
+
# values are integers, or null. Either `external_messages_day` or
|
|
150
|
+
# `external_messages_period` is included depending on the organization's billing
|
|
151
|
+
# mode (per-day vs. per-plan-period messaging quota). Each key:
|
|
152
|
+
#
|
|
153
|
+
# - `contacts`: Stored contacts — The maximum number of contacts stored in your
|
|
154
|
+
# contact database at any time. Each contact can have a name, phone number, and up
|
|
155
|
+
# to 100 custom fields, and can be added to groups. By default, a contact is
|
|
156
|
+
# automatically created for each phone number you communicate with, as long as there
|
|
157
|
+
# is space in your contact database. Automatic contact creation can be disabled in
|
|
158
|
+
# the project settings if you don't need to store contacts. You can send messages to
|
|
159
|
+
# an unlimited number of different phone numbers if you don't store them in your
|
|
160
|
+
# contact database.
|
|
161
|
+
# - `phones`: Routes — The maximum number of different routes that your
|
|
162
|
+
# organization uses to send or receive messages through Telerivet, including Android
|
|
163
|
+
# phones, virtual numbers, alphanumeric sender IDs, SMS shortcodes, and integrations
|
|
164
|
+
# with chat apps like WhatsApp. On service plans that support multiple routes, you
|
|
165
|
+
# can distribute messages among different routes for higher volume, geographic
|
|
166
|
+
# reach, or better rates.
|
|
167
|
+
# - `active_services`: Active automated services — The number of automated
|
|
168
|
+
# services that run in response to certain events, such as when a new message is
|
|
169
|
+
# received, when a message's status changes, or when triggered by a user. Common
|
|
170
|
+
# types of automations like polls and auto-replies can be created from built-in
|
|
171
|
+
# templates. Custom actions can be created using a drag-and-drop flow builder,
|
|
172
|
+
# JavaScript, or a webhook.
|
|
173
|
+
# - `users`: User logins — The maximum number of user accounts you can add for
|
|
174
|
+
# people in your organization to log in and use Telerivet. Each user account can
|
|
175
|
+
# have its own permissions.
|
|
176
|
+
# - `stored_messages`: Stored messages — The total number of messages stored in
|
|
177
|
+
# your Telerivet account, including scheduled messages. You can delete old or
|
|
178
|
+
# unneeded messages to stay under this limit.
|
|
179
|
+
# - `service_invocations_day`: Daily service invocations — The maximum number of
|
|
180
|
+
# times automated services can run per day, excluding Webhook API services. This
|
|
181
|
+
# includes service rules triggered by incoming messages, scheduled triggers, and
|
|
182
|
+
# manual invocations. The counter resets at midnight in your organization's
|
|
183
|
+
# timezone.
|
|
184
|
+
# - `api_requests_day`: Daily API requests — The maximum number of API requests
|
|
185
|
+
# your organization can make per day, counting both REST API and Webhook API
|
|
186
|
+
# requests. The quota resets daily at midnight in the organization's time zone. If
|
|
187
|
+
# you pay Telerivet directly for each message, REST API requests to send messages,
|
|
188
|
+
# and Webhook API requests to receive notifications of incoming messages and
|
|
189
|
+
# delivery reports, are exempt from this limit.
|
|
190
|
+
# - `projects`: Projects — Each project represents an independent mobile messaging
|
|
191
|
+
# system. Each project has its own messages, contacts, routes, and services, and its
|
|
192
|
+
# own set of user permissions. If necessary, you can add multiple projects under one
|
|
193
|
+
# organization and one billing plan.
|
|
194
|
+
# - `data_rows`: Rows in custom data tables — Custom data tables are used to store
|
|
195
|
+
# responses to polls and other automated services. You can also import your own data
|
|
196
|
+
# to build data-driven automations.
|
|
197
|
+
# - `script_module_mb`: Cloud Script module storage quota (MB) — Storage quota for
|
|
198
|
+
# Cloud Script modules — code modules that you push to Telerivet to run as part of
|
|
199
|
+
# automated services. Measured as the total size of all module files across the
|
|
200
|
+
# organization.
|
|
201
|
+
# - `stored_file_mb`: File storage quota (MB) — Storage quota for files uploaded
|
|
202
|
+
# to Telerivet, including media attachments sent or received in messages.
|
|
203
|
+
# - `custom_actions`: Custom actions per service — The maximum number of custom
|
|
204
|
+
# actions or conditions allowed per automated service. Custom actions extend
|
|
205
|
+
# services with logic written in a drag-and-drop flow builder, JavaScript, or
|
|
206
|
+
# webhooks. Plans with the Advanced Automation feature have no per-service limit.
|
|
207
|
+
# - `groups`: Contact groups — The maximum number of contact groups. Groups are
|
|
208
|
+
# used to organize contacts and to send messages to many recipients at once.
|
|
209
|
+
# - `custom_contact_fields`: Custom contact fields — The maximum number of custom
|
|
210
|
+
# fields that can be defined for contacts. Custom fields store extra information
|
|
211
|
+
# about contacts beyond the built-in name and phone number — for example, an
|
|
212
|
+
# account ID, language preference, or any project-specific attribute.
|
|
213
|
+
# - `external_messages_day`: Included Messages/Day - Bring Your Own Connectivity —
|
|
214
|
+
# The maximum number of messages that can be sent or received per day when using
|
|
215
|
+
# your own connectivity provider or an Android phone with the Telerivet Gateway app
|
|
216
|
+
# (not when paying Telerivet for each message). The counter resets at midnight in
|
|
217
|
+
# your organization's timezone. This limit applies when the plan's billing mode has
|
|
218
|
+
# a per-day messaging quota.
|
|
219
|
+
# - `external_messages_period`: Included Messages/Plan Period - Bring Your Own
|
|
220
|
+
# Connectivity — The maximum number of messages that can be sent or received per
|
|
221
|
+
# plan period (typically monthly or yearly) when using your own connectivity
|
|
222
|
+
# provider or an Android phone with the Telerivet Gateway app (not when paying
|
|
223
|
+
# Telerivet for each message). This limit applies when the plan has a
|
|
224
|
+
# per-plan-period messaging quota. Each sent or received SMS message part, voice
|
|
225
|
+
# call, USSD session, chat app message, or MMS message is counted as one message;
|
|
226
|
+
# multi-part SMS messages are counted based on the number of SMS parts in the
|
|
227
|
+
# message.
|
|
228
|
+
# - `ai_chat_credits_day`: AI chat credits/day
|
|
229
|
+
#
|
|
230
|
+
# - plan_features (Hash)
|
|
231
|
+
# * Object describing which platform features are enabled for this organization. The
|
|
232
|
+
# keys are string feature IDs and the values are booleans. Available features:
|
|
233
|
+
#
|
|
234
|
+
# - `direct_connectivity`: Direct Connectivity — Use Telerivet-managed phone
|
|
235
|
+
# routes where Telerivet handles billing with upstream messaging gateways on your
|
|
236
|
+
# behalf, instead of requiring you to bring your own gateway credentials.
|
|
237
|
+
# - `airtime_transfer`: Airtime Topup & Transfer — Send airtime to prepaid mobile
|
|
238
|
+
# phones as a reward or participation incentive, or top-up the airtime on your own
|
|
239
|
+
# SIM card directly from Telerivet. (Requires Pro plan or above)
|
|
240
|
+
# - `click_tracking`: Click Tracking — Shorten links and track which contacts
|
|
241
|
+
# clicked a link in your message.
|
|
242
|
+
# - `custom_gateway`: Custom Gateways — Integrate with an SMS shortcode or another
|
|
243
|
+
# gateway API. Telerivet can integrate with both HTTP or SMPP messaging APIs, and
|
|
244
|
+
# can configure VPN connections directly with mobile networks if necessary.
|
|
245
|
+
# (Integration fee varies depending on API - contact us)
|
|
246
|
+
# - `custom_logo`: Custom Logo — Replace the Telerivet logo in the web app with
|
|
247
|
+
# your own logo. (Requires Pro plan or above)
|
|
248
|
+
# - `custom_domain`: Custom Domain Name — Access your Telerivet account from your
|
|
249
|
+
# own domain name like sms.example.com, and hide Telerivet branding from users.
|
|
250
|
+
# Configure a custom domain for branded short links. (Contact us for pricing)
|
|
251
|
+
# - `soft_limits`: Soft Limits — Allow exceeding your plan's daily, monthly, or
|
|
252
|
+
# annual limits by paying for extra messages, API requests, or service invocations.
|
|
253
|
+
# - `auto_resend`: Automatic Message Resend & Failover — Configure custom rules to
|
|
254
|
+
# automatically resend failed messages and failover between routes. (Requires plan
|
|
255
|
+
# with Advanced custom automation)
|
|
256
|
+
# - `export_storage`: Cloud Data Export — Automatically export and backup
|
|
257
|
+
# messages, contacts, and other data to the cloud. Connect your own Amazon Web
|
|
258
|
+
# Services S3 account for data storage. (Requires plan with Advanced custom
|
|
259
|
+
# automation)
|
|
260
|
+
# - `static_ip_address`: Static IP Address — Configure Telerivet to use a static
|
|
261
|
+
# IP address for outbound HTTP requests if you need to allow inbound traffic from
|
|
262
|
+
# specific IP addresses in your firewall. (Requires plan with Advanced custom
|
|
263
|
+
# automation)
|
|
264
|
+
# - `script_modules`: Cloud Script Modules — Run Cloud Script API code from an
|
|
265
|
+
# external codebase hosted on GitHub, or push code to Telerivet directly from your
|
|
266
|
+
# development environment. Use source control to track version history. (Requires
|
|
267
|
+
# plan with Advanced custom automation)
|
|
268
|
+
# - `service_templates`: Service Templates — Create reusable automated services
|
|
269
|
+
# that can be shared with multiple projects and organizations. (Contact us for
|
|
270
|
+
# pricing)
|
|
271
|
+
# - `single_sign_on`: SAML Single Sign-On — Allow users to log in via your
|
|
272
|
+
# organization's single sign-on identity provider (SAML 2.0). (Contact us for
|
|
273
|
+
# pricing)
|
|
274
|
+
# - `contact_sync`: Contact Data Sync — Synchronize contact information and
|
|
275
|
+
# opt-out status across multiple Telerivet projects. (Requires Growth plan or above)
|
|
276
|
+
# - `external_airtime_providers`: External Airtime Providers — Configure airtime
|
|
277
|
+
# providers in your projects using your own credentials with an external airtime
|
|
278
|
+
# provider, in addition to (or instead of) Telerivet-managed airtime.
|
|
279
|
+
# - `wire_payments`: Wire Payments — Pay Telerivet invoices via bank wire transfer
|
|
280
|
+
# in addition to credit card and other online payment methods.
|
|
281
|
+
# - `custom_dashboards`: Custom Dashboards — Create custom dashboards with charts
|
|
282
|
+
# and metrics showing Telerivet usage and providing business intelligence about the
|
|
283
|
+
# results of your campaigns. (Requires Pro plan or above)
|
|
284
|
+
# - `branded_short_links`: Branded Short Links — Configure a custom domain name
|
|
285
|
+
# for short links, instead of using the default domain (rvt.me). (Requires Growth
|
|
286
|
+
# plan or above)
|
|
287
|
+
# - `custom_solutions`: Custom Solution Development — Work with Telerivet's
|
|
288
|
+
# professional services team to implement a custom solution for your business needs.
|
|
289
|
+
# (Contact us for pricing)
|
|
290
|
+
#
|
|
291
|
+
# - overage_rates (Hash)
|
|
292
|
+
# * Per-unit overage rates billed when usage exceeds the corresponding plan limit.
|
|
293
|
+
# Only present when the `soft_limits` feature is enabled in `plan_features` —
|
|
294
|
+
# without `soft_limits`, reaching a limit blocks further usage until the counter
|
|
295
|
+
# resets rather than accruing per-unit charges, so the rates would not apply and the
|
|
296
|
+
# field is omitted entirely. When present, each entry is an object with `amount` and
|
|
297
|
+
# `currency` properties, where `amount` is the positive per-unit cost in `currency`,
|
|
298
|
+
# or null if no rate is configured. Keys:
|
|
299
|
+
#
|
|
300
|
+
# - `message`: Cost per external (bring your own connectivity) message sent or
|
|
301
|
+
# received beyond the daily limit (`plan_limits.external_messages_day`) or
|
|
302
|
+
# per-period limit (`plan_limits.external_messages_period`).
|
|
303
|
+
# - `api_request`: Cost per REST API request beyond `plan_limits.api_requests_day`.
|
|
304
|
+
# - `service_invocation`: Cost per automated-service invocation beyond
|
|
305
|
+
# `plan_limits.service_invocations_day`.
|
|
306
|
+
#
|
|
307
|
+
# - minimum_usage_fees (array)
|
|
308
|
+
# * Array of minimum usage fees configured for this organization. Each fee
|
|
309
|
+
# guarantees a minimum amount of usage-based billing per billing cycle (the period
|
|
310
|
+
# from `plan_start_time` to `plan_end_time`, recurring per `plan_rrule`) for a
|
|
311
|
+
# particular set of usage categories — for example, a monthly minimum on
|
|
312
|
+
# per-message fees via a particular provider. If the actual usage-based charges
|
|
313
|
+
# across the fee's categories add up to less than the minimum during a billing
|
|
314
|
+
# cycle, the shortfall is billed up to the minimum amount, and added to the
|
|
315
|
+
# organization's recurring billing alongside the plan price. If actual usage exceeds
|
|
316
|
+
# the minimum, no additional minimum-usage charge is applied for that cycle. The
|
|
317
|
+
# array is empty when no minimum usage fees are configured.
|
|
125
318
|
#
|
|
126
319
|
# - recurring_billing_enabled (boolean)
|
|
127
320
|
# * True if recurring billing is enabled, false otherwise
|
|
128
321
|
#
|
|
129
322
|
# - auto_refill_enabled (boolean)
|
|
130
323
|
# * True if auto-refill is enabled, false otherwise
|
|
324
|
+
#
|
|
325
|
+
# - usage (Hash)
|
|
326
|
+
# * Object mapping each `plan_limits` key to the current integer usage count for
|
|
327
|
+
# that metric — present only when the request was made with `usage=true`. Includes
|
|
328
|
+
# either `external_messages_day` or `external_messages_period` (matching whichever
|
|
329
|
+
# the organization's billing mode produces in `plan_limits`), not both. Reset
|
|
330
|
+
# schedules and the per-service `custom_actions` semantics described on
|
|
331
|
+
# [getUsage](#Organization.getUsage) apply here as well.
|
|
131
332
|
#
|
|
132
|
-
def get_billing_details()
|
|
133
|
-
data = @api.do_request("GET", get_base_api_path() + "/billing")
|
|
333
|
+
def get_billing_details(options = nil)
|
|
334
|
+
data = @api.do_request("GET", get_base_api_path() + "/billing", options)
|
|
134
335
|
return data
|
|
135
336
|
end
|
|
136
337
|
|
|
137
338
|
#
|
|
138
|
-
# Retrieves the current usage count associated with a particular service plan limit.
|
|
139
|
-
#
|
|
140
|
-
#
|
|
339
|
+
# Retrieves the current usage count associated with a particular service plan limit.
|
|
340
|
+
#
|
|
341
|
+
# The available `usage_type` values are the same as the keys returned
|
|
342
|
+
# in `plan_limits` from the [getBillingDetails](#Organization.getBillingDetails) method, so
|
|
343
|
+
# each call returns the current value of the corresponding limit's counter.
|
|
344
|
+
#
|
|
345
|
+
# Notes:
|
|
346
|
+
#
|
|
347
|
+
# - `external_messages_day` and `external_messages_period` reset on
|
|
348
|
+
# different schedules: daily counters reset at midnight in the organization's timezone; period
|
|
349
|
+
# counters reset at the start of the next plan period (`plan_start_time` to `plan_end_time`
|
|
350
|
+
# from `getBillingDetails`).
|
|
351
|
+
# - `custom_actions` is the highest custom-action count across any
|
|
352
|
+
# single active service in the organization (since the corresponding limit is enforced per
|
|
353
|
+
# service, not per organization).
|
|
354
|
+
# - `messages_day` is retained as a deprecated alias for
|
|
355
|
+
# `external_messages_day`
|
|
141
356
|
#
|
|
142
357
|
# Arguments:
|
|
143
358
|
# - usage_type
|
|
144
|
-
# * Usage type.
|
|
145
|
-
#
|
|
146
|
-
#
|
|
359
|
+
# * Usage type. Same as the keys returned in `plan_limits` from
|
|
360
|
+
# `Organization.getBillingDetails`.
|
|
361
|
+
# * Allowed values: contacts, phones, active_services, users, stored_messages,
|
|
362
|
+
# service_invocations_day, api_requests_day, projects, data_rows, script_module_mb,
|
|
363
|
+
# stored_file_mb, custom_actions, groups, custom_contact_fields, external_messages_day,
|
|
364
|
+
# external_messages_period, ai_chat_credits_day
|
|
147
365
|
# * Required
|
|
148
366
|
#
|
|
149
367
|
# Returns:
|
|
@@ -153,6 +371,67 @@ class Organization < Entity
|
|
|
153
371
|
return @api.do_request("GET", get_base_api_path() + "/usage/#{usage_type}")
|
|
154
372
|
end
|
|
155
373
|
|
|
374
|
+
#
|
|
375
|
+
# Retrieves the daily history of the usage count associated with a particular service plan
|
|
376
|
+
# limit.
|
|
377
|
+
#
|
|
378
|
+
# Telerivet stores a snapshot of each organization's usage once per
|
|
379
|
+
# day, shortly after midnight in the organization's time zone. For usage types that are
|
|
380
|
+
# counted per day (`external_messages_day`, `api_requests_day`, `service_invocations_day`, and
|
|
381
|
+
# `ai_chat_credits_day`), each entry contains the usage counted during that entire day. For
|
|
382
|
+
# all other usage types, each entry contains the usage count at the time the snapshot was
|
|
383
|
+
# recorded.
|
|
384
|
+
#
|
|
385
|
+
# The maximum supported date range is 500 days between start_date and
|
|
386
|
+
# end_date. If the requested date range includes the current time, the response will also
|
|
387
|
+
# include a final entry with `current: true` containing the live usage count computed at the
|
|
388
|
+
# time of the API request.
|
|
389
|
+
#
|
|
390
|
+
# Usage snapshots are only recorded while an organization is active,
|
|
391
|
+
# so an entry may not be available for every date in the requested range.
|
|
392
|
+
#
|
|
393
|
+
# Arguments:
|
|
394
|
+
# - options (Hash)
|
|
395
|
+
# * Required
|
|
396
|
+
#
|
|
397
|
+
# - usage_type (string)
|
|
398
|
+
# * Usage type, corresponding to the keys in the `plan_limits` property returned by
|
|
399
|
+
# [getBillingDetails](#Organization.getBillingDetails).
|
|
400
|
+
# * Allowed values: contacts, phones, active_services, users, stored_messages,
|
|
401
|
+
# service_invocations_day, api_requests_day, projects, data_rows, script_module_mb,
|
|
402
|
+
# stored_file_mb, custom_actions, groups, custom_contact_fields,
|
|
403
|
+
# external_messages_day, external_messages_period, ai_chat_credits_day
|
|
404
|
+
# * Required
|
|
405
|
+
#
|
|
406
|
+
# - start_date (string)
|
|
407
|
+
# * Start date of usage history, in YYYY-MM-DD format (in the organization's time
|
|
408
|
+
# zone)
|
|
409
|
+
# * Required
|
|
410
|
+
#
|
|
411
|
+
# - end_date (string)
|
|
412
|
+
# * End date of usage history (inclusive), in YYYY-MM-DD format (in the organization's
|
|
413
|
+
# time zone)
|
|
414
|
+
# * Required
|
|
415
|
+
#
|
|
416
|
+
# Returns:
|
|
417
|
+
# (associative array)
|
|
418
|
+
# - timezone_id (string)
|
|
419
|
+
# * The organization's time zone ID, used to determine the date associated with each
|
|
420
|
+
# entry
|
|
421
|
+
#
|
|
422
|
+
# - usage_type (string)
|
|
423
|
+
# * The usage type from the request
|
|
424
|
+
#
|
|
425
|
+
# - history (array)
|
|
426
|
+
# * List of usage entries in chronological order, one for each daily usage snapshot
|
|
427
|
+
# recorded within the requested date range (plus the live usage entry if the range
|
|
428
|
+
# includes the current time).
|
|
429
|
+
#
|
|
430
|
+
def get_usage_history(options)
|
|
431
|
+
data = @api.do_request("GET", get_base_api_path() + "/usage_history", options)
|
|
432
|
+
return data
|
|
433
|
+
end
|
|
434
|
+
|
|
156
435
|
#
|
|
157
436
|
# Retrieves statistics about messages sent or received via Telerivet. This endpoint returns
|
|
158
437
|
# historical data that is computed shortly after midnight each day in the project's time zone,
|
|
@@ -183,16 +462,14 @@ class Organization < Entity
|
|
|
183
462
|
#
|
|
184
463
|
# - metrics (string)
|
|
185
464
|
# * Comma separated list of metrics to return (summed for each distinct value of the
|
|
186
|
-
# requested properties)
|
|
187
|
-
#
|
|
465
|
+
# requested properties). Supported metrics are `count` (the number of messages),
|
|
466
|
+
# `num_parts` (the number of SMS parts), `duration` (the total duration of calls, in
|
|
467
|
+
# seconds), and `price.<currency>` (the total price of messages priced in the
|
|
468
|
+
# specified ISO 4217 currency, e.g. `price.USD`). Amounts are not converted between
|
|
469
|
+
# currencies: each `price.<currency>` metric only includes messages priced in the
|
|
470
|
+
# specified currency.
|
|
188
471
|
# * Required
|
|
189
472
|
#
|
|
190
|
-
# - currency (string)
|
|
191
|
-
# * Three-letter ISO 4217 currency code used when returning the 'price' field. If the
|
|
192
|
-
# original price was in a different currency, it will be converted to the requested
|
|
193
|
-
# currency using the approximate current exchange rate.
|
|
194
|
-
# * Default: USD
|
|
195
|
-
#
|
|
196
473
|
# - filters (Hash)
|
|
197
474
|
# * Key-value pairs of properties and corresponding values; the returned statistics
|
|
198
475
|
# will only include messages where the property matches the provided value. Only the
|
data/lib/telerivet/phone.rb
CHANGED
|
@@ -68,6 +68,21 @@ module Telerivet
|
|
|
68
68
|
# to send messages. When null, there is no restriction on recipient countries.
|
|
69
69
|
# * Updatable via API
|
|
70
70
|
#
|
|
71
|
+
# - sent_message_limit (int)
|
|
72
|
+
# * Maximum number of messages that can be sent from this phone in a given period. When
|
|
73
|
+
# the sent_message_count reaches this limit, sending is automatically paused. Set to
|
|
74
|
+
# null to disable the limit.
|
|
75
|
+
# * Updatable via API
|
|
76
|
+
#
|
|
77
|
+
# - sent_message_count (int)
|
|
78
|
+
# * Number of messages sent from this phone since the counter was last reset (see
|
|
79
|
+
# sent_message_epoch). This property is not updated if sent_message_limit is null.
|
|
80
|
+
# * Read-only
|
|
81
|
+
#
|
|
82
|
+
# - sent_message_epoch (UNIX timestamp)
|
|
83
|
+
# * The UNIX timestamp when the sent_message_count was last reset to 0.
|
|
84
|
+
# * Read-only
|
|
85
|
+
#
|
|
71
86
|
# - send_delay (number)
|
|
72
87
|
# * Number of seconds to wait after sending each message from this phone, to avoid
|
|
73
88
|
# exceeding carrier rate limits.
|
|
@@ -176,6 +191,10 @@ module Telerivet
|
|
|
176
191
|
# Only applicable for routes that support external API configuration. Write-only; not
|
|
177
192
|
# returned by the API when retrieving a phone.
|
|
178
193
|
# * Updatable via API
|
|
194
|
+
#
|
|
195
|
+
# - url
|
|
196
|
+
# * URL to this phone in the Telerivet web app
|
|
197
|
+
# * Read-only
|
|
179
198
|
#
|
|
180
199
|
class Phone < Entity
|
|
181
200
|
#
|
|
@@ -195,7 +214,7 @@ class Phone < Entity
|
|
|
195
214
|
# - source
|
|
196
215
|
# * Filter messages by source
|
|
197
216
|
# * Allowed values: phone, provider, web, api, service, webhook, scheduled,
|
|
198
|
-
# integration
|
|
217
|
+
# integration, mcp
|
|
199
218
|
#
|
|
200
219
|
# - starred (bool)
|
|
201
220
|
# * Filter messages by starred/unstarred
|
|
@@ -267,6 +286,15 @@ class Phone < Entity
|
|
|
267
286
|
super
|
|
268
287
|
end
|
|
269
288
|
|
|
289
|
+
#
|
|
290
|
+
# Resets this route's sent_message_count to 0 and updates sent_message_epoch to the current
|
|
291
|
+
# time. If sending was automatically paused because the previous count reached the limit,
|
|
292
|
+
# sending will be resumed.
|
|
293
|
+
#
|
|
294
|
+
def reset_sent_message_count()
|
|
295
|
+
@api.do_request("POST", get_base_api_path() + "/reset_sent_message_count")
|
|
296
|
+
end
|
|
297
|
+
|
|
270
298
|
def id
|
|
271
299
|
get('id')
|
|
272
300
|
end
|
|
@@ -331,6 +359,22 @@ class Phone < Entity
|
|
|
331
359
|
set('allowed_recipient_countries', value)
|
|
332
360
|
end
|
|
333
361
|
|
|
362
|
+
def sent_message_limit
|
|
363
|
+
get('sent_message_limit')
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
def sent_message_limit=(value)
|
|
367
|
+
set('sent_message_limit', value)
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
def sent_message_count
|
|
371
|
+
get('sent_message_count')
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
def sent_message_epoch
|
|
375
|
+
get('sent_message_epoch')
|
|
376
|
+
end
|
|
377
|
+
|
|
334
378
|
def send_delay
|
|
335
379
|
get('send_delay')
|
|
336
380
|
end
|
|
@@ -443,6 +487,10 @@ class Phone < Entity
|
|
|
443
487
|
set('external_secret', value)
|
|
444
488
|
end
|
|
445
489
|
|
|
490
|
+
def url
|
|
491
|
+
get('url')
|
|
492
|
+
end
|
|
493
|
+
|
|
446
494
|
def get_base_api_path()
|
|
447
495
|
"/projects/#{get('project_id')}/phones/#{get('id')}"
|
|
448
496
|
end
|