mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-04 00:00:47 -04:00
updated generated and manually maintained code to move V2::Event, V2::EventDestination and V2::EventNotification to V2::Core, and UnknownEventNotification to Stripe::Events (#1677)
Co-authored-by: Jesse Rosalia <jar@stripe.com>
This commit is contained in:
parent
8330a2bfa5
commit
7ce6ec4092
@ -52,7 +52,7 @@ require "stripe/api_resource_test_helpers"
|
||||
require "stripe/singleton_api_resource"
|
||||
require "stripe/webhook"
|
||||
require "stripe/stripe_configuration"
|
||||
require "stripe/event_notification"
|
||||
require "stripe/resources/v2/core/event_notification"
|
||||
|
||||
# Named API resources
|
||||
require "stripe/resources"
|
||||
|
@ -1,72 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Stripe
|
||||
module V2
|
||||
class EventReasonRequest
|
||||
attr_reader :id, :idempotency_key
|
||||
|
||||
def initialize(event_reason_request_payload = {})
|
||||
@id = event_reason_request_payload[:id]
|
||||
@idempotency_key = event_reason_request_payload[:idempotency_key]
|
||||
end
|
||||
end
|
||||
|
||||
class EventReason
|
||||
attr_reader :type, :request
|
||||
|
||||
def initialize(event_reason_payload = {})
|
||||
@type = event_reason_payload[:type]
|
||||
@request = EventReasonRequest.new(event_reason_payload[:request])
|
||||
end
|
||||
end
|
||||
|
||||
class RelatedObject
|
||||
attr_reader :id, :type, :url
|
||||
|
||||
def initialize(related_object)
|
||||
@id = related_object[:id]
|
||||
@type = related_object[:type]
|
||||
@url = related_object[:url]
|
||||
end
|
||||
end
|
||||
|
||||
class EventNotification
|
||||
attr_reader :id, :type, :created, :context, :livemode, :reason
|
||||
|
||||
def initialize(event_payload, client)
|
||||
@id = event_payload[:id]
|
||||
@type = event_payload[:type]
|
||||
@created = event_payload[:created]
|
||||
@livemode = event_payload[:livemode]
|
||||
@reason = EventReason.new(event_payload[:reason]) if event_payload[:reason]
|
||||
if event_payload[:context] && !event_payload[:context].empty?
|
||||
@context = StripeContext.parse(event_payload[:context])
|
||||
end
|
||||
# private unless a child declares an attr_reader
|
||||
@related_object = RelatedObject.new(event_payload[:related_object]) if event_payload[:related_object]
|
||||
|
||||
# internal use
|
||||
@client = client
|
||||
end
|
||||
|
||||
# Retrieves the Event that generated this EventNotification.
|
||||
def fetch_event
|
||||
resp = @client.raw_request(:get, "/v2/core/events/#{id}", opts: { stripe_context: context },
|
||||
usage: ["fetch_event"])
|
||||
@client.deserialize(resp.http_body, api_mode: :v2)
|
||||
end
|
||||
end
|
||||
|
||||
class UnknownEventNotification < EventNotification
|
||||
attr_reader :related_object
|
||||
|
||||
def fetch_related_object
|
||||
return nil if @related_object.nil?
|
||||
|
||||
resp = @client.raw_request(:get, related_object.url, opts: { stripe_context: context },
|
||||
usage: ["fetch_related_object"])
|
||||
@client.deserialize(resp.http_body, api_mode: Util.get_api_mode(related_object.url))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
19
lib/stripe/events/unknown_event_notification.rb
Normal file
19
lib/stripe/events/unknown_event_notification.rb
Normal file
@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "stripe/resources/v2/core/event_notification"
|
||||
|
||||
module Stripe
|
||||
module Events
|
||||
class UnknownEventNotification < Stripe::V2::Core::EventNotification
|
||||
attr_reader :related_object
|
||||
|
||||
def fetch_related_object
|
||||
return nil if @related_object.nil?
|
||||
|
||||
resp = @client.raw_request(:get, related_object.url, opts: { stripe_context: context },
|
||||
usage: ["fetch_related_object"])
|
||||
@client.deserialize(resp.http_body, api_mode: Util.get_api_mode(related_object.url))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -4,7 +4,7 @@
|
||||
module Stripe
|
||||
module Events
|
||||
# Occurs when a Meter has invalid async usage events.
|
||||
class V1BillingMeterErrorReportTriggeredEvent < Stripe::V2::Event
|
||||
class V1BillingMeterErrorReportTriggeredEvent < Stripe::V2::Core::Event
|
||||
def self.lookup_type
|
||||
"v1.billing.meter.error_report_triggered"
|
||||
end
|
||||
@ -101,7 +101,7 @@ module Stripe
|
||||
end
|
||||
|
||||
# Occurs when a Meter has invalid async usage events.
|
||||
class V1BillingMeterErrorReportTriggeredEventNotification < Stripe::V2::EventNotification
|
||||
class V1BillingMeterErrorReportTriggeredEventNotification < Stripe::V2::Core::EventNotification
|
||||
def self.lookup_type
|
||||
"v1.billing.meter.error_report_triggered"
|
||||
end
|
||||
|
@ -4,7 +4,7 @@
|
||||
module Stripe
|
||||
module Events
|
||||
# Occurs when a Meter's id is missing or invalid in async usage events.
|
||||
class V1BillingMeterNoMeterFoundEvent < Stripe::V2::Event
|
||||
class V1BillingMeterNoMeterFoundEvent < Stripe::V2::Core::Event
|
||||
def self.lookup_type
|
||||
"v1.billing.meter.no_meter_found"
|
||||
end
|
||||
@ -91,7 +91,7 @@ module Stripe
|
||||
end
|
||||
|
||||
# Occurs when a Meter's id is missing or invalid in async usage events.
|
||||
class V1BillingMeterNoMeterFoundEventNotification < Stripe::V2::EventNotification
|
||||
class V1BillingMeterNoMeterFoundEventNotification < Stripe::V2::Core::EventNotification
|
||||
def self.lookup_type
|
||||
"v1.billing.meter.no_meter_found"
|
||||
end
|
||||
|
@ -4,7 +4,7 @@
|
||||
module Stripe
|
||||
module Events
|
||||
# A ping event used to test the connection to an EventDestination.
|
||||
class V2CoreEventDestinationPingEvent < Stripe::V2::Event
|
||||
class V2CoreEventDestinationPingEvent < Stripe::V2::Core::Event
|
||||
def self.lookup_type
|
||||
"v2.core.event_destination.ping"
|
||||
end
|
||||
@ -22,7 +22,7 @@ module Stripe
|
||||
end
|
||||
|
||||
# A ping event used to test the connection to an EventDestination.
|
||||
class V2CoreEventDestinationPingEventNotification < Stripe::V2::EventNotification
|
||||
class V2CoreEventDestinationPingEventNotification < Stripe::V2::Core::EventNotification
|
||||
def self.lookup_type
|
||||
"v2.core.event_destination.ping"
|
||||
end
|
||||
|
@ -162,8 +162,8 @@ module Stripe
|
||||
V2::Billing::MeterEvent.object_name => V2::Billing::MeterEvent,
|
||||
V2::Billing::MeterEventAdjustment.object_name => V2::Billing::MeterEventAdjustment,
|
||||
V2::Billing::MeterEventSession.object_name => V2::Billing::MeterEventSession,
|
||||
V2::Event.object_name => V2::Event,
|
||||
V2::EventDestination.object_name => V2::EventDestination,
|
||||
V2::Core::Event.object_name => V2::Core::Event,
|
||||
V2::Core::EventDestination.object_name => V2::Core::EventDestination,
|
||||
# v2 object classes: The end of the section generated from our OpenAPI spec
|
||||
}
|
||||
end
|
||||
|
@ -141,9 +141,9 @@ require "stripe/resources/treasury/transaction_entry"
|
||||
require "stripe/resources/v2/billing/meter_event"
|
||||
require "stripe/resources/v2/billing/meter_event_adjustment"
|
||||
require "stripe/resources/v2/billing/meter_event_session"
|
||||
require "stripe/resources/v2/core/event"
|
||||
require "stripe/resources/v2/core/event_destination"
|
||||
require "stripe/resources/v2/deleted_object"
|
||||
require "stripe/resources/v2/event"
|
||||
require "stripe/resources/v2/event_destination"
|
||||
require "stripe/resources/webhook_endpoint"
|
||||
require "stripe/events/v1_billing_meter_error_report_triggered_event"
|
||||
require "stripe/events/v1_billing_meter_no_meter_found_event"
|
||||
|
67
lib/stripe/resources/v2/core/event.rb
Normal file
67
lib/stripe/resources/v2/core/event.rb
Normal file
@ -0,0 +1,67 @@
|
||||
# File generated from our OpenAPI spec
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Stripe
|
||||
module V2
|
||||
module Core
|
||||
# Events are generated to keep you informed of activity in your business account. APIs in the /v2 namespace generate [thin events](https://docs.stripe.com/event-destinations#benefits-of-thin-events) which have small, unversioned payloads that include a reference to the ID of the object that has changed. The Events v2 API returns these new thin events. [Retrieve the event object](https://docs.stripe.com/event-destinations#fetch-data) for additional data about the event. Use the related object ID in the event payload to [fetch the API resource](https://docs.stripe.com/event-destinations#retrieve-the-object-associated-with-thin-events) of the object associated with the event. Comparatively, events generated by most API v1 include a versioned snapshot of an API object in their payload.
|
||||
class Event < APIResource
|
||||
OBJECT_NAME = "v2.core.event"
|
||||
def self.object_name
|
||||
"v2.core.event"
|
||||
end
|
||||
|
||||
class Reason < Stripe::StripeObject
|
||||
class Request < Stripe::StripeObject
|
||||
# ID of the API request that caused the event.
|
||||
attr_reader :id
|
||||
# The idempotency key transmitted during the request.
|
||||
attr_reader :idempotency_key
|
||||
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
# Event reason type.
|
||||
attr_reader :type
|
||||
# Information on the API request that instigated the event.
|
||||
attr_reader :request
|
||||
|
||||
def self.inner_class_types
|
||||
@inner_class_types = { request: Request }
|
||||
end
|
||||
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
# Authentication context needed to fetch the event or related object.
|
||||
attr_reader :context
|
||||
# Time at which the object was created.
|
||||
attr_reader :created
|
||||
# Unique identifier for the event.
|
||||
attr_reader :id
|
||||
# String representing the object's type. Objects of the same type share the same value of the object field.
|
||||
attr_reader :object
|
||||
# Reason for the event.
|
||||
attr_reader :reason
|
||||
# The type of the event.
|
||||
attr_reader :type
|
||||
# Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
|
||||
attr_reader :livemode
|
||||
|
||||
def self.inner_class_types
|
||||
@inner_class_types = { reason: Reason }
|
||||
end
|
||||
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
119
lib/stripe/resources/v2/core/event_destination.rb
Normal file
119
lib/stripe/resources/v2/core/event_destination.rb
Normal file
@ -0,0 +1,119 @@
|
||||
# File generated from our OpenAPI spec
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Stripe
|
||||
module V2
|
||||
module Core
|
||||
# Set up an event destination to receive events from Stripe across multiple destination types, including [webhook endpoints](https://docs.stripe.com/webhooks) and [Amazon EventBridge](https://docs.stripe.com/event-destinations/eventbridge). Event destinations support receiving [thin events](https://docs.stripe.com/api/v2/events) and [snapshot events](https://docs.stripe.com/api/events).
|
||||
class EventDestination < APIResource
|
||||
OBJECT_NAME = "v2.core.event_destination"
|
||||
def self.object_name
|
||||
"v2.core.event_destination"
|
||||
end
|
||||
|
||||
class StatusDetails < Stripe::StripeObject
|
||||
class Disabled < Stripe::StripeObject
|
||||
# Reason event destination has been disabled.
|
||||
attr_reader :reason
|
||||
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
# Details about why the event destination has been disabled.
|
||||
attr_reader :disabled
|
||||
|
||||
def self.inner_class_types
|
||||
@inner_class_types = { disabled: Disabled }
|
||||
end
|
||||
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
|
||||
class AmazonEventbridge < Stripe::StripeObject
|
||||
# The AWS account ID.
|
||||
attr_reader :aws_account_id
|
||||
# The ARN of the AWS event source.
|
||||
attr_reader :aws_event_source_arn
|
||||
# The state of the AWS event source.
|
||||
attr_reader :aws_event_source_status
|
||||
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
|
||||
class WebhookEndpoint < Stripe::StripeObject
|
||||
# The signing secret of the webhook endpoint, only includable on creation.
|
||||
attr_reader :signing_secret
|
||||
# The URL of the webhook endpoint, includable.
|
||||
attr_reader :url
|
||||
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
# Time at which the object was created.
|
||||
attr_reader :created
|
||||
# An optional description of what the event destination is used for.
|
||||
attr_reader :description
|
||||
# The list of events to enable for this endpoint.
|
||||
attr_reader :enabled_events
|
||||
# Payload type of events being subscribed to.
|
||||
attr_reader :event_payload
|
||||
# Where events should be routed from.
|
||||
attr_reader :events_from
|
||||
# Unique identifier for the object.
|
||||
attr_reader :id
|
||||
# Metadata.
|
||||
attr_reader :metadata
|
||||
# Event destination name.
|
||||
attr_reader :name
|
||||
# String representing the object's type. Objects of the same type share the same value of the object field.
|
||||
attr_reader :object
|
||||
# If using the snapshot event payload, the API version events are rendered as.
|
||||
attr_reader :snapshot_api_version
|
||||
# Status. It can be set to either enabled or disabled.
|
||||
attr_reader :status
|
||||
# Additional information about event destination status.
|
||||
attr_reader :status_details
|
||||
# Event destination type.
|
||||
attr_reader :type
|
||||
# Time at which the object was last updated.
|
||||
attr_reader :updated
|
||||
# Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
|
||||
attr_reader :livemode
|
||||
# Amazon EventBridge configuration.
|
||||
attr_reader :amazon_eventbridge
|
||||
# Webhook endpoint configuration.
|
||||
attr_reader :webhook_endpoint
|
||||
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {
|
||||
status_details: StatusDetails,
|
||||
amazon_eventbridge: AmazonEventbridge,
|
||||
webhook_endpoint: WebhookEndpoint,
|
||||
}
|
||||
end
|
||||
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
62
lib/stripe/resources/v2/core/event_notification.rb
Normal file
62
lib/stripe/resources/v2/core/event_notification.rb
Normal file
@ -0,0 +1,62 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Stripe
|
||||
module V2
|
||||
module Core
|
||||
class EventReasonRequest
|
||||
attr_reader :id, :idempotency_key
|
||||
|
||||
def initialize(event_reason_request_payload = {})
|
||||
@id = event_reason_request_payload[:id]
|
||||
@idempotency_key = event_reason_request_payload[:idempotency_key]
|
||||
end
|
||||
end
|
||||
|
||||
class EventReason
|
||||
attr_reader :type, :request
|
||||
|
||||
def initialize(event_reason_payload = {})
|
||||
@type = event_reason_payload[:type]
|
||||
@request = EventReasonRequest.new(event_reason_payload[:request])
|
||||
end
|
||||
end
|
||||
|
||||
class RelatedObject
|
||||
attr_reader :id, :type, :url
|
||||
|
||||
def initialize(related_object)
|
||||
@id = related_object[:id]
|
||||
@type = related_object[:type]
|
||||
@url = related_object[:url]
|
||||
end
|
||||
end
|
||||
|
||||
class EventNotification
|
||||
attr_reader :id, :type, :created, :context, :livemode, :reason
|
||||
|
||||
def initialize(event_payload, client)
|
||||
@id = event_payload[:id]
|
||||
@type = event_payload[:type]
|
||||
@created = event_payload[:created]
|
||||
@livemode = event_payload[:livemode]
|
||||
@reason = EventReason.new(event_payload[:reason]) if event_payload[:reason]
|
||||
if event_payload[:context] && !event_payload[:context].empty?
|
||||
@context = StripeContext.parse(event_payload[:context])
|
||||
end
|
||||
# private unless a child declares an attr_reader
|
||||
@related_object = RelatedObject.new(event_payload[:related_object]) if event_payload[:related_object]
|
||||
|
||||
# internal use
|
||||
@client = client
|
||||
end
|
||||
|
||||
# Retrieves the Event that generated this EventNotification.
|
||||
def fetch_event
|
||||
resp = @client.raw_request(:get, "/v2/core/events/#{id}", opts: { stripe_context: context },
|
||||
usage: ["fetch_event"])
|
||||
@client.deserialize(resp.http_body, api_mode: :v2)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,65 +0,0 @@
|
||||
# File generated from our OpenAPI spec
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Stripe
|
||||
module V2
|
||||
# Events are generated to keep you informed of activity in your business account. APIs in the /v2 namespace generate [thin events](https://docs.stripe.com/event-destinations#benefits-of-thin-events) which have small, unversioned payloads that include a reference to the ID of the object that has changed. The Events v2 API returns these new thin events. [Retrieve the event object](https://docs.stripe.com/event-destinations#fetch-data) for additional data about the event. Use the related object ID in the event payload to [fetch the API resource](https://docs.stripe.com/event-destinations#retrieve-the-object-associated-with-thin-events) of the object associated with the event. Comparatively, events generated by most API v1 include a versioned snapshot of an API object in their payload.
|
||||
class Event < APIResource
|
||||
OBJECT_NAME = "v2.core.event"
|
||||
def self.object_name
|
||||
"v2.core.event"
|
||||
end
|
||||
|
||||
class Reason < Stripe::StripeObject
|
||||
class Request < Stripe::StripeObject
|
||||
# ID of the API request that caused the event.
|
||||
attr_reader :id
|
||||
# The idempotency key transmitted during the request.
|
||||
attr_reader :idempotency_key
|
||||
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
# Event reason type.
|
||||
attr_reader :type
|
||||
# Information on the API request that instigated the event.
|
||||
attr_reader :request
|
||||
|
||||
def self.inner_class_types
|
||||
@inner_class_types = { request: Request }
|
||||
end
|
||||
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
# Authentication context needed to fetch the event or related object.
|
||||
attr_reader :context
|
||||
# Time at which the object was created.
|
||||
attr_reader :created
|
||||
# Unique identifier for the event.
|
||||
attr_reader :id
|
||||
# String representing the object's type. Objects of the same type share the same value of the object field.
|
||||
attr_reader :object
|
||||
# Reason for the event.
|
||||
attr_reader :reason
|
||||
# The type of the event.
|
||||
attr_reader :type
|
||||
# Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
|
||||
attr_reader :livemode
|
||||
|
||||
def self.inner_class_types
|
||||
@inner_class_types = { reason: Reason }
|
||||
end
|
||||
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,117 +0,0 @@
|
||||
# File generated from our OpenAPI spec
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Stripe
|
||||
module V2
|
||||
# Set up an event destination to receive events from Stripe across multiple destination types, including [webhook endpoints](https://docs.stripe.com/webhooks) and [Amazon EventBridge](https://docs.stripe.com/event-destinations/eventbridge). Event destinations support receiving [thin events](https://docs.stripe.com/api/v2/events) and [snapshot events](https://docs.stripe.com/api/events).
|
||||
class EventDestination < APIResource
|
||||
OBJECT_NAME = "v2.core.event_destination"
|
||||
def self.object_name
|
||||
"v2.core.event_destination"
|
||||
end
|
||||
|
||||
class StatusDetails < Stripe::StripeObject
|
||||
class Disabled < Stripe::StripeObject
|
||||
# Reason event destination has been disabled.
|
||||
attr_reader :reason
|
||||
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
# Details about why the event destination has been disabled.
|
||||
attr_reader :disabled
|
||||
|
||||
def self.inner_class_types
|
||||
@inner_class_types = { disabled: Disabled }
|
||||
end
|
||||
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
|
||||
class AmazonEventbridge < Stripe::StripeObject
|
||||
# The AWS account ID.
|
||||
attr_reader :aws_account_id
|
||||
# The ARN of the AWS event source.
|
||||
attr_reader :aws_event_source_arn
|
||||
# The state of the AWS event source.
|
||||
attr_reader :aws_event_source_status
|
||||
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
|
||||
class WebhookEndpoint < Stripe::StripeObject
|
||||
# The signing secret of the webhook endpoint, only includable on creation.
|
||||
attr_reader :signing_secret
|
||||
# The URL of the webhook endpoint, includable.
|
||||
attr_reader :url
|
||||
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
# Time at which the object was created.
|
||||
attr_reader :created
|
||||
# An optional description of what the event destination is used for.
|
||||
attr_reader :description
|
||||
# The list of events to enable for this endpoint.
|
||||
attr_reader :enabled_events
|
||||
# Payload type of events being subscribed to.
|
||||
attr_reader :event_payload
|
||||
# Where events should be routed from.
|
||||
attr_reader :events_from
|
||||
# Unique identifier for the object.
|
||||
attr_reader :id
|
||||
# Metadata.
|
||||
attr_reader :metadata
|
||||
# Event destination name.
|
||||
attr_reader :name
|
||||
# String representing the object's type. Objects of the same type share the same value of the object field.
|
||||
attr_reader :object
|
||||
# If using the snapshot event payload, the API version events are rendered as.
|
||||
attr_reader :snapshot_api_version
|
||||
# Status. It can be set to either enabled or disabled.
|
||||
attr_reader :status
|
||||
# Additional information about event destination status.
|
||||
attr_reader :status_details
|
||||
# Event destination type.
|
||||
attr_reader :type
|
||||
# Time at which the object was last updated.
|
||||
attr_reader :updated
|
||||
# Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
|
||||
attr_reader :livemode
|
||||
# Amazon EventBridge configuration.
|
||||
attr_reader :amazon_eventbridge
|
||||
# Webhook endpoint configuration.
|
||||
attr_reader :webhook_endpoint
|
||||
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {
|
||||
status_details: StatusDetails,
|
||||
amazon_eventbridge: AmazonEventbridge,
|
||||
webhook_endpoint: WebhookEndpoint,
|
||||
}
|
||||
end
|
||||
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,6 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "json"
|
||||
require "stripe/events/unknown_event_notification"
|
||||
|
||||
module Stripe
|
||||
class StripeClient
|
||||
@ -67,7 +68,7 @@ module Stripe
|
||||
|
||||
parsed = JSON.parse(payload, symbolize_names: true)
|
||||
|
||||
cls = Util.event_notification_classes.fetch(parsed[:type], Stripe::V2::UnknownEventNotification)
|
||||
cls = Util.event_notification_classes.fetch(parsed[:type], Stripe::Events::UnknownEventNotification)
|
||||
|
||||
cls.new(parsed, self)
|
||||
end
|
||||
|
284
rbi/stripe.rbi
284
rbi/stripe.rbi
@ -118643,13 +118643,41 @@ end
|
||||
# typed: true
|
||||
module Stripe
|
||||
module V2
|
||||
# Set up an event destination to receive events from Stripe across multiple destination types, including [webhook endpoints](https://docs.stripe.com/webhooks) and [Amazon EventBridge](https://docs.stripe.com/event-destinations/eventbridge). Event destinations support receiving [thin events](https://docs.stripe.com/api/v2/events) and [snapshot events](https://docs.stripe.com/api/events).
|
||||
class EventDestination < APIResource
|
||||
class StatusDetails < Stripe::StripeObject
|
||||
class Disabled < Stripe::StripeObject
|
||||
# Reason event destination has been disabled.
|
||||
module Core
|
||||
# Set up an event destination to receive events from Stripe across multiple destination types, including [webhook endpoints](https://docs.stripe.com/webhooks) and [Amazon EventBridge](https://docs.stripe.com/event-destinations/eventbridge). Event destinations support receiving [thin events](https://docs.stripe.com/api/v2/events) and [snapshot events](https://docs.stripe.com/api/events).
|
||||
class EventDestination < APIResource
|
||||
class StatusDetails < Stripe::StripeObject
|
||||
class Disabled < Stripe::StripeObject
|
||||
# Reason event destination has been disabled.
|
||||
sig { returns(String) }
|
||||
def reason; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
# Details about why the event destination has been disabled.
|
||||
sig { returns(T.nilable(Disabled)) }
|
||||
def disabled; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {disabled: Disabled}
|
||||
end
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
class AmazonEventbridge < Stripe::StripeObject
|
||||
# The AWS account ID.
|
||||
sig { returns(String) }
|
||||
def reason; end
|
||||
def aws_account_id; end
|
||||
# The ARN of the AWS event source.
|
||||
sig { returns(String) }
|
||||
def aws_event_source_arn; end
|
||||
# The state of the AWS event source.
|
||||
sig { returns(String) }
|
||||
def aws_event_source_status; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
@ -118657,155 +118685,131 @@ module Stripe
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
# Details about why the event destination has been disabled.
|
||||
sig { returns(T.nilable(Disabled)) }
|
||||
def disabled; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {disabled: Disabled}
|
||||
class WebhookEndpoint < Stripe::StripeObject
|
||||
# The signing secret of the webhook endpoint, only includable on creation.
|
||||
sig { returns(T.nilable(String)) }
|
||||
def signing_secret; end
|
||||
# The URL of the webhook endpoint, includable.
|
||||
sig { returns(T.nilable(String)) }
|
||||
def url; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
class AmazonEventbridge < Stripe::StripeObject
|
||||
# The AWS account ID.
|
||||
# Time at which the object was created.
|
||||
sig { returns(String) }
|
||||
def aws_account_id; end
|
||||
# The ARN of the AWS event source.
|
||||
def created; end
|
||||
# An optional description of what the event destination is used for.
|
||||
sig { returns(String) }
|
||||
def aws_event_source_arn; end
|
||||
# The state of the AWS event source.
|
||||
def description; end
|
||||
# The list of events to enable for this endpoint.
|
||||
sig { returns(T::Array[String]) }
|
||||
def enabled_events; end
|
||||
# Payload type of events being subscribed to.
|
||||
sig { returns(String) }
|
||||
def aws_event_source_status; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
class WebhookEndpoint < Stripe::StripeObject
|
||||
# The signing secret of the webhook endpoint, only includable on creation.
|
||||
def event_payload; end
|
||||
# Where events should be routed from.
|
||||
sig { returns(T.nilable(T::Array[String])) }
|
||||
def events_from; end
|
||||
# Unique identifier for the object.
|
||||
sig { returns(String) }
|
||||
def id; end
|
||||
# Metadata.
|
||||
sig { returns(T.nilable(T::Hash[String, String])) }
|
||||
def metadata; end
|
||||
# Event destination name.
|
||||
sig { returns(String) }
|
||||
def name; end
|
||||
# String representing the object's type. Objects of the same type share the same value of the object field.
|
||||
sig { returns(String) }
|
||||
def object; end
|
||||
# If using the snapshot event payload, the API version events are rendered as.
|
||||
sig { returns(T.nilable(String)) }
|
||||
def signing_secret; end
|
||||
# The URL of the webhook endpoint, includable.
|
||||
sig { returns(T.nilable(String)) }
|
||||
def url; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
def snapshot_api_version; end
|
||||
# Status. It can be set to either enabled or disabled.
|
||||
sig { returns(String) }
|
||||
def status; end
|
||||
# Additional information about event destination status.
|
||||
sig { returns(T.nilable(StatusDetails)) }
|
||||
def status_details; end
|
||||
# Event destination type.
|
||||
sig { returns(String) }
|
||||
def type; end
|
||||
# Time at which the object was last updated.
|
||||
sig { returns(String) }
|
||||
def updated; end
|
||||
# Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
|
||||
sig { returns(T::Boolean) }
|
||||
def livemode; end
|
||||
# Amazon EventBridge configuration.
|
||||
sig { returns(T.nilable(AmazonEventbridge)) }
|
||||
def amazon_eventbridge; end
|
||||
# Webhook endpoint configuration.
|
||||
sig { returns(T.nilable(WebhookEndpoint)) }
|
||||
def webhook_endpoint; end
|
||||
end
|
||||
# Time at which the object was created.
|
||||
sig { returns(String) }
|
||||
def created; end
|
||||
# An optional description of what the event destination is used for.
|
||||
sig { returns(String) }
|
||||
def description; end
|
||||
# The list of events to enable for this endpoint.
|
||||
sig { returns(T::Array[String]) }
|
||||
def enabled_events; end
|
||||
# Payload type of events being subscribed to.
|
||||
sig { returns(String) }
|
||||
def event_payload; end
|
||||
# Where events should be routed from.
|
||||
sig { returns(T.nilable(T::Array[String])) }
|
||||
def events_from; end
|
||||
# Unique identifier for the object.
|
||||
sig { returns(String) }
|
||||
def id; end
|
||||
# Metadata.
|
||||
sig { returns(T.nilable(T::Hash[String, String])) }
|
||||
def metadata; end
|
||||
# Event destination name.
|
||||
sig { returns(String) }
|
||||
def name; end
|
||||
# String representing the object's type. Objects of the same type share the same value of the object field.
|
||||
sig { returns(String) }
|
||||
def object; end
|
||||
# If using the snapshot event payload, the API version events are rendered as.
|
||||
sig { returns(T.nilable(String)) }
|
||||
def snapshot_api_version; end
|
||||
# Status. It can be set to either enabled or disabled.
|
||||
sig { returns(String) }
|
||||
def status; end
|
||||
# Additional information about event destination status.
|
||||
sig { returns(T.nilable(StatusDetails)) }
|
||||
def status_details; end
|
||||
# Event destination type.
|
||||
sig { returns(String) }
|
||||
def type; end
|
||||
# Time at which the object was last updated.
|
||||
sig { returns(String) }
|
||||
def updated; end
|
||||
# Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
|
||||
sig { returns(T::Boolean) }
|
||||
def livemode; end
|
||||
# Amazon EventBridge configuration.
|
||||
sig { returns(T.nilable(AmazonEventbridge)) }
|
||||
def amazon_eventbridge; end
|
||||
# Webhook endpoint configuration.
|
||||
sig { returns(T.nilable(WebhookEndpoint)) }
|
||||
def webhook_endpoint; end
|
||||
end
|
||||
end
|
||||
end
|
||||
# typed: true
|
||||
module Stripe
|
||||
module V2
|
||||
# Events are generated to keep you informed of activity in your business account. APIs in the /v2 namespace generate [thin events](https://docs.stripe.com/event-destinations#benefits-of-thin-events) which have small, unversioned payloads that include a reference to the ID of the object that has changed. The Events v2 API returns these new thin events. [Retrieve the event object](https://docs.stripe.com/event-destinations#fetch-data) for additional data about the event. Use the related object ID in the event payload to [fetch the API resource](https://docs.stripe.com/event-destinations#retrieve-the-object-associated-with-thin-events) of the object associated with the event. Comparatively, events generated by most API v1 include a versioned snapshot of an API object in their payload.
|
||||
class Event < APIResource
|
||||
class Reason < Stripe::StripeObject
|
||||
class Request < Stripe::StripeObject
|
||||
# ID of the API request that caused the event.
|
||||
module Core
|
||||
# Events are generated to keep you informed of activity in your business account. APIs in the /v2 namespace generate [thin events](https://docs.stripe.com/event-destinations#benefits-of-thin-events) which have small, unversioned payloads that include a reference to the ID of the object that has changed. The Events v2 API returns these new thin events. [Retrieve the event object](https://docs.stripe.com/event-destinations#fetch-data) for additional data about the event. Use the related object ID in the event payload to [fetch the API resource](https://docs.stripe.com/event-destinations#retrieve-the-object-associated-with-thin-events) of the object associated with the event. Comparatively, events generated by most API v1 include a versioned snapshot of an API object in their payload.
|
||||
class Event < APIResource
|
||||
class Reason < Stripe::StripeObject
|
||||
class Request < Stripe::StripeObject
|
||||
# ID of the API request that caused the event.
|
||||
sig { returns(String) }
|
||||
def id; end
|
||||
# The idempotency key transmitted during the request.
|
||||
sig { returns(String) }
|
||||
def idempotency_key; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
# Event reason type.
|
||||
sig { returns(String) }
|
||||
def id; end
|
||||
# The idempotency key transmitted during the request.
|
||||
sig { returns(String) }
|
||||
def idempotency_key; end
|
||||
def type; end
|
||||
# Information on the API request that instigated the event.
|
||||
sig { returns(T.nilable(Request)) }
|
||||
def request; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
@inner_class_types = {request: Request}
|
||||
end
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
# Event reason type.
|
||||
# Authentication context needed to fetch the event or related object.
|
||||
sig { returns(T.nilable(String)) }
|
||||
def context; end
|
||||
# Time at which the object was created.
|
||||
sig { returns(String) }
|
||||
def created; end
|
||||
# Unique identifier for the event.
|
||||
sig { returns(String) }
|
||||
def id; end
|
||||
# String representing the object's type. Objects of the same type share the same value of the object field.
|
||||
sig { returns(String) }
|
||||
def object; end
|
||||
# Reason for the event.
|
||||
sig { returns(T.nilable(Reason)) }
|
||||
def reason; end
|
||||
# The type of the event.
|
||||
sig { returns(String) }
|
||||
def type; end
|
||||
# Information on the API request that instigated the event.
|
||||
sig { returns(T.nilable(Request)) }
|
||||
def request; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {request: Request}
|
||||
end
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
# Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
|
||||
sig { returns(T::Boolean) }
|
||||
def livemode; end
|
||||
end
|
||||
# Authentication context needed to fetch the event or related object.
|
||||
sig { returns(T.nilable(String)) }
|
||||
def context; end
|
||||
# Time at which the object was created.
|
||||
sig { returns(String) }
|
||||
def created; end
|
||||
# Unique identifier for the event.
|
||||
sig { returns(String) }
|
||||
def id; end
|
||||
# String representing the object's type. Objects of the same type share the same value of the object field.
|
||||
sig { returns(String) }
|
||||
def object; end
|
||||
# Reason for the event.
|
||||
sig { returns(T.nilable(Reason)) }
|
||||
def reason; end
|
||||
# The type of the event.
|
||||
sig { returns(String) }
|
||||
def type; end
|
||||
# Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
|
||||
sig { returns(T::Boolean) }
|
||||
def livemode; end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -204402,7 +204406,7 @@ module Stripe
|
||||
|
||||
# Retrieves the details of an event.
|
||||
sig {
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventService::RetrieveParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::Event)
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventService::RetrieveParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::Core::Event)
|
||||
}
|
||||
def retrieve(id, params = {}, opts = {}); end
|
||||
end
|
||||
@ -204611,7 +204615,7 @@ module Stripe
|
||||
class PingParams < Stripe::RequestParams; end
|
||||
# Create a new event destination.
|
||||
sig {
|
||||
params(params: T.any(::Stripe::V2::Core::EventDestinationService::CreateParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::EventDestination)
|
||||
params(params: T.any(::Stripe::V2::Core::EventDestinationService::CreateParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::Core::EventDestination)
|
||||
}
|
||||
def create(params = {}, opts = {}); end
|
||||
|
||||
@ -204623,13 +204627,13 @@ module Stripe
|
||||
|
||||
# Disable an event destination.
|
||||
sig {
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::DisableParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::EventDestination)
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::DisableParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::Core::EventDestination)
|
||||
}
|
||||
def disable(id, params = {}, opts = {}); end
|
||||
|
||||
# Enable an event destination.
|
||||
sig {
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::EnableParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::EventDestination)
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::EnableParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::Core::EventDestination)
|
||||
}
|
||||
def enable(id, params = {}, opts = {}); end
|
||||
|
||||
@ -204641,19 +204645,19 @@ module Stripe
|
||||
|
||||
# Send a `ping` event to an event destination.
|
||||
sig {
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::PingParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::Event)
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::PingParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::Core::Event)
|
||||
}
|
||||
def ping(id, params = {}, opts = {}); end
|
||||
|
||||
# Retrieves the details of an event destination.
|
||||
sig {
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::RetrieveParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::EventDestination)
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::RetrieveParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::Core::EventDestination)
|
||||
}
|
||||
def retrieve(id, params = {}, opts = {}); end
|
||||
|
||||
# Update the details of an event destination.
|
||||
sig {
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::UpdateParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::EventDestination)
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::UpdateParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::Core::EventDestination)
|
||||
}
|
||||
def update(id, params = {}, opts = {}); end
|
||||
end
|
||||
|
@ -1,41 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
# typed: true
|
||||
|
||||
module Stripe
|
||||
module V2
|
||||
class EventReasonRequest
|
||||
sig { returns(String) }
|
||||
def id; end
|
||||
sig { returns(String) }
|
||||
def idempotency_key; end
|
||||
|
||||
sig { params(event_reason_request_payload: T::Hash[T.untyped, T.untyped]).void }
|
||||
def initialize(event_reason_request_payload = {}); end
|
||||
end
|
||||
|
||||
class EventReason
|
||||
sig { returns(String) }
|
||||
def type; end
|
||||
sig { returns(::Stripe::V2::EventReasonRequest) }
|
||||
def request; end
|
||||
|
||||
sig { params(event_reason_payload: T::Hash[T.untyped, T.untyped]).void }
|
||||
def initialize(event_reason_payload = {}); end
|
||||
end
|
||||
|
||||
class EventNotification
|
||||
sig { returns(String) }
|
||||
def id; end
|
||||
sig { returns(String) }
|
||||
def type; end
|
||||
sig { returns(String) }
|
||||
def created; end
|
||||
sig { returns(T.nilable(String)) }
|
||||
def context; end
|
||||
sig { returns(T::Boolean) }
|
||||
def livemode; end
|
||||
sig { returns(T.nilable(::Stripe::V2::EventReason)) }
|
||||
def reason; end
|
||||
end
|
||||
end
|
||||
end
|
62
rbi/stripe/resources/v2/core/event.rbi
Normal file
62
rbi/stripe/resources/v2/core/event.rbi
Normal file
@ -0,0 +1,62 @@
|
||||
# File generated from our OpenAPI spec
|
||||
# frozen_string_literal: true
|
||||
|
||||
# typed: true
|
||||
module Stripe
|
||||
module V2
|
||||
module Core
|
||||
# Events are generated to keep you informed of activity in your business account. APIs in the /v2 namespace generate [thin events](https://docs.stripe.com/event-destinations#benefits-of-thin-events) which have small, unversioned payloads that include a reference to the ID of the object that has changed. The Events v2 API returns these new thin events. [Retrieve the event object](https://docs.stripe.com/event-destinations#fetch-data) for additional data about the event. Use the related object ID in the event payload to [fetch the API resource](https://docs.stripe.com/event-destinations#retrieve-the-object-associated-with-thin-events) of the object associated with the event. Comparatively, events generated by most API v1 include a versioned snapshot of an API object in their payload.
|
||||
class Event < APIResource
|
||||
class Reason < Stripe::StripeObject
|
||||
class Request < Stripe::StripeObject
|
||||
# ID of the API request that caused the event.
|
||||
sig { returns(String) }
|
||||
def id; end
|
||||
# The idempotency key transmitted during the request.
|
||||
sig { returns(String) }
|
||||
def idempotency_key; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
# Event reason type.
|
||||
sig { returns(String) }
|
||||
def type; end
|
||||
# Information on the API request that instigated the event.
|
||||
sig { returns(T.nilable(Request)) }
|
||||
def request; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {request: Request}
|
||||
end
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
# Authentication context needed to fetch the event or related object.
|
||||
sig { returns(T.nilable(String)) }
|
||||
def context; end
|
||||
# Time at which the object was created.
|
||||
sig { returns(String) }
|
||||
def created; end
|
||||
# Unique identifier for the event.
|
||||
sig { returns(String) }
|
||||
def id; end
|
||||
# String representing the object's type. Objects of the same type share the same value of the object field.
|
||||
sig { returns(String) }
|
||||
def object; end
|
||||
# Reason for the event.
|
||||
sig { returns(T.nilable(Reason)) }
|
||||
def reason; end
|
||||
# The type of the event.
|
||||
sig { returns(String) }
|
||||
def type; end
|
||||
# Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
|
||||
sig { returns(T::Boolean) }
|
||||
def livemode; end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
117
rbi/stripe/resources/v2/core/event_destination.rbi
Normal file
117
rbi/stripe/resources/v2/core/event_destination.rbi
Normal file
@ -0,0 +1,117 @@
|
||||
# File generated from our OpenAPI spec
|
||||
# frozen_string_literal: true
|
||||
|
||||
# typed: true
|
||||
module Stripe
|
||||
module V2
|
||||
module Core
|
||||
# Set up an event destination to receive events from Stripe across multiple destination types, including [webhook endpoints](https://docs.stripe.com/webhooks) and [Amazon EventBridge](https://docs.stripe.com/event-destinations/eventbridge). Event destinations support receiving [thin events](https://docs.stripe.com/api/v2/events) and [snapshot events](https://docs.stripe.com/api/events).
|
||||
class EventDestination < APIResource
|
||||
class StatusDetails < Stripe::StripeObject
|
||||
class Disabled < Stripe::StripeObject
|
||||
# Reason event destination has been disabled.
|
||||
sig { returns(String) }
|
||||
def reason; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
# Details about why the event destination has been disabled.
|
||||
sig { returns(T.nilable(Disabled)) }
|
||||
def disabled; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {disabled: Disabled}
|
||||
end
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
class AmazonEventbridge < Stripe::StripeObject
|
||||
# The AWS account ID.
|
||||
sig { returns(String) }
|
||||
def aws_account_id; end
|
||||
# The ARN of the AWS event source.
|
||||
sig { returns(String) }
|
||||
def aws_event_source_arn; end
|
||||
# The state of the AWS event source.
|
||||
sig { returns(String) }
|
||||
def aws_event_source_status; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
class WebhookEndpoint < Stripe::StripeObject
|
||||
# The signing secret of the webhook endpoint, only includable on creation.
|
||||
sig { returns(T.nilable(String)) }
|
||||
def signing_secret; end
|
||||
# The URL of the webhook endpoint, includable.
|
||||
sig { returns(T.nilable(String)) }
|
||||
def url; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
# Time at which the object was created.
|
||||
sig { returns(String) }
|
||||
def created; end
|
||||
# An optional description of what the event destination is used for.
|
||||
sig { returns(String) }
|
||||
def description; end
|
||||
# The list of events to enable for this endpoint.
|
||||
sig { returns(T::Array[String]) }
|
||||
def enabled_events; end
|
||||
# Payload type of events being subscribed to.
|
||||
sig { returns(String) }
|
||||
def event_payload; end
|
||||
# Where events should be routed from.
|
||||
sig { returns(T.nilable(T::Array[String])) }
|
||||
def events_from; end
|
||||
# Unique identifier for the object.
|
||||
sig { returns(String) }
|
||||
def id; end
|
||||
# Metadata.
|
||||
sig { returns(T.nilable(T::Hash[String, String])) }
|
||||
def metadata; end
|
||||
# Event destination name.
|
||||
sig { returns(String) }
|
||||
def name; end
|
||||
# String representing the object's type. Objects of the same type share the same value of the object field.
|
||||
sig { returns(String) }
|
||||
def object; end
|
||||
# If using the snapshot event payload, the API version events are rendered as.
|
||||
sig { returns(T.nilable(String)) }
|
||||
def snapshot_api_version; end
|
||||
# Status. It can be set to either enabled or disabled.
|
||||
sig { returns(String) }
|
||||
def status; end
|
||||
# Additional information about event destination status.
|
||||
sig { returns(T.nilable(StatusDetails)) }
|
||||
def status_details; end
|
||||
# Event destination type.
|
||||
sig { returns(String) }
|
||||
def type; end
|
||||
# Time at which the object was last updated.
|
||||
sig { returns(String) }
|
||||
def updated; end
|
||||
# Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
|
||||
sig { returns(T::Boolean) }
|
||||
def livemode; end
|
||||
# Amazon EventBridge configuration.
|
||||
sig { returns(T.nilable(AmazonEventbridge)) }
|
||||
def amazon_eventbridge; end
|
||||
# Webhook endpoint configuration.
|
||||
sig { returns(T.nilable(WebhookEndpoint)) }
|
||||
def webhook_endpoint; end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
43
rbi/stripe/resources/v2/core/event_notification.rbi
Normal file
43
rbi/stripe/resources/v2/core/event_notification.rbi
Normal file
@ -0,0 +1,43 @@
|
||||
# frozen_string_literal: true
|
||||
# typed: true
|
||||
|
||||
module Stripe
|
||||
module V2
|
||||
module Core
|
||||
class EventReasonRequest
|
||||
sig { returns(String) }
|
||||
def id; end
|
||||
sig { returns(String) }
|
||||
def idempotency_key; end
|
||||
|
||||
sig { params(event_reason_request_payload: T::Hash[T.untyped, T.untyped]).void }
|
||||
def initialize(event_reason_request_payload = {}); end
|
||||
end
|
||||
|
||||
class EventReason
|
||||
sig { returns(String) }
|
||||
def type; end
|
||||
sig { returns(::Stripe::V2::Core::EventReasonRequest) }
|
||||
def request; end
|
||||
|
||||
sig { params(event_reason_payload: T::Hash[T.untyped, T.untyped]).void }
|
||||
def initialize(event_reason_payload = {}); end
|
||||
end
|
||||
|
||||
class EventNotification
|
||||
sig { returns(String) }
|
||||
def id; end
|
||||
sig { returns(String) }
|
||||
def type; end
|
||||
sig { returns(String) }
|
||||
def created; end
|
||||
sig { returns(T.nilable(String)) }
|
||||
def context; end
|
||||
sig { returns(T::Boolean) }
|
||||
def livemode; end
|
||||
sig { returns(T.nilable(::Stripe::V2::Core::EventReason)) }
|
||||
def reason; end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,60 +0,0 @@
|
||||
# File generated from our OpenAPI spec
|
||||
# frozen_string_literal: true
|
||||
|
||||
# typed: true
|
||||
module Stripe
|
||||
module V2
|
||||
# Events are generated to keep you informed of activity in your business account. APIs in the /v2 namespace generate [thin events](https://docs.stripe.com/event-destinations#benefits-of-thin-events) which have small, unversioned payloads that include a reference to the ID of the object that has changed. The Events v2 API returns these new thin events. [Retrieve the event object](https://docs.stripe.com/event-destinations#fetch-data) for additional data about the event. Use the related object ID in the event payload to [fetch the API resource](https://docs.stripe.com/event-destinations#retrieve-the-object-associated-with-thin-events) of the object associated with the event. Comparatively, events generated by most API v1 include a versioned snapshot of an API object in their payload.
|
||||
class Event < APIResource
|
||||
class Reason < Stripe::StripeObject
|
||||
class Request < Stripe::StripeObject
|
||||
# ID of the API request that caused the event.
|
||||
sig { returns(String) }
|
||||
def id; end
|
||||
# The idempotency key transmitted during the request.
|
||||
sig { returns(String) }
|
||||
def idempotency_key; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
# Event reason type.
|
||||
sig { returns(String) }
|
||||
def type; end
|
||||
# Information on the API request that instigated the event.
|
||||
sig { returns(T.nilable(Request)) }
|
||||
def request; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {request: Request}
|
||||
end
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
# Authentication context needed to fetch the event or related object.
|
||||
sig { returns(T.nilable(String)) }
|
||||
def context; end
|
||||
# Time at which the object was created.
|
||||
sig { returns(String) }
|
||||
def created; end
|
||||
# Unique identifier for the event.
|
||||
sig { returns(String) }
|
||||
def id; end
|
||||
# String representing the object's type. Objects of the same type share the same value of the object field.
|
||||
sig { returns(String) }
|
||||
def object; end
|
||||
# Reason for the event.
|
||||
sig { returns(T.nilable(Reason)) }
|
||||
def reason; end
|
||||
# The type of the event.
|
||||
sig { returns(String) }
|
||||
def type; end
|
||||
# Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
|
||||
sig { returns(T::Boolean) }
|
||||
def livemode; end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,115 +0,0 @@
|
||||
# File generated from our OpenAPI spec
|
||||
# frozen_string_literal: true
|
||||
|
||||
# typed: true
|
||||
module Stripe
|
||||
module V2
|
||||
# Set up an event destination to receive events from Stripe across multiple destination types, including [webhook endpoints](https://docs.stripe.com/webhooks) and [Amazon EventBridge](https://docs.stripe.com/event-destinations/eventbridge). Event destinations support receiving [thin events](https://docs.stripe.com/api/v2/events) and [snapshot events](https://docs.stripe.com/api/events).
|
||||
class EventDestination < APIResource
|
||||
class StatusDetails < Stripe::StripeObject
|
||||
class Disabled < Stripe::StripeObject
|
||||
# Reason event destination has been disabled.
|
||||
sig { returns(String) }
|
||||
def reason; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
# Details about why the event destination has been disabled.
|
||||
sig { returns(T.nilable(Disabled)) }
|
||||
def disabled; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {disabled: Disabled}
|
||||
end
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
class AmazonEventbridge < Stripe::StripeObject
|
||||
# The AWS account ID.
|
||||
sig { returns(String) }
|
||||
def aws_account_id; end
|
||||
# The ARN of the AWS event source.
|
||||
sig { returns(String) }
|
||||
def aws_event_source_arn; end
|
||||
# The state of the AWS event source.
|
||||
sig { returns(String) }
|
||||
def aws_event_source_status; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
class WebhookEndpoint < Stripe::StripeObject
|
||||
# The signing secret of the webhook endpoint, only includable on creation.
|
||||
sig { returns(T.nilable(String)) }
|
||||
def signing_secret; end
|
||||
# The URL of the webhook endpoint, includable.
|
||||
sig { returns(T.nilable(String)) }
|
||||
def url; end
|
||||
def self.inner_class_types
|
||||
@inner_class_types = {}
|
||||
end
|
||||
def self.field_remappings
|
||||
@field_remappings = {}
|
||||
end
|
||||
end
|
||||
# Time at which the object was created.
|
||||
sig { returns(String) }
|
||||
def created; end
|
||||
# An optional description of what the event destination is used for.
|
||||
sig { returns(String) }
|
||||
def description; end
|
||||
# The list of events to enable for this endpoint.
|
||||
sig { returns(T::Array[String]) }
|
||||
def enabled_events; end
|
||||
# Payload type of events being subscribed to.
|
||||
sig { returns(String) }
|
||||
def event_payload; end
|
||||
# Where events should be routed from.
|
||||
sig { returns(T.nilable(T::Array[String])) }
|
||||
def events_from; end
|
||||
# Unique identifier for the object.
|
||||
sig { returns(String) }
|
||||
def id; end
|
||||
# Metadata.
|
||||
sig { returns(T.nilable(T::Hash[String, String])) }
|
||||
def metadata; end
|
||||
# Event destination name.
|
||||
sig { returns(String) }
|
||||
def name; end
|
||||
# String representing the object's type. Objects of the same type share the same value of the object field.
|
||||
sig { returns(String) }
|
||||
def object; end
|
||||
# If using the snapshot event payload, the API version events are rendered as.
|
||||
sig { returns(T.nilable(String)) }
|
||||
def snapshot_api_version; end
|
||||
# Status. It can be set to either enabled or disabled.
|
||||
sig { returns(String) }
|
||||
def status; end
|
||||
# Additional information about event destination status.
|
||||
sig { returns(T.nilable(StatusDetails)) }
|
||||
def status_details; end
|
||||
# Event destination type.
|
||||
sig { returns(String) }
|
||||
def type; end
|
||||
# Time at which the object was last updated.
|
||||
sig { returns(String) }
|
||||
def updated; end
|
||||
# Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
|
||||
sig { returns(T::Boolean) }
|
||||
def livemode; end
|
||||
# Amazon EventBridge configuration.
|
||||
sig { returns(T.nilable(AmazonEventbridge)) }
|
||||
def amazon_eventbridge; end
|
||||
# Webhook endpoint configuration.
|
||||
sig { returns(T.nilable(WebhookEndpoint)) }
|
||||
def webhook_endpoint; end
|
||||
end
|
||||
end
|
||||
end
|
@ -203,7 +203,7 @@ module Stripe
|
||||
class PingParams < Stripe::RequestParams; end
|
||||
# Create a new event destination.
|
||||
sig {
|
||||
params(params: T.any(::Stripe::V2::Core::EventDestinationService::CreateParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::EventDestination)
|
||||
params(params: T.any(::Stripe::V2::Core::EventDestinationService::CreateParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::Core::EventDestination)
|
||||
}
|
||||
def create(params = {}, opts = {}); end
|
||||
|
||||
@ -215,13 +215,13 @@ module Stripe
|
||||
|
||||
# Disable an event destination.
|
||||
sig {
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::DisableParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::EventDestination)
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::DisableParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::Core::EventDestination)
|
||||
}
|
||||
def disable(id, params = {}, opts = {}); end
|
||||
|
||||
# Enable an event destination.
|
||||
sig {
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::EnableParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::EventDestination)
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::EnableParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::Core::EventDestination)
|
||||
}
|
||||
def enable(id, params = {}, opts = {}); end
|
||||
|
||||
@ -233,19 +233,19 @@ module Stripe
|
||||
|
||||
# Send a `ping` event to an event destination.
|
||||
sig {
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::PingParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::Event)
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::PingParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::Core::Event)
|
||||
}
|
||||
def ping(id, params = {}, opts = {}); end
|
||||
|
||||
# Retrieves the details of an event destination.
|
||||
sig {
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::RetrieveParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::EventDestination)
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::RetrieveParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::Core::EventDestination)
|
||||
}
|
||||
def retrieve(id, params = {}, opts = {}); end
|
||||
|
||||
# Update the details of an event destination.
|
||||
sig {
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::UpdateParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::EventDestination)
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::UpdateParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::Core::EventDestination)
|
||||
}
|
||||
def update(id, params = {}, opts = {}); end
|
||||
end
|
||||
|
@ -31,7 +31,7 @@ module Stripe
|
||||
|
||||
# Retrieves the details of an event.
|
||||
sig {
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventService::RetrieveParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::Event)
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventService::RetrieveParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::Core::Event)
|
||||
}
|
||||
def retrieve(id, params = {}, opts = {}); end
|
||||
end
|
||||
|
@ -10,7 +10,7 @@ module Stripe
|
||||
secret: String,
|
||||
tolerance: T.nilable(Integer)
|
||||
)
|
||||
.returns(::Stripe::V2::EventNotification)
|
||||
.returns(::Stripe::V2::Core::EventNotification)
|
||||
end
|
||||
def parse_event_notification(payload, sig_header, secret, tolerance:); end
|
||||
end
|
||||
|
@ -35,7 +35,7 @@ Gem::Specification.new do |s|
|
||||
# Handwritten RBIs
|
||||
# TODO(helenye): http://go/j/DEVSDK-2769
|
||||
%r{\Arbi/stripe/stripe_client.rbi\z},
|
||||
%r{\Arbi/stripe/event_notification.rbi\z}
|
||||
%r{\Arbi/stripe/resources/v2/core/event_notification.rbi\z}
|
||||
)
|
||||
s.files = `git ls-files`.split("\n").grep(included)
|
||||
s.bindir = "exe"
|
||||
|
@ -914,13 +914,13 @@ module Stripe
|
||||
context "v2 resources" do
|
||||
should "raise an NotImplementedError on resource_url" do
|
||||
assert_raises NotImplementedError do
|
||||
Stripe::V2::Event.resource_url
|
||||
Stripe::V2::Core::Event.resource_url
|
||||
end
|
||||
end
|
||||
|
||||
should "raise an NotImplementedError on retrieve" do
|
||||
assert_raises NotImplementedError do
|
||||
Stripe::V2::Event.retrieve("acct_123")
|
||||
Stripe::V2::Core::Event.retrieve("acct_123")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -158,7 +158,7 @@ module Stripe
|
||||
|
||||
assert_equal nil, req.headers["Content-Type"]
|
||||
|
||||
assert resp.is_a?(Stripe::V2::Event)
|
||||
assert resp.is_a?(Stripe::V2::Core::Event)
|
||||
assert_equal "sk_test_123", resp.instance_variable_get(:@opts)[:api_key]
|
||||
assert_equal 200, resp.last_response.http_status
|
||||
end
|
||||
@ -380,7 +380,7 @@ module Stripe
|
||||
|
||||
obj = @client.deserialize(expected_body, api_mode: :v2)
|
||||
|
||||
assert_equal obj.class, Stripe::V2::Event
|
||||
assert_equal obj.class, Stripe::V2::Core::Event
|
||||
assert_equal obj.id, "evt_123"
|
||||
end
|
||||
end
|
||||
|
@ -377,7 +377,7 @@ module Stripe
|
||||
context: "workspace/account/customer",
|
||||
}
|
||||
|
||||
notification = Stripe::V2::EventNotification.new(event_payload, client)
|
||||
notification = Stripe::V2::Core::EventNotification.new(event_payload, client)
|
||||
|
||||
assert_not_nil notification.context
|
||||
assert_equal "workspace/account/customer", notification.context.to_s
|
||||
@ -395,7 +395,7 @@ module Stripe
|
||||
context: nil,
|
||||
}
|
||||
|
||||
notification = Stripe::V2::EventNotification.new(event_payload, client)
|
||||
notification = Stripe::V2::Core::EventNotification.new(event_payload, client)
|
||||
|
||||
assert_nil notification.context
|
||||
end
|
||||
@ -410,7 +410,7 @@ module Stripe
|
||||
context: "",
|
||||
}
|
||||
|
||||
notification = Stripe::V2::EventNotification.new(event_payload, client)
|
||||
notification = Stripe::V2::Core::EventNotification.new(event_payload, client)
|
||||
|
||||
assert_nil notification.context
|
||||
end
|
||||
|
@ -95,7 +95,7 @@ module Stripe
|
||||
context ".event_signing" do
|
||||
should "parse v2 events" do
|
||||
event = parse_signed_event(@v2_push_payload)
|
||||
assert event.is_a?(Stripe::V2::EventNotification)
|
||||
assert event.is_a?(Stripe::V2::Core::EventNotification)
|
||||
assert_equal "evt_234", event.id
|
||||
assert_equal "v1.billing.meter.error_report_triggered", event.type
|
||||
assert_equal "2022-02-15T00:27:45.330Z", event.created
|
||||
@ -104,9 +104,9 @@ module Stripe
|
||||
|
||||
should "parse v2 events with livemode and reason" do
|
||||
event = parse_signed_event(@v2_push_payload_with_livemode_and_reason)
|
||||
assert event.is_a?(Stripe::V2::EventNotification)
|
||||
assert event.related_object.is_a?(Stripe::V2::RelatedObject)
|
||||
assert event.reason.is_a?(Stripe::V2::EventReason)
|
||||
assert event.is_a?(Stripe::V2::Core::EventNotification)
|
||||
assert event.related_object.is_a?(Stripe::V2::Core::RelatedObject)
|
||||
assert event.reason.is_a?(Stripe::V2::Core::EventReason)
|
||||
|
||||
assert_equal "evt_234", event.id
|
||||
assert_equal "v1.billing.meter.error_report_triggered", event.type
|
||||
@ -158,7 +158,7 @@ module Stripe
|
||||
|
||||
should "parse unknown events" do
|
||||
event_notif = parse_signed_event(@v2_payload_fake_event)
|
||||
assert event_notif.instance_of?(Stripe::V2::UnknownEventNotification)
|
||||
assert event_notif.instance_of?(Stripe::Events::UnknownEventNotification)
|
||||
|
||||
stub_request(:get, "#{Stripe::DEFAULT_API_BASE}/v2/core/events/evt_234")
|
||||
.to_return(body: {
|
||||
@ -169,7 +169,7 @@ module Stripe
|
||||
}.to_json)
|
||||
|
||||
event = event_notif.fetch_event
|
||||
assert event.instance_of?(Stripe::V2::Event)
|
||||
assert event.instance_of?(Stripe::V2::Core::Event)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -199,7 +199,7 @@ module Stripe
|
||||
.to_return(body: JSON.generate(data: [{ id: 2, object: "v2.core.event" }, { id: 3, object: "v2.core.event" }, { id: 4, object: "v2.core.event" }], next_page_url: nil))
|
||||
|
||||
list.each do |obj|
|
||||
assert_instance_of(Stripe::V2::Event, obj)
|
||||
assert_instance_of(Stripe::V2::Core::Event, obj)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user