Method: Esi#api_version=
- Defined in:
- lib/esi.rb
#api_version=(value) ⇒ Symbol (writeonly)
Returns the Esi Api version used by the gem.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/esi.rb', line 17 module Esi autoload :VERSION, 'esi/version' autoload :AccessToken, 'esi/access_token' autoload :OAuth, 'esi/o_auth' autoload :Calls, 'esi/calls' autoload :Client, 'esi/client' autoload :Response, 'esi/response' require_relative 'esi/api_error' # Default ESI access scopes # @return [Array<String>] the default scopes SCOPES = %w( esi-assets.read_assets.v1 esi-bookmarks.read_character_bookmarks.v1 esi-calendar.read_calendar_events.v1 esi-calendar.respond_calendar_events.v1 esi-characters.read_agents_research.v1 esi-characters.read_blueprints.v1 esi-characters.read_chat_channels.v1 esi-characters.read_contacts.v1 esi-characters.read_corporation_roles.v1 esi-characters.read_fatigue.v1 esi-characters.read_loyalty.v1 esi-characters.read_medals.v1 esi-characters.read_opportunities.v1 esi-characters.read_standings.v1 esi-characters.write_contacts.v1 esi-clones.read_clones.v1 esi-clones.read_implants.v1 esi-contracts.read_character_contracts.v1 esi-corporations.read_corporation_membership.v1 esi-corporations.read_structures.v1 esi-corporations.track_members.v1 esi-corporations.write_structures.v1 esi-fittings.read_fittings.v1 esi-fittings.write_fittings.v1 esi-fleets.read_fleet.v1 esi-fleets.write_fleet.v1 esi-industry.read_character_jobs.v1 esi-killmails.read_killmails.v1 esi-location.read_location.v1 esi-location.read_online.v1 esi-location.read_ship_type.v1 esi-mail.organize_mail.v1 esi-mail.read_mail.v1 esi-mail.send_mail.v1 esi-markets.read_character_orders.v1 esi-markets.structure_markets.v1 esi-planets.manage_planets.v1 esi-search.search_structures.v1 esi-skills.read_skillqueue.v1 esi-skills.read_skills.v1 esi-ui.open_window.v1 esi-ui.write_waypoint.v1 esi-universe.read_structures.v1 esi-wallet.read_character_wallet.v1 esi-wallet.read_corporation_wallets.v1 ).freeze # The default Esi gem configuration # @return [Hash{Symbol => Symbol|String|Fixnum|Object|Array}] the default configuration DEFAULT_CONFIG = { datasource: :tranquility, oauth_host: 'https://login.eveonline.com', api_host: 'https://esi.tech.ccp.is', api_version: :latest, log_level: :info, log_target: STDOUT, response_log_path: nil, timeout: 60, client_id: nil, client_secret: nil, cache: ActiveSupport::Cache::MemoryStore.new, scopes: SCOPES }.freeze class << self attr_writer :api_version, :config, :logger, :cache # The Esi Configuration # @return [OpenStruct] the configuration object def config @config ||= OpenStruct.new(DEFAULT_CONFIG) end # The Esi logger class instance # @return [MyLoggerInstance|Logger] an instance of the logger class def logger @logger ||= Esi.config.logger || Logger.new(Esi.config.log_target).tap do |l| l.level = Logger.const_get(Esi.config.log_level.upcase) end end # The Esi cache class instance # @return [ActiveSupport::Cache::Store] an instance of cache def cache if Esi.config.cache.nil? @cache ||= ActiveSupport::Cache::NullStore.new else Esi.config.cache end end # The Esi Api version to interface with # @return [Symbol] the esi api version def api_version @api_version || :latest end # Generate an Esi url for a given path # @param [String] path the path to generate an esi url for # @param [Hash{Symbol => String|Fixnum}] params the params for the url query # @return [String] the generated url def generate_url(path, params = {}) url = url_for_path(path) uri = Addressable::URI.parse(url) uri.query_values = { datasource: config.datasource }.merge(params.to_h) uri.to_s end # The current Esi client # @return [Esi::Client] the current client def client @client ||= Client.current end private def url_for_path(path) path = path[1..-1] if path.start_with?('/') path += '/' unless path.end_with?('/') [config.api_host, config.api_version, path].join('/') end end end |