Sha256: 0f0352bcc30042eb19c132e3dba52d1473657947d65c676edf051e532eb1fe36

Contents?: true

Size: 587 Bytes

Versions: 18

Compression:

Stored size: 587 Bytes

Contents

require 'time'

module Notifications
  class Client
    class ReceivedText
      FIELDS = %i(
        id
        created_at
        content
        notify_number
        service_id
        user_number
      ).freeze

      attr_reader(*FIELDS)

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

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
notifications-ruby-client-6.2.0 lib/notifications/client/received_text.rb
notifications-ruby-client-6.0.0 lib/notifications/client/received_text.rb
notifications-ruby-client-5.4.0 lib/notifications/client/received_text.rb
notifications-ruby-client-5.3.0 lib/notifications/client/received_text.rb
notifications-ruby-client-5.2.0 lib/notifications/client/received_text.rb
notifications-ruby-client-5.1.2 lib/notifications/client/received_text.rb
notifications-ruby-client-5.1.1 lib/notifications/client/received_text.rb
notifications-ruby-client-5.1.0 lib/notifications/client/received_text.rb
notifications-ruby-client-4.0.0 lib/notifications/client/received_text.rb
notifications-ruby-client-3.1.0 lib/notifications/client/received_text.rb
notifications-ruby-client-3.0.0 lib/notifications/client/received_text.rb
notifications-ruby-client-2.10.0 lib/notifications/client/received_text.rb
notifications-ruby-client-2.9.0 lib/notifications/client/received_text.rb
notifications-ruby-client-2.8.0 lib/notifications/client/received_text.rb
notifications-ruby-client-2.7.0 lib/notifications/client/received_text.rb
notifications-ruby-client-2.6.0 lib/notifications/client/received_text.rb
notifications-ruby-client-2.5.1 lib/notifications/client/received_text.rb
notifications-ruby-client-2.5.0 lib/notifications/client/received_text.rb