Class: RubyBareEsi
- Inherits:
-
Object
- Object
- RubyBareEsi
- 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
-
#initialize(rest_url = nil, params = {}, test_mode: false, debug_mode: false) ⇒ RubyBareEsi
constructor
This initialize an RubyBareEsi download object.
- #set_auth_token(user = nil) ⇒ Object
Methods included from RubyBareEsiGetPages::GetAllPages
Methods included from RubyBareEsiGetPages::GetPageRetryOnError
Methods included from RubyBareEsiGetPages::GetPage
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.
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 |