Class: Wot::Api
- Inherits:
-
Object
- Object
- Wot::Api
- Defined in:
- lib/wot/api.rb,
lib/wot/api/error.rb,
lib/wot/api/version.rb,
lib/wot/api/clusters.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
"1.1.0"
- CLUSTERS =
{ "RU" => { :base_url => "http://api.worldoftanks.ru", :application_id => "171745d21f7f98fd8878771da1000a31" }, "EU" => { :base_url => "api.worldoftanks.eu", :application_id => "d0a293dc77667c9328783d489c8cef73" }, "NA" => { :base_url => "http://api.worldoftanks.com", :application_id => "16924c431c705523aae25b6f638c54dd" }, "ASIA" => { :base_url => "http://api.worldoftanks.asia", :application_id => "39b4939f5f2460b3285bfa708e4b252c" }, "KR" => { :base_url => "http://api.worldoftanks.kr", :application_id => "ffea0f1c3c5f770db09357d94fe6abfb" } }
Class Method Summary collapse
Instance Method Summary collapse
- #achievements_list ⇒ Object
- #engines_list ⇒ Object
- #find(account_ids, options = {}) ⇒ Object
- #guns_list ⇒ Object
-
#initialize(region, language = 'en') ⇒ Api
constructor
A new instance of Api.
- #make_request(suffix, parameters) ⇒ Object
- #player_achievements(account_id) ⇒ Object
- #player_raitings(account_id) ⇒ Object
- #player_stats(account_id, hours_ago) ⇒ Object
- #player_tanks(account_id) ⇒ Object
- #players_info(account_ids) ⇒ Object
- #radios_list ⇒ Object
- #search(username, options = {}) ⇒ Object
- #suspensions_list ⇒ Object
- #tank_info(tank_id) ⇒ Object
- #tanks_list ⇒ Object
- #turrets_list ⇒ Object
Constructor Details
Class Method Details
.cluster(region) ⇒ Object
26 27 28 29 30 |
# File 'lib/wot/api/clusters.rb', line 26 def self.cluster(region) cluster = CLUSTERS[region.to_s] fail "Region '#{region}' not found!" if cluster.nil? return cluster end |
.version ⇒ Object
5 6 7 |
# File 'lib/wot/api/version.rb', line 5 def self.version return VERSION end |
Instance Method Details
#achievements_list ⇒ Object
56 57 58 |
# File 'lib/wot/api.rb', line 56 def achievements_list() raise NotImplementedError end |
#engines_list ⇒ Object
60 61 62 |
# File 'lib/wot/api.rb', line 60 def engines_list() raise NotImplementedError end |
#find(account_ids, options = {}) ⇒ Object
23 24 25 |
# File 'lib/wot/api.rb', line 23 def find(account_ids, = {}) return Wot::Player.find self, account_ids, end |
#guns_list ⇒ Object
64 65 66 |
# File 'lib/wot/api.rb', line 64 def guns_list() raise NotImplementedError end |
#make_request(suffix, parameters) ⇒ Object
80 81 82 83 84 85 86 87 88 |
# File 'lib/wot/api.rb', line 80 def make_request(suffix,parameters) params = {:params => parameters.dup} params[:params][:application_id] = @app_id params[:params][:language] = @language response = JSON.parse(RestClient.get("#{@base_url}/2.0/#{suffix}", params)) response = response.nested_under_indifferent_access raise Wot::Api::Error.new(response[:error]) if response[:status].downcase == "error" return response end |
#player_achievements(account_id) ⇒ Object
36 37 38 |
# File 'lib/wot/api.rb', line 36 def player_achievements(account_id) return make_request "account/achievements/", {:account_id => account_id} end |
#player_raitings(account_id) ⇒ Object
44 45 46 |
# File 'lib/wot/api.rb', line 44 def player_raitings(account_id) return make_request "account/raitings/", {:account_id => account_id} end |
#player_stats(account_id, hours_ago) ⇒ Object
40 41 42 |
# File 'lib/wot/api.rb', line 40 def player_stats(account_id,hours_ago) return make_request "stats/accountbytime/", {:account_id => account_id, :hours_ago => hours_ago} end |
#player_tanks(account_id) ⇒ Object
32 33 34 |
# File 'lib/wot/api.rb', line 32 def player_tanks(account_id) return make_request "account/tanks/", {:account_id => account_id} end |
#players_info(account_ids) ⇒ Object
27 28 29 30 |
# File 'lib/wot/api.rb', line 27 def players_info(account_ids) ids = (account_ids.class == Array ? account_ids : [account_ids]) return make_request "account/info/", {:account_id => ids.join(",")} end |
#radios_list ⇒ Object
68 69 70 |
# File 'lib/wot/api.rb', line 68 def radios_list() raise NotImplementedError end |
#search(username, options = {}) ⇒ Object
19 20 21 |
# File 'lib/wot/api.rb', line 19 def search(username, = {}) return Wot::Player.search self, username, end |
#suspensions_list ⇒ Object
72 73 74 |
# File 'lib/wot/api.rb', line 72 def suspensions_list() raise NotImplementedError end |
#tank_info(tank_id) ⇒ Object
52 53 54 |
# File 'lib/wot/api.rb', line 52 def tank_info(tank_id) return make_request "encyclopedia/tankinfo/", {:tank_id => tank_id} end |
#tanks_list ⇒ Object
48 49 50 |
# File 'lib/wot/api.rb', line 48 def tanks_list() return make_request "encyclopedia/tanks/", {} end |
#turrets_list ⇒ Object
76 77 78 |
# File 'lib/wot/api.rb', line 76 def turrets_list raise NotImplementedError end |