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.
-
.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
#==, #[], #[]=, 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.
167 168 169 |
# File 'lib/stripe/resources/billing/meter.rb', line 167 def created @created end |
#customer_mapping ⇒ Object (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_aggregation ⇒ Object (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_name ⇒ Object (readonly)
The meter’s name.
173 174 175 |
# File 'lib/stripe/resources/billing/meter.rb', line 173 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.
175 176 177 |
# File 'lib/stripe/resources/billing/meter.rb', line 175 def event_name @event_name end |
#event_time_window ⇒ Object (readonly)
The time window which meter events have been pre-aggregated for, if any.
177 178 179 |
# File 'lib/stripe/resources/billing/meter.rb', line 177 def event_time_window @event_time_window end |
#id ⇒ Object (readonly)
Unique identifier for the object.
179 180 181 |
# File 'lib/stripe/resources/billing/meter.rb', line 179 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.
181 182 183 |
# File 'lib/stripe/resources/billing/meter.rb', line 181 def livemode @livemode end |
#object ⇒ Object (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 |
#status ⇒ Object (readonly)
The meter’s status.
185 186 187 |
# File 'lib/stripe/resources/billing/meter.rb', line 185 def status @status end |
#status_transitions ⇒ Object (readonly)
Attribute for field status_transitions
187 188 189 |
# File 'lib/stripe/resources/billing/meter.rb', line 187 def status_transitions @status_transitions end |
#updated ⇒ Object (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_settings ⇒ Object (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_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.
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 |