Class: GoCardlessPro::Resources::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/gocardless_pro/resources/event.rb

Overview

Events are stored for all webhooks. An event refers to a resource which has been updated, for example a payment which has been collected, or a mandate which has been transferred. Event creation is an asynchronous process, so it can take some time between an action occurring and its corresponding event getting included in API responses. See [here](#event-actions) for a complete list of event types.

Defined Under Namespace

Classes: Links

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, response = nil) ⇒ Event

Initialize a event resource instance

Parameters:

  • object (Hash)

    an object returned from the API



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/gocardless_pro/resources/event.rb', line 25

def initialize(object, response = nil)
  @object = object

  @action = object['action']
  @created_at = object['created_at']
  @customer_notifications = object['customer_notifications']
  @details = object['details']
  @id = object['id']
  @links = object['links']
  @metadata = object['metadata']
  @resource_metadata = object['resource_metadata']
  @resource_type = object['resource_type']
  @response = response
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



20
21
22
# File 'lib/gocardless_pro/resources/event.rb', line 20

def action
  @action
end

#created_atObject (readonly)

Returns the value of attribute created_at.



20
21
22
# File 'lib/gocardless_pro/resources/event.rb', line 20

def created_at
  @created_at
end

#customer_notificationsObject (readonly)

Returns the value of attribute customer_notifications.



20
21
22
# File 'lib/gocardless_pro/resources/event.rb', line 20

def customer_notifications
  @customer_notifications
end

#detailsObject (readonly)

Returns the value of attribute details.



20
21
22
# File 'lib/gocardless_pro/resources/event.rb', line 20

def details
  @details
end

#idObject (readonly)

Returns the value of attribute id.



20
21
22
# File 'lib/gocardless_pro/resources/event.rb', line 20

def id
  @id
end

#metadataObject (readonly)

Returns the value of attribute metadata.



20
21
22
# File 'lib/gocardless_pro/resources/event.rb', line 20

def 
  @metadata
end

#resource_metadataObject (readonly)

Returns the value of attribute resource_metadata.



20
21
22
# File 'lib/gocardless_pro/resources/event.rb', line 20

def 
  @resource_metadata
end

#resource_typeObject (readonly)

Returns the value of attribute resource_type.



20
21
22
# File 'lib/gocardless_pro/resources/event.rb', line 20

def resource_type
  @resource_type
end

Instance Method Details

#api_responseObject



40
41
42
# File 'lib/gocardless_pro/resources/event.rb', line 40

def api_response
  ApiResponse.new(@response)
end

Return the links that the resource has



45
46
47
# File 'lib/gocardless_pro/resources/event.rb', line 45

def links
  @event_links ||= Links.new(@links)
end

#to_hObject

Provides the event resource as a hash of all its readable attributes



50
51
52
# File 'lib/gocardless_pro/resources/event.rb', line 50

def to_h
  @object
end