Class: RubyBareEsi

Inherits:
Object
  • Object
show all
Includes:
RubyBareEsiGetPages::GetAllPages, RubyBareEsiGetPages::GetPage, RubyBareEsiGetPages::GetPageRetryOnError
Defined in:
lib/ruby-bare-esi.rb,
lib/ruby-bare-esi/version.rb

Overview

This class is the entry point for all method allowing data retrieval from the ESI API

Constant Summary collapse

ESI_BASE_URL =

This is the default address of the ESI API

'https://esi.evetech.net/latest/'
ESI_DATA_SOURCE =

And the default server used for the requests

{ datasource: :tranquility }
VERSION =
'0.0.3'

Instance Method Summary collapse

Methods included from RubyBareEsiGetPages::GetAllPages

#get_all_pages

Methods included from RubyBareEsiGetPages::GetPageRetryOnError

#get_page_retry_on_error

Methods included from RubyBareEsiGetPages::GetPage

#get_page

Constructor Details

#initialize(rest_url = nil, params = {}, test_mode: false, debug_mode: false) ⇒ RubyBareEsi

This initialize an RubyBareEsi download object.

tests to turn off some errors warnings and to reduce sleep time in case of automatic retry.

Parameters:

  • rest_url (String) (defaults to: nil)

    the path of the method to access ESI (the exact path you would send to the API).

  • params (Hash) (defaults to: {})

    the params if required.

  • test_mode (Boolean) (defaults to: false)

    turns on or off test_mode. test_mode is off by default. It is turned on only during

  • debug_mode (Boolean) (defaults to: false)

    turns on debugging if required. This also turn on verbose_mode.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ruby-bare-esi.rb', line 31

def initialize( rest_url = nil, params = {}, test_mode: false, debug_mode: false )

  # Of course it can, lots of processes defines the url later.
  # raise "RubyBareEsi.initialize : rest_url can't be nil" unless rest_url

  @debug_mode = debug_mode || ENV['EBS_DEBUG_MODE'] == 'true'
  @test_mode = test_mode

  puts 'RubyBareEsi.initialize : debug mode on' if @debug_mode

  @rest_url = rest_url
  @params = params.merge( ESI_DATA_SOURCE )
  @forbidden_count = 0
end

Instance Method Details

#set_auth_token(user = nil) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/ruby-bare-esi.rb', line 46

def set_auth_token( user=nil )

  # p user

  return false unless user.expires_on && user.token && user.renew_token

  unless user
    user_id = File.open( 'config/character_id.txt' ).read.to_i
    user = User.find_by_uid( user_id )
  end

  if user.expires_on < Time.now().utc
    puts "Token expired - #{user.expires_on} < #{Time.now().utc}"
    renew_token( user )
  end

  @params[:token] = user.token

  true
end