Class: Stripe::Billing::MeterService

Inherits:
StripeService show all
Defined in:
lib/stripe/services/billing/meter_service.rb

Defined Under Namespace

Classes: CreateParams, DeactivateParams, ListParams, ReactivateParams, RetrieveParams, UpdateParams

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from StripeService

#request, #request_stream

Constructor Details

#initialize(requestor) ⇒ MeterService

Returns a new instance of MeterService.



9
10
11
12
# File 'lib/stripe/services/billing/meter_service.rb', line 9

def initialize(requestor)
  super(requestor)
  @event_summaries = Stripe::Billing::MeterEventSummaryService.new(@requestor)
end

Instance Attribute Details

#event_summariesObject (readonly)

Returns the value of attribute event_summaries.



7
8
9
# File 'lib/stripe/services/billing/meter_service.rb', line 7

def event_summaries
  @event_summaries
end

Instance Method Details

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

Creates a billing meter.



145
146
147
148
149
150
151
152
153
# File 'lib/stripe/services/billing/meter_service.rb', line 145

def create(params = {}, opts = {})
  request(
    method: :post,
    path: "/v1/billing/meters",
    params: params,
    opts: opts,
    base_address: :api
  )
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.



156
157
158
159
160
161
162
163
164
# File 'lib/stripe/services/billing/meter_service.rb', line 156

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

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

Retrieve a list of billing meters.



167
168
169
170
171
172
173
174
175
# File 'lib/stripe/services/billing/meter_service.rb', line 167

def list(params = {}, opts = {})
  request(
    method: :get,
    path: "/v1/billing/meters",
    params: params,
    opts: opts,
    base_address: :api
  )
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.



178
179
180
181
182
183
184
185
186
# File 'lib/stripe/services/billing/meter_service.rb', line 178

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

#retrieve(id, params = {}, opts = {}) ⇒ Object

Retrieves a billing meter given an ID.



189
190
191
192
193
194
195
196
197
# File 'lib/stripe/services/billing/meter_service.rb', line 189

def retrieve(id, params = {}, opts = {})
  request(
    method: :get,
    path: format("/v1/billing/meters/%<id>s", { id: CGI.escape(id) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

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

Updates a billing meter.



200
201
202
203
204
205
206
207
208
# File 'lib/stripe/services/billing/meter_service.rb', line 200

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