Class: Orb::Resources::Alerts
- Inherits:
-
Object
- Object
- Orb::Resources::Alerts
- Defined in:
- lib/orb/resources/alerts.rb
Instance Method Summary collapse
-
#create_for_customer(customer_id, currency: , type: , thresholds: nil, request_options: {}) ⇒ Orb::Models::Alert
This endpoint creates a new alert to monitor a customer’s credit balance.
-
#create_for_external_customer(external_customer_id, currency: , type: , thresholds: nil, request_options: {}) ⇒ Orb::Models::Alert
This endpoint creates a new alert to monitor a customer’s credit balance.
-
#create_for_subscription(subscription_id, thresholds: , type: , metric_id: nil, request_options: {}) ⇒ Orb::Models::Alert
This endpoint is used to create alerts at the subscription level.
-
#disable(alert_configuration_id, subscription_id: nil, request_options: {}) ⇒ Orb::Models::Alert
This endpoint allows you to disable an alert.
-
#enable(alert_configuration_id, subscription_id: nil, request_options: {}) ⇒ Orb::Models::Alert
This endpoint allows you to enable an alert.
-
#initialize(client:) ⇒ Alerts
constructor
private
A new instance of Alerts.
-
#list(created_at_gt: nil, created_at_gte: nil, created_at_lt: nil, created_at_lte: nil, cursor: nil, customer_id: nil, external_customer_id: nil, limit: nil, subscription_id: nil, request_options: {}) ⇒ Orb::Internal::Page<Orb::Models::Alert>
Some parameter documentations has been truncated, see Models::AlertListParams for more details.
-
#retrieve(alert_id, request_options: {}) ⇒ Orb::Models::Alert
This endpoint retrieves an alert by its ID.
-
#update(alert_configuration_id, thresholds: , request_options: {}) ⇒ Orb::Models::Alert
This endpoint updates the thresholds of an alert.
Constructor Details
#initialize(client:) ⇒ Alerts
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Alerts.
269 270 271 |
# File 'lib/orb/resources/alerts.rb', line 269 def initialize(client:) @client = client end |
Instance Method Details
#create_for_customer(customer_id, currency: , type: , thresholds: nil, request_options: {}) ⇒ Orb::Models::Alert
This endpoint creates a new alert to monitor a customer’s credit balance. There are three types of alerts that can be scoped to customers: ‘credit_balance_depleted`, `credit_balance_dropped`, and `credit_balance_recovered`. Customers can have a maximum of one of each type of alert per [credit balance currency](/product-catalog/prepurchase). `credit_balance_dropped` alerts require a list of thresholds to be provided while `credit_balance_depleted` and `credit_balance_recovered` alerts do not require thresholds.
130 131 132 133 134 135 136 137 138 139 |
# File 'lib/orb/resources/alerts.rb', line 130 def create_for_customer(customer_id, params) parsed, = Orb::AlertCreateForCustomerParams.dump_request(params) @client.request( method: :post, path: ["alerts/customer_id/%1$s", customer_id], body: parsed, model: Orb::Alert, options: ) end |
#create_for_external_customer(external_customer_id, currency: , type: , thresholds: nil, request_options: {}) ⇒ Orb::Models::Alert
This endpoint creates a new alert to monitor a customer’s credit balance. There are three types of alerts that can be scoped to customers: ‘credit_balance_depleted`, `credit_balance_dropped`, and `credit_balance_recovered`. Customers can have a maximum of one of each type of alert per [credit balance currency](/product-catalog/prepurchase). `credit_balance_dropped` alerts require a list of thresholds to be provided while `credit_balance_depleted` and `credit_balance_recovered` alerts do not require thresholds.
165 166 167 168 169 170 171 172 173 174 |
# File 'lib/orb/resources/alerts.rb', line 165 def create_for_external_customer(external_customer_id, params) parsed, = Orb::AlertCreateForExternalCustomerParams.dump_request(params) @client.request( method: :post, path: ["alerts/external_customer_id/%1$s", external_customer_id], body: parsed, model: Orb::Alert, options: ) end |
#create_for_subscription(subscription_id, thresholds: , type: , metric_id: nil, request_options: {}) ⇒ Orb::Models::Alert
This endpoint is used to create alerts at the subscription level.
Subscription level alerts can be one of two types: ‘usage_exceeded` or `cost_exceeded`. A `usage_exceeded` alert is scoped to a particular metric and is triggered when the usage of that metric exceeds predefined thresholds during the current billing cycle. A `cost_exceeded` alert is triggered when the total amount due during the current billing cycle surpasses predefined thresholds. `cost_exceeded` alerts do not include burndown of pre-purchase credits. Each subscription can have one `cost_exceeded` alert and one `usage_exceeded` alert per metric that is a part of the subscription. Alerts are triggered based on usage or cost conditions met during the current billing cycle.
203 204 205 206 207 208 209 210 211 212 |
# File 'lib/orb/resources/alerts.rb', line 203 def create_for_subscription(subscription_id, params) parsed, = Orb::AlertCreateForSubscriptionParams.dump_request(params) @client.request( method: :post, path: ["alerts/subscription_id/%1$s", subscription_id], body: parsed, model: Orb::Alert, options: ) end |
#disable(alert_configuration_id, subscription_id: nil, request_options: {}) ⇒ Orb::Models::Alert
This endpoint allows you to disable an alert. To disable a plan-level alert for a specific subscription, you must include the ‘subscription_id`. The `subscription_id` is not required for customer or subscription level alerts.
229 230 231 232 233 234 235 236 237 238 |
# File 'lib/orb/resources/alerts.rb', line 229 def disable(alert_configuration_id, params = {}) parsed, = Orb::AlertDisableParams.dump_request(params) @client.request( method: :post, path: ["alerts/%1$s/disable", alert_configuration_id], query: parsed, model: Orb::Alert, options: ) end |
#enable(alert_configuration_id, subscription_id: nil, request_options: {}) ⇒ Orb::Models::Alert
This endpoint allows you to enable an alert. To enable a plan-level alert for a specific subscription, you must include the ‘subscription_id`. The `subscription_id` is not required for customer or subscription level alerts.
255 256 257 258 259 260 261 262 263 264 |
# File 'lib/orb/resources/alerts.rb', line 255 def enable(alert_configuration_id, params = {}) parsed, = Orb::AlertEnableParams.dump_request(params) @client.request( method: :post, path: ["alerts/%1$s/enable", alert_configuration_id], query: parsed, model: Orb::Alert, options: ) end |
#list(created_at_gt: nil, created_at_gte: nil, created_at_lt: nil, created_at_lte: nil, cursor: nil, customer_id: nil, external_customer_id: nil, limit: nil, subscription_id: nil, request_options: {}) ⇒ Orb::Internal::Page<Orb::Models::Alert>
Some parameter documentations has been truncated, see Models::AlertListParams for more details.
This endpoint returns a list of alerts within Orb.
The request must specify one of ‘customer_id`, `external_customer_id`, or `subscription_id`.
If querying by subscripion_id, the endpoint will return the subscription level alerts as well as the plan level alerts associated with the subscription.
The list of alerts is ordered starting from the most recently created alert. This endpoint follows Orb’s [standardized pagination format](/api-reference/pagination).
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/orb/resources/alerts.rb', line 89 def list(params = {}) parsed, = Orb::AlertListParams.dump_request(params) @client.request( method: :get, path: "alerts", query: parsed.transform_keys( created_at_gt: "created_at[gt]", created_at_gte: "created_at[gte]", created_at_lt: "created_at[lt]", created_at_lte: "created_at[lte]" ), page: Orb::Internal::Page, model: Orb::Alert, options: ) end |
#retrieve(alert_id, request_options: {}) ⇒ Orb::Models::Alert
This endpoint retrieves an alert by its ID.
16 17 18 19 20 21 22 23 |
# File 'lib/orb/resources/alerts.rb', line 16 def retrieve(alert_id, params = {}) @client.request( method: :get, path: ["alerts/%1$s", alert_id], model: Orb::Alert, options: params[:request_options] ) end |
#update(alert_configuration_id, thresholds: , request_options: {}) ⇒ Orb::Models::Alert
This endpoint updates the thresholds of an alert.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/orb/resources/alerts.rb', line 38 def update(alert_configuration_id, params) parsed, = Orb::AlertUpdateParams.dump_request(params) @client.request( method: :put, path: ["alerts/%1$s", alert_configuration_id], body: parsed, model: Orb::Alert, options: ) end |