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.

Constant Summary collapse

OBJECT_NAME =
"billing.alert"

Constants inherited from StripeObject

StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary

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

#==, #[], #[]=, 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

Class Method Details

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

Reactivates this alert, allowing it to trigger again.



27
28
29
30
31
32
33
34
# File 'lib/stripe/resources/billing/alert.rb', line 27

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.



47
48
49
50
51
52
53
54
# File 'lib/stripe/resources/billing/alert.rb', line 47

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



57
58
59
# File 'lib/stripe/resources/billing/alert.rb', line 57

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.



72
73
74
75
76
77
78
79
# File 'lib/stripe/resources/billing/alert.rb', line 72

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

.list(filters = {}, opts = {}) ⇒ Object

Lists billing active and inactive alerts



82
83
84
# File 'lib/stripe/resources/billing/alert.rb', line 82

def self.list(filters = {}, opts = {})
  request_stripe_object(method: :get, path: "/v1/billing/alerts", params: filters, 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.



17
18
19
20
21
22
23
24
# File 'lib/stripe/resources/billing/alert.rb', line 17

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.



37
38
39
40
41
42
43
44
# File 'lib/stripe/resources/billing/alert.rb', line 37

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.



62
63
64
65
66
67
68
69
# File 'lib/stripe/resources/billing/alert.rb', line 62

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