Class: Esi::Calls::Base
- Inherits:
-
Object
- Object
- Esi::Calls::Base
- Defined in:
- lib/esi/calls/base.rb
Overview
Base parent class used for all API calls. Provides basic functionality and state for caching and request initialization
Direct Known Subclasses
Alliance, AllianceNames, Alliances, Assets, Character, CharacterAssets, CharacterBlueprints, CharacterContracts, CharacterIndustryJobs, CharacterLocation, CharacterMail, CharacterNames, CharacterOnline, CharacterOrders, CharacterShip, CharacterSkills, CharacterWallet, CharacterWalletJournal, CharacterWalletTransactions, Constellation, Constellations, ContractItems, Corporation, CorporationAssets, CorporationBlueprints, CorporationIndustryJobs, CorporationMemberTracking, CorporationMembers, CorporationNames, CorporationRoles, CorporationStructures, CorporationWallet, CorporationWalletJournal, CorporationWallets, DeleteFitting, DogmaAttribute, DogmaAttributes, DogmaEffect, DogmaEffects, Fittings, Fleet, FleetMembers, FleetWings, IndustryFacilities, IndustrySystems, Killmail, Killmails, MarketGroup, MarketGroups, MarketHistory, MarketOrders, MarketPrices, MarketTypes, Moon, OpenMarketDetails, Planet, Region, Regions, Route, Search, SolarSystem, SolarSystems, SovereigntyCampaigns, SovereigntyMap, SovereigntyStructures, Star, Stargate, Station, Structure, StructureOrders, Structures, SystemJumps, SystemKills, Type, Types
Constant Summary collapse
- CACHE_NAMESPACE =
'esi'
Instance Attribute Summary collapse
-
#params ⇒ Hash
Request params.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
-
#cache_key ⇒ String
Returns an unique key based on the endpoint and params which is used for caching.
-
#method ⇒ Symbol
Returns the request HTTP method to use.
-
#page ⇒ Integer
Page number.
- #page=(page) ⇒ Object
-
#paginated? ⇒ Boolean
Returns whether the endpoint supports pagination.
-
#url ⇒ String
Returns the generated endpoint URL including any parameters.
Instance Attribute Details
#params ⇒ Hash
Returns request params.
56 57 58 |
# File 'lib/esi/calls/base.rb', line 56 def params @params || {} end |
#path ⇒ Object
Returns the value of attribute path.
15 16 17 |
# File 'lib/esi/calls/base.rb', line 15 def path @path end |
Instance Method Details
#cache_key ⇒ String
Returns an unique key based on the endpoint and params which is used for caching
20 21 22 23 24 25 |
# File 'lib/esi/calls/base.rb', line 20 def cache_key @cache_key ||= begin checksum = Digest::MD5.hexdigest("#{path.gsub(%r{^\/}, '')}:#{sorted_params}") "#{CACHE_NAMESPACE}:#{checksum}" end end |
#method ⇒ Symbol
Returns the request HTTP method to use
29 30 31 |
# File 'lib/esi/calls/base.rb', line 29 def method @method ||= :get end |
#page ⇒ Integer
Returns page number.
45 46 47 |
# File 'lib/esi/calls/base.rb', line 45 def page params[:page] || 1 end |
#page=(page) ⇒ Object
40 41 42 |
# File 'lib/esi/calls/base.rb', line 40 def page=(page) params[:page] = page end |
#paginated? ⇒ Boolean
Returns whether the endpoint supports pagination
51 52 53 |
# File 'lib/esi/calls/base.rb', line 51 def paginated? @paginated end |
#url ⇒ String
Returns the generated endpoint URL including any parameters
35 36 37 |
# File 'lib/esi/calls/base.rb', line 35 def url Esi.generate_url(path, params) end |