Class: Stripe::Billing::MeterService

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

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.



15
16
17
18
19
20
21
22
23
# File 'lib/stripe/services/billing/meter_service.rb', line 15

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.



26
27
28
29
30
31
32
33
34
# File 'lib/stripe/services/billing/meter_service.rb', line 26

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.



37
38
39
40
41
42
43
44
45
# File 'lib/stripe/services/billing/meter_service.rb', line 37

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.



48
49
50
51
52
53
54
55
56
# File 'lib/stripe/services/billing/meter_service.rb', line 48

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.



59
60
61
62
63
64
65
66
67
# File 'lib/stripe/services/billing/meter_service.rb', line 59

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.



70
71
72
73
74
75
76
77
78
# File 'lib/stripe/services/billing/meter_service.rb', line 70

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