Sha256: 905271c975522799ec83d9674274bf4a5b5a85c5dd76beddd6dd6ffcda9e407b

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

module EveOnline
  module Account
    # https://eveonline-third-party-documentation.readthedocs.org/en/latest/xmlapi/account/account_accountstatus.html
    class Status < BaseXML
      API_ENDPOINT = 'https://api.eveonline.com/account/AccountStatus.xml.aspx'.freeze

      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
        {
          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
        parse_datetime_with_timezone(result.fetch('paidUntil'))
      end

      def create_date
        parse_datetime_with_timezone(result.fetch('createDate'))
      end

      def logon_count
        result.fetch('logonCount').to_i
      end

      def logon_minutes
        result.fetch('logonMinutes').to_i
      end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
eve_online-0.11.0 lib/eve_online/account/status.rb
eve_online-0.10.0 lib/eve_online/account/status.rb
eve_online-0.9.0 lib/eve_online/account/status.rb