rating-chgk-v2 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +7 -0
  2. data/.github/CODE_OF_CONDUCT.md +46 -0
  3. data/.github/CONTRIBUTING.md +14 -0
  4. data/.github/PULL_REQUEST_TEMPLATE.md +11 -0
  5. data/CHANGELOG.md +5 -0
  6. data/Gemfile +5 -0
  7. data/README.md +60 -0
  8. data/Rakefile +21 -0
  9. data/lib/rating_chgk_v2/client.rb +16 -0
  10. data/lib/rating_chgk_v2/collections/base_collection.rb +48 -0
  11. data/lib/rating_chgk_v2/collections/countries_collection.rb +11 -0
  12. data/lib/rating_chgk_v2/collections/player_seasons_collection.rb +11 -0
  13. data/lib/rating_chgk_v2/collections/player_tournaments_collection.rb +11 -0
  14. data/lib/rating_chgk_v2/collections/players_collection.rb +11 -0
  15. data/lib/rating_chgk_v2/collections/regions_collection.rb +11 -0
  16. data/lib/rating_chgk_v2/collections/releases_collection.rb +11 -0
  17. data/lib/rating_chgk_v2/collections/seasons_collection.rb +11 -0
  18. data/lib/rating_chgk_v2/collections/team_tournaments_collection.rb +11 -0
  19. data/lib/rating_chgk_v2/collections/teams_collection.rb +11 -0
  20. data/lib/rating_chgk_v2/collections/tournament_appeals_collection.rb +9 -0
  21. data/lib/rating_chgk_v2/collections/tournament_flags_collection.rb +9 -0
  22. data/lib/rating_chgk_v2/collections/tournament_requests_collection.rb +9 -0
  23. data/lib/rating_chgk_v2/collections/tournament_results_collection.rb +9 -0
  24. data/lib/rating_chgk_v2/collections/tournament_types_collection.rb +9 -0
  25. data/lib/rating_chgk_v2/collections/tournaments_collection.rb +11 -0
  26. data/lib/rating_chgk_v2/collections/towns_collection.rb +11 -0
  27. data/lib/rating_chgk_v2/collections/venue_types_collection.rb +11 -0
  28. data/lib/rating_chgk_v2/collections/venues_collection.rb +11 -0
  29. data/lib/rating_chgk_v2/concerns/paginated.rb +31 -0
  30. data/lib/rating_chgk_v2/connection.rb +33 -0
  31. data/lib/rating_chgk_v2/data/authentication_token.yml +1 -0
  32. data/lib/rating_chgk_v2/data/country.yml +2 -0
  33. data/lib/rating_chgk_v2/data/player.yml +4 -0
  34. data/lib/rating_chgk_v2/data/player_season.yml +6 -0
  35. data/lib/rating_chgk_v2/data/player_tournament.yml +3 -0
  36. data/lib/rating_chgk_v2/data/region.yml +3 -0
  37. data/lib/rating_chgk_v2/data/release.yml +4 -0
  38. data/lib/rating_chgk_v2/data/season.yml +3 -0
  39. data/lib/rating_chgk_v2/data/team.yml +3 -0
  40. data/lib/rating_chgk_v2/data/team_tournament.yml +2 -0
  41. data/lib/rating_chgk_v2/data/tournament.yml +20 -0
  42. data/lib/rating_chgk_v2/data/tournament_flag.yml +3 -0
  43. data/lib/rating_chgk_v2/data/tournament_result.yml +10 -0
  44. data/lib/rating_chgk_v2/data/tournament_synch_appeal.yml +10 -0
  45. data/lib/rating_chgk_v2/data/tournament_synch_controversial.yml +8 -0
  46. data/lib/rating_chgk_v2/data/tournament_synch_request.yml +8 -0
  47. data/lib/rating_chgk_v2/data/tournament_type.yml +2 -0
  48. data/lib/rating_chgk_v2/data/town.yml +4 -0
  49. data/lib/rating_chgk_v2/data/venue.yml +6 -0
  50. data/lib/rating_chgk_v2/data/venue_type.yml +2 -0
  51. data/lib/rating_chgk_v2/endpoints/authentication_token_endpoint.rb +13 -0
  52. data/lib/rating_chgk_v2/endpoints/base_endpoint.rb +58 -0
  53. data/lib/rating_chgk_v2/endpoints/countries_endpoint.rb +13 -0
  54. data/lib/rating_chgk_v2/endpoints/players_endpoint.rb +13 -0
  55. data/lib/rating_chgk_v2/endpoints/regions_endpoint.rb +13 -0
  56. data/lib/rating_chgk_v2/endpoints/releases_endpoint.rb +13 -0
  57. data/lib/rating_chgk_v2/endpoints/seasons_endpoint.rb +13 -0
  58. data/lib/rating_chgk_v2/endpoints/teams_endpoint.rb +13 -0
  59. data/lib/rating_chgk_v2/endpoints/tournament_flags_endpoint.rb +13 -0
  60. data/lib/rating_chgk_v2/endpoints/tournament_synch_appeals_endpoint.rb +13 -0
  61. data/lib/rating_chgk_v2/endpoints/tournament_synch_controversials_endpoint.rb +13 -0
  62. data/lib/rating_chgk_v2/endpoints/tournament_synch_requests_endpoint.rb +13 -0
  63. data/lib/rating_chgk_v2/endpoints/tournament_types_endpoint.rb +13 -0
  64. data/lib/rating_chgk_v2/endpoints/tournaments_endpoint.rb +13 -0
  65. data/lib/rating_chgk_v2/endpoints/towns_endpoint.rb +13 -0
  66. data/lib/rating_chgk_v2/endpoints/venue_types_endpoint.rb +13 -0
  67. data/lib/rating_chgk_v2/endpoints/venues_endpoint.rb +13 -0
  68. data/lib/rating_chgk_v2/error.rb +52 -0
  69. data/lib/rating_chgk_v2/json_handler.rb +19 -0
  70. data/lib/rating_chgk_v2/models/authentication_token_model.rb +8 -0
  71. data/lib/rating_chgk_v2/models/base_model.rb +38 -0
  72. data/lib/rating_chgk_v2/models/country_model.rb +16 -0
  73. data/lib/rating_chgk_v2/models/player_model.rb +17 -0
  74. data/lib/rating_chgk_v2/models/player_season_model.rb +8 -0
  75. data/lib/rating_chgk_v2/models/player_tournament_model.rb +8 -0
  76. data/lib/rating_chgk_v2/models/region_model.rb +8 -0
  77. data/lib/rating_chgk_v2/models/release_model.rb +8 -0
  78. data/lib/rating_chgk_v2/models/season_model.rb +16 -0
  79. data/lib/rating_chgk_v2/models/team_model.rb +17 -0
  80. data/lib/rating_chgk_v2/models/team_tournament_model.rb +8 -0
  81. data/lib/rating_chgk_v2/models/tournament_flag_model.rb +8 -0
  82. data/lib/rating_chgk_v2/models/tournament_model.rb +22 -0
  83. data/lib/rating_chgk_v2/models/tournament_result_model.rb +8 -0
  84. data/lib/rating_chgk_v2/models/tournament_synch_appeal_model.rb +8 -0
  85. data/lib/rating_chgk_v2/models/tournament_synch_controversial_model.rb +8 -0
  86. data/lib/rating_chgk_v2/models/tournament_synch_request_model.rb +8 -0
  87. data/lib/rating_chgk_v2/models/tournament_type_model.rb +8 -0
  88. data/lib/rating_chgk_v2/models/town_model.rb +8 -0
  89. data/lib/rating_chgk_v2/models/venue_model.rb +16 -0
  90. data/lib/rating_chgk_v2/models/venue_type_model.rb +8 -0
  91. data/lib/rating_chgk_v2/request.rb +58 -0
  92. data/lib/rating_chgk_v2/rest/authentication_token.rb +11 -0
  93. data/lib/rating_chgk_v2/rest/countries.rb +27 -0
  94. data/lib/rating_chgk_v2/rest/players.rb +23 -0
  95. data/lib/rating_chgk_v2/rest/regions.rb +15 -0
  96. data/lib/rating_chgk_v2/rest/releases.rb +15 -0
  97. data/lib/rating_chgk_v2/rest/seasons.rb +27 -0
  98. data/lib/rating_chgk_v2/rest/teams.rb +23 -0
  99. data/lib/rating_chgk_v2/rest/tournament_flags.rb +15 -0
  100. data/lib/rating_chgk_v2/rest/tournament_synch_appeals.rb +11 -0
  101. data/lib/rating_chgk_v2/rest/tournament_synch_controversials.rb +11 -0
  102. data/lib/rating_chgk_v2/rest/tournament_synch_requests.rb +11 -0
  103. data/lib/rating_chgk_v2/rest/tournament_types.rb +15 -0
  104. data/lib/rating_chgk_v2/rest/tournaments.rb +27 -0
  105. data/lib/rating_chgk_v2/rest/towns.rb +15 -0
  106. data/lib/rating_chgk_v2/rest/venue_types.rb +19 -0
  107. data/lib/rating_chgk_v2/rest/venues.rb +27 -0
  108. data/lib/rating_chgk_v2/rest.rb +45 -0
  109. data/lib/rating_chgk_v2/utils/string_utils.rb +28 -0
  110. data/lib/rating_chgk_v2/version.rb +5 -0
  111. data/lib/rating_chgk_v2.rb +22 -0
  112. data/rating-chgk-v2.gemspec +47 -0
  113. data/spec/lib/rating_chgk_v2/collections/base_collection_spec.rb +53 -0
  114. data/spec/lib/rating_chgk_v2/collections/countries_collection_spec.rb +5 -0
  115. data/spec/lib/rating_chgk_v2/collections/player_seasons_collection_spec.rb +5 -0
  116. data/spec/lib/rating_chgk_v2/collections/player_tournaments_collection_spec.rb +5 -0
  117. data/spec/lib/rating_chgk_v2/collections/players_collection_spec.rb +5 -0
  118. data/spec/lib/rating_chgk_v2/collections/regions_collection_spec.rb +5 -0
  119. data/spec/lib/rating_chgk_v2/collections/releases_collection_spec.rb +5 -0
  120. data/spec/lib/rating_chgk_v2/collections/seasons_collection_spec.rb +5 -0
  121. data/spec/lib/rating_chgk_v2/collections/teams_collection_spec.rb +5 -0
  122. data/spec/lib/rating_chgk_v2/collections/tournaments_collection_spec.rb +5 -0
  123. data/spec/lib/rating_chgk_v2/collections/towns_collection_spec.rb +5 -0
  124. data/spec/lib/rating_chgk_v2/collections/venue_types_collection_spec.rb +5 -0
  125. data/spec/lib/rating_chgk_v2/collections/venues_collection_spec.rb +5 -0
  126. data/spec/lib/rating_chgk_v2/connection_spec.rb +22 -0
  127. data/spec/lib/rating_chgk_v2/endpoints/base_endpoint_spec.rb +15 -0
  128. data/spec/lib/rating_chgk_v2/error_spec.rb +11 -0
  129. data/spec/lib/rating_chgk_v2/models/country_model_spec.rb +30 -0
  130. data/spec/lib/rating_chgk_v2/models/player_model_spec.rb +59 -0
  131. data/spec/lib/rating_chgk_v2/models/season_model_spec.rb +36 -0
  132. data/spec/lib/rating_chgk_v2/models/team_model_spec.rb +35 -0
  133. data/spec/lib/rating_chgk_v2/models/tournament_model_spec.rb +38 -0
  134. data/spec/lib/rating_chgk_v2/models/venue_model_spec.rb +30 -0
  135. data/spec/lib/rating_chgk_v2/rest/authentication_token_spec.rb +19 -0
  136. data/spec/lib/rating_chgk_v2/rest/countries_spec.rb +94 -0
  137. data/spec/lib/rating_chgk_v2/rest/players_spec.rb +126 -0
  138. data/spec/lib/rating_chgk_v2/rest/regions_spec.rb +37 -0
  139. data/spec/lib/rating_chgk_v2/rest/releases_spec.rb +34 -0
  140. data/spec/lib/rating_chgk_v2/rest/seasons_spec.rb +71 -0
  141. data/spec/lib/rating_chgk_v2/rest/teams_spec.rb +66 -0
  142. data/spec/lib/rating_chgk_v2/rest/tournament_flags_spec.rb +27 -0
  143. data/spec/lib/rating_chgk_v2/rest/tournament_synch_appeals_spec.rb +22 -0
  144. data/spec/lib/rating_chgk_v2/rest/tournament_synch_controversials_spec.rb +20 -0
  145. data/spec/lib/rating_chgk_v2/rest/tournament_synch_requests_spec.rb +20 -0
  146. data/spec/lib/rating_chgk_v2/rest/tournament_types_spec.rb +23 -0
  147. data/spec/lib/rating_chgk_v2/rest/tournaments_spec.rb +89 -0
  148. data/spec/lib/rating_chgk_v2/rest/towns_spec.rb +35 -0
  149. data/spec/lib/rating_chgk_v2/rest/venue_types_spec.rb +46 -0
  150. data/spec/lib/rating_chgk_v2/rest/venues_spec.rb +71 -0
  151. data/spec/lib/rating_chgk_v2_spec.rb +9 -0
  152. data/spec/spec_helper.rb +37 -0
  153. data/spec/support/shared/paginated.rb +41 -0
  154. data/spec/support/test_client.rb +7 -0
  155. data/spec/support/vcr.rb +15 -0
  156. metadata +455 -0
