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

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

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
# 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 },
                                                            usage: ["fetch_event"])
  @client.deserialize(resp.http_body, api_mode: :v2)
end