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: CustomerMapping, DefaultAggregation, StatusTransitions, 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

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

#createdObject (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_mappingObject (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_aggregationObject (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_nameObject (readonly)

The meter’s name.



84
85
86
# File 'lib/stripe/resources/billing/meter.rb', line 84

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.



86
87
88
# File 'lib/stripe/resources/billing/meter.rb', line 86

def event_name
  @event_name
end

#event_time_windowObject (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

#idObject (readonly)

Unique identifier for the object.



90
91
92
# File 'lib/stripe/resources/billing/meter.rb', line 90

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.



92
93
94
# File 'lib/stripe/resources/billing/meter.rb', line 92

def livemode
  @livemode
end

#objectObject (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

#statusObject (readonly)

The meter’s status.



96
97
98
# File 'lib/stripe/resources/billing/meter.rb', line 96

def status
  @status
end

#status_transitionsObject (readonly)

Attribute for field status_transitions



98
99
100
# File 'lib/stripe/resources/billing/meter.rb', line 98

def status_transitions
  @status_transitions
end

#updatedObject (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_settingsObject (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_remappingsObject



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

def self.field_remappings
  @field_remappings = {}
end

.inner_class_typesObject



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_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.



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