Class: Esirb::Client
- Inherits:
-
Object
- Object
- Esirb::Client
- Defined in:
- lib/esirb/client.rb
Constant Summary collapse
- BASE_URL =
"https://esi.evetech.net"- DEFAULT_HEADERS =
{ "Accept" => "application/json", "Accept-Language" => "en", "If-Modified-Since" => "", "If-None-Match" => "", "X-Tenant" => "tranquility", "X-Compatibility-Date" => "2026-06-09" }
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#cache_store ⇒ Object
readonly
Returns the value of attribute cache_store.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#raise_errors ⇒ Object
readonly
Returns the value of attribute raise_errors.
-
#tenant ⇒ Object
readonly
Returns the value of attribute tenant.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(token: nil, tenant: "tranquility", language: "en", cache: true, cache_store: nil, raise_errors: true) ⇒ Client
constructor
A new instance of Client.
- #method_missing(m, *args, &block) ⇒ Object
Constructor Details
#initialize(token: nil, tenant: "tranquility", language: "en", cache: true, cache_store: nil, raise_errors: true) ⇒ Client
Returns a new instance of Client.
20 21 22 23 24 25 26 27 |
# File 'lib/esirb/client.rb', line 20 def initialize(token: nil, tenant: "tranquility", language: "en", cache: true, cache_store: nil, raise_errors: true) @token = token @tenant = tenant @language = language @cache = cache @cache_store = cache_store @raise_errors = raise_errors end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
18 19 20 |
# File 'lib/esirb/client.rb', line 18 def cache @cache end |
#cache_store ⇒ Object (readonly)
Returns the value of attribute cache_store.
18 19 20 |
# File 'lib/esirb/client.rb', line 18 def cache_store @cache_store end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
18 19 20 |
# File 'lib/esirb/client.rb', line 18 def language @language end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
18 19 20 |
# File 'lib/esirb/client.rb', line 18 def path @path end |
#raise_errors ⇒ Object (readonly)
Returns the value of attribute raise_errors.
18 19 20 |
# File 'lib/esirb/client.rb', line 18 def raise_errors @raise_errors end |
#tenant ⇒ Object (readonly)
Returns the value of attribute tenant.
18 19 20 |
# File 'lib/esirb/client.rb', line 18 def tenant @tenant end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
18 19 20 |
# File 'lib/esirb/client.rb', line 18 def token @token end |
Instance Method Details
#connection ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/esirb/client.rb', line 29 def connection @connection ||= Faraday.new(BASE_URL) do |c| c.request :authorization, "Bearer", token if token if cache c.use :http_cache, store: cache_store, strategy: Faraday::HttpCache::Strategies::ByUrl, serializer: Marshal end c.request :json c.headers = DEFAULT_HEADERS c.response :raise_error if raise_errors c.response :json, content_type: "application/json" end end |