Class: EveBadger::EveAPI
- Inherits:
-
Object
- Object
- EveBadger::EveAPI
- Includes:
- EndpointData, RequestCache
- Defined in:
- lib/eve_badger/eve_api.rb
Instance Attribute Summary collapse
-
#character_id ⇒ Object
Returns the value of attribute character_id.
-
#key_id ⇒ Object
Returns the value of attribute key_id.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
-
#vcode ⇒ Object
Returns the value of attribute vcode.
Instance Method Summary collapse
- #access_mask ⇒ Object
- #access_mask=(mask) ⇒ Object
- #account(endpoint_name) ⇒ Object
- #character(endpoint_name) ⇒ Object
- #corporation(endpoint_name) ⇒ Object
- #details(endpoint_name, id_of_interest, fromid = nil, rowcount = nil) ⇒ Object
-
#initialize(args = {}) ⇒ EveAPI
constructor
A new instance of EveAPI.
- #key_type ⇒ Object
- #key_type=(type) ⇒ Object
Methods included from RequestCache
Methods included from EndpointData
Constructor Details
#initialize(args = {}) ⇒ EveAPI
Returns a new instance of EveAPI.
15 16 17 18 19 20 21 22 23 |
# File 'lib/eve_badger/eve_api.rb', line 15 def initialize(args={}) @domain = args[:sisi] ? EveBadger.sisi_domain : EveBadger.tq_domain @user_agent = EveBadger.user_agent @key_id = args[:key_id].to_s if args[:key_id] @vcode = args[:vcode].to_s if args[:vcode] @character_id = args[:character_id].to_s if args[:character_id] @access_mask = args[:access_mask].to_i if args[:access_mask] @key_type = args[:key_type].to_sym if args[:key_type] end |
Instance Attribute Details
#character_id ⇒ Object
Returns the value of attribute character_id.
11 12 13 |
# File 'lib/eve_badger/eve_api.rb', line 11 def character_id @character_id end |
#key_id ⇒ Object
Returns the value of attribute key_id.
11 12 13 |
# File 'lib/eve_badger/eve_api.rb', line 11 def key_id @key_id end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
10 11 12 |
# File 'lib/eve_badger/eve_api.rb', line 10 def user_agent @user_agent end |
#vcode ⇒ Object
Returns the value of attribute vcode.
11 12 13 |
# File 'lib/eve_badger/eve_api.rb', line 11 def vcode @vcode end |
Instance Method Details
#access_mask ⇒ Object
45 46 47 |
# File 'lib/eve_badger/eve_api.rb', line 45 def access_mask @access_mask ||= get_access_mask end |
#access_mask=(mask) ⇒ Object
37 38 39 |
# File 'lib/eve_badger/eve_api.rb', line 37 def access_mask=(mask) @access_mask = mask ? mask.to_i : nil end |
#account(endpoint_name) ⇒ Object
53 54 55 56 57 |
# File 'lib/eve_badger/eve_api.rb', line 53 def account(endpoint_name) raise 'missing required key_id or vcode' unless @key_id && @vcode endpoint = EveAPI.account_endpoint[endpoint_name.to_sym] badgerfish_from api_request(endpoint) end |
#character(endpoint_name) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/eve_badger/eve_api.rb', line 59 def character(endpoint_name) raise 'missing required character_id key_id or_vcode' unless @character_id && @key_id && @vcode raise 'wrong key type' unless key_type == :Character || :Account endpoint = EveAPI.character_endpoint[endpoint_name.to_sym] badgerfish_from api_request(endpoint) end |
#corporation(endpoint_name) ⇒ Object
66 67 68 69 70 71 |
# File 'lib/eve_badger/eve_api.rb', line 66 def corporation(endpoint_name) raise 'missing required character_id key_id or_vcode' unless @character_id && @key_id && @vcode raise 'wrong key type' unless key_type == :Corporation endpoint = EveAPI.corporation_endpoint[endpoint_name.to_sym] badgerfish_from api_request(endpoint) end |
#details(endpoint_name, id_of_interest, fromid = nil, rowcount = nil) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/eve_badger/eve_api.rb', line 73 def details(endpoint_name, id_of_interest, fromid=nil, rowcount=nil) raise 'wrong key type' unless key_type == :Character || :Corporation || :Account endpoint = EveAPI.detail_endpoint[endpoint_name.to_sym] if endpoint_permitted?(endpoint) uri = build_uri(endpoint) uri << "&#{endpoint[:detail_id]}=#{id_of_interest}" uri << "&fromID=#{fromid}" if fromid uri << "&rowCount=#{rowcount}" if rowcount badgerfish_from get_response(uri) else raise "#{endpoint[:path]} not permitted by access mask" end end |
#key_type ⇒ Object
49 50 51 |
# File 'lib/eve_badger/eve_api.rb', line 49 def key_type @key_type ||= get_key_type end |
#key_type=(type) ⇒ Object
41 42 43 |
# File 'lib/eve_badger/eve_api.rb', line 41 def key_type=(type) @key_type = type ? type.to_sym : nil end |