Class: Stripe::Billing::Meter
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::Billing::Meter
- 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
-
#created ⇒ Object
readonly
Time at which the object was created.
-
#customer_mapping ⇒ Object
readonly
Attribute for field customer_mapping.
-
#default_aggregation ⇒ Object
readonly
Attribute for field default_aggregation.
-
#display_name ⇒ Object
readonly
The meter’s name.
-
#event_name ⇒ Object
readonly
The name of the meter event to record usage for.
-
#event_time_window ⇒ Object
readonly
The time window which meter events have been pre-aggregated for, if any.
-
#id ⇒ Object
readonly
Unique identifier for the object.
-
#livemode ⇒ Object
readonly
Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.
-
#object ⇒ Object
readonly
String representing the object’s type.
-
#status ⇒ Object
readonly
The meter’s status.
-
#status_transitions ⇒ Object
readonly
Attribute for field status_transitions.
-
#updated ⇒ Object
readonly
Time at which the object was last updated.
-
#value_settings ⇒ Object
readonly
Attribute for field value_settings.
Attributes inherited from APIResource
Attributes inherited from StripeObject
Class Method Summary collapse
-
.create(params = {}, opts = {}) ⇒ Object
Creates a billing meter.
-
.deactivate(id, params = {}, opts = {}) ⇒ Object
When a meter is deactivated, no more meter events will be accepted for this meter.
- .field_remappings ⇒ Object
- .inner_class_types ⇒ Object
-
.list(params = {}, opts = {}) ⇒ Object
Retrieve a list of billing meters.
- .object_name ⇒ Object
-
.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.
-
.update(id, params = {}, opts = {}) ⇒ Object
Updates a billing meter.
Instance Method Summary collapse
-
#deactivate(params = {}, opts = {}) ⇒ Object
When a meter is deactivated, no more meter events will be accepted for this meter.
-
#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.
Methods included from APIOperations::Create
Methods included from APIOperations::List
Methods included from APIOperations::NestedResource
Methods included from APIOperations::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
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
#created ⇒ Object (readonly)
Time at which the object was created. Measured in seconds since the Unix epoch.
199 200 201 |
# File 'lib/stripe/resources/billing/meter.rb', line 199 def created @created end |
#customer_mapping ⇒ Object (readonly)
Attribute for field customer_mapping
201 202 203 |
# File 'lib/stripe/resources/billing/meter.rb', line 201 def customer_mapping @customer_mapping end |
#default_aggregation ⇒ Object (readonly)
Attribute for field default_aggregation
203 204 205 |
# File 'lib/stripe/resources/billing/meter.rb', line 203 def default_aggregation @default_aggregation end |
#display_name ⇒ Object (readonly)
The meter’s name.
205 206 207 |
# File 'lib/stripe/resources/billing/meter.rb', line 205 def display_name @display_name end |
#event_name ⇒ Object (readonly)
The name of the meter event to record usage for. Corresponds with the ‘event_name` field on meter events.
207 208 209 |
# File 'lib/stripe/resources/billing/meter.rb', line 207 def event_name @event_name end |
#event_time_window ⇒ Object (readonly)
The time window which meter events have been pre-aggregated for, if any.
209 210 211 |
# File 'lib/stripe/resources/billing/meter.rb', line 209 def event_time_window @event_time_window end |
#id ⇒ Object (readonly)
Unique identifier for the object.
211 212 213 |
# File 'lib/stripe/resources/billing/meter.rb', line 211 def id @id end |
#livemode ⇒ Object (readonly)
Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.
213 214 215 |
# File 'lib/stripe/resources/billing/meter.rb', line 213 def livemode @livemode end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
215 216 217 |
# File 'lib/stripe/resources/billing/meter.rb', line 215 def object @object end |
#status ⇒ Object (readonly)
The meter’s status.
217 218 219 |
# File 'lib/stripe/resources/billing/meter.rb', line 217 def status @status end |
#status_transitions ⇒ Object (readonly)
Attribute for field status_transitions
219 220 221 |
# File 'lib/stripe/resources/billing/meter.rb', line 219 def status_transitions @status_transitions end |
#updated ⇒ Object (readonly)
Time at which the object was last updated. Measured in seconds since the Unix epoch.
221 222 223 |
# File 'lib/stripe/resources/billing/meter.rb', line 221 def updated @updated end |
#value_settings ⇒ Object (readonly)
Attribute for field value_settings
223 224 225 |
# File 'lib/stripe/resources/billing/meter.rb', line 223 def value_settings @value_settings end |
Class Method Details
.create(params = {}, opts = {}) ⇒ Object
Creates a billing meter.
226 227 228 |
# File 'lib/stripe/resources/billing/meter.rb', line 226 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.
241 242 243 244 245 246 247 248 |
# File 'lib/stripe/resources/billing/meter.rb', line 241 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 |
.field_remappings ⇒ Object
294 295 296 |
# File 'lib/stripe/resources/billing/meter.rb', line 294 def self.field_remappings @field_remappings = {} end |
.inner_class_types ⇒ Object
285 286 287 288 289 290 291 292 |
# File 'lib/stripe/resources/billing/meter.rb', line 285 def self.inner_class_types @inner_class_types = { customer_mapping: CustomerMapping, default_aggregation: DefaultAggregation, status_transitions: StatusTransitions, value_settings: ValueSettings, } end |
.list(params = {}, opts = {}) ⇒ Object
Retrieve a list of billing meters.
251 252 253 |
# File 'lib/stripe/resources/billing/meter.rb', line 251 def self.list(params = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/billing/meters", params: params, opts: opts) end |
.object_name ⇒ Object
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.
266 267 268 269 270 271 272 273 |
# File 'lib/stripe/resources/billing/meter.rb', line 266 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.
276 277 278 279 280 281 282 283 |
# File 'lib/stripe/resources/billing/meter.rb', line 276 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.
231 232 233 234 235 236 237 238 |
# File 'lib/stripe/resources/billing/meter.rb', line 231 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.
256 257 258 259 260 261 262 263 |
# File 'lib/stripe/resources/billing/meter.rb', line 256 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 |