diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index b4113d3d..3be20c39 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v1137 \ No newline at end of file +v1152 \ No newline at end of file diff --git a/lib/stripe/object_types.rb b/lib/stripe/object_types.rb index 2059ac67..42862fd8 100644 --- a/lib/stripe/object_types.rb +++ b/lib/stripe/object_types.rb @@ -24,6 +24,7 @@ module Stripe Balance.object_name => Balance, BalanceTransaction.object_name => BalanceTransaction, BankAccount.object_name => BankAccount, + Billing::Alert.object_name => Billing::Alert, Billing::Meter.object_name => Billing::Meter, Billing::MeterEvent.object_name => Billing::MeterEvent, Billing::MeterEventAdjustment.object_name => Billing::MeterEventAdjustment, diff --git a/lib/stripe/resources.rb b/lib/stripe/resources.rb index cd0554a9..2e79673a 100644 --- a/lib/stripe/resources.rb +++ b/lib/stripe/resources.rb @@ -12,6 +12,7 @@ require "stripe/resources/apps/secret" require "stripe/resources/balance" require "stripe/resources/balance_transaction" require "stripe/resources/bank_account" +require "stripe/resources/billing/alert" require "stripe/resources/billing/meter" require "stripe/resources/billing/meter_event" require "stripe/resources/billing/meter_event_adjustment" diff --git a/lib/stripe/resources/billing/alert.rb b/lib/stripe/resources/billing/alert.rb new file mode 100644 index 00000000..90451eb8 --- /dev/null +++ b/lib/stripe/resources/billing/alert.rb @@ -0,0 +1,87 @@ +# File generated from our OpenAPI spec +# frozen_string_literal: true + +module Stripe + module Billing + # A billing alert is a resource that notifies you when a certain usage threshold on a meter is crossed. For example, you might create a billing alert to notify you when a certain user made 100 API requests. + class Alert < APIResource + extend Stripe::APIOperations::Create + extend Stripe::APIOperations::List + + OBJECT_NAME = "billing.alert" + def self.object_name + "billing.alert" + end + + # Reactivates this alert, allowing it to trigger again. + def activate(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/billing/alerts/%s/activate", { id: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + + # Reactivates this alert, allowing it to trigger again. + def self.activate(id, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/billing/alerts/%s/activate", { id: CGI.escape(id) }), + params: params, + opts: opts + ) + end + + # Archives this alert, removing it from the list view and APIs. This is non-reversible. + def archive(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/billing/alerts/%s/archive", { id: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + + # Archives this alert, removing it from the list view and APIs. This is non-reversible. + def self.archive(id, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/billing/alerts/%s/archive", { id: CGI.escape(id) }), + params: params, + opts: opts + ) + end + + # Creates a billing alert + def self.create(params = {}, opts = {}) + request_stripe_object(method: :post, path: "/v1/billing/alerts", params: params, opts: opts) + end + + # Deactivates this alert, preventing it from triggering. + def deactivate(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/billing/alerts/%s/deactivate", { id: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + + # Deactivates this alert, preventing it from triggering. + def self.deactivate(id, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/billing/alerts/%s/deactivate", { id: CGI.escape(id) }), + params: params, + opts: opts + ) + end + + # Lists billing active and inactive alerts + def self.list(filters = {}, opts = {}) + request_stripe_object(method: :get, path: "/v1/billing/alerts", params: filters, opts: opts) + end + end + end +end