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: ActivateParams, ArchiveParams, CreateParams, DeactivateParams, ListParams, RetrieveParams, 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

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



162
163
164
# File 'lib/stripe/resources/billing/alert.rb', line 162

def alert_type
  @alert_type
end

#idObject (readonly)

Unique identifier for the object.



165
166
167
# File 'lib/stripe/resources/billing/alert.rb', line 165

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.



168
169
170
# File 'lib/stripe/resources/billing/alert.rb', line 168

def livemode
  @livemode
end

#objectObject (readonly)

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



171
172
173
# File 'lib/stripe/resources/billing/alert.rb', line 171

def object
  @object
end

#statusObject (readonly)

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



174
175
176
# File 'lib/stripe/resources/billing/alert.rb', line 174

def status
  @status
end

#titleObject (readonly)

Title of the alert.



177
178
179
# File 'lib/stripe/resources/billing/alert.rb', line 177

def title
  @title
end

#usage_thresholdObject (readonly)

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



180
181
182
# File 'lib/stripe/resources/billing/alert.rb', line 180

def usage_threshold
  @usage_threshold
end

Class Method Details

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

Reactivates this alert, allowing it to trigger again.



193
194
195
196
197
198
199
200
# File 'lib/stripe/resources/billing/alert.rb', line 193

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.



213
214
215
216
217
218
219
220
# File 'lib/stripe/resources/billing/alert.rb', line 213

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



223
224
225
# File 'lib/stripe/resources/billing/alert.rb', line 223

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.



238
239
240
241
242
243
244
245
# File 'lib/stripe/resources/billing/alert.rb', line 238

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(params = {}, opts = {}) ⇒ Object

Lists billing active and inactive alerts



248
249
250
# File 'lib/stripe/resources/billing/alert.rb', line 248

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.



183
184
185
186
187
188
189
190
# File 'lib/stripe/resources/billing/alert.rb', line 183

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.



203
204
205
206
207
208
209
210
# File 'lib/stripe/resources/billing/alert.rb', line 203

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.



228
229
230
231
232
233
234
235
# File 'lib/stripe/resources/billing/alert.rb', line 228

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