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: CustomerMapping, DefaultAggregation, StatusTransitions, 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.
78 79 80 |
# File 'lib/stripe/resources/billing/meter.rb', line 78 def created @created end |
#customer_mapping ⇒ Object (readonly)
Attribute for field customer_mapping
80 81 82 |
# File 'lib/stripe/resources/billing/meter.rb', line 80 def customer_mapping @customer_mapping end |
#default_aggregation ⇒ Object (readonly)
Attribute for field default_aggregation
82 83 84 |
# File 'lib/stripe/resources/billing/meter.rb', line 82 def default_aggregation @default_aggregation end |
#display_name ⇒ Object (readonly)
The meter’s name.
84 85 86 |
# File 'lib/stripe/resources/billing/meter.rb', line 84 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.
86 87 88 |
# File 'lib/stripe/resources/billing/meter.rb', line 86 def event_name @event_name end |
#event_time_window ⇒ Object (readonly)
The time window which meter events have been pre-aggregated for, if any.
88 89 90 |
# File 'lib/stripe/resources/billing/meter.rb', line 88 def event_time_window @event_time_window end |
#id ⇒ Object (readonly)
Unique identifier for the object.
90 91 92 |
# File 'lib/stripe/resources/billing/meter.rb', line 90 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.
92 93 94 |
# File 'lib/stripe/resources/billing/meter.rb', line 92 def livemode @livemode end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
94 95 96 |
# File 'lib/stripe/resources/billing/meter.rb', line 94 def object @object end |
#status ⇒ Object (readonly)
The meter’s status.
96 97 98 |
# File 'lib/stripe/resources/billing/meter.rb', line 96 def status @status end |
#status_transitions ⇒ Object (readonly)
Attribute for field status_transitions
98 99 100 |
# File 'lib/stripe/resources/billing/meter.rb', line 98 def status_transitions @status_transitions end |
#updated ⇒ Object (readonly)
Time at which the object was last updated. Measured in seconds since the Unix epoch.
100 101 102 |
# File 'lib/stripe/resources/billing/meter.rb', line 100 def updated @updated end |
#value_settings ⇒ Object (readonly)
Attribute for field value_settings
102 103 104 |
# File 'lib/stripe/resources/billing/meter.rb', line 102 def value_settings @value_settings end |
Class Method Details
.create(params = {}, opts = {}) ⇒ Object
Creates a billing meter.
105 106 107 |
# File 'lib/stripe/resources/billing/meter.rb', line 105 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.
120 121 122 123 124 125 126 127 |
# File 'lib/stripe/resources/billing/meter.rb', line 120 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
173 174 175 |
# File 'lib/stripe/resources/billing/meter.rb', line 173 def self.field_remappings @field_remappings = {} end |
.inner_class_types ⇒ Object
164 165 166 167 168 169 170 171 |
# File 'lib/stripe/resources/billing/meter.rb', line 164 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.
130 131 132 |
# File 'lib/stripe/resources/billing/meter.rb', line 130 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.
145 146 147 148 149 150 151 152 |
# File 'lib/stripe/resources/billing/meter.rb', line 145 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.
155 156 157 158 159 160 161 162 |
# File 'lib/stripe/resources/billing/meter.rb', line 155 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.
110 111 112 113 114 115 116 117 |
# File 'lib/stripe/resources/billing/meter.rb', line 110 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.
135 136 137 138 139 140 141 142 |
# File 'lib/stripe/resources/billing/meter.rb', line 135 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 |