Class: Stripe::Billing::Meter

Inherits:
APIResource show all
Extended by:
APIOperations::Create, APIOperations::List, APIOperations::NestedResource
Includes:
APIOperations::Save
Defined in:
lib/stripe/resources/billing/meter.rb

Overview

Meters specify how to aggregate meter events over a billing period. Meter events represent the actions that customers take in your system. Meters attach to prices and form the basis of the bill.

Related guide: [Usage based billing](docs.stripe.com/billing/subscriptions/usage-based)

Defined Under Namespace

Classes: CreateParams, CustomerMapping, DeactivateParams, DefaultAggregation, ListParams, ReactivateParams, StatusTransitions, UpdateParams, ValueSettings

Constant Summary collapse

OBJECT_NAME =
"billing.meter"

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 included from APIOperations::NestedResource

nested_resource_class_methods

Methods included from APIOperations::Save

included, #save

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

#createdObject (readonly)

Time at which the object was created. Measured in seconds since the Unix epoch.



167
168
169
# File 'lib/stripe/resources/billing/meter.rb', line 167

def created
  @created
end

#customer_mappingObject (readonly)

Attribute for field customer_mapping



169
170
171
# File 'lib/stripe/resources/billing/meter.rb', line 169

def customer_mapping
  @customer_mapping
end

#default_aggregationObject (readonly)

Attribute for field default_aggregation



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

def default_aggregation
  @default_aggregation
end

#display_nameObject (readonly)

The meter’s name.



173
174
175
# File 'lib/stripe/resources/billing/meter.rb', line 173

def display_name
  @display_name
end

#event_nameObject (readonly)

The name of the meter event to record usage for. Corresponds with the ‘event_name` field on meter events.



175
176
177
# File 'lib/stripe/resources/billing/meter.rb', line 175

def event_name
  @event_name
end

#event_time_windowObject (readonly)

The time window to pre-aggregate meter events for, if any.



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

def event_time_window
  @event_time_window
end

#idObject (readonly)

Unique identifier for the object.



179
180
181
# File 'lib/stripe/resources/billing/meter.rb', line 179

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.



181
182
183
# File 'lib/stripe/resources/billing/meter.rb', line 181

def livemode
  @livemode
end

#objectObject (readonly)

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



183
184
185
# File 'lib/stripe/resources/billing/meter.rb', line 183

def object
  @object
end

#statusObject (readonly)

The meter’s status.



185
186
187
# File 'lib/stripe/resources/billing/meter.rb', line 185

def status
  @status
end

#status_transitionsObject (readonly)

Attribute for field status_transitions



187
188
189
# File 'lib/stripe/resources/billing/meter.rb', line 187

def status_transitions
  @status_transitions
end

#updatedObject (readonly)

Time at which the object was last updated. Measured in seconds since the Unix epoch.



189
190
191
# File 'lib/stripe/resources/billing/meter.rb', line 189

def updated
  @updated
end

#value_settingsObject (readonly)

Attribute for field value_settings



191
192
193
# File 'lib/stripe/resources/billing/meter.rb', line 191

def value_settings
  @value_settings
end

Class Method Details

.create(params = {}, opts = {}) ⇒ Object

Creates a billing meter.



194
195
196
# File 'lib/stripe/resources/billing/meter.rb', line 194

def self.create(params = {}, opts = {})
  request_stripe_object(method: :post, path: "/v1/billing/meters", params: params, opts: opts)
end

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

When a meter is deactivated, no more meter events will be accepted for this meter. You can’t attach a deactivated meter to a price.



209
210
211
212
213
214
215
216
# File 'lib/stripe/resources/billing/meter.rb', line 209

def self.deactivate(id, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/billing/meters/%<id>s/deactivate", { id: CGI.escape(id) }),
    params: params,
    opts: opts
  )
end

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

Retrieve a list of billing meters.



219
220
221
# File 'lib/stripe/resources/billing/meter.rb', line 219

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

.object_nameObject



16
17
18
# File 'lib/stripe/resources/billing/meter.rb', line 16

def self.object_name
  "billing.meter"
end

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

When a meter is reactivated, events for this meter can be accepted and you can attach the meter to a price.



234
235
236
237
238
239
240
241
# File 'lib/stripe/resources/billing/meter.rb', line 234

def self.reactivate(id, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/billing/meters/%<id>s/reactivate", { id: CGI.escape(id) }),
    params: params,
    opts: opts
  )
end

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

Updates a billing meter.



244
245
246
247
248
249
250
251
# File 'lib/stripe/resources/billing/meter.rb', line 244

def self.update(id, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/billing/meters/%<id>s", { id: CGI.escape(id) }),
    params: params,
    opts: opts
  )
end

Instance Method Details

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

When a meter is deactivated, no more meter events will be accepted for this meter. You can’t attach a deactivated meter to a price.



199
200
201
202
203
204
205
206
# File 'lib/stripe/resources/billing/meter.rb', line 199

def deactivate(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/billing/meters/%<id>s/deactivate", { id: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

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

When a meter is reactivated, events for this meter can be accepted and you can attach the meter to a price.



224
225
226
227
228
229
230
231
# File 'lib/stripe/resources/billing/meter.rb', line 224

def reactivate(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/billing/meters/%<id>s/reactivate", { id: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end