clash_of_clans_api 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/clash_of_clans_api/api.rb +17 -17
- data/lib/clash_of_clans_api/client.rb +28 -15
- data/lib/clash_of_clans_api/endpoint_methods.rb +10 -11
- data/lib/clash_of_clans_api/models/achievement.rb +15 -0
- data/lib/clash_of_clans_api/models/base.rb +32 -11
- data/lib/clash_of_clans_api/models/clan.rb +32 -0
- data/lib/clash_of_clans_api/models/hero.rb +12 -0
- data/lib/clash_of_clans_api/models/label.rb +12 -0
- data/lib/clash_of_clans_api/models/league.rb +1 -1
- data/lib/clash_of_clans_api/models/legend_season.rb +11 -0
- data/lib/clash_of_clans_api/models/legend_statistics.rb +13 -0
- data/lib/clash_of_clans_api/models/paginated_response.rb +18 -0
- data/lib/clash_of_clans_api/models/player.rb +43 -0
- data/lib/clash_of_clans_api/models/spell.rb +12 -0
- data/lib/clash_of_clans_api/models/token.rb +1 -7
- data/lib/clash_of_clans_api/models/troop.rb +13 -0
- data/lib/clash_of_clans_api/no_success_error.rb +2 -0
- data/lib/clash_of_clans_api/token_client.rb +2 -2
- data/lib/clash_of_clans_api/utils.rb +2 -2
- data/lib/clash_of_clans_api/version.rb +1 -1
- metadata +14 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17f2ed1ae9f529afa9f24bb6ee50bc3f35b70fb420bd972b22feedcf5df185da
|
4
|
+
data.tar.gz: 464de1457dd80505922d87511956aa4db139bf42ac51bea7a73d17d9f9572423
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 249a37b6c0fa133af87ef742a7f23ede23fc85264a898f5c32672ff6be0c1099f00d6471a776eca315e09fbeb2ec7e248d466954bdc0cc1cdb03034bc41f7064
|
7
|
+
data.tar.gz: da0f8eca3f5482d89f091eb033f28de91d23f42c031ef5420b328c42dc02ae1cf859e744554c66d8695c0dc89f2454010bce1d7843561b3b8ab6a4a6dec017ed
|
@@ -24,30 +24,30 @@ module ClashOfClansApi
|
|
24
24
|
}
|
25
25
|
end
|
26
26
|
|
27
|
-
define_endpoint :clan_currentwar_leaguegroup, method: :get, endpoint: proc { |clan_tag | "clans/#{Utils.url_escape(clan_tag)}/currentwar/leaguegroup"
|
28
|
-
define_endpoint :clanwarleagues_war, method: :get, endpoint: proc { | war_tag | "clanwarleagues/wars/#{Utils.url_escape(war_tag)}"
|
29
|
-
define_endpoint :clan_warlog, method: :get, endpoint: proc { |clan_tag | "clans/#{Utils.url_escape(clan_tag)}/warlog"
|
30
|
-
define_endpoint :clans, method: :get, endpoint:
|
31
|
-
define_endpoint :clan_currentwar, method: :get, endpoint: proc { |clan_tag | "clans/#{Utils.url_escape(clan_tag)}/currentwar"
|
32
|
-
define_endpoint :clan, method: :get, endpoint: proc { |clan_tag | "clans/#{Utils.url_escape(clan_tag)}"
|
33
|
-
define_endpoint :clan_members, method: :get, endpoint: proc { |clan_tag | "clans/#{Utils.url_escape(clan_tag)}/members"
|
27
|
+
define_endpoint :clan_currentwar_leaguegroup, method: :get, endpoint: proc { |clan_tag | "clans/#{Utils.url_escape(clan_tag)}/currentwar/leaguegroup" }
|
28
|
+
define_endpoint :clanwarleagues_war, method: :get, endpoint: proc { | war_tag | "clanwarleagues/wars/#{Utils.url_escape(war_tag)}" }
|
29
|
+
define_endpoint :clan_warlog, method: :get, endpoint: proc { |clan_tag | "clans/#{Utils.url_escape(clan_tag)}/warlog" }
|
30
|
+
define_endpoint :clans, method: :get, endpoint: 'clans'
|
31
|
+
define_endpoint :clan_currentwar, method: :get, endpoint: proc { |clan_tag | "clans/#{Utils.url_escape(clan_tag)}/currentwar" }
|
32
|
+
define_endpoint :clan, method: :get, endpoint: proc { |clan_tag | "clans/#{Utils.url_escape(clan_tag)}" }
|
33
|
+
define_endpoint :clan_members, method: :get, endpoint: proc { |clan_tag | "clans/#{Utils.url_escape(clan_tag)}/members" }
|
34
34
|
|
35
|
-
define_endpoint :player, method: :get, endpoint: proc { |player_tag | "players/#{Utils.url_escape(player_tag)}"
|
36
|
-
define_endpoint :player_verifytoken, method: :post, endpoint: proc { |player_tag | "players/#{Utils.url_escape(player_tag)}/verifytoken"
|
35
|
+
define_endpoint :player, method: :get, endpoint: proc { |player_tag | "players/#{Utils.url_escape(player_tag)}" }
|
36
|
+
define_endpoint :player_verifytoken, method: :post, endpoint: proc { |player_tag | "players/#{Utils.url_escape(player_tag)}/verifytoken" }, body: proc { |token:| %Q({"token":"#{token}"}) }
|
37
37
|
|
38
38
|
define_endpoint :leagues, method: :get, endpoint: 'leagues'
|
39
39
|
define_endpoint :league_season, method: :get, endpoint: proc { | league_id, season_id| "leagues/#{Utils.url_escape( league_id)}/seasons/#{Utils.url_escape(season_id)}" }
|
40
|
-
define_endpoint :league, method: :get, endpoint: proc { | league_id | "leagues/#{Utils.url_escape( league_id)}"
|
41
|
-
define_endpoint :league_seasons, method: :get, endpoint: proc { | league_id | "leagues/#{Utils.url_escape( league_id)}/seasons"
|
42
|
-
define_endpoint :warleague, method: :get, endpoint: proc { |warleague_id | "warleagues/#{Utils.url_escape(warleague_id)}"
|
40
|
+
define_endpoint :league, method: :get, endpoint: proc { | league_id | "leagues/#{Utils.url_escape( league_id)}" }
|
41
|
+
define_endpoint :league_seasons, method: :get, endpoint: proc { | league_id | "leagues/#{Utils.url_escape( league_id)}/seasons" }
|
42
|
+
define_endpoint :warleague, method: :get, endpoint: proc { |warleague_id | "warleagues/#{Utils.url_escape(warleague_id)}" }
|
43
43
|
define_endpoint :warleagues, method: :get, endpoint: 'warleagues'
|
44
44
|
|
45
|
-
define_endpoint :location_rankings_clans, method: :get, endpoint: proc { |location_id | "locations/#{Utils.url_escape(location_id)}/rankings/clans"
|
46
|
-
define_endpoint :location_rankings_players, method: :get, endpoint: proc { |location_id | "locations/#{Utils.url_escape(location_id)}/rankings/players"
|
47
|
-
define_endpoint :location_rankings_clansversus, method: :get, endpoint: proc { |location_id | "locations/#{Utils.url_escape(location_id)}/rankings/clans-versus"
|
48
|
-
define_endpoint :location_rankings_playersversus, method: :get, endpoint: proc { |location_id | "locations/#{Utils.url_escape(location_id)}/rankings/players-versus"
|
45
|
+
define_endpoint :location_rankings_clans, method: :get, endpoint: proc { |location_id | "locations/#{Utils.url_escape(location_id)}/rankings/clans" }
|
46
|
+
define_endpoint :location_rankings_players, method: :get, endpoint: proc { |location_id | "locations/#{Utils.url_escape(location_id)}/rankings/players" }
|
47
|
+
define_endpoint :location_rankings_clansversus, method: :get, endpoint: proc { |location_id | "locations/#{Utils.url_escape(location_id)}/rankings/clans-versus" }
|
48
|
+
define_endpoint :location_rankings_playersversus, method: :get, endpoint: proc { |location_id | "locations/#{Utils.url_escape(location_id)}/rankings/players-versus" }
|
49
49
|
define_endpoint :locations, method: :get, endpoint: 'locations'
|
50
|
-
define_endpoint :location, method: :get, endpoint: proc { |location_id | "locations/#{Utils.url_escape(location_id)}"
|
50
|
+
define_endpoint :location, method: :get, endpoint: proc { |location_id | "locations/#{Utils.url_escape(location_id)}" }
|
51
51
|
|
52
52
|
define_endpoint :goldpass_seasons_current, method: :get, endpoint: 'goldpass/seasons/current'
|
53
53
|
|
@@ -1,4 +1,7 @@
|
|
1
1
|
require_relative 'api'
|
2
|
+
require_relative 'models/paginated_response'
|
3
|
+
require_relative 'models/clan'
|
4
|
+
require_relative 'models/player'
|
2
5
|
require_relative 'models/league'
|
3
6
|
|
4
7
|
module ClashOfClansApi
|
@@ -10,7 +13,7 @@ module ClashOfClansApi
|
|
10
13
|
end
|
11
14
|
|
12
15
|
def authorized?
|
13
|
-
api.
|
16
|
+
api.perform_request(:get, 'test').code == '404'
|
14
17
|
end
|
15
18
|
|
16
19
|
def player_verifytoken(player_tag, token)
|
@@ -20,27 +23,37 @@ module ClashOfClansApi
|
|
20
23
|
raise "Sent token #{ token .inspect} but received #{response['token'].inspect}." unless token == response['token']
|
21
24
|
|
22
25
|
case response['status']
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
when 'ok'
|
27
|
+
true
|
28
|
+
when 'invalid'
|
29
|
+
false
|
30
|
+
else
|
31
|
+
raise "Unknown status #{response['status'].inspect}."
|
29
32
|
end
|
30
33
|
end
|
31
34
|
|
35
|
+
def clan(tag)
|
36
|
+
Models::Clan.new(api.clan(tag), self)
|
37
|
+
end
|
38
|
+
|
39
|
+
def clan_members(tag)
|
40
|
+
Models::PaginatedResponse.new(Models::Player, api.clan_members(tag), self)
|
41
|
+
end
|
42
|
+
|
32
43
|
def leagues
|
33
|
-
|
34
|
-
|
35
|
-
raise NotImplementedError, "Found a paging cursor but handling it is not implemented yet." if response['paging']['cursors'].any?
|
36
|
-
|
37
|
-
response['items'].map do |league|
|
38
|
-
Models::League.new(league)
|
39
|
-
end
|
44
|
+
Models::PaginatedResponse.new(Models::League, api.leagues, self)
|
40
45
|
end
|
41
46
|
|
42
47
|
def league(id)
|
43
|
-
Models::League.new(api.league(id))
|
48
|
+
Models::League.new(api.league(id), self)
|
49
|
+
end
|
50
|
+
|
51
|
+
def player(tag)
|
52
|
+
Models::Player.new(api.player(tag), self)
|
53
|
+
end
|
54
|
+
|
55
|
+
def league_season(league_id=29000022, season_id, limit: nil, before: nil, after: nil) # rubocop:disable Style/OptionalArguments
|
56
|
+
Models::PaginatedResponse.new(Models::Player, api.league_season(league_id, season_id, query: {limit: limit, before: before, after: after}.compact), self)
|
44
57
|
end
|
45
58
|
end
|
46
59
|
end
|
@@ -9,17 +9,17 @@ module ClashOfClansApi
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def perform_request(method, api_path, query: nil, body: nil, headers: nil)
|
12
|
-
uri = self.base_uri+api_path
|
12
|
+
uri = self.base_uri + api_path
|
13
13
|
uri.query = URI.encode_www_form(query) if query
|
14
14
|
|
15
|
-
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme=='https') do |http|
|
15
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
16
16
|
case method
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
when :get
|
18
|
+
Net::HTTP::Get
|
19
|
+
when :post
|
20
|
+
Net::HTTP::Post
|
21
|
+
else
|
22
|
+
raise ArgumentError, "Invalid method #{method.inspect}."
|
23
23
|
end.new(uri).tap do |request|
|
24
24
|
endpoint_headers.merge(headers || {}).each do |name, value|
|
25
25
|
request[name] = value
|
@@ -39,11 +39,10 @@ module ClashOfClansApi
|
|
39
39
|
if response.is_a?(Net::HTTPSuccess)
|
40
40
|
JSON.parse(response.body)
|
41
41
|
else
|
42
|
-
raise NoSuccessError
|
42
|
+
raise NoSuccessError, response
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
|
47
46
|
def self.included(klass)
|
48
47
|
klass.extend(ClassMethods)
|
49
48
|
end
|
@@ -54,7 +53,7 @@ module ClashOfClansApi
|
|
54
53
|
uri = endpoint.respond_to?(:call) ? ClashOfClansApi::Utils.call_proc_without_unknown_keywords(endpoint, *args, **kwargs) : endpoint
|
55
54
|
request_body = body .respond_to?(:call) ? ClashOfClansApi::Utils.call_proc_without_unknown_keywords(body, *args, **kwargs) : body
|
56
55
|
|
57
|
-
perform_request(method, uri, body: request_body, query: kwargs.
|
56
|
+
perform_request(method, uri, body: request_body, query: kwargs.key?(:query) ? kwargs.fetch(:query) : nil, headers: kwargs.key?(:headers) ? kwargs.fetch(:headers) : nil).then do |response|
|
58
57
|
if !kwargs.key?(:plain_response) || !kwargs.fetch(:plain_response)
|
59
58
|
transform_response(response)
|
60
59
|
else
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
|
3
|
+
module ClashOfClansApi
|
4
|
+
module Models
|
5
|
+
class Achievement < Base
|
6
|
+
property :name, 'name', required: true
|
7
|
+
property :stars, 'stars', required: true
|
8
|
+
property :value, 'value', required: true
|
9
|
+
property :target, 'target', required: true
|
10
|
+
property :info, 'info', required: true
|
11
|
+
property :completion_info, 'completionInfo', required: true
|
12
|
+
property :village, 'village', required: true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -3,8 +3,11 @@ require_relative 'invalid_data_error'
|
|
3
3
|
module ClashOfClansApi
|
4
4
|
module Models
|
5
5
|
class Base
|
6
|
-
|
7
|
-
|
6
|
+
attr_reader :client
|
7
|
+
|
8
|
+
def initialize(hash, client)
|
9
|
+
@hash = hash
|
10
|
+
@client = client
|
8
11
|
|
9
12
|
validate!
|
10
13
|
end
|
@@ -20,23 +23,41 @@ module ClashOfClansApi
|
|
20
23
|
class << self
|
21
24
|
attr_reader :required_fields
|
22
25
|
|
23
|
-
def property(name, key, type: nil, required: false)
|
26
|
+
def property(name, key, type: nil, required: false, default: nil)
|
24
27
|
define_method(name) do
|
25
|
-
|
28
|
+
type =
|
29
|
+
case type
|
30
|
+
when Symbol
|
31
|
+
send(type)
|
32
|
+
when String
|
33
|
+
self.class.const_get(type)
|
34
|
+
else
|
35
|
+
type
|
36
|
+
end
|
37
|
+
|
38
|
+
if !@hash.key?(key) && !default.nil?
|
39
|
+
default
|
40
|
+
elsif type.nil?
|
26
41
|
self[key]
|
42
|
+
elsif property_cached?(name)
|
43
|
+
property_from_cache(name)
|
27
44
|
else
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
45
|
+
initializer_proc = proc do |item|
|
46
|
+
if type.ancestors.include?(ClashOfClansApi::Models::Base)
|
47
|
+
type.new(item, self.client)
|
48
|
+
else
|
49
|
+
type.new(item)
|
50
|
+
end
|
34
51
|
end
|
52
|
+
|
53
|
+
cache_property(name, self[key].then do |prop|
|
54
|
+
prop.is_a?(Array) ? prop.map(&initializer_proc) : initializer_proc.call(prop)
|
55
|
+
end)
|
35
56
|
end
|
36
57
|
end
|
37
58
|
|
38
59
|
if required
|
39
|
-
@required_fields = (@required_fields || [])+[key]
|
60
|
+
@required_fields = (@required_fields || []) + [key]
|
40
61
|
end
|
41
62
|
end
|
42
63
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
require_relative 'icon_set'
|
3
|
+
require_relative 'label'
|
4
|
+
|
5
|
+
module ClashOfClansApi
|
6
|
+
module Models
|
7
|
+
class Clan < Base
|
8
|
+
property :tag, 'tag', required: true
|
9
|
+
property :name, 'name', required: true
|
10
|
+
property :clan_level, 'clanLevel', required: true
|
11
|
+
property :badge_urls, 'badgeUrls', required: true, type: IconSet
|
12
|
+
property :type, 'type'
|
13
|
+
property :location, 'location'
|
14
|
+
property :clan_points, 'clanPoints'
|
15
|
+
property :clan_versus_points, 'clanVersusPoints'
|
16
|
+
property :required_trophies, 'requiredTrophies'
|
17
|
+
property :war_frequency, 'warFrequency'
|
18
|
+
property :war_win_streak, 'warWinStreak'
|
19
|
+
property :war_wins, 'warWins'
|
20
|
+
property :war_ties, 'warTies'
|
21
|
+
property :war_losses, 'warLosses'
|
22
|
+
property :is_war_log_public, 'isWarLogPublic'
|
23
|
+
property :war_league, 'warLeague'
|
24
|
+
property :members, 'members'
|
25
|
+
property :member_list, 'memberList', type: 'ClashOfClansApi::Models::Player'
|
26
|
+
property :labels, 'labels', type: Label
|
27
|
+
property :chat_language, 'chatLanguage'
|
28
|
+
property :required_versus_trophies, 'requiredVersusTrophies'
|
29
|
+
property :required_townhall_level, 'requiredTownhallLevel'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
|
3
|
+
module ClashOfClansApi
|
4
|
+
module Models
|
5
|
+
class Hero < Base
|
6
|
+
property :name, 'name', required: true
|
7
|
+
property :level, 'level', required: true
|
8
|
+
property :max_level, 'maxLevel', required: true
|
9
|
+
property :village, 'village', required: true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
require_relative 'icon_set'
|
3
|
+
|
4
|
+
module ClashOfClansApi
|
5
|
+
module Models
|
6
|
+
class Label < Base
|
7
|
+
property :id, 'id', required: true
|
8
|
+
property :name, 'name', required: true
|
9
|
+
property :icon_urls, 'iconUrls', required: true, type: IconSet
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
require_relative 'legend_season'
|
3
|
+
|
4
|
+
module ClashOfClansApi
|
5
|
+
module Models
|
6
|
+
class LegendStatistics < Base
|
7
|
+
property :legend_trophies, 'legendTrophies', required: true
|
8
|
+
property :previous_season, 'previousSeason', required: true, type: LegendSeason
|
9
|
+
property :best_season, 'bestSeason', required: true, type: LegendSeason
|
10
|
+
property :current_season, 'currentSeason', required: true, type: LegendSeason
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
|
3
|
+
module ClashOfClansApi
|
4
|
+
module Models
|
5
|
+
class PaginatedResponse < Base
|
6
|
+
attr_accessor :item_type
|
7
|
+
|
8
|
+
property :items, 'items', type: :item_type, required: true
|
9
|
+
property :paging, 'paging'
|
10
|
+
|
11
|
+
def initialize(item_type, hash, client)
|
12
|
+
self.item_type = item_type
|
13
|
+
|
14
|
+
super(hash, client)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
require_relative 'achievement'
|
3
|
+
require_relative 'hero'
|
4
|
+
require_relative 'label'
|
5
|
+
require_relative 'league'
|
6
|
+
require_relative 'legend_statistics'
|
7
|
+
require_relative 'spell'
|
8
|
+
require_relative 'troop'
|
9
|
+
|
10
|
+
module ClashOfClansApi
|
11
|
+
module Models
|
12
|
+
class Player < Base
|
13
|
+
property :tag, 'tag', required: true
|
14
|
+
property :name, 'name', required: true
|
15
|
+
property :town_hall_level, 'townHallLevel'
|
16
|
+
property :town_hall_weapon_level, 'townHallWeaponLevel'
|
17
|
+
property :exp_level, 'expLevel'
|
18
|
+
property :trophies, 'trophies', required: true
|
19
|
+
property :best_trophies, 'bestTrophies'
|
20
|
+
property :war_stars, 'warStars'
|
21
|
+
property :attack_wins, 'attackWins'
|
22
|
+
property :defense_wins, 'defenseWins'
|
23
|
+
property :builder_hall_level, 'builderHallLevel'
|
24
|
+
property :versus_trophies, 'versusTrophies'
|
25
|
+
property :best_versus_trophies, 'bestVersusTrophies'
|
26
|
+
property :versus_battle_wins, 'versusBattleWins'
|
27
|
+
property :role, 'role'
|
28
|
+
property :war_preference, 'warPreference'
|
29
|
+
property :donations, 'donations'
|
30
|
+
property :donations_received, 'donationsReceived'
|
31
|
+
property :rank, 'rank'
|
32
|
+
property :clan, 'clan', type: 'ClashOfClansApi::Models::Clan'
|
33
|
+
property :league, 'league', type: League
|
34
|
+
property :legend_statistics, 'legendStatistics', type: LegendStatistics
|
35
|
+
property :achievements, 'achievements', type: Achievement
|
36
|
+
property :versus_battle_win_count, 'versusBattleWinCount'
|
37
|
+
property :labels, 'labels', type: Label
|
38
|
+
property :troops, 'troops', type: Troop
|
39
|
+
property :heroes, 'heroes', type: Hero
|
40
|
+
property :spells, 'spells', type: Spell
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
|
3
|
+
module ClashOfClansApi
|
4
|
+
module Models
|
5
|
+
class Spell < Base
|
6
|
+
property :name, 'name', required: true
|
7
|
+
property :level, 'level', required: true
|
8
|
+
property :max_level, 'maxLevel', required: true
|
9
|
+
property :village, 'village', required: true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -14,14 +14,8 @@ module ClashOfClansApi
|
|
14
14
|
property :valid_until, 'validUntil'
|
15
15
|
property :key, 'key', required: true
|
16
16
|
|
17
|
-
def initialize(hash, token_client:)
|
18
|
-
super(hash)
|
19
|
-
|
20
|
-
@token_client = token_client
|
21
|
-
end
|
22
|
-
|
23
17
|
def revoke
|
24
|
-
|
18
|
+
self.client.revoke_api_key(self.id)
|
25
19
|
end
|
26
20
|
|
27
21
|
def client_from_token
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
|
3
|
+
module ClashOfClansApi
|
4
|
+
module Models
|
5
|
+
class Troop < Base
|
6
|
+
property :name, 'name', required: true
|
7
|
+
property :level, 'level', required: true
|
8
|
+
property :max_level, 'maxLevel', required: true
|
9
|
+
property :village, 'village', required: true
|
10
|
+
property :super_troop_is_active, 'superTroopIsActive', required: false, default: false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -36,14 +36,14 @@ module ClashOfClansApi
|
|
36
36
|
response = TokenApi.apikey_list(headers: @session_headers)
|
37
37
|
|
38
38
|
response['keys'].map do |key|
|
39
|
-
Models::Token.new(key,
|
39
|
+
Models::Token.new(key, self)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
def create_api_key(name, description, ip_addresses)
|
44
44
|
response = TokenApi.apikey_create(name: name, description: description, ip_addresses: (ip_addresses.is_a?(Array) ? ip_addresses : [ip_addresses]), headers: @session_headers)
|
45
45
|
|
46
|
-
Models::Token.new(response['key'],
|
46
|
+
Models::Token.new(response['key'], self)
|
47
47
|
end
|
48
48
|
|
49
49
|
def revoke_api_key(id)
|
@@ -21,13 +21,13 @@ module ClashOfClansApi
|
|
21
21
|
if params.key?(:keyrest)
|
22
22
|
kwargs
|
23
23
|
else
|
24
|
-
kwargs.slice(*
|
24
|
+
kwargs.slice(*params.values_at(:key, :keyreq).compact.flatten)
|
25
25
|
end
|
26
26
|
|
27
27
|
proc.call(*args, **proc_keys, &block)
|
28
28
|
end
|
29
29
|
|
30
|
-
def self.
|
30
|
+
def self.current_ipv4_address
|
31
31
|
IPAddr.new(URI('https://ipv4.icanhazip.com').open.read.strip).to_s
|
32
32
|
end
|
33
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clash_of_clans_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- expeehaa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -22,11 +22,21 @@ files:
|
|
22
22
|
- lib/clash_of_clans_api/api.rb
|
23
23
|
- lib/clash_of_clans_api/client.rb
|
24
24
|
- lib/clash_of_clans_api/endpoint_methods.rb
|
25
|
+
- lib/clash_of_clans_api/models/achievement.rb
|
25
26
|
- lib/clash_of_clans_api/models/base.rb
|
27
|
+
- lib/clash_of_clans_api/models/clan.rb
|
28
|
+
- lib/clash_of_clans_api/models/hero.rb
|
26
29
|
- lib/clash_of_clans_api/models/icon_set.rb
|
27
30
|
- lib/clash_of_clans_api/models/invalid_data_error.rb
|
31
|
+
- lib/clash_of_clans_api/models/label.rb
|
28
32
|
- lib/clash_of_clans_api/models/league.rb
|
33
|
+
- lib/clash_of_clans_api/models/legend_season.rb
|
34
|
+
- lib/clash_of_clans_api/models/legend_statistics.rb
|
35
|
+
- lib/clash_of_clans_api/models/paginated_response.rb
|
36
|
+
- lib/clash_of_clans_api/models/player.rb
|
37
|
+
- lib/clash_of_clans_api/models/spell.rb
|
29
38
|
- lib/clash_of_clans_api/models/token.rb
|
39
|
+
- lib/clash_of_clans_api/models/troop.rb
|
30
40
|
- lib/clash_of_clans_api/no_success_error.rb
|
31
41
|
- lib/clash_of_clans_api/tags.rb
|
32
42
|
- lib/clash_of_clans_api/token_api.rb
|
@@ -37,6 +47,7 @@ homepage: https://github.com/expeehaa/clash_of_clans_api
|
|
37
47
|
licenses: []
|
38
48
|
metadata:
|
39
49
|
allowed_push_host: https://rubygems.org
|
50
|
+
rubygems_mfa_required: 'true'
|
40
51
|
post_install_message:
|
41
52
|
rdoc_options: []
|
42
53
|
require_paths:
|
@@ -52,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
63
|
- !ruby/object:Gem::Version
|
53
64
|
version: '0'
|
54
65
|
requirements: []
|
55
|
-
rubygems_version: 3.
|
66
|
+
rubygems_version: 3.3.3
|
56
67
|
signing_key:
|
57
68
|
specification_version: 4
|
58
69
|
summary: Client library for interacting with the ClashOfClans API.
|