@@ -0,0 +1,6 @@
1
+ - id
2
+ - name
3
+ - town
4
+ - type
5
+ - address
6
+ - urls
@@ -0,0 +1,2 @@
1
+ - id
2
+ - name
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Endpoints
5
+ class AuthenticationTokenEndpoint < BaseEndpoint
6
+ private
7
+
8
+ def base_query
9
+ [:authentication_token]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Endpoints
5
+ class BaseEndpoint
6
+ include RatingChgkV2::Request
7
+
8
+ attr_reader :params
9
+
10
+ def initialize(client, query_params = [], params = {})
11
+ setup client, base_query.push(*query_params), params
12
+ end
13
+
14
+ def reinitialize(new_params: {}, add_query: [])
15
+ add_query = [add_query] unless add_query.is_a?(Array)
16
+ new_query = add_query&.any? ? @query_params.push(*add_query) : @query_params
17
+ setup @client, new_query, new_params
18
+ self
19
+ end
20
+
21
+ private
22
+
23
+ HTTP_METHODS_REGEXP = /\Ado_(get|post|put|delete)\z/.freeze
24
+
25
+ def respond_to_missing?(method, _include_all)
26
+ return true if HTTP_METHODS_REGEXP.match?(method.to_s)
27
+
28
+ super
29
+ end
30
+
31
+ def method_missing(method, *_args)
32
+ if method.to_s =~ HTTP_METHODS_REGEXP
33
+ send Regexp.last_match(1), @uri, @client, @params
34
+ else
35
+ super
36
+ end
37
+ end
38
+
39
+ def setup(client, query_params = [], params = {})
40
+ @query_params = query_params
41
+ @uri = partial_uri(@query_params)
42
+ @client = client
43
+ @params = params
44
+ end
45
+
46
+ def partial_uri(raw_mapping)
47
+ template = Addressable::Template.new '{/segments*}'
48
+ template.expand(
49
+ segments: raw_mapping.to_a.flatten
50
+ ).to_s
51
+ end
52
+
53
+ def base_query
54
+ []
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Endpoints
5
+ class CountriesEndpoint < BaseEndpoint
6
+ private
7
+
8
+ def base_query
9
+ [:countries]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Endpoints
5
+ class PlayersEndpoint < BaseEndpoint
6
+ private
7
+
8
+ def base_query
9
+ [:players]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Endpoints
5
+ class RegionsEndpoint < BaseEndpoint
6
+ private
7
+
8
+ def base_query
9
+ [:regions]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Endpoints
5
+ class ReleasesEndpoint < BaseEndpoint
6
+ private
7
+
8
+ def base_query
9
+ [:releases]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Endpoints
5
+ class SeasonsEndpoint < BaseEndpoint
6
+ private
7
+
8
+ def base_query
9
+ [:seasons]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Endpoints
5
+ class TeamsEndpoint < BaseEndpoint
6
+ private
7
+
8
+ def base_query
9
+ [:teams]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Endpoints
5
+ class TournamentFlagsEndpoint < BaseEndpoint
6
+ private
7
+
8
+ def base_query
9
+ [:tournament_flags]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Endpoints
5
+ class TournamentSynchAppealsEndpoint < BaseEndpoint
6
+ private
7
+
8
+ def base_query
9
+ [:tournament_synch_appeals]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Endpoints
5
+ class TournamentSynchControversialsEndpoint < BaseEndpoint
6
+ private
7
+
8
+ def base_query
9
+ [:tournament_synch_controversials]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Endpoints
5
+ class TournamentSynchRequestsEndpoint < BaseEndpoint
6
+ private
7
+
8
+ def base_query
9
+ [:tournament_synch_requests]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Endpoints
5
+ class TournamentTypesEndpoint < BaseEndpoint
6
+ private
7
+
8
+ def base_query
9
+ [:tournament_types]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Endpoints
5
+ class TournamentsEndpoint < BaseEndpoint
6
+ private
7
+
8
+ def base_query
9
+ [:tournaments]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Endpoints
5
+ class TownsEndpoint < BaseEndpoint
6
+ private
7
+
8
+ def base_query
9
+ [:towns]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Endpoints
5
+ class VenueTypesEndpoint < BaseEndpoint
6
+ private
7
+
8
+ def base_query
9
+ [:venue_types]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Endpoints
5
+ class VenuesEndpoint < BaseEndpoint
6
+ private
7
+
8
+ def base_query
9
+ [:venues]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ class Error < StandardError
5
+ ClientError = Class.new(self)
6
+ ServerError = Class.new(self)
7
+
8
+ BadRequest = Class.new(ClientError)
9
+ Unauthorized = Class.new(ClientError)
10
+ NotAcceptable = Class.new(ClientError)
11
+ NotFound = Class.new(ClientError)
12
+ Conflict = Class.new(ClientError)
13
+ TooManyRequests = Class.new(ClientError)
14
+ Forbidden = Class.new(ClientError)
15
+ Locked = Class.new(ClientError)
16
+ MethodNotAllowed = Class.new(ClientError)
17
+
18
+ NotImplemented = Class.new(ServerError)
19
+ BadGateway = Class.new(ServerError)
20
+ ServiceUnavailable = Class.new(ServerError)
21
+ GatewayTimeout = Class.new(ServerError)
22
+
23
+ ERRORS = {
24
+ 400 => RatingChgkV2::Error::BadRequest,
25
+ 401 => RatingChgkV2::Error::Unauthorized,
26
+ 403 => RatingChgkV2::Error::Forbidden,
27
+ 404 => RatingChgkV2::Error::NotFound,
28
+ 405 => RatingChgkV2::Error::MethodNotAllowed,
29
+ 406 => RatingChgkV2::Error::NotAcceptable,
30
+ 409 => RatingChgkV2::Error::Conflict,
31
+ 423 => RatingChgkV2::Error::Locked,
32
+ 429 => RatingChgkV2::Error::TooManyRequests,
33
+ 500 => RatingChgkV2::Error::ServerError,
34
+ 502 => RatingChgkV2::Error::BadGateway,
35
+ 503 => RatingChgkV2::Error::ServiceUnavailable,
36
+ 504 => RatingChgkV2::Error::GatewayTimeout
37
+ }.freeze
38
+
39
+ class << self
40
+ # Create a new error from an HTTP response
41
+ def from_response(body)
42
+ msg = body['detail'] || body['message']
43
+ new msg.to_s
44
+ end
45
+ end
46
+
47
+ # Initializes a new Error object
48
+ def initialize(message = '')
49
+ super(message)
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+
5
+ module RatingChgkV2
6
+ module JsonHandler
7
+ # JSON custom parser. Uses built-in JSON by default but can be overridden to any other parser
8
+
9
+ # Converts Ruby object to JSON
10
+ def custom_dump(obj)
11
+ JSON.dump obj
12
+ end
13
+
14
+ # Converts JSON to Ruby object
15
+ def custom_load(obj)
16
+ JSON.parse obj
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Models
5
+ class AuthenticationTokenModel < BaseModel
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Models
5
+ class BaseModel
6
+ using RatingChgkV2::Utils::StringUtils
7
+
8
+ attr_reader :endpoint
9
+
10
+ def self.load(method, endpoint)
11
+ new endpoint.send(method), endpoint
12
+ end
13
+
14
+ def initialize(raw_data, endpoint = nil)
15
+ @endpoint = endpoint
16
+
17
+ self.class.const_get(:ATTRIBUTES).each do |att|
18
+ instance_variable_set :"@#{att}", (raw_data[att] || raw_data[att.to_sym])
19
+ end
20
+ end
21
+
22
+ def self.inherited(subclass)
23
+ subclass.class_exec do
24
+ filename = subclass.name.base_class_name.snakecase.delete_suffix('_model')
25
+ attrs = YAML.load_file File.expand_path("../data/#{filename}.yml", __dir__)
26
+
27
+ const_set :ATTRIBUTES, attrs
28
+
29
+ attrs.each do |att|
30
+ attr_reader(att)
31
+ end
32
+ end
33
+
34
+ super
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Models
5
+ class CountryModel < BaseModel
6
+ def update(params = {})
7
+ endpoint.reinitialize new_params: params
8
+ self.class.load :do_put, endpoint
9
+ end
10
+
11
+ def destroy
12
+ endpoint.do_delete
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Models
5
+ class PlayerModel < BaseModel
6
+ def seasons(params = {})
7
+ endpoint.reinitialize new_params: params, add_query: :seasons
8
+ RatingChgkV2::Collections::PlayerSeasonsCollection.load :do_get, endpoint
9
+ end
10
+
11
+ def tournaments(params = {})
12
+ endpoint.reinitialize new_params: params, add_query: :tournaments
13
+ RatingChgkV2::Collections::PlayerTournamentsCollection.load :do_get, endpoint
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Models
5
+ class PlayerSeasonModel < BaseModel
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Models
5
+ class PlayerTournamentModel < BaseModel
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Models
5
+ class RegionModel < BaseModel
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Models
5
+ class ReleaseModel < BaseModel
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Models
5
+ class SeasonModel < BaseModel
6
+ def update(params = {})
7
+ endpoint.reinitialize new_params: params
8
+ self.class.load :do_put, endpoint
9
+ end
10
+
11
+ def destroy
12
+ endpoint.do_delete
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Models
5
+ class TeamModel < BaseModel
6
+ def seasons(params = {})
7
+ endpoint.reinitialize new_params: params, add_query: :seasons
8
+ RatingChgkV2::Collections::PlayerSeasonsCollection.load :do_get, endpoint
9
+ end
10
+
11
+ def tournaments(params = {})
12
+ endpoint.reinitialize new_params: params, add_query: :tournaments
13
+ RatingChgkV2::Collections::TeamTournamentsCollection.load :do_get, endpoint
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Models
5
+ class TeamTournamentModel < BaseModel
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Models
5
+ class TournamentFlagModel < BaseModel
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Models
5
+ class TournamentModel < BaseModel
6
+ def appeals
7
+ endpoint.reinitialize add_query: :appeals
8
+ RatingChgkV2::Collections::TournamentAppealsCollection.load :do_get, endpoint
9
+ end
10
+
11
+ def requests
12
+ endpoint.reinitialize add_query: :requests
13
+ RatingChgkV2::Collections::TournamentRequestsCollection.load :do_get, endpoint
14
+ end
15
+
16
+ def results(params = {})
17
+ endpoint.reinitialize new_params: params, add_query: :results
18
+ RatingChgkV2::Collections::TournamentResultsCollection.load :do_get, endpoint
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Models
5
+ class TournamentResultModel < BaseModel
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Models
5
+ class TournamentSynchAppealModel < BaseModel
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Models
5
+ class TournamentSynchControversialModel < BaseModel
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Models
5
+ class TournamentSynchRequestModel < BaseModel
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Models
5
+ class TournamentTypeModel < BaseModel
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Models
5
+ class TownModel < BaseModel
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Models
5
+ class VenueModel < BaseModel
6
+ def update(params = {})
7
+ endpoint.reinitialize new_params: params
8
+ self.class.load :do_put, endpoint
9
+ end
10
+
11
+ def destroy
12
+ endpoint.do_delete
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Models
5
+ class VenueTypeModel < BaseModel
6
+ end
7
+ end
8
+ end