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.



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

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.



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

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.



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

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.



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

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.



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

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.



212
213
214
215
216
217
218
219
220
# File 'lib/stripe/services/billing/meter_service.rb', line 212

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