Class: Notifications::Client::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/notifications/client/notification.rb

Constant Summary collapse

FIELDS =
[
  :id,
  :api_key,
  :billable_units,
  :to,
  :subject,
  :body,
  :job,
  :notification_type,
  :status,
  :service,
  :sent_at,
  :sent_by,
  :template,
  :template_version,
  :reference,
  :created_at,
  :updated_at
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(notification) ⇒ Notification

Returns a new instance of Notification.



26
27
28
29
30
31
32
33
# File 'lib/notifications/client/notification.rb', line 26

def initialize(notification)
  notification = normalize(notification)

  FIELDS.each do |field|
      instance_variable_set(:"@#{field}", notification.fetch(field.to_s, nil)
      )
  end
end