Class: Stripe::Billing::AlertService

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from StripeService

#request, #request_stream

Constructor Details

#initialize(requestor) ⇒ AlertService

Returns a new instance of AlertService.



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

def initialize(requestor)
  super
  @notifications = Stripe::Billing::AlertNotificationService.new(@requestor)
end

Instance Attribute Details

#notificationsObject (readonly)

Returns the value of attribute notifications.



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

def notifications
  @notifications
end

Instance Method Details

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

Reactivates this alert, allowing it to trigger again.



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

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

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

Archives this alert, removing it from the list view and APIs. This is non-reversible.



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

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

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

Creates a billing alert



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

def create(params = {}, opts = {})
  params = ::Stripe::Billing::AlertCreateParams.coerce_params(params) unless params.is_a?(Stripe::RequestParams)

  request(
    method: :post,
    path: "/v1/billing/alerts",
    params: params,
    opts: opts,
    base_address: :api
  )
end

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

Deactivates this alert, preventing it from triggering.



50
51
52
53
54
55
56
57
58
# File 'lib/stripe/services/billing/alert_service.rb', line 50

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

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

Lists billing active and inactive alerts



61
62
63
64
65
66
67
68
69
# File 'lib/stripe/services/billing/alert_service.rb', line 61

def list(params = {}, opts = {})
  request(
    method: :get,
    path: "/v1/billing/alerts",
    params: params,
    opts: opts,
    base_address: :api
  )
end

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

Retrieves a billing alert given an ID



72
73
74
75
76
77
78
79
80
# File 'lib/stripe/services/billing/alert_service.rb', line 72

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