class Clashinator::Location
This class represents the location model
Public Class Methods
list_locations(http, options = {})
click to toggle source
# File lib/clashinator/location.rb, line 8 def self.list_locations(http, options = {}) new_options = prepare_options(options) response = http.get('/v1/locations', new_options) parsed = JSON.parse(response.body) if response.success? return Clashinator::ArrayResource.new( Clashinator::Location, parsed['items'], parsed['paging'] ) end raise parsed['message'] unless response.success? end
location_clan_rankings(http, location_id, options = {})
click to toggle source
# File lib/clashinator/location.rb, line 29 def self.location_clan_rankings(http, location_id, options = {}) new_options = prepare_options(options) response = http.get("/v1/locations/#{location_id}/rankings/clans", new_options) parsed = JSON.parse(response.body) if response.success? return Clashinator::ArrayResource.new( Clashinator::ClanRanking, parsed['items'], parsed['paging'] ) end raise parsed['reason'] unless response.success? end
location_info(http, location_id)
click to toggle source
# File lib/clashinator/location.rb, line 21 def self.location_info(http, location_id) response = http.get("/v1/locations/#{location_id}") parsed = JSON.parse(response.body) return new(parsed) if response.success? raise parsed['message'] unless response.success? end
location_player_rankings(http, location_id, options = {})
click to toggle source
# File lib/clashinator/location.rb, line 42 def self.location_player_rankings(http, location_id, options = {}) response = http.get( "/v1/locations/#{location_id}/rankings/players", prepare_options(options) ) parsed = JSON.parse(response.body) return Clashinator::ArrayResource.new( Clashinator::PlayerRanking, parsed['items'], parsed['paging'] ) if response.success? raise parsed['reason'] unless response.success? end
new(attrs)
click to toggle source
Calls superclass method
Clashinator::Base::new
# File lib/clashinator/location.rb, line 4 def initialize(attrs) super(attrs) end