Module: XIVAPI::Request
Overview
Collection of requests that can be made to XIVAPI
Constant Summary collapse
- LODESTONE_LIMIT =
The results limit applied to Lodestone requests
50.freeze
- ALL_CHARACTER_DATA =
Options used to retrieve all data when querying a character
'AC,MIMO,CJ,FR,FC,FCM,PVP'.freeze
Constants included from HTTP
HTTP::API_BASE, HTTP::STAGING_API_BASE
Instance Method Summary collapse
-
#character(id: nil, all_data: false, extended: false, data: [], columns: []) ⇒ OpenStruct
The requested character.
-
#character_search(name: nil, server: nil, columns: []) ⇒ XIVAPI::Paginator
Enumerable search results.
-
#character_verified?(id: nil, token: nil) ⇒ true, false
Whether or not the character is verified.
-
#content(name: nil, ids: [], minify: false, limit: 100, columns: []) ⇒ Array<String>, ...
Calling with no parameters will return the list of content names Calling with a name and a single ID will return that specific content Calling with a name and not a singe ID will return enumerable results.
-
#free_company(id: nil, members: false, columns: []) ⇒ OpenStruct
The requested free company.
-
#free_company_search(name: nil, server: nil, columns: []) ⇒ XIVAPI::Paginator
Enumerable search results.
-
#linkshell(id: nil, columns: []) ⇒ OpenStruct
The requested linkshell.
-
#linkshell_search(name: nil, server: nil, columns: []) ⇒ XIVAPI::Paginator
Enumerable search results.
-
#lore(string: '', limit: 100) ⇒ XIVAPI::Paginator
Enumerable lore results.
-
#patch_list ⇒ Array<OpenStruct>
List of game patches.
-
#pvp_team(id: nil, columns: []) ⇒ OpenStruct
The requested PVP team.
-
#pvp_team_search(name: nil, server: nil, columns: []) ⇒ XIVAPI::Paginator
Enumerable search results.
-
#search(indexes: [], string: '', string_column: nil, string_algo: nil, sort_field: nil, sort_order: nil, limit: 100, body: nil, filters: [], columns: []) ⇒ XIVAPI::Paginator
Enumerable search results.
-
#servers(group: false) ⇒ Array<String>
List of servers.
Methods included from HTTP
Instance Method Details
#character(id: nil, all_data: false, extended: false, data: [], columns: []) ⇒ OpenStruct
Returns The requested character
70 71 72 73 74 |
# File 'lib/xivapi/request.rb', line 70 def character(id: nil, all_data: false, extended: false, data: [], columns: []) params = { data: character_data(all_data, data), columns: [*columns].join(',') } params[:extended] = 1 if extended request(self, "character/#{id}", params) end |
#character_search(name: nil, server: nil, columns: []) ⇒ XIVAPI::Paginator
Returns Enumerable search results
80 81 82 83 |
# File 'lib/xivapi/request.rb', line 80 def character_search(name: nil, server: nil, columns: []) params = { name: name, server: server, columns: [*columns].join(',') } XIVAPI::Paginator.new(self, params, 'character/search', LODESTONE_LIMIT) end |
#character_verified?(id: nil, token: nil) ⇒ true, false
Returns Whether or not the character is verified
88 89 90 |
# File 'lib/xivapi/request.rb', line 88 def character_verified?(id: nil, token: nil) character(id: id, columns: 'Character.Bio').character.bio.match?(token) end |
#content(name: nil, ids: [], minify: false, limit: 100, columns: []) ⇒ Array<String>, ...
Returns Calling with no parameters will return the list of content names Calling with a name and a single ID will return that specific content Calling with a name and not a singe ID will return enumerable results
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/xivapi/request.rb', line 45 def content(name: nil, ids: [], minify: false, limit: 100, columns: []) if name.nil? request(self, 'content') elsif [*ids].size == 1 params = { minify: minify ? 1 : 0, columns: [*columns].join(',') } request(self, "#{name}/#{[*ids].first}", params) else params = { ids: [*ids].join(','), columns: [*columns].join(',') } XIVAPI::Paginator.new(self, params, name, limit) end end |
#free_company(id: nil, members: false, columns: []) ⇒ OpenStruct
Returns The requested free company
96 97 98 99 |
# File 'lib/xivapi/request.rb', line 96 def free_company(id: nil, members: false, columns: []) params = { data: members ? 'FCM' : nil, columns: [*columns].join(',') } request(self, "freecompany/#{id}", params) end |
#free_company_search(name: nil, server: nil, columns: []) ⇒ XIVAPI::Paginator
Returns Enumerable search results
105 106 107 108 |
# File 'lib/xivapi/request.rb', line 105 def free_company_search(name: nil, server: nil, columns: []) params = { name: name, server: server, columns: [*columns].join(',') } XIVAPI::Paginator.new(self, params, 'freecompany/search', LODESTONE_LIMIT) end |
#linkshell(id: nil, columns: []) ⇒ OpenStruct
Returns The requested linkshell
113 114 115 116 |
# File 'lib/xivapi/request.rb', line 113 def linkshell(id: nil, columns: []) params = { columns: [*columns].join(',') } request(self, "linkshell/#{id}", params) end |
#linkshell_search(name: nil, server: nil, columns: []) ⇒ XIVAPI::Paginator
Returns Enumerable search results
122 123 124 125 |
# File 'lib/xivapi/request.rb', line 122 def linkshell_search(name: nil, server: nil, columns: []) params = { name: name, server: server, columns: [*columns].join(',') } XIVAPI::Paginator.new(self, params, 'linkshell/search', LODESTONE_LIMIT) end |
#lore(string: '', limit: 100) ⇒ XIVAPI::Paginator
Returns Enumerable lore results
32 33 34 |
# File 'lib/xivapi/request.rb', line 32 def lore(string: '', limit: 100) XIVAPI::Paginator.new(self, { string: string }, 'lore', limit) end |
#patch_list ⇒ Array<OpenStruct>
Returns List of game patches
145 146 147 |
# File 'lib/xivapi/request.rb', line 145 def patch_list request(self, 'patchlist') end |
#pvp_team(id: nil, columns: []) ⇒ OpenStruct
Returns The requested PVP team
130 131 132 133 |
# File 'lib/xivapi/request.rb', line 130 def pvp_team(id: nil, columns: []) params = { columns: [*columns].join(',') } request(self, "pvpteam/#{id}", params) end |
#pvp_team_search(name: nil, server: nil, columns: []) ⇒ XIVAPI::Paginator
Returns Enumerable search results
139 140 141 142 |
# File 'lib/xivapi/request.rb', line 139 def pvp_team_search(name: nil, server: nil, columns: []) params = { name: name, server: server, columns: [*columns].join(',') } XIVAPI::Paginator.new(self, params, 'pvpteam/search', LODESTONE_LIMIT) end |
#search(indexes: [], string: '', string_column: nil, string_algo: nil, sort_field: nil, sort_order: nil, limit: 100, body: nil, filters: [], columns: []) ⇒ XIVAPI::Paginator
Returns Enumerable search results
22 23 24 25 26 27 |
# File 'lib/xivapi/request.rb', line 22 def search(indexes: [], string: '', string_column: nil, string_algo: nil, sort_field: nil, sort_order: nil, limit: 100, body: nil, filters: [], columns: []) params = { indexes: [*indexes].join(','), string: string, string_column: string_column, string_algo: string_algo, sort_field: sort_field, sort_order: sort_order, filters: [*filters].join(','), columns: [*columns].join(',') } XIVAPI::Paginator.new(self, params, 'search', limit, body) end |
#servers(group: false) ⇒ Array<String>
Returns List of servers
59 60 61 62 |
# File 'lib/xivapi/request.rb', line 59 def servers(group: false) endpoint = group ? 'servers/dc' : 'servers' request(self, endpoint) end |