Class: Stripe::Billing::Alert
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::Billing::Alert
- Defined in:
- lib/stripe/resources/billing/alert.rb
Overview
A billing alert is a resource that notifies you when a certain usage threshold on a meter is crossed. For example, you might create a billing alert to notify you when a certain user made 100 API requests.
Defined Under Namespace
Classes: CreditBalanceThreshold, SpendThreshold, UsageThreshold
Constant Summary collapse
- OBJECT_NAME =
"billing.alert"
Constants inherited from StripeObject
StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary collapse
-
#alert_type ⇒ Object
readonly
Defines the type of the alert.
-
#credit_balance_threshold ⇒ Object
readonly
Encapsulates configuration of the alert to monitor billing credit balance.
-
#id ⇒ Object
readonly
Unique identifier for the object.
-
#livemode ⇒ Object
readonly
If the object exists in live mode, the value is
true. -
#object ⇒ Object
readonly
String representing the object's type.
-
#spend_threshold ⇒ Object
readonly
Encapsulates the alert's configuration to monitor spend on pricing plan subscriptions.
-
#status ⇒ Object
readonly
Status of the alert.
-
#title ⇒ Object
readonly
Title of the alert.
-
#usage_threshold ⇒ Object
readonly
Encapsulates configuration of the alert to monitor usage on a specific Billing Meter.
Attributes inherited from APIResource
Attributes inherited from StripeObject
Class Method Summary collapse
-
.activate(id, params = {}, opts = {}) ⇒ Object
Reactivates this alert, allowing it to trigger again.
-
.archive(id, params = {}, opts = {}) ⇒ Object
Archives this alert, removing it from the list view and APIs.
-
.create(params = {}, opts = {}) ⇒ Object
Creates a billing alert.
-
.deactivate(id, params = {}, opts = {}) ⇒ Object
Deactivates this alert, preventing it from triggering.
- .field_encodings ⇒ Object
- .field_remappings ⇒ Object
- .inner_class_types ⇒ Object
-
.list(params = {}, opts = {}) ⇒ Object
Lists billing active and inactive alerts.
- .object_name ⇒ Object
Instance Method Summary collapse
-
#activate(params = {}, opts = {}) ⇒ Object
Reactivates this alert, allowing it to trigger again.
-
#archive(params = {}, opts = {}) ⇒ Object
Archives this alert, removing it from the list view and APIs.
-
#deactivate(params = {}, opts = {}) ⇒ Object
Deactivates this alert, preventing it from triggering.
Methods included from APIOperations::Create
Methods included from APIOperations::List
Methods included from APIOperations::NestedResource
Methods inherited from APIResource
class_name, custom_method, #refresh, #request_stripe_object, resource_url, #resource_url, retrieve, save_nested_resource
Methods included from APIOperations::Request
Methods inherited from StripeObject
#==, #[], #[]=, #_get_inner_class_type, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values
Constructor Details
This class inherits a constructor from Stripe::StripeObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject
Instance Attribute Details
#alert_type ⇒ Object (readonly)
Defines the type of the alert.
294 295 296 |
# File 'lib/stripe/resources/billing/alert.rb', line 294 def alert_type @alert_type end |
#credit_balance_threshold ⇒ Object (readonly)
Encapsulates configuration of the alert to monitor billing credit balance.
296 297 298 |
# File 'lib/stripe/resources/billing/alert.rb', line 296 def credit_balance_threshold @credit_balance_threshold end |
#id ⇒ Object (readonly)
Unique identifier for the object.
298 299 300 |
# File 'lib/stripe/resources/billing/alert.rb', line 298 def id @id end |
#livemode ⇒ Object (readonly)
If the object exists in live mode, the value is true. If the object exists in test mode, the value is false.
300 301 302 |
# File 'lib/stripe/resources/billing/alert.rb', line 300 def livemode @livemode end |
#object ⇒ Object (readonly)
String representing the object's type. Objects of the same type share the same value.
302 303 304 |
# File 'lib/stripe/resources/billing/alert.rb', line 302 def object @object end |
#spend_threshold ⇒ Object (readonly)
Encapsulates the alert's configuration to monitor spend on pricing plan subscriptions.
304 305 306 |
# File 'lib/stripe/resources/billing/alert.rb', line 304 def spend_threshold @spend_threshold end |
#status ⇒ Object (readonly)
Status of the alert. This can be active, inactive or archived.
306 307 308 |
# File 'lib/stripe/resources/billing/alert.rb', line 306 def status @status end |
#title ⇒ Object (readonly)
Title of the alert.
308 309 310 |
# File 'lib/stripe/resources/billing/alert.rb', line 308 def title @title end |
#usage_threshold ⇒ Object (readonly)
Encapsulates configuration of the alert to monitor usage on a specific Billing Meter.
310 311 312 |
# File 'lib/stripe/resources/billing/alert.rb', line 310 def usage_threshold @usage_threshold end |
Class Method Details
.activate(id, params = {}, opts = {}) ⇒ Object
Reactivates this alert, allowing it to trigger again.
323 324 325 326 327 328 329 330 |
# File 'lib/stripe/resources/billing/alert.rb', line 323 def self.activate(id, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/billing/alerts/%<id>s/activate", { id: CGI.escape(id) }), params: params, opts: opts ) end |
.archive(id, params = {}, opts = {}) ⇒ Object
Archives this alert, removing it from the list view and APIs. This is non-reversible.
343 344 345 346 347 348 349 350 |
# File 'lib/stripe/resources/billing/alert.rb', line 343 def self.archive(id, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/billing/alerts/%<id>s/archive", { id: CGI.escape(id) }), params: params, opts: opts ) end |
.create(params = {}, opts = {}) ⇒ Object
Creates a billing alert
353 354 355 |
# File 'lib/stripe/resources/billing/alert.rb', line 353 def self.create(params = {}, opts = {}) request_stripe_object(method: :post, path: "/v1/billing/alerts", params: params, opts: opts) end |
.deactivate(id, params = {}, opts = {}) ⇒ Object
Deactivates this alert, preventing it from triggering.
368 369 370 371 372 373 374 375 |
# File 'lib/stripe/resources/billing/alert.rb', line 368 def self.deactivate(id, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/billing/alerts/%<id>s/deactivate", { id: CGI.escape(id) }), params: params, opts: opts ) end |
.field_encodings ⇒ Object
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
# File 'lib/stripe/resources/billing/alert.rb', line 394 def self.field_encodings @field_encodings = { credit_balance_threshold: { kind: :object, fields: { lte: { kind: :object, fields: { custom_pricing_unit: { kind: :object, fields: { value: :decimal_string } } }, }, }, }, spend_threshold: { kind: :object, fields: { gte: { kind: :object, fields: { custom_pricing_unit: { kind: :object, fields: { value: :decimal_string } } }, }, }, }, } end |
.field_remappings ⇒ Object
390 391 392 |
# File 'lib/stripe/resources/billing/alert.rb', line 390 def self.field_remappings @field_remappings = {} end |
.inner_class_types ⇒ Object
382 383 384 385 386 387 388 |
# File 'lib/stripe/resources/billing/alert.rb', line 382 def self.inner_class_types @inner_class_types = { credit_balance_threshold: CreditBalanceThreshold, spend_threshold: SpendThreshold, usage_threshold: UsageThreshold, } end |
.list(params = {}, opts = {}) ⇒ Object
Lists billing active and inactive alerts
378 379 380 |
# File 'lib/stripe/resources/billing/alert.rb', line 378 def self.list(params = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/billing/alerts", params: params, opts: opts) end |
.object_name ⇒ Object
13 14 15 |
# File 'lib/stripe/resources/billing/alert.rb', line 13 def self.object_name "billing.alert" end |
Instance Method Details
#activate(params = {}, opts = {}) ⇒ Object
Reactivates this alert, allowing it to trigger again.
313 314 315 316 317 318 319 320 |
# File 'lib/stripe/resources/billing/alert.rb', line 313 def activate(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/billing/alerts/%<id>s/activate", { id: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#archive(params = {}, opts = {}) ⇒ Object
Archives this alert, removing it from the list view and APIs. This is non-reversible.
333 334 335 336 337 338 339 340 |
# File 'lib/stripe/resources/billing/alert.rb', line 333 def archive(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/billing/alerts/%<id>s/archive", { id: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#deactivate(params = {}, opts = {}) ⇒ Object
Deactivates this alert, preventing it from triggering.
358 359 360 361 362 363 364 365 |
# File 'lib/stripe/resources/billing/alert.rb', line 358 def deactivate(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/billing/alerts/%<id>s/deactivate", { id: CGI.escape(self["id"]) }), params: params, opts: opts ) end |