Class: Stripe::V2::Core::EventNotification

Inherits:
Object
  • Object
show all
Defined in:
lib/stripe/resources/v2/core/event_notification.rb

Direct Known Subclasses

Events::UnknownEventNotification, Events::V1BillingMeterErrorReportTriggeredEventNotification, Events::V1BillingMeterNoMeterFoundEventNotification, Events::V2CoreAccountClosedEventNotification, Events::V2CoreAccountCreatedEventNotification, Events::V2CoreAccountIncludingConfigurationCustomerCapabilityStatusUpdatedEventNotification, Events::V2CoreAccountIncludingConfigurationCustomerUpdatedEventNotification, Events::V2CoreAccountIncludingConfigurationMerchantCapabilityStatusUpdatedEventNotification, Events::V2CoreAccountIncludingConfigurationMerchantUpdatedEventNotification, Events::V2CoreAccountIncludingConfigurationRecipientCapabilityStatusUpdatedEventNotification, Events::V2CoreAccountIncludingConfigurationRecipientUpdatedEventNotification, Events::V2CoreAccountIncludingConfigurationStorerCapabilityStatusUpdatedEventNotification, Events::V2CoreAccountIncludingConfigurationStorerUpdatedEventNotification, Events::V2CoreAccountIncludingDefaultsUpdatedEventNotification, Events::V2CoreAccountIncludingFutureRequirementsUpdatedEventNotification, Events::V2CoreAccountIncludingIdentityUpdatedEventNotification, Events::V2CoreAccountIncludingRequirementsUpdatedEventNotification, Events::V2CoreAccountLinkReturnedEventNotification, Events::V2CoreAccountPersonCreatedEventNotification, Events::V2CoreAccountPersonDeletedEventNotification, Events::V2CoreAccountPersonUpdatedEventNotification, Events::V2CoreAccountUpdatedEventNotification, Events::V2CoreBatchJobBatchFailedEventNotification, Events::V2CoreBatchJobCanceledEventNotification, Events::V2CoreBatchJobCompletedEventNotification, Events::V2CoreBatchJobCreatedEventNotification, Events::V2CoreBatchJobReadyForUploadEventNotification, Events::V2CoreBatchJobTimeoutEventNotification, Events::V2CoreBatchJobUpdatedEventNotification, Events::V2CoreBatchJobUploadTimeoutEventNotification, Events::V2CoreBatchJobValidatingEventNotification, Events::V2CoreBatchJobValidationFailedEventNotification, Events::V2CoreEventDestinationPingEventNotification, Events::V2CoreHealthEventGenerationFailureResolvedEventNotification, Events::V2MoneyManagementAdjustmentCreatedEventNotification, Events::V2MoneyManagementFinancialAccountCreatedEventNotification, Events::V2MoneyManagementFinancialAccountUpdatedEventNotification, Events::V2MoneyManagementFinancialAddressActivatedEventNotification, Events::V2MoneyManagementFinancialAddressFailedEventNotification, Events::V2MoneyManagementInboundTransferAvailableEventNotification, Events::V2MoneyManagementInboundTransferBankDebitFailedEventNotification, Events::V2MoneyManagementInboundTransferBankDebitProcessingEventNotification, Events::V2MoneyManagementInboundTransferBankDebitQueuedEventNotification, Events::V2MoneyManagementInboundTransferBankDebitReturnedEventNotification, Events::V2MoneyManagementInboundTransferBankDebitSucceededEventNotification, Events::V2MoneyManagementOutboundPaymentCanceledEventNotification, Events::V2MoneyManagementOutboundPaymentCreatedEventNotification, Events::V2MoneyManagementOutboundPaymentFailedEventNotification, Events::V2MoneyManagementOutboundPaymentPostedEventNotification, Events::V2MoneyManagementOutboundPaymentReturnedEventNotification, Events::V2MoneyManagementOutboundPaymentUpdatedEventNotification, Events::V2MoneyManagementOutboundTransferCanceledEventNotification, Events::V2MoneyManagementOutboundTransferCreatedEventNotification, Events::V2MoneyManagementOutboundTransferFailedEventNotification, Events::V2MoneyManagementOutboundTransferPostedEventNotification, Events::V2MoneyManagementOutboundTransferReturnedEventNotification, Events::V2MoneyManagementOutboundTransferUpdatedEventNotification, Events::V2MoneyManagementPayoutMethodCreatedEventNotification, Events::V2MoneyManagementPayoutMethodUpdatedEventNotification, Events::V2MoneyManagementReceivedCreditAvailableEventNotification, Events::V2MoneyManagementReceivedCreditFailedEventNotification, Events::V2MoneyManagementReceivedCreditReturnedEventNotification, Events::V2MoneyManagementReceivedCreditSucceededEventNotification, Events::V2MoneyManagementReceivedDebitCanceledEventNotification, Events::V2MoneyManagementReceivedDebitFailedEventNotification, Events::V2MoneyManagementReceivedDebitPendingEventNotification, Events::V2MoneyManagementReceivedDebitSucceededEventNotification, Events::V2MoneyManagementReceivedDebitUpdatedEventNotification, Events::V2MoneyManagementTransactionCreatedEventNotification, Events::V2MoneyManagementTransactionUpdatedEventNotification

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event_payload, client) ⇒ EventNotification

Returns a new instance of EventNotification.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/stripe/resources/v2/core/event_notification.rb', line 37

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

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



35
36
37
# File 'lib/stripe/resources/v2/core/event_notification.rb', line 35

def context
  @context
end

#createdObject (readonly)

Returns the value of attribute created.



35
36
37
# File 'lib/stripe/resources/v2/core/event_notification.rb', line 35

def created
  @created
end

#idObject (readonly)

Returns the value of attribute id.



35
36
37
# File 'lib/stripe/resources/v2/core/event_notification.rb', line 35

def id
  @id
end

#livemodeObject (readonly)

Returns the value of attribute livemode.



35
36
37
# File 'lib/stripe/resources/v2/core/event_notification.rb', line 35

def livemode
  @livemode
end

#reasonObject (readonly)

Returns the value of attribute reason.



35
36
37
# File 'lib/stripe/resources/v2/core/event_notification.rb', line 35

def reason
  @reason
end

#typeObject (readonly)

Returns the value of attribute type.



35
36
37
# File 'lib/stripe/resources/v2/core/event_notification.rb', line 35

def type
  @type
end

Instance Method Details

#fetch_eventObject

Retrieves the Event that generated this EventNotification.



54
55
56
57
58
59
# File 'lib/stripe/resources/v2/core/event_notification.rb', line 54

def fetch_event
  resp = @client.raw_request(:get, "/v2/core/events/#{id}", opts: { stripe_context: context,
                                                                    "Stripe-Request-Trigger" => "event=#{id}", },
                                                            usage: ["fetch_event"])
  @client.deserialize(resp.http_body, api_mode: :v2)
end