Class: Stripe::Billing::Alert

Inherits:
APIResource show all
Extended by:
APIOperations::Create, APIOperations::List
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

Attributes inherited from APIResource

#save_with_parent

Attributes inherited from StripeObject

#last_response

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::List

list

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

included

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_typeObject (readonly)

Defines the type of the alert.



255
256
257
# File 'lib/stripe/resources/billing/alert.rb', line 255

def alert_type
  @alert_type
end

#credit_balance_thresholdObject (readonly)

Encapsulates configuration of the alert to monitor billing credit balance.



257
258
259
# File 'lib/stripe/resources/billing/alert.rb', line 257

def credit_balance_threshold
  @credit_balance_threshold
end

#idObject (readonly)

Unique identifier for the object.



259
260
261
# File 'lib/stripe/resources/billing/alert.rb', line 259

def id
  @id
end

#livemodeObject (readonly)

Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.



261
262
263
# File 'lib/stripe/resources/billing/alert.rb', line 261

def livemode
  @livemode
end

#objectObject (readonly)

String representing the object’s type. Objects of the same type share the same value.



263
264
265
# File 'lib/stripe/resources/billing/alert.rb', line 263

def object
  @object
end

#spend_thresholdObject (readonly)

Encapsulates the alert’s configuration to monitor spend on pricing plan subscriptions.



265
266
267
# File 'lib/stripe/resources/billing/alert.rb', line 265

def spend_threshold
  @spend_threshold
end

#statusObject (readonly)

Status of the alert. This can be active, inactive or archived.



267
268
269
# File 'lib/stripe/resources/billing/alert.rb', line 267

def status
  @status
end

#titleObject (readonly)

Title of the alert.



269
270
271
# File 'lib/stripe/resources/billing/alert.rb', line 269

def title
  @title
end

#usage_thresholdObject (readonly)

Encapsulates configuration of the alert to monitor usage on a specific [Billing Meter](docs.stripe.com/api/billing/meter).



271
272
273
# File 'lib/stripe/resources/billing/alert.rb', line 271

def usage_threshold
  @usage_threshold
end

Class Method Details

.activate(id, params = {}, opts = {}) ⇒ Object

Reactivates this alert, allowing it to trigger again.



284
285
286
287
288
289
290
291
# File 'lib/stripe/resources/billing/alert.rb', line 284

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.



304
305
306
307
308
309
310
311
# File 'lib/stripe/resources/billing/alert.rb', line 304

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



314
315
316
# File 'lib/stripe/resources/billing/alert.rb', line 314

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.



329
330
331
332
333
334
335
336
# File 'lib/stripe/resources/billing/alert.rb', line 329

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_remappingsObject



351
352
353
# File 'lib/stripe/resources/billing/alert.rb', line 351

def self.field_remappings
  @field_remappings = {}
end

.inner_class_typesObject



343
344
345
346
347
348
349
# File 'lib/stripe/resources/billing/alert.rb', line 343

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



339
340
341
# File 'lib/stripe/resources/billing/alert.rb', line 339

def self.list(params = {}, opts = {})
  request_stripe_object(method: :get, path: "/v1/billing/alerts", params: params, opts: opts)
end

.object_nameObject



12
13
14
# File 'lib/stripe/resources/billing/alert.rb', line 12

def self.object_name
  "billing.alert"
end

Instance Method Details

#activate(params = {}, opts = {}) ⇒ Object

Reactivates this alert, allowing it to trigger again.



274
275
276
277
278
279
280
281
# File 'lib/stripe/resources/billing/alert.rb', line 274

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.



294
295
296
297
298
299
300
301
# File 'lib/stripe/resources/billing/alert.rb', line 294

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.



319
320
321
322
323
324
325
326
# File 'lib/stripe/resources/billing/alert.rb', line 319

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