Sha256: 8e49a423fff166d84fe49286c7c70ed14a9c3d39f02bdca092ff3781e1cb0ee6

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

module EveOnline
  module Account
    # http://wiki.eve-id.net/APIv2_Account_AccountStatus_XML
    class Status < Base
      API_ENDPOINT = 'https://api.eveonline.com/account/AccountStatus.xml.aspx'

      attr_reader :key_id, :v_code

      def initialize(key_id, v_code)
        super()
        @key_id = key_id
        @v_code = v_code
      end

      def as_json(*args)
        {
          current_time: current_time,
          paid_until: paid_until,
          create_date: create_date,
          logon_count: logon_count,
          logon_minutes: logon_minutes,
          cached_until: cached_until
        }
      end

      def paid_until
        @paid_until ||= begin
          ActiveSupport::TimeZone['UTC'].parse(result.fetch('paidUntil'))
        end
      end

      def create_date
        @create_date ||= begin
          ActiveSupport::TimeZone['UTC'].parse(result.fetch('createDate'))
        end
      end

      def logon_count
        @logon_count ||= result.fetch('logonCount').to_i
      end

      def logon_minutes
        @logon_minutes ||= result.fetch('logonMinutes').to_i
      end

      def version
        @version ||= eveapi.fetch('@version').to_i
      end

      def url
        "#{ API_ENDPOINT }?keyID=#{ key_id }&vCode=#{ v_code }"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eve_online-0.4.0 lib/eve_online/account/status.rb