telerivet 1.8.2 → 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.
@@ -0,0 +1,197 @@
1
+
2
+ module Telerivet
3
+
4
+ #
5
+ # Represents a reusable message template that can be used when composing or scheduling
6
+ # messages.
7
+ #
8
+ # Message templates can include placeholder variables using double square
9
+ # brackets (e.g. `[[contact.name]]`) that are replaced with actual values when the message is
10
+ # sent. For available variables, see [Variable Reference](#variables). The double square
11
+ # brackets may also include [filters](/api/rules_engine#filters) to transform variables, such
12
+ # as to set a default value.
13
+ #
14
+ # Templates synchronized from a WhatsApp Business Account are read-only and
15
+ # cannot be modified or deleted via the API.
16
+ # (When using Telerivet to send messages via a WhatsApp route, Telerivet tries
17
+ # to match the content of each outgoing message to one of these WhatsApp message templates. If
18
+ # a template matches, Telerivet sends a WhatsApp template message instead of a session
19
+ # message.)
20
+ #
21
+ # Fields:
22
+ #
23
+ # - id (string, max 34 characters)
24
+ # * ID of the message template
25
+ # * Read-only
26
+ #
27
+ # - name (string)
28
+ # * Name of the template (max 127 characters)
29
+ # * Updatable via API
30
+ #
31
+ # - content (string)
32
+ # * Content of the message template (max 2000 characters)
33
+ # * Updatable via API
34
+ #
35
+ # - track_clicks (bool)
36
+ # * If true, URLs in the content will be replaced with short links that track clicks
37
+ # when the template is used
38
+ # * Updatable via API
39
+ #
40
+ # - readonly (bool)
41
+ # * True if the template cannot be modified or deleted (i.e., it was synchronized from a
42
+ # WhatsApp Business Account)
43
+ # * Read-only
44
+ #
45
+ # - short_link_params (Hash)
46
+ # * Custom parameters for short links (only if track_clicks is true)
47
+ # * Updatable via API
48
+ #
49
+ # - attachments (array)
50
+ # * List of attachment objects with file URLs
51
+ # * Updatable via API
52
+ #
53
+ # - route_params (Hash)
54
+ # * Route-specific parameters to use when sending messages with this template.
55
+ #
56
+ # When sending messages via chat apps such as WhatsApp, the route_params
57
+ # parameter can be used to send messages with app-specific features such as quick
58
+ # replies and link buttons.
59
+ #
60
+ # For more details, see [Route-Specific Parameters](#route_params).
61
+ # * Updatable via API
62
+ #
63
+ # - waba_id (string)
64
+ # * ID of the WhatsApp Business Account that this template is associated with (only
65
+ # present for WhatsApp templates)
66
+ # * Read-only
67
+ #
68
+ # - whatsapp_template (Hash)
69
+ # * For templates synchronized from a WhatsApp Business Account, contains the full
70
+ # template data from WhatsApp with properties including `id`, `name`, `language`,
71
+ # `status`, `category`, and `components`. The full format is defined in the [WhatsApp
72
+ # Template API
73
+ # documentation](https://developers.facebook.com/documentation/business-messaging/whatsapp/reference/whatsapp-business-account/template-api#get-version-template-id).
74
+ # Only present for WhatsApp templates.
75
+ # * Read-only
76
+ #
77
+ # - time_created (UNIX timestamp)
78
+ # * Time the template was created in Telerivet
79
+ # * Read-only
80
+ #
81
+ # - time_updated (UNIX timestamp)
82
+ # * Time the template was last updated
83
+ # * Read-only
84
+ #
85
+ # - vars (Hash)
86
+ # * Custom variables stored for this template. Variable names may be up to 32 characters
87
+ # in length and can contain the characters a-z, A-Z, 0-9, and _.
88
+ # Values may be strings, numbers, or boolean (true/false).
89
+ # String values may be up to 4096 bytes in length when encoded as UTF-8.
90
+ # Up to 100 variables are supported per object.
91
+ # Setting a variable to null will delete the variable.
92
+ # * Updatable via API
93
+ #
94
+ # - project_id
95
+ # * ID of the project this template belongs to
96
+ # * Read-only
97
+ #
98
+ class MessageTemplate < Entity
99
+ #
100
+ # Saves any fields that have changed for the message template.
101
+ #
102
+ def save()
103
+ super
104
+ end
105
+
106
+ #
107
+ # Deletes the message template.
108
+ #
109
+ # Note: Templates synchronized from a WhatsApp Business Account cannot be deleted via the API.
110
+ #
111
+ def delete()
112
+ @api.do_request("DELETE", get_base_api_path())
113
+ end
114
+
115
+ def id
116
+ get('id')
117
+ end
118
+
119
+ def name
120
+ get('name')
121
+ end
122
+
123
+ def name=(value)
124
+ set('name', value)
125
+ end
126
+
127
+ def content
128
+ get('content')
129
+ end
130
+
131
+ def content=(value)
132
+ set('content', value)
133
+ end
134
+
135
+ def track_clicks
136
+ get('track_clicks')
137
+ end
138
+
139
+ def track_clicks=(value)
140
+ set('track_clicks', value)
141
+ end
142
+
143
+ def readonly
144
+ get('readonly')
145
+ end
146
+
147
+ def short_link_params
148
+ get('short_link_params')
149
+ end
150
+
151
+ def short_link_params=(value)
152
+ set('short_link_params', value)
153
+ end
154
+
155
+ def attachments
156
+ get('attachments')
157
+ end
158
+
159
+ def attachments=(value)
160
+ set('attachments', value)
161
+ end
162
+
163
+ def route_params
164
+ get('route_params')
165
+ end
166
+
167
+ def route_params=(value)
168
+ set('route_params', value)
169
+ end
170
+
171
+ def waba_id
172
+ get('waba_id')
173
+ end
174
+
175
+ def whatsapp_template
176
+ get('whatsapp_template')
177
+ end
178
+
179
+ def time_created
180
+ get('time_created')
181
+ end
182
+
183
+ def time_updated
184
+ get('time_updated')
185
+ end
186
+
187
+ def project_id
188
+ get('project_id')
189
+ end
190
+
191
+ def get_base_api_path()
192
+ "/projects/#{get('project_id')}/message_templates/#{get('id')}"
193
+ end
194
+
195
+ end
196
+
197
+ end
@@ -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 automatically.
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
@@ -51,6 +52,17 @@ class Organization < Entity
51
52
  # contact.
