Skip to content

Commit c6d1458

Browse files
committed
Remove Lodestone cache, market methods
All Lodestone data is served in realtime, removing the Info hash as well as the need for polling. All previously cached Lodestone requests are now treated as regular requests. Custom Lodestone errors have been removed. Market methods have been removed since the endpoint no longer exists.
1 parent 863ea72 commit c6d1458

File tree

7 files changed

+15
-141
lines changed

7 files changed

+15
-141
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
xivapi (0.2.5)
4+
xivapi (0.3.0)
55
rest-client (~> 2.0.2)
66

77
GEM

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ A Ruby library for [XIVAPI](https://www.xivapi.com/).
77
Add this line to your application's Gemfile:
88

99
```ruby
10-
gem 'xivapi', git: 'https://github.com/xivapi/xivapi-ruby.git', tag: 'v0.2.5'
10+
gem 'xivapi', git: 'https://github.com/xivapi/xivapi-ruby.git', tag: 'v0.3.0'
1111
```
1212

1313
And then run:
@@ -31,7 +31,7 @@ require 'xivapi'
3131
client = XIVAPI::Client.new(api_key: 'abc123')
3232

3333
# Advanced configuration
34-
client = XIVAPI::Client.new(api_key: 'abc123', language: 'en', poll_rate: 5)
34+
client = XIVAPI::Client.new(api_key: 'abc123', language: 'fr')
3535
```
3636

3737
Now that you have a client, you can use it to contact the API. Examples have been provided below for the various endpoints. For the full list of endpoints and their parameters, please reference the [request documentation](https://xivapi.github.io/xivapi-ruby/XIVAPI/Request.html).
@@ -108,7 +108,7 @@ See the examples below to get a better idea of how to access the data.
108108
=> ...
109109
>> id = linkshells.first.id
110110
=> "21955048183495181"
111-
>> linkshell = client.linkshell(id: id, poll: true).linkshell
111+
>> linkshell = client.linkshell(id: id).linkshell
112112
=> ...
113113
>> linkshell.name
114114
=> "Thunderbirds"

lib/xivapi.rb

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@ class Client
3030
# Initializes a new client for querying XIVAPI
3131
# @param api_key [String] API key provided by XIVAPI
3232
# @param language [String] Requested response langauge
33-
# @param poll_rate [Integer] Frequency at which to poll when waiting for data to cache
3433
# @param staging [true, false] Whether or not to query the staging API instead of production
35-
def initialize(api_key: nil, language: :en, poll_rate: 5, staging: false)
34+
def initialize(api_key: nil, language: :en, staging: false)
3635
@api_key = api_key
3736

3837
self.language = language
39-
self.poll_rate = poll_rate
4038
self.staging = staging
4139
end
4240

@@ -53,18 +51,6 @@ def language=(language)
5351
@language = lang
5452
end
5553

56-
# @return [Integer] The rate at which cached requests are polled
57-
def poll_rate
58-
@poll_rate
59-
end
60-
61-
# @param rate [Integer] The rate at which to poll cached requests
62-
# @return [Integer] The poll rate
63-
def poll_rate=(rate)
64-
raise ArgumentError, 'Poll rate must be a positive integer' unless rate.is_a?(Integer) && rate > 0
65-
@poll_rate = rate
66-
end
67-
6854
# @return [Hash] The default parameters for the client
6955
def default_params
7056
{ private_key: @api_key, language: @language }

lib/xivapi/errors.rb

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,5 @@ def initialize
2020
super('Too many requests.')
2121
end
2222
end
23-
24-
# Content not available
25-
class ContentNotAvailable < StandardError
26-
def initialize
27-
super('Content is not currently available on XIVAPI.')
28-
end
29-
end
30-
31-
# Content not found
32-
class ContentNotFound < StandardError
33-
def initialize
34-
super('Content does not exist on the Lodestone.')
35-
end
36-
end
37-
38-
# Content blacklisted
39-
class ContentBlacklisted < StandardError
40-
def initialize
41-
super('Content has been blacklisted.')
42-
end
43-
end
44-
45-
# Content private
46-
class ContentPrivate < StandardError
47-
def initialize
48-
super('Content is private.')
49-
end
50-
end
5123
end
5224
end

lib/xivapi/http.rb

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -39,44 +39,6 @@ def request(client, endpoint, params = {}, payload = nil)
3939
end
4040
end
4141

42-
# Makes a request to XIVAPI for cached data. This is data that must be cached
43-
# by XIVAPI before it can be served. This method should be used over the standard
44-
# request in order to properly throw custom errors and enable polling. Polling
45-
# will continuously call the API until the data is cached and returned.
46-
#
47-
# @param client [XIVAPI::Client] The client making the request
48-
# @param endpoint [String, Symbol] The endpoint to request
49-
# @param key [String, Symbol] The results key that stores the cached data
50-
# @param params [Hash] Request parameters
51-
# @param poll [true, false] Whether or not to poll XIVAPI until data is returned
52-
# @return the results of the request
53-
def request_cached(client, endpoint, key, params = {}, poll = false)
54-
columns = params[:columns]
55-
unless columns.empty? || columns.match?('Info')
56-
params[:columns] = columns.split(',').push('Info').join(',')
57-
end
58-
59-
response = request(client, endpoint, params)
60-
61-
case(response.info[key].state)
62-
when 0
63-
raise XIVAPI::ContentNotAvailable
64-
when 1
65-
if poll
66-
sleep(client.poll_rate)
67-
response = request_cached(client, endpoint, key, params, poll)
68-
end
69-
when 3
70-
raise XIVAPI::ContentNotFound
71-
when 4
72-
raise XIVAPI::ContentBlacklisted
73-
when 5
74-
raise XIVAPI::ContentPrivate
75-
end
76-
77-
response
78-
end
79-
8042
private
8143
def request_url(client, endpoint)
8244
"#{client.staging ? STAGING_API_BASE : API_BASE}/#{endpoint}"

lib/xivapi/request.rb

Lines changed: 9 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -61,51 +61,14 @@ def servers(group: false)
6161
request(self, endpoint)
6262
end
6363

64-
# @param ids [Integer, Array<Integer>] ID(s) of the item(s) to look up
65-
# @param servers [String, Array<String>] Server(s) to retrieve the market for
66-
# @param data_center [String] Data center to retrieve the market for
67-
# @param max_history [Integer] The maximum amount of history to retrieve
68-
# @param columns [String, Array <String>] One or more columns to limit results to
69-
# @return [OpenStruct] Market price results
70-
def market(ids: [], servers: [], data_center: nil, max_history: nil, columns: [])
71-
ids, server_names = [*ids], [*servers]
72-
params = { max_history: max_history, columns: [*columns].join(',') }
73-
74-
if ids.size > 1
75-
params.merge!(ids: ids.join(','), dc: data_center, servers: server_names.join(','))
76-
request(self, 'market/items', params)
77-
elsif data_center || server_names.size > 1 || server_names[0].match?(',')
78-
params.merge!(dc: data_center, servers: server_names.join(','))
79-
request(self, "market/item/#{ids.first}", params)
80-
else
81-
request(self, "market/#{server_names.first}/item/#{ids.first}", params)
82-
end
83-
end
84-
85-
# @return [Array<OpenStruct>] List of Market categories
86-
def market_categories
87-
request(self, 'market/categories')
88-
end
89-
9064
# @param id [Integer] Character ID
9165
# @param all_data [true, false] Return the full set of character data
92-
# @param poll [true, false] Continuously call the API until a result is cached and returned
9366
# @param data [String, Array <String>] Additional data to request, see: https://xivapi.com/docs/Character#character
9467
# @param columns [String, Array <String>] One or more columns to limit results to
9568
# @return [OpenStruct] The requested character
96-
def character(id: nil, all_data: false, poll: false, data: [], columns: [])
69+
def character(id: nil, all_data: false, data: [], columns: [])
9770
params = { data: character_data(all_data, data), columns: [*columns].join(',') }
98-
request_cached(self, "character/#{id}", :character, params, poll)
99-
end
100-
101-
# @param ids [String, Array<Integer>] Character IDs
102-
# @param all_data [true, false] Return the full set of character data
103-
# @param data [String, Array <String>] Additional data to request, see: https://xivapi.com/docs/Character#character
104-
# @param columns [String, Array <String>] One or more columns to limit results to
105-
# @return [Array<OpenStruct>] The requested characters
106-
def characters(ids: nil, all_data: false, data: [], columns: [])
107-
body = { ids: [*ids].join(','), data: character_data(all_data, data), columns: [*columns].join(',') }
108-
request(self, 'characters', {}, body)
71+
request(self, "character/#{id}", params)
10972
end
11073

11174
# @param name [String] Character name
@@ -117,27 +80,20 @@ def character_search(name: nil, server: nil, columns: [])
11780
XIVAPI::Paginator.new(self, params, 'character/search', LODESTONE_LIMIT)
11881
end
11982

120-
# @param id [Integer] Character ID
121-
# @return [true, false] Whether or not the character update was requested successfully
122-
def character_update(id: nil)
123-
request(self, "character/#{id}/update") == 1
124-
end
125-
12683
# @param id [Integer] Character ID
12784
# @param token [String] Verification token to check for
12885
# @return [true, false] Whether or not the character is verified
12986
def character_verified?(id: nil, token: nil)
130-
request(self, "character/#{id}/verification", { token: token }).pass
87+
character(id: id, columns: 'Character.Bio').character.bio.match?(token)
13188
end
13289

13390
# @param id [Integer] Free company ID
13491
# @param members [true, false] Return member data
135-
# @param poll [true, false] Continuously call the API until a result is cached and returned
13692
# @param columns [String, Array <String>] One or more columns to limit results to
13793
# @return [OpenStruct] The requested free company
138-
def free_company(id: nil, members: false, poll: false, columns: [])
94+
def free_company(id: nil, members: false, columns: [])
13995
params = { data: members ? 'FCM' : nil, columns: [*columns].join(',') }
140-
request_cached(self, "freecompany/#{id}", :free_company, params, poll)
96+
request(self, "freecompany/#{id}", params)
14197
end
14298

14399
# @param name [String] Free company name
@@ -150,12 +106,11 @@ def free_company_search(name: nil, server: nil, columns: [])
150106
end
151107

152108
# @param id [Integer] Linkshell ID
153-
# @param poll [true, false] Continuously call the API until a result is cached and returned
154109
# @param columns [String, Array <String>] One or more columns to limit results to
155110
# @return [OpenStruct] The requested linkshell
156-
def linkshell(id: nil, poll: false, columns: [])
111+
def linkshell(id: nil, columns: [])
157112
params = { columns: [*columns].join(',') }
158-
request_cached(self, "linkshell/#{id}", :linkshell, params, poll)
113+
request(self, "linkshell/#{id}", params)
159114
end
160115

161116
# @param name [String] Linkshell name
@@ -168,12 +123,11 @@ def linkshell_search(name: nil, server: nil, columns: [])
168123
end
169124

170125
# @param id [Integer] PVP team ID
171-
# @param poll [true, false] Continuously call the API until a result is cached and returned
172126
# @param columns [String, Array <String>] One or more columns to limit results to
173127
# @return [OpenStruct] The requested PVP team
174-
def pvp_team(id: nil, poll: false, columns: [])
128+
def pvp_team(id: nil, columns: [])
175129
params = { columns: [*columns].join(',') }
176-
request_cached(self, "pvpteam/#{id}", :pvp_team, params, poll)
130+
request(self, "pvpteam/#{id}", params)
177131
end
178132

179133
# @param name [String] PVP team name

lib/xivapi/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module XIVAPI
22
# Gem version
3-
VERSION = "0.2.5"
3+
VERSION = "0.3.0"
44
end

0 commit comments

Comments
 (0)