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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3e53b64ea30c84c114b5b01ceb285985bb4ac2bb319fd5f6e4561fbca0b71bbc
4
+ data.tar.gz: 2f1dc39b971c9d27fce1ad4b19d8bc537cebc587ed4a16e20d630983bffa0cb5
5
+ SHA512:
6
+ metadata.gz: d2dd209511a8b1ba0157a14170674d3050db1c957311d50e750c9e07b015457e210142cc107ddfc70a5b17a887803db8ef8ab1d7b72799220d124c4bf5d39a63
7
+ data.tar.gz: c6a48f19b76ef12a483fcf7e0e3d28b15dc97646400fd1a832d7afe417e9d74f4c30ff822886377ad5fd6d07ada01c6fdb9b79738cc8cc4030e9d5dd56483d93
@@ -0,0 +1,46 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming and inclusive language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+ * Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * Public or private harassment
22
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at golosizpru@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
+
39
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
+
45
+ [homepage]: http://contributor-covenant.org
46
+ [version]: http://contributor-covenant.org/version/1/4/
@@ -0,0 +1,14 @@
1
+ # Contributing
2
+
3
+ 1. [Fork the repository.][fork]
4
+ 2. [Create a topic branch.][branch]
5
+ 3. Implement your feature or bug fix.
6
+ 4. Don't forget to add specs and make sure they pass by running `rspec .`.
7
+ 5. Make sure your code complies with the style guide by running `rubocop`. `rubocop -a` can automatically fix most issues for you. Run `rubocop -A` to make it more aggressive.
8
+ 6. If necessary, add documentation for your feature or bug fix.
9
+ 7. Commit and push your changes.
10
+ 8. [Submit a pull request.][pr]
11
+
12
+ [fork]: http://help.github.com/fork-a-repo/
13
+ [branch]: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-branches
14
+ [pr]: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests
@@ -0,0 +1,11 @@
1
+ ### Summary
2
+
3
+ Provide a general description of the code changes in your pull
4
+ request. Were there any bugs you had fixed? If so, mention them. If
5
+ these bugs have open GitHub issues, be sure to tag them here as well,
6
+ to keep the conversation linked together.
7
+
8
+ ### Other Information
9
+
10
+ If there's anything else that's important and relevant to your pull
11
+ request, mention that information here.
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0.rc1 (11-Apr-22)
4
+
5
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'http://rubygems.org'
4
+
5
+ gemspec
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # RatingChgkV2
2
+
3
+ ![CI](https://github.com/bodrovis/rating-chgk-v2/actions/workflows/ci.yml/badge.svg)
4
+ [![Test Coverage](https://codecov.io/gh/bodrovis/rating-chgk-v2/graph/badge.svg)](https://codecov.io/gh/bodrovis/rating-chgk-v2)
5
+
6
+ Ruby client for [competitive "What? Where? When?" (aka "CHGK") API](http://api.rating.chgk.net/). This gem is a replacement for [ChgkRating](https://github.com/bodrovis/ChgkRating) which worked only with the deprecated API version.
7
+
8
+ ## Installation and requirements
9
+
10
+ This gem requires Ruby 2.7+. Install it by running:
11
+
12
+ ```
13
+ $ gem install rating-chgk-v2
14
+ ```
15
+
16
+ Include it in your script:
17
+
18
+ ```ruby
19
+ require 'rating_chgk_v2'
20
+ ```
21
+
22
+ ## Client initialization
23
+
24
+ Initialize an API client:
25
+
26
+ ```ruby
27
+ @client = RatingChgkV2.client
28
+ ```
29
+
30
+ Optionally, provide your JWT token and connection options (please note that JWT is not required to access most of the endpoints):
31
+
32
+ ```ruby
33
+ @client = RatingChgkV2.client token: 'MY_JWT', params: {open_timeout: 100, timeout: 500}
34
+ ```
35
+
36
+ Now use client to perform API requests:
37
+
38
+ ```ruby
39
+ teams = @client.teams itemsPerPage: 2, name: 'Н', page: 3
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ **[Please find documentation at our Wiki](https://github.com/bodrovis/rating-chgk-v2/wiki)**.
45
+
46
+ ## Running tests
47
+
48
+ Tests are written in RSpec (all HTTP requests are stubbed):
49
+
50
+ ```
51
+ rspec .
52
+ ```
53
+
54
+ Observe test results and coverage.
55
+
56
+ ## Copyright and license
57
+
58
+ Licensed under the [MIT license](./LICENSE.md).
59
+
60
+ Copyright (c) 2022 [Ilya Bodrov-Krukowski](http://bodrovis.tech)
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rake'
4
+
5
+ begin
6
+ require 'bundler/setup'
7
+ Bundler::GemHelper.install_tasks
8
+ rescue LoadError
9
+ puts 'although not required, bundler is recommened for running the tests'
10
+ end
11
+
12
+ task default: :spec
13
+
14
+ require 'rspec/core/rake_task'
15
+ RSpec::Core::RakeTask.new(:spec)
16
+
17
+ require 'rubocop/rake_task'
18
+ RuboCop::RakeTask.new do |task|
19
+ task.requires << 'rubocop-performance'
20
+ task.requires << 'rubocop-rspec'
21
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ class Client
5
+ include RatingChgkV2::Rest
6
+
7
+ attr_reader :token
8
+ attr_accessor :timeout, :open_timeout
9
+
10
+ def initialize(token: '', params: {})
11
+ @token = token
12
+ @timeout = params.fetch(:timeout, nil)
13
+ @open_timeout = params.fetch(:open_timeout, nil)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Collections
5
+ # Base class for all collections. A collection contains an array of models, for example
6
+ # a collection of players, tournaments, or regions. Some collections are paginated but not all.
7
+ class BaseCollection
8
+ include Enumerable
9
+ extend Forwardable
10
+
11
+ MODEL = ''
12
+ attr_reader :items, :endpoint
13
+
14
+ def_delegators :items, :[], :last, :each
15
+
16
+ class << self
17
+ def load(method, endpoint)
18
+ new endpoint.send(method), endpoint
19
+ end
20
+
21
+ def paginated
22
+ include RatingChgkV2::Concerns::Paginated
23
+ end
24
+ end
25
+
26
+ def initialize(raw_data, endpoint = nil)
27
+ setup raw_data, endpoint
28
+ end
29
+
30
+ private
31
+
32
+ def setup(raw_data, endpoint)
33
+ @endpoint = endpoint
34
+ @items = produce_models_from raw_data
35
+ end
36
+
37
+ def produce_models_from(raw_data)
38
+ return [] if raw_data&.empty?
39
+
40
+ model_name = self.class.const_get :MODEL
41
+ model_klass = RatingChgkV2::Models.const_get "#{model_name}Model"
42
+ raw_data.map do |item|
43
+ model_klass.new item
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Collections
5
+ class CountriesCollection < BaseCollection
6
+ paginated
7
+
8
+ MODEL = 'Country'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Collections
5
+ class PlayerSeasonsCollection < BaseCollection
6
+ paginated
7
+
8
+ MODEL = 'PlayerSeason'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Collections
5
+ class PlayerTournamentsCollection < BaseCollection
6
+ paginated
7
+
8
+ MODEL = 'PlayerTournament'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Collections
5
+ class PlayersCollection < BaseCollection
6
+ paginated
7
+
8
+ MODEL = 'Player'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Collections
5
+ class RegionsCollection < BaseCollection
6
+ paginated
7
+
8
+ MODEL = 'Region'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Collections
5
+ class ReleasesCollection < BaseCollection
6
+ paginated
7
+
8
+ MODEL = 'Release'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Collections
5
+ class SeasonsCollection < BaseCollection
6
+ paginated
7
+
8
+ MODEL = 'Season'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Collections
5
+ class TeamTournamentsCollection < BaseCollection
6
+ paginated
7
+
8
+ MODEL = 'TeamTournament'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Collections
5
+ class TeamsCollection < BaseCollection
6
+ paginated
7
+
8
+ MODEL = 'Team'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Collections
5
+ class TournamentAppealsCollection < BaseCollection
6
+ MODEL = 'TournamentSynchAppeal'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Collections
5
+ class TournamentFlagsCollection < BaseCollection
6
+ MODEL = 'TournamentFlag'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Collections
5
+ class TournamentRequestsCollection < BaseCollection
6
+ MODEL = 'TournamentSynchRequest'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Collections
5
+ class TournamentResultsCollection < BaseCollection
6
+ MODEL = 'TournamentResult'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Collections
5
+ class TournamentTypesCollection < BaseCollection
6
+ MODEL = 'TournamentType'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Collections
5
+ class TournamentsCollection < BaseCollection
6
+ paginated
7
+
8
+ MODEL = 'Tournament'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Collections
5
+ class TownsCollection < BaseCollection
6
+ paginated
7
+
8
+ MODEL = 'Town'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Collections
5
+ class VenueTypesCollection < BaseCollection
6
+ paginated
7
+
8
+ MODEL = 'VenueType'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Collections
5
+ class VenuesCollection < BaseCollection
6
+ paginated
7
+
8
+ MODEL = 'Venue'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Concerns
5
+ module Paginated
6
+ def next_page!
7
+ page_num = current_page + 1
8
+ params = endpoint.params.merge({page: page_num})
9
+ endpoint.reinitialize new_params: params
10
+ setup endpoint.do_get, endpoint
11
+ self
12
+ end
13
+
14
+ def prev_page!
15
+ return if current_page <= 1
16
+
17
+ page_num = current_page - 1
18
+ params = endpoint.params.merge({page: page_num})
19
+ endpoint.reinitialize new_params: params
20
+ setup endpoint.do_get, endpoint
21
+ self
22
+ end
23
+
24
+ private
25
+
26
+ def current_page
27
+ endpoint.params[:page] || 1
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RatingChgkV2
4
+ module Connection
5
+ BASE_URL = 'https://api.rating.chgk.net/'
6
+
7
+ def connection(client)
8
+ Faraday.new(options(client), request_params_for(client)) do |faraday|
9
+ faraday.adapter Faraday.default_adapter
10
+ end
11
+ end
12
+
13
+ private
14
+
15
+ def options(client)
16
+ headers = {
17
+ accept: 'application/json',
18
+ user_agent: "rating-chgk-v2 gem/#{RatingChgkV2::VERSION}",
19
+ 'Content-Type': 'application/json',
20
+ accept_encoding: 'gzip,deflate,br'
21
+ }
22
+
23
+ headers = headers.merge({Authorization: "Bearer #{client.token}"}) if client.token
24
+
25
+ {headers: headers, url: BASE_URL}
26
+ end
27
+
28
+ # Allows to customize request params per-client
29
+ def request_params_for(client)
30
+ {request: {timeout: client.timeout, open_timeout: client.open_timeout}}
31
+ end
32
+ end
33
+ end
@@ -0,0 +1 @@
1
+ - token
@@ -0,0 +1,2 @@
1
+ - id
2
+ - name
@@ -0,0 +1,4 @@
1
+ - id
2
+ - name
3
+ - patronymic
4
+ - surname
@@ -0,0 +1,6 @@
1
+ - idplayer
2
+ - idseason
3
+ - idteam
4
+ - dateAdded
5
+ - dateRemoved
6
+ - playerNumber
@@ -0,0 +1,3 @@
1
+ - idplayer
2
+ - idteam
3
+ - idtournament
@@ -0,0 +1,3 @@
1
+ - id
2
+ - name
3
+ - country
@@ -0,0 +1,4 @@
1
+ - id
2
+ - date
3
+ - realDate
4
+ - lastRunRefresh
@@ -0,0 +1,3 @@
1
+ - id
2
+ - dateStart
3
+ - dateEnd
@@ -0,0 +1,3 @@
1
+ - id
2
+ - name
3
+ - town
@@ -0,0 +1,2 @@
1
+ - idteam
2
+ - idtournament
@@ -0,0 +1,20 @@
1
+ - id
2
+ - name
3
+ - lastEditDate
4
+ - dateStart
5
+ - dateEnd
6
+ - type
7
+ - orgcommittee
8
+ - synchData
9
+ - mainPayment
10
+ - discountedPayment
11
+ - discountedPaymentReason
12
+ - currency
13
+ - editors
14
+ - tournamentInRatingBalanced
15
+ - difficultyForecast
16
+ - maiiAegis
17
+ - maiiAegisUpdatedAt
18
+ - maiiRating
19
+ - maiiRatingUpdatedAt
20
+ - questionQty
@@ -0,0 +1,3 @@
1
+ - id
2
+ - shortName
3
+ - longName
@@ -0,0 +1,10 @@
1
+ - team
2
+ - mask
3
+ - current
4
+ - rating
5
+ - controversials
6
+ - flags
7
+ - teamMembers
8
+ - questionsTotal
9
+ - synchRequest
10
+ - position
@@ -0,0 +1,10 @@
1
+ - id
2
+ - idtournament
3
+ - type
4
+ - issuedAt
5
+ - status
6
+ - appeal
7
+ - comment
8
+ - overriddenBy
9
+ - questionNumber
10
+ - answer
@@ -0,0 +1,8 @@
1
+ - id
2
+ - questionNumber
3
+ - answer
4
+ - issuedAt
5
+ - status
6
+ - comment
7
+ - resolvedAt
8
+ - appealJuryComment
@@ -0,0 +1,8 @@
1
+ - id
2
+ - status
3
+ - venue
4
+ - representative
5
+ - narrators
6
+ - approximateTeamsCount
7
+ - issuedAt
8
+ - tournamentId
@@ -0,0 +1,2 @@
1
+ - id
2
+ - name
@@ -0,0 +1,4 @@
1
+ - id
2
+ - name
3
+ - region
4
+ - country