Class: Sendly::WebhookEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/sendly/webhooks.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ WebhookEvent

Returns a new instance of WebhookEvent.



153
154
155
156
157
158
159
160
161
# File 'lib/sendly/webhooks.rb', line 153

def initialize(data)
  @id = data[:id]
  @type = data[:type]
  obj = data[:data][:object] || data[:data]
  @data = WebhookMessageData.new(obj)
  @created = data[:created] || data[:created_at] || 0
  @api_version = data[:api_version] || '2024-01'
  @livemode = data[:livemode] || false
end

Instance Attribute Details

#api_versionObject (readonly)

Returns the value of attribute api_version.



151
152
153
# File 'lib/sendly/webhooks.rb', line 151

def api_version
  @api_version
end

#createdObject (readonly)

Returns the value of attribute created.



151
152
153
# File 'lib/sendly/webhooks.rb', line 151

def created
  @created
end

#dataObject (readonly)

Returns the value of attribute data.



151
152
153
# File 'lib/sendly/webhooks.rb', line 151

def data
  @data
end

#idObject (readonly)

Returns the value of attribute id.



151
152
153
# File 'lib/sendly/webhooks.rb', line 151

def id
  @id
end

#livemodeObject (readonly)

Returns the value of attribute livemode.



151
152
153
# File 'lib/sendly/webhooks.rb', line 151

def livemode
  @livemode
end

#typeObject (readonly)

Returns the value of attribute type.



151
152
153
# File 'lib/sendly/webhooks.rb', line 151

def type
  @type
end

Instance Method Details

#created_atObject



163
164
165
# File 'lib/sendly/webhooks.rb', line 163

def created_at
  @created
end

#to_hObject



167
168
169
170
171
172
173
174
175
176
# File 'lib/sendly/webhooks.rb', line 167

def to_h
  {
    id: @id,
    type: @type,
    data: @data.to_h,
    created: @created,
    api_version: @api_version,
    livemode: @livemode
  }
end