52
53
  # * Default: 1
53
54
  #
55
+ # - message_retention_days (int)
56
+ # * Number of days to retain messages in this project. Messages older than this will
57
+ # be automatically deleted. If null or not provided, messages will be retained
58
+ # forever.
59
+ #
60
+ # - short_link_scheme (bool)
61
+ # * If true (the default), short links in messages will include the scheme (e.g.,
62
+ # 'https://rvt.me/xxxxxxxxx'). If false, short links will not include the scheme
63
+ # (e.g., 'rvt.me/xxxxxxxxx').
64
+ # * Default: 1
65
+ #
54
66
  # - vars
55
67
  # * Custom variables and values to set for this project
56
68
  #
@@ -70,8 +82,34 @@ class Organization < Entity
70
82
  end
71
83
 
72
84
  #
73
- # Retrieves information about the organization's service plan and account balance.
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.
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).
74
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
+ #
75
113
  # Returns:
76
114
  # (associative array)
77
115
  # - balance (string)
@@ -108,29 +146,222 @@ class Organization < Entity
108
146
  #
109
147
  # - plan_limits (Hash)
110
148
  # * Object describing the limits associated with the current service plan. The
111
- # object contains the following keys: `phones`, `projects`, `active_services`,
112
- # `users`, `contacts`, `messages_day`, `stored_messages`, `data_rows`,
113
- # `api_requests_day`. The values corresponding to each key are integers, or null.
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.
114
318
  #
115
319
  # - recurring_billing_enabled (boolean)
116
320
  # * True if recurring billing is enabled, false otherwise
117
321
  #
118
322
  # - auto_refill_enabled (boolean)
119
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.
120
332
  #
121
- def get_billing_details()
122
- 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)
123
335
  return data
124
336
  end
125
337
 
126
338
  #
127
- # Retrieves the current usage count associated with a particular service plan limit. Available
128
- # usage types are `phones`, `projects`, `users`, `contacts`, `messages_day`,
129
- # `stored_messages`, `data_rows`, and `api_requests_day`.
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`
130
356
  #
131
357
  # Arguments:
132
358
  # - usage_type
133
- # * Usage type.
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
134
365
  # * Required
135
366
  #
136
367
  # Returns:
@@ -140,6 +371,67 @@ class Organization < Entity
140
371
  return @api.do_request("GET", get_base_api_path() + "/usage/#{usage_type}")
141
372
  end
142
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
+
143
435
  #
144
436
  # Retrieves statistics about messages sent or received via Telerivet. This endpoint returns
145
437
  # historical data that is computed shortly after midnight each day in the project's time zone,
@@ -170,16 +462,14 @@ class Organization < Entity
170
462
  #
171
463
  # - metrics (string)
172
464
  # * Comma separated list of metrics to return (summed for each distinct value of the
173
- # requested properties)
174
- # * Allowed values: count, num_parts, duration, price
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.
175
471
  # * Required
176
472
  #
177
- # - currency (string)
178
- # * Three-letter ISO 4217 currency code used when returning the 'price' field. If the
179
- # original price was in a different currency, it will be converted to the requested
180
- # currency using the approximate current exchange rate.
181
- # * Default: USD
182
- #
183
473
  # - filters (Hash)
184
474
  # * Key-value pairs of properties and corresponding values; the returned statistics
185
475
  # will only include messages where the property matches the provided value. Only the
@@ -191,29 +481,6 @@ class Organization < Entity
191
481
  # - intervals (array)
192
482
  # * List of objects representing each date interval containing at least one message
193
483
  # matching the filters.
194
- # Each object has the following properties:
195
- #
196
- # <table>
197
- # <tr><td> start_time </td> <td> The UNIX timestamp of the start
198
- # of the interval (int) </td></tr>
199
- # <tr><td> end_time </td> <td> The UNIX timestamp of the end of
200
- # the interval, exclusive (int) </td></tr>
201
- # <tr><td> start_date </td> <td> The date of the start of the
202
- # interval in YYYY-MM-DD format (string) </td></tr>
203
- # <tr><td> end_date </td> <td> The date of the end of the
204
- # interval in YYYY-MM-DD format, inclusive (string) </td></tr>
205
- # <tr><td> groups </td> <td> Array of groups for each
206
- # combination of requested property values matching the filters (array)
207
- # <br /><br />
208
- # Each object has the following properties:
209
- # <table>
210
- # <tr><td> properties </td> <td> An object of key/value
211
- # pairs for each distinct value of the requested properties (object) </td></tr>
212
- # <tr><td> metrics </td> <td> An object of key/value pairs
213
- # for each requested metric (object) </td></tr>
214
- # </table>
215
- # </td></tr>
216
- # </table>
217
484
  #
218
485
  def get_message_stats(options)
219
486
  data = @api.do_request("GET", get_base_api_path() + "/message_stats", options)