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.



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

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.



167
168
169
# File 'lib/sendly/webhooks.rb', line 167

def api_version
  @api_version
end

#createdObject (readonly)

Returns the value of attribute created.



167
168
169
# File 'lib/sendly/webhooks.rb', line 167

def created
  @created
end

#dataObject (readonly)

Returns the value of attribute data.



167
168
169
# File 'lib/sendly/webhooks.rb', line 167

def data
  @data
end

#idObject (readonly)

Returns the value of attribute id.



167
168
169
# File 'lib/sendly/webhooks.rb', line 167

def id
  @id
end

#livemodeObject (readonly)

Returns the value of attribute livemode.



167
168
169
# File 'lib/sendly/webhooks.rb', line 167

def livemode
  @livemode
end

#typeObject (readonly)

Returns the value of attribute type.



167
168
169
# File 'lib/sendly/webhooks.rb', line 167

def type
  @type
end

Instance Method Details

#created_atObject



179
180
181
# File 'lib/sendly/webhooks.rb', line 179

def created_at
  @created
end

#to_hObject



183
184
185
186
187
188
189
190
191
192
# File 'lib/sendly/webhooks.rb', line 183

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