Class: EveOnline::ESI::Resources::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/eve_online/esi/resources/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Resource

Returns a new instance of Resource.

Parameters:



10
11
12
13
# File 'lib/eve_online/esi/resources/resource.rb', line 10

def initialize(client)
  @client = client
  @response = nil
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



7
8
9
# File 'lib/eve_online/esi/resources/resource.rb', line 7

def client
  @client
end

Instance Method Details

#compatibility_dateObject



42
43
# File 'lib/eve_online/esi/resources/resource.rb', line 42

def compatibility_date
end

#default_headersObject



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/eve_online/esi/resources/resource.rb', line 29

def default_headers
  h = {}

  # h = h.merge(Authorization: token) if defined?(token)
  h["User-Agent"] = user_agent
  h["Accept"] = "application/json"
  h["Accept-Language"] = client.language
  h["X-Tenant"] = client.tenant
  h["X-Compatibility-Date"] = compatibility_date if compatibility_date

  h
end

#get_request(url, params: {}, headers: {}) ⇒ Object

Parameters:

  • url (String)

    URL to get

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


18
19
20
# File 'lib/eve_online/esi/resources/resource.rb', line 18

def get_request(url, params: {}, headers: {})
  client.connection.get(url, params, default_headers.merge(headers))
end

#post_request(url, params: {}, headers: {}) ⇒ Object

Parameters:

  • url (String)

    URL to post

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


25
26
27
# File 'lib/eve_online/esi/resources/resource.rb', line 25

def post_request(url, params: {}, headers: {})
  client.connection.post(url, params, default_headers.merge(headers))
end

#user_agentObject



45
46
47
# File 'lib/eve_online/esi/resources/resource.rb', line 45

def user_agent
  "EveOnline API (https://github.com/evemonk/eve_online) v#{VERSION}"
end