Skip to content

Commit f1356ca

Browse files
committed
Reorganize requests
Reorganizes requests to follow the ordering of the XIVAPI docs. Also adds the `columns` parameter that was missing from character search.
1 parent eb12fde commit f1356ca

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

lib/xivapi/request.rb

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,38 @@ module XIVAPI::Request
44
LODESTONE_LIMIT = 50.freeze
55
ALL_CHARACTER_DATA = 'AC,FR,FC,FCM,PVP'.freeze
66

7+
# Search
78
def search(indexes: [], string: '', string_column: 'Name_en', string_algo: 'wildcard_plus',
89
sort_field: nil, sort_order: nil, limit: 100, filters: [], columns: [])
910
params = { indexes: [*indexes].join(','), string: string, string_column: string_column, string_algo: string_algo,
1011
sort_field: sort_field, sort_order: sort_order, filters: [*filters].join(','), columns: [*columns].join(',') }
1112
XIVAPI::Paginator.new(self, params, 'search', limit)
1213
end
1314

15+
# Content
16+
def content(name: nil, ids: [], limit: 100, columns: [])
17+
if name.nil?
18+
request(self, 'content')
19+
elsif [*ids].size == 1
20+
request("#{name.capitalize}/#{[*ids].first}")
21+
else
22+
params = { ids: [*ids].join(','), columns: [*columns].join(',') }
23+
XIVAPI::Paginator.new(self, params, name.capitalize, limit)
24+
end
25+
end
26+
27+
def servers
28+
request(self, 'servers')
29+
end
30+
31+
# Character
1432
def character(id: nil, all_data: false, poll: false, columns: [])
1533
params = { data: all_data ? ALL_CHARACTER_DATA : nil, columns: [*columns].join(',') }
1634
request_cached(self, "character/#{id}", :character, params, poll)
1735
end
1836

19-
def character_search(name: nil, server: nil)
20-
params = { name: name, server: server&.capitalize }
37+
def character_search(name: nil, server: nil, columns: [])
38+
params = { name: name, server: server&.capitalize, columns: [*columns].join(',') }
2139
XIVAPI::Paginator.new(self, params, 'character/search', LODESTONE_LIMIT)
2240
end
2341

@@ -33,19 +51,4 @@ def character_update(id: nil)
3351
def character_verified?(id: nil)
3452
request(self, "character/#{id}/verification").verification_token_pass
3553
end
36-
37-
def content(name: nil, ids: [], limit: 100, columns: [])
38-
if name.nil?
39-
request(self, 'content')
40-
elsif [*ids].size == 1
41-
request("#{name.capitalize}/#{[*ids].first}")
42-
else
43-
params = { ids: [*ids].join(','), columns: [*columns].join(',') }
44-
XIVAPI::Paginator.new(self, params, name.capitalize, limit)
45-
end
46-
end
47-
48-
def servers
49-
request(self, 'servers')
50-
end
5154
end

0 commit comments

Comments
 (0)