Class: XIVAPI::Client
Overview
Client for making requests to XIVAPI
Constant Summary
Constants included from Request
Request::ALL_CHARACTER_DATA, Request::LODESTONE_LIMIT
Constants included from HTTP
HTTP::API_BASE, HTTP::STAGING_API_BASE
Instance Attribute Summary collapse
-
#api_key ⇒ String
The API key.
-
#staging ⇒ true, false
Whether or not to query the staging API instead of production.
Instance Method Summary collapse
-
#default_params ⇒ Hash
The default parameters for the client.
-
#initialize(api_key: nil, language: :en, staging: false) ⇒ Client
constructor
Initializes a new client for querying XIVAPI.
-
#language ⇒ String
The language.
-
#language=(language) ⇒ Object
The language.
Methods included from Request
#character, #character_search, #character_verified?, #content, #free_company, #free_company_search, #linkshell, #linkshell_search, #lore, #patch_list, #pvp_team, #pvp_team_search, #search, #servers
Methods included from HTTP
Constructor Details
#initialize(api_key: nil, language: :en, staging: false) ⇒ Client
Initializes a new client for querying XIVAPI
34 35 36 37 38 39 |
# File 'lib/xivapi.rb', line 34 def initialize(api_key: nil, language: :en, staging: false) @api_key = api_key self.language = language self.staging = staging end |
Instance Attribute Details
#api_key ⇒ String
Returns The API key
25 26 27 |
# File 'lib/xivapi.rb', line 25 def api_key @api_key end |
#staging ⇒ true, false
Returns Whether or not to query the staging API instead of production
28 29 30 |
# File 'lib/xivapi.rb', line 28 def staging @staging end |
Instance Method Details
#default_params ⇒ Hash
Returns The default parameters for the client
55 56 57 |
# File 'lib/xivapi.rb', line 55 def default_params { private_key: @api_key, language: @language } end |
#language ⇒ String
Returns The language
42 43 44 |
# File 'lib/xivapi.rb', line 42 def language @language end |
#language=(language) ⇒ Object
Returns The language
48 49 50 51 52 |
# File 'lib/xivapi.rb', line 48 def language=(language) lang = language.to_s.downcase raise ArgumentError, 'Unsupported language' unless LANGUAGE_OPTIONS.include?(lang) @language = lang end |