Sha256: d99542a2d5acd6571cd975b42dd0c2ef7f7576d77db11df332722f4eff6ac7d2

Contents?: true

Size: 788 Bytes

Versions: 6

Compression:

Stored size: 788 Bytes

Contents

require 'active_support/time'

module EveOnline
  class ContactNotification
    attr_reader :options

    def initialize(options)
      @options = options
    end

    def as_json
      {
        notification_id: notification_id,
        sender_id: sender_id,
        sender_name: sender_name,
        sent_date: sent_date,
        message_data: message_data
      }
    end

    def notification_id
      options.fetch('@notificationID').to_i
    end

    def sender_id
      options.fetch('@senderID').to_i
    end

    def sender_name
      options.fetch('@senderName')
    end

    def sent_date
      ActiveSupport::TimeZone['UTC'].parse(options.fetch('@sentDate'))
    end

    def message_data
      # TODO: parse @messageData
      options.fetch('@messageData')
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
eve_online-0.14.0 lib/eve_online/contact_notification.rb
eve_online-0.13.0 lib/eve_online/contact_notification.rb
eve_online-0.12.0 lib/eve_online/contact_notification.rb
eve_online-0.11.0 lib/eve_online/contact_notification.rb
eve_online-0.10.0 lib/eve_online/contact_notification.rb
eve_online-0.9.0 lib/eve_online/contact_notification.rb