Class: Notifications::Client::ReceivedText

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

Constant Summary collapse

FIELDS =
%i(
  id
  created_at
  content
  notify_number
  service_id
  user_number
).freeze

Instance Method Summary collapse

Constructor Details

#initialize(received_text) ⇒ ReceivedText

Returns a new instance of ReceivedText.



17
18
19
20
21
# File 'lib/notifications/client/received_text.rb', line 17

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

Instance Method Details

#created_atObject



23
24
25
26
27
28
# File 'lib/notifications/client/received_text.rb', line 23

def created_at
  value = instance_variable_get(:@created_at)
  Time.parse(value)
rescue StandardError
  value
end