Module: WotApi
- Defined in:
- lib/wot_api/base.rb,
lib/wot_api.rb,
lib/wot_api/version.rb,
lib/wot_api/wot_api.rb,
lib/wot_api/wrapper.rb,
lib/wot_api/exceptions.rb
Overview
WotApi::Base wrapper for WotApi for compatibility, moved all real functionality directly to WotApi module This need never change - any future methods added do not need to be added here
Defined Under Namespace
Classes: Base, ConnectionError, Error, InvalidArguments, InvalidConfigError, InvalidRegionError, ResponseError, Wrapper
Constant Summary collapse
- VERSION =
"1.2.2"
Class Method Summary collapse
-
.clans_accounts(params = {}) ⇒ Object
methods outside of ‘typical’ WoT API calls:.
- .config(params = {}) ⇒ Object
- .method_missing(method_sym, *params, &block) ⇒ Object
- .respond_to?(method_sym, include_private = false) ⇒ Boolean
Class Method Details
.clans_accounts(params = {}) ⇒ Object
methods outside of ‘typical’ WoT API calls:
37 38 39 40 41 |
# File 'lib/wot_api/wot_api.rb', line 37 def self.clans_accounts(params={}) raise WotApi::InvalidArguments, ":clan_id required" unless params[:clan_id] response = WotApi::Wrapper.wot_web_get("/clans/#{params[:clan_id]}/accounts", headers: {"X-Requested-With"=> "XMLHttpRequest"}) JSON.parse(response||"{}")['items'] end |
.config(params = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/wot_api/wot_api.rb', line 5 def self.config(params={}) WotApi::Wrapper.configuration = {} WotApi::Wrapper.default_region = nil params.each do |region, id| region = region.to_sym if WotApi::Wrapper::REGIONS[region] && id WotApi::Wrapper.default_region ||= region WotApi::Wrapper.configuration[region] = id.to_s else raise WotApi::InvalidConfigError, "Region: #{region} or ID: #{id} is invalid" end end end |
.method_missing(method_sym, *params, &block) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/wot_api/wot_api.rb', line 19 def self.method_missing(method_sym, *params, &block) if WotApi::Wrapper.valid_endpoint?(method_sym) return WotApi::Wrapper.wot_api_post(method_sym, params.first) else super end end |
.respond_to?(method_sym, include_private = false) ⇒ Boolean
27 28 29 30 31 32 33 |
# File 'lib/wot_api/wot_api.rb', line 27 def self.respond_to?(method_sym, include_private = false) if WotApi::Wrapper.valid_endpoint?(method_sym) return true else super end end |