crawlora-faceit 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6b97f833c5e916d968ef0253894caaf53a3667ddf1e07d3b533756576021c27d
4
+ data.tar.gz: ba5cfe301bf4b5cee1c548fe9156813024616b7d38c265779c7ed3670056f46d
5
+ SHA512:
6
+ metadata.gz: fd46753987f881238678a0b96026e65da20863decf76974b1333698400ec2082576b7e971f3884134f5d192dc10906a55043f7dc6d7938818c05f1f72cef1c5a
7
+ data.tar.gz: db1292b8f8d926e2150904f13ac1b5a8e4577d919fc30dbf85e200392d983e7c40e49605a82dc9f1738857a474307bc8ebd1ac251b55c00518454f8753705f7c
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.1.1
4
+
5
+ - Initial focused FACEIT Ruby client for Crawlora's hosted API.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Crawlora
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # Crawlora FACEIT API client for Ruby (`crawlora-faceit`)
2
+
3
+ This Ruby gem calls Crawlora's hosted FACEIT API at `https://api.crawlora.net/api/v1`. It exposes 35 endpoints covering leaderboards, players, teams, matches, tournaments, clips, hubs, and public game modes; it does not call or scrape FACEIT directly. Requests require your Crawlora API key and use your account's service plan.
4
+
5
+ ## Install
6
+
7
+ ```ruby
8
+ gem "crawlora-faceit"
9
+ ```
10
+
11
+ Create an account at [crawlora.net](https://crawlora.net/signup?utm_source=rubygems&utm_medium=referral&utm_campaign=platform-clients&utm_content=faceit-ruby-signup), open the [Crawlora console](https://crawlora.net/app?utm_source=rubygems&utm_medium=referral&utm_campaign=platform-clients&utm_content=faceit-ruby-console) to get an API key, and set `CRAWLORA_API_KEY` before running the client:
12
+
13
+ ```ruby
14
+ require "json"
15
+ require "crawlora/faceit"
16
+
17
+ client = Crawlora::Faceit::Client.new
18
+ result = client.request("faceit-championship-search", JSON.parse("{}"))
19
+ puts result
20
+ client.close
21
+ ```
22
+
23
+ Use an operation-specific method for normal calls. `request(operation_id, params = {}, response_type: :auto)` is available for every operation. `response_type: :text` returns raw response text. This gem includes 35 API operations.
24
+
25
+ ```ruby
26
+ client = Crawlora::Faceit::Client.new(api_key: ENV.fetch("CRAWLORA_API_KEY"), timeout: 30)
27
+ # client.<operation_method>(<endpoint parameters>)
28
+ client.close
29
+ ```
30
+
31
+ Client options include `api_key`, `base_url`, and `timeout`. Ruby stdlib provides the HTTP and JSON support.
32
+
33
+ ## Supported FACEIT API endpoints
34
+
35
+ Browse every route included in this gem. The [endpoint reference](https://github.com/Crawlora-org/crawlora-faceit/blob/main/docs/usage.md) includes parameter and response details.
36
+
37
+ | Method | Endpoint | API operation | Description |
38
+ | --- | --- | --- | --- |
39
+ | `GET` | `/faceit/ban-reasons` | `faceit-ban-reasons` | FACEIT ban reason enum |
40
+ | `GET` | `/faceit/banlist` | `faceit-banlist` | FACEIT public ban list page |
41
+ | `GET` | `/faceit/banlist-stats` | `faceit-banlist-stats` | FACEIT ban list aggregate counters |
42
+ | `GET` | `/faceit/best-clips` | `faceit-best-clips` | FACEIT player best clips in a time window |
43
+ | `GET` | `/faceit/championship` | `faceit-championship` | FACEIT championship detail by id |
44
+ | `GET` | `/faceit/championship-bracket` | `faceit-championship-bracket` | FACEIT championship group bracket by group and round |
45
+ | `GET` | `/faceit/championship-participants` | `faceit-championship-participants` | FACEIT championship participants page |
46
+ | `GET` | `/faceit/championship-search` | `faceit-championship-search` | Discover FACEIT championships and leaderboards |
47
+ | `GET` | `/faceit/clip` | `faceit-clip` | FACEIT Allstar clip detail |
48
+ | `GET` | `/faceit/clips` | `faceit-clips` | FACEIT player Allstar clips |
49
+ | `GET` | `/faceit/competition-matches` | `faceit-competition-matches` | FACEIT competition match list |
50
+ | `GET` | `/faceit/fpl` | `faceit-fpl` | FACEIT Pro League circuits |
51
+ | `GET` | `/faceit/game-modes` | `faceit-game-modes` | FACEIT public queues for a game and region |
52
+ | `GET` | `/faceit/games` | `faceit-games` | FACEIT game slugs confirmed by the live map oracle |
53
+ | `GET` | `/faceit/hub` | `faceit-hub` | FACEIT hub detail by id |
54
+ | `GET` | `/faceit/hub-categories` | `faceit-hub-categories` | FACEIT hub category enum |
55
+ | `GET` | `/faceit/hub-memberships` | `faceit-hub-memberships` | FACEIT user hub memberships |
56
+ | `GET` | `/faceit/hubs` | `faceit-hubs` | FACEIT hubs by id |
57
+ | `GET` | `/faceit/hubs-detailed` | `faceit-hubs-detailed` | FACEIT full hub objects for up to 20 ids |
58
+ | `GET` | `/faceit/leaderboard` | `faceit-leaderboard` | FACEIT ranked leaderboard for one game and region |
59
+ | `GET` | `/faceit/leaderboard-detail` | `faceit-leaderboard-detail` | FACEIT leaderboard detail by id |
60
+ | `GET` | `/faceit/leaderboard-statuses` | `faceit-leaderboard-statuses` | FACEIT leaderboard status enum |
61
+ | `GET` | `/faceit/maps` | `faceit-maps` | FACEIT votable maps for a game |
62
+ | `GET` | `/faceit/match-clips` | `faceit-match-clips` | FACEIT Allstar clips for one match |
63
+ | `GET` | `/faceit/organizer` | `faceit-organizer` | FACEIT organizer profile by id |
64
+ | `GET` | `/faceit/player` | `faceit-player` | FACEIT player profile by nickname or user id |
65
+ | `GET` | `/faceit/player-rank` | `faceit-player-rank` | FACEIT player ranked position in one game and region |
66
+ | `GET` | `/faceit/regions` | `faceit-regions` | FACEIT region codes known to the website |
67
+ | `GET` | `/faceit/rule` | `faceit-rule` | FACEIT competition rule detail |
68
+ | `GET` | `/faceit/rules` | `faceit-rules` | FACEIT published competition rules |
69
+ | `GET` | `/faceit/skill-levels` | `faceit-skill-levels` | FACEIT skill levels and Elo bands for a game |
70
+ | `GET` | `/faceit/standings` | `faceit-standings` | FACEIT championship standings by group and round |
71
+ | `GET` | `/faceit/team` | `faceit-team` | FACEIT team profile by id |
72
+ | `GET` | `/faceit/tournaments-past` | `faceit-tournaments-past` | FACEIT player past tournament history |
73
+ | `GET` | `/faceit/user-skills` | `faceit-user-skills` | FACEIT player skills for up to 10 users in one game |
74
+
75
+ See [Crawlora](https://crawlora.net/?utm_source=rubygems&utm_medium=referral&utm_campaign=platform-clients&utm_content=faceit-ruby-homepage), the [API documentation](https://crawlora.net/docs?utm_source=rubygems&utm_medium=referral&utm_campaign=platform-clients&utm_content=faceit-ruby-api-docs), and [the package repository](https://github.com/Crawlora-org/crawlora-faceit) for account setup, the API operation reference, and release history.
@@ -0,0 +1,336 @@
1
+ require "json"
2
+ require "net/http"
3
+ require "uri"
4
+
5
+ module Crawlora
6
+ module Faceit
7
+ module Errors
8
+ class Error < StandardError
9
+ attr_reader :status, :operation_id, :body
10
+
11
+ def initialize(message, status: nil, operation_id: nil, body: nil)
12
+ super(message)
13
+ @status, @operation_id, @body = status, operation_id, body
14
+ end
15
+ end
16
+ class ClientError < Error; end
17
+ class ServerError < Error; end
18
+ class NetworkError < Error; end
19
+ end
20
+
21
+ OPERATIONS = JSON.parse(<<~'JSON').freeze
22
+ {"faceit-ban-reasons": {"bodyParam": null, "bodyRequired": false, "id": "faceit-ban-reasons", "method": "GET", "params": [], "path": "/faceit/ban-reasons", "pathParams": [], "produces": ["application/json"], "queryParams": [], "security": ["ApiKeyAuth"]}, "faceit-banlist": {"bodyParam": null, "bodyRequired": false, "id": "faceit-banlist", "method": "GET", "params": [{"description": "Optional page size, 5-100; default 25.", "in": "query", "name": "size", "type": "integer", "x-example": 25}, {"description": "Optional opaque cursor copied from the previous response; omit for the first page.", "in": "query", "name": "cursor", "type": "string"}, {"description": "Optional ban reason, one of: ban evasion, cheating, multiple accounts, platform abuse, smurfing, toxicity, playing on a smurf (see faceit-ban-reasons).", "in": "query", "name": "reason", "type": "string", "x-example": "toxicity"}], "path": "/faceit/banlist", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "size", "type": "integer"}, {"in": "query", "name": "cursor", "type": "string"}, {"in": "query", "name": "reason", "type": "string"}], "security": ["ApiKeyAuth"]}, "faceit-banlist-stats": {"bodyParam": null, "bodyRequired": false, "id": "faceit-banlist-stats", "method": "GET", "params": [], "path": "/faceit/banlist-stats", "pathParams": [], "produces": ["application/json"], "queryParams": [], "security": ["ApiKeyAuth"]}, "faceit-best-clips": {"bodyParam": null, "bodyRequired": false, "id": "faceit-best-clips", "method": "GET", "params": [{"description": "Game slug; only cs2 has Allstar clips.", "enum": ["cs2"], "in": "query", "name": "game", "required": true, "type": "string", "x-example": "cs2"}, {"description": "FACEIT user UUID.", "in": "query", "name": "user_id", "required": true, "type": "string", "x-example": "74df0e6b-5b41-42d7-93b4-05dc78b9a699"}, {"description": "Inclusive lower bound as an RFC3339 timestamp.", "in": "query", "name": "from", "required": true, "type": "string", "x-example": "2026-01-01T00:00:00Z"}, {"description": "Inclusive upper bound as an RFC3339 timestamp.", "in": "query", "name": "to", "required": true, "type": "string", "x-example": "2026-11-10T00:00:00Z"}, {"description": "Optional page size, 1-100; default 10.", "in": "query", "name": "limit", "type": "integer", "x-example": 10}], "path": "/faceit/best-clips", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["cs2"], "in": "query", "name": "game", "required": true, "type": "string"}, {"in": "query", "name": "user_id", "required": true, "type": "string"}, {"in": "query", "name": "from", "required": true, "type": "string"}, {"in": "query", "name": "to", "required": true, "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "faceit-championship": {"bodyParam": null, "bodyRequired": false, "id": "faceit-championship", "method": "GET", "params": [{"description": "Championship UUID from faceit-championship-search.", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "9888a3f4-e292-4c3a-a511-15d5d2fb112b"}], "path": "/faceit/championship", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "faceit-championship-bracket": {"bodyParam": null, "bodyRequired": false, "id": "faceit-championship-bracket", "method": "GET", "params": [{"description": "Championship UUID from faceit-championship-search.", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "9888a3f4-e292-4c3a-a511-15d5d2fb112b"}, {"description": "Group number.", "in": "query", "name": "group", "required": true, "type": "integer", "x-example": 1}, {"description": "Round number.", "in": "query", "name": "round", "required": true, "type": "integer", "x-example": 1}, {"description": "Optional non-negative start offset.", "in": "query", "name": "start", "type": "integer", "x-example": 0}, {"description": "Optional end offset.", "in": "query", "name": "end", "type": "integer", "x-example": 50}], "path": "/faceit/championship-bracket", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}, {"in": "query", "name": "group", "required": true, "type": "integer"}, {"in": "query", "name": "round", "required": true, "type": "integer"}, {"in": "query", "name": "start", "type": "integer"}, {"in": "query", "name": "end", "type": "integer"}], "security": ["ApiKeyAuth"]}, "faceit-championship-participants": {"bodyParam": null, "bodyRequired": false, "id": "faceit-championship-participants", "method": "GET", "params": [{"description": "Championship UUID from faceit-championship-search.", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "9888a3f4-e292-4c3a-a511-15d5d2fb112b"}, {"description": "Optional page size, 1-50; default 20.", "in": "query", "name": "limit", "type": "integer", "x-example": 20}, {"description": "Optional non-negative row offset.", "in": "query", "name": "offset", "type": "integer", "x-example": 0}], "path": "/faceit/championship-participants", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "offset", "type": "integer"}], "security": ["ApiKeyAuth"]}, "faceit-championship-search": {"bodyParam": null, "bodyRequired": false, "id": "faceit-championship-search", "method": "GET", "params": [{"description": "Optional entity type; defaults to championship. Documented values: championship, hub, tournament, league, club, matchmaking.", "in": "query", "name": "entity_type", "type": "string", "x-example": "championship"}, {"description": "Optional leaderboard type; defaults to championship and normally equals entity_type.", "in": "query", "name": "type", "type": "string", "x-example": "championship"}, {"description": "Optional status, one of ONGOING, UPCOMING or FINISHED; defaults to ONGOING.", "enum": ["ONGOING", "UPCOMING", "FINISHED"], "in": "query", "name": "status", "type": "string", "x-example": "ONGOING"}, {"description": "Optional leaderboard subtype filter.", "in": "query", "name": "subtype", "type": "string"}, {"description": "Optional two-letter ISO country code such as DE.", "in": "query", "name": "country", "type": "string", "x-example": "DE"}, {"description": "Optional game slug, one of the values returned by faceit-games.", "enum": ["cs2", "csgo", "ow2", "valorant", "pubg", "tf2", "krunker", "pubgmobile", "apex", "fortnite", "wow", "brawl_stars", "insidia", "dota2", "hearthstone", "wildrift", "clash_royale", "smite", "lol_NA", "lol_EUW", "lol_EUN", "overwatch_EU", "wot_EU", "wot_RU", "rainbow_6", "csdz", "battalion"], "in": "query", "name": "game", "type": "string", "x-example": "cs2,csgo,ow2,valorant,pubg,tf2,krunker,pubgmobile,apex,fortnite,wow,brawl_stars,insidia,dota2,hearthstone,wildrift,clash_royale,smite,lol_NA,lol_EUW,lol_EUN,overwatch_EU,wot_EU,wot_RU,rainbow_6,csdz,battalion"}, {"description": "Optional drops filter.", "in": "query", "name": "has_drops", "type": "boolean", "x-example": true}, {"description": "Optional page size, 1-100; default 25.", "in": "query", "name": "limit", "type": "integer", "x-example": 20}, {"description": "Optional non-negative row offset.", "in": "query", "name": "offset", "type": "integer", "x-example": 0}], "path": "/faceit/championship-search", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "entity_type", "type": "string"}, {"in": "query", "name": "type", "type": "string"}, {"enum": ["ONGOING", "UPCOMING", "FINISHED"], "in": "query", "name": "status", "type": "string"}, {"in": "query", "name": "subtype", "type": "string"}, {"in": "query", "name": "country", "type": "string"}, {"enum": ["cs2", "csgo", "ow2", "valorant", "pubg", "tf2", "krunker", "pubgmobile", "apex", "fortnite", "wow", "brawl_stars", "insidia", "dota2", "hearthstone", "wildrift", "clash_royale", "smite", "lol_NA", "lol_EUW", "lol_EUN", "overwatch_EU", "wot_EU", "wot_RU", "rainbow_6", "csdz", "battalion"], "in": "query", "name": "game", "type": "string"}, {"in": "query", "name": "has_drops", "type": "boolean"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "offset", "type": "integer"}], "security": ["ApiKeyAuth"]}, "faceit-clip": {"bodyParam": null, "bodyRequired": false, "id": "faceit-clip", "method": "GET", "params": [{"description": "24-character clip id from faceit-clips.", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "6a57e63f8d9a5a0549f503c8"}], "path": "/faceit/clip", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "faceit-clips": {"bodyParam": null, "bodyRequired": false, "id": "faceit-clips", "method": "GET", "params": [{"description": "Game slug; only cs2 has Allstar clips.", "enum": ["cs2"], "in": "query", "name": "game", "required": true, "type": "string", "x-example": "cs2,csgo,ow2,valorant,pubg,tf2,krunker,pubgmobile,apex,fortnite,wow,brawl_stars,insidia,dota2,hearthstone,wildrift,clash_royale,smite,lol_NA,lol_EUW,lol_EUN,overwatch_EU,wot_EU,wot_RU,rainbow_6,csdz,battalion"}, {"description": "FACEIT user UUID.", "in": "query", "name": "user_id", "required": true, "type": "string", "x-example": "74df0e6b-5b41-42d7-93b4-05dc78b9a699"}, {"description": "Optional page size, 1-100; default 10.", "in": "query", "name": "limit", "type": "integer", "x-example": 10}, {"description": "Optional non-negative row offset.", "in": "query", "name": "offset", "type": "integer", "x-example": 0}], "path": "/faceit/clips", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["cs2"], "in": "query", "name": "game", "required": true, "type": "string"}, {"in": "query", "name": "user_id", "required": true, "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "offset", "type": "integer"}], "security": ["ApiKeyAuth"]}, "faceit-competition-matches": {"bodyParam": null, "bodyRequired": false, "id": "faceit-competition-matches", "method": "GET", "params": [{"description": "Competition id from faceit-championship-search.", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "9888a3f4-e292-4c3a-a511-15d5d2fb112b"}, {"description": "Competition type such as championship; the upstream rejects a missing type.", "in": "query", "name": "type", "required": true, "type": "string", "x-example": "championship"}, {"description": "Optional player UUID filter.", "in": "query", "name": "player_id", "type": "string", "x-example": "74df0e6b-5b41-42d7-93b4-05dc78b9a699"}, {"description": "Optional non-negative page number; default 0.", "in": "query", "name": "page", "type": "integer", "x-example": 0}, {"description": "Optional page size, 1-100; default 20.", "in": "query", "name": "size", "type": "integer", "x-example": 20}], "path": "/faceit/competition-matches", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}, {"in": "query", "name": "type", "required": true, "type": "string"}, {"in": "query", "name": "player_id", "type": "string"}, {"in": "query", "name": "page", "type": "integer"}, {"in": "query", "name": "size", "type": "integer"}], "security": ["ApiKeyAuth"]}, "faceit-fpl": {"bodyParam": null, "bodyRequired": false, "id": "faceit-fpl", "method": "GET", "params": [{"description": "Optional game slug, one of the values returned by faceit-games.", "enum": ["cs2", "csgo", "ow2", "valorant", "pubg", "tf2", "krunker", "pubgmobile", "apex", "fortnite", "wow", "brawl_stars", "insidia", "dota2", "hearthstone", "wildrift", "clash_royale", "smite", "lol_NA", "lol_EUW", "lol_EUN", "overwatch_EU", "wot_EU", "wot_RU", "rainbow_6", "csdz", "battalion"], "in": "query", "name": "game", "type": "string", "x-example": "cs2,csgo,ow2,valorant,pubg,tf2,krunker,pubgmobile,apex,fortnite,wow,brawl_stars,insidia,dota2,hearthstone,wildrift,clash_royale,smite,lol_NA,lol_EUW,lol_EUN,overwatch_EU,wot_EU,wot_RU,rainbow_6,csdz,battalion"}, {"description": "Optional page size, 1-100; default 20.", "in": "query", "name": "limit", "type": "integer", "x-example": 20}, {"description": "Optional non-negative row offset.", "in": "query", "name": "offset", "type": "integer", "x-example": 0}], "path": "/faceit/fpl", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["cs2", "csgo", "ow2", "valorant", "pubg", "tf2", "krunker", "pubgmobile", "apex", "fortnite", "wow", "brawl_stars", "insidia", "dota2", "hearthstone", "wildrift", "clash_royale", "smite", "lol_NA", "lol_EUW", "lol_EUN", "overwatch_EU", "wot_EU", "wot_RU", "rainbow_6", "csdz", "battalion"], "in": "query", "name": "game", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "offset", "type": "integer"}], "security": ["ApiKeyAuth"]}, "faceit-game-modes": {"bodyParam": null, "bodyRequired": false, "id": "faceit-game-modes", "method": "GET", "params": [{"description": "Game slug, one of the values returned by faceit-games.", "enum": ["cs2", "csgo", "ow2", "valorant", "pubg", "tf2", "krunker", "pubgmobile", "apex", "fortnite", "wow", "brawl_stars", "insidia", "dota2", "hearthstone", "wildrift", "clash_royale", "smite", "lol_NA", "lol_EUW", "lol_EUN", "overwatch_EU", "wot_EU", "wot_RU", "rainbow_6", "csdz", "battalion"], "in": "query", "name": "game", "required": true, "type": "string", "x-example": "cs2,csgo,ow2,valorant,pubg,tf2,krunker,pubgmobile,apex,fortnite,wow,brawl_stars,insidia,dota2,hearthstone,wildrift,clash_royale,smite,lol_NA,lol_EUW,lol_EUN,overwatch_EU,wot_EU,wot_RU,rainbow_6,csdz,battalion"}, {"description": "Region code such as EU; see faceit-regions.", "in": "query", "name": "region", "required": true, "type": "string", "x-example": "EU"}], "path": "/faceit/game-modes", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["cs2", "csgo", "ow2", "valorant", "pubg", "tf2", "krunker", "pubgmobile", "apex", "fortnite", "wow", "brawl_stars", "insidia", "dota2", "hearthstone", "wildrift", "clash_royale", "smite", "lol_NA", "lol_EUW", "lol_EUN", "overwatch_EU", "wot_EU", "wot_RU", "rainbow_6", "csdz", "battalion"], "in": "query", "name": "game", "required": true, "type": "string"}, {"in": "query", "name": "region", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "faceit-games": {"bodyParam": null, "bodyRequired": false, "id": "faceit-games", "method": "GET", "params": [], "path": "/faceit/games", "pathParams": [], "produces": ["application/json"], "queryParams": [], "security": ["ApiKeyAuth"]}, "faceit-hub": {"bodyParam": null, "bodyRequired": false, "id": "faceit-hub", "method": "GET", "params": [{"description": "Hub UUID from faceit-hub-memberships.", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "27ccb2d1-2715-4f65-be3f-c5de635fcd31"}], "path": "/faceit/hub", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "faceit-hub-categories": {"bodyParam": null, "bodyRequired": false, "id": "faceit-hub-categories", "method": "GET", "params": [], "path": "/faceit/hub-categories", "pathParams": [], "produces": ["application/json"], "queryParams": [], "security": ["ApiKeyAuth"]}, "faceit-hub-memberships": {"bodyParam": null, "bodyRequired": false, "id": "faceit-hub-memberships", "method": "GET", "params": [{"description": "FACEIT user UUID.", "in": "query", "name": "user_id", "required": true, "type": "string", "x-example": "74df0e6b-5b41-42d7-93b4-05dc78b9a699"}, {"description": "Optional hub category; one of community, chat or ihl.", "enum": ["community", "chat", "ihl"], "in": "query", "name": "category", "type": "string", "x-example": "community"}, {"description": "Optional page size, 1-50; default 20.", "in": "query", "name": "limit", "type": "integer", "x-example": 20}, {"description": "Optional non-negative row offset.", "in": "query", "name": "offset", "type": "integer", "x-example": 0}], "path": "/faceit/hub-memberships", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "user_id", "required": true, "type": "string"}, {"enum": ["community", "chat", "ihl"], "in": "query", "name": "category", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "offset", "type": "integer"}], "security": ["ApiKeyAuth"]}, "faceit-hubs": {"bodyParam": null, "bodyRequired": false, "id": "faceit-hubs", "method": "GET", "params": [{"collectionFormat": "multi", "description": "Hub UUIDs; repeat the parameter for up to 20 hubs.", "in": "query", "items": {"type": "string"}, "name": "ids", "required": true, "type": "array", "x-example": "27ccb2d1-2715-4f65-be3f-c5de635fcd31"}], "path": "/faceit/hubs", "pathParams": [], "produces": ["application/json"], "queryParams": [{"collectionFormat": "multi", "in": "query", "name": "ids", "required": true, "type": "array"}], "security": ["ApiKeyAuth"]}, "faceit-hubs-detailed": {"bodyParam": null, "bodyRequired": false, "id": "faceit-hubs-detailed", "method": "GET", "params": [{"collectionFormat": "multi", "description": "Hub UUIDs; repeat the parameter for up to 20 hubs.", "in": "query", "items": {"type": "string"}, "name": "ids", "required": true, "type": "array", "x-example": "27ccb2d1-2715-4f65-be3f-c5de635fcd31"}], "path": "/faceit/hubs-detailed", "pathParams": [], "produces": ["application/json"], "queryParams": [{"collectionFormat": "multi", "in": "query", "name": "ids", "required": true, "type": "array"}], "security": ["ApiKeyAuth"]}, "faceit-leaderboard": {"bodyParam": null, "bodyRequired": false, "id": "faceit-leaderboard", "method": "GET", "params": [{"description": "Game slug, one of the values returned by faceit-games.", "enum": ["cs2", "csgo", "ow2", "valorant", "pubg", "tf2", "krunker", "pubgmobile", "apex", "fortnite", "wow", "brawl_stars", "insidia", "dota2", "hearthstone", "wildrift", "clash_royale", "smite", "lol_NA", "lol_EUW", "lol_EUN", "overwatch_EU", "wot_EU", "wot_RU", "rainbow_6", "csdz", "battalion"], "in": "query", "name": "game", "required": true, "type": "string", "x-example": "cs2,csgo,ow2,valorant,pubg,tf2,krunker,pubgmobile,apex,fortnite,wow,brawl_stars,insidia,dota2,hearthstone,wildrift,clash_royale,smite,lol_NA,lol_EUW,lol_EUN,overwatch_EU,wot_EU,wot_RU,rainbow_6,csdz,battalion"}, {"description": "Region code such as EU or NA; see faceit-regions.", "in": "query", "name": "region", "required": true, "type": "string", "x-example": "EU"}, {"description": "Optional season number; when set the season-aware ranking is read.", "in": "query", "name": "season", "type": "integer", "x-example": 10}, {"description": "Optional page size, 1-100; default 20 and the gateway caps a page at 100 rows.", "in": "query", "name": "limit", "type": "integer", "x-example": 20}, {"description": "Optional non-negative row offset.", "in": "query", "name": "offset", "type": "integer", "x-example": 0}], "path": "/faceit/leaderboard", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["cs2", "csgo", "ow2", "valorant", "pubg", "tf2", "krunker", "pubgmobile", "apex", "fortnite", "wow", "brawl_stars", "insidia", "dota2", "hearthstone", "wildrift", "clash_royale", "smite", "lol_NA", "lol_EUW", "lol_EUN", "overwatch_EU", "wot_EU", "wot_RU", "rainbow_6", "csdz", "battalion"], "in": "query", "name": "game", "required": true, "type": "string"}, {"in": "query", "name": "region", "required": true, "type": "string"}, {"in": "query", "name": "season", "type": "integer"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "offset", "type": "integer"}], "security": ["ApiKeyAuth"]}, "faceit-leaderboard-detail": {"bodyParam": null, "bodyRequired": false, "id": "faceit-leaderboard-detail", "method": "GET", "params": [{"description": "24-character leaderboard id from faceit-championship-search or faceit-standings.", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "5b0d895ef2e59b000687c9ed"}], "path": "/faceit/leaderboard-detail", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "faceit-leaderboard-statuses": {"bodyParam": null, "bodyRequired": false, "id": "faceit-leaderboard-statuses", "method": "GET", "params": [], "path": "/faceit/leaderboard-statuses", "pathParams": [], "produces": ["application/json"], "queryParams": [], "security": ["ApiKeyAuth"]}, "faceit-maps": {"bodyParam": null, "bodyRequired": false, "id": "faceit-maps", "method": "GET", "params": [{"description": "Game slug, one of the values returned by faceit-games.", "enum": ["cs2", "csgo", "ow2", "valorant", "pubg", "tf2", "krunker", "pubgmobile", "apex", "fortnite", "wow", "brawl_stars", "insidia", "dota2", "hearthstone", "wildrift", "clash_royale", "smite", "lol_NA", "lol_EUW", "lol_EUN", "overwatch_EU", "wot_EU", "wot_RU", "rainbow_6", "csdz", "battalion"], "in": "query", "name": "game", "required": true, "type": "string", "x-example": "cs2,csgo,ow2,valorant,pubg,tf2,krunker,pubgmobile,apex,fortnite,wow,brawl_stars,insidia,dota2,hearthstone,wildrift,clash_royale,smite,lol_NA,lol_EUW,lol_EUN,overwatch_EU,wot_EU,wot_RU,rainbow_6,csdz,battalion"}], "path": "/faceit/maps", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["cs2", "csgo", "ow2", "valorant", "pubg", "tf2", "krunker", "pubgmobile", "apex", "fortnite", "wow", "brawl_stars", "insidia", "dota2", "hearthstone", "wildrift", "clash_royale", "smite", "lol_NA", "lol_EUW", "lol_EUN", "overwatch_EU", "wot_EU", "wot_RU", "rainbow_6", "csdz", "battalion"], "in": "query", "name": "game", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "faceit-match-clips": {"bodyParam": null, "bodyRequired": false, "id": "faceit-match-clips", "method": "GET", "params": [{"description": "Game slug; only cs2 has Allstar clips.", "enum": ["cs2"], "in": "query", "name": "game", "required": true, "type": "string", "x-example": "cs2"}, {"description": "Upstream match id from a clip row, for example 1-bef84e57-4ce3-41aa-b5e5-2918228c1c28.", "in": "query", "name": "match_id", "required": true, "type": "string", "x-example": "1-bef84e57-4ce3-41aa-b5e5-2918228c1c28"}, {"description": "Optional page size, 1-100; default 10.", "in": "query", "name": "limit", "type": "integer", "x-example": 10}, {"description": "Optional non-negative row offset.", "in": "query", "name": "offset", "type": "integer", "x-example": 0}], "path": "/faceit/match-clips", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["cs2"], "in": "query", "name": "game", "required": true, "type": "string"}, {"in": "query", "name": "match_id", "required": true, "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "offset", "type": "integer"}], "security": ["ApiKeyAuth"]}, "faceit-organizer": {"bodyParam": null, "bodyRequired": false, "id": "faceit-organizer", "method": "GET", "params": [{"description": "Organizer UUID.", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "73d4185d-559f-4dbc-8398-9eae47adfe27"}], "path": "/faceit/organizer", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "faceit-player": {"bodyParam": null, "bodyRequired": false, "id": "faceit-player", "method": "GET", "params": [{"description": "Optional FACEIT nickname; exactly one of nickname and user_id is required.", "in": "query", "name": "nickname", "type": "string", "x-example": "dem0nnnnnnnn"}, {"description": "Optional FACEIT user UUID; exactly one of nickname and user_id is required.", "in": "query", "name": "user_id", "type": "string", "x-example": "74df0e6b-5b41-42d7-93b4-05dc78b9a699"}], "path": "/faceit/player", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "nickname", "type": "string"}, {"in": "query", "name": "user_id", "type": "string"}], "security": ["ApiKeyAuth"]}, "faceit-player-rank": {"bodyParam": null, "bodyRequired": false, "id": "faceit-player-rank", "method": "GET", "params": [{"description": "Game slug, one of the values returned by faceit-games.", "enum": ["cs2", "csgo", "ow2", "valorant", "pubg", "tf2", "krunker", "pubgmobile", "apex", "fortnite", "wow", "brawl_stars", "insidia", "dota2", "hearthstone", "wildrift", "clash_royale", "smite", "lol_NA", "lol_EUW", "lol_EUN", "overwatch_EU", "wot_EU", "wot_RU", "rainbow_6", "csdz", "battalion"], "in": "query", "name": "game", "required": true, "type": "string", "x-example": "cs2,csgo,ow2,valorant,pubg,tf2,krunker,pubgmobile,apex,fortnite,wow,brawl_stars,insidia,dota2,hearthstone,wildrift,clash_royale,smite,lol_NA,lol_EUW,lol_EUN,overwatch_EU,wot_EU,wot_RU,rainbow_6,csdz,battalion"}, {"description": "Region code such as EU or NA; see faceit-regions for the documented values.", "in": "query", "name": "region", "required": true, "type": "string", "x-example": "EU"}, {"description": "Optional FACEIT nickname; exactly one of nickname and user_id is required.", "in": "query", "name": "nickname", "type": "string", "x-example": "dem0nnnnnnnn"}, {"description": "Optional FACEIT user UUID; exactly one of nickname and user_id is required.", "in": "query", "name": "user_id", "type": "string", "x-example": "74df0e6b-5b41-42d7-93b4-05dc78b9a699"}, {"description": "Optional season number; when set the season-aware ranking is read.", "in": "query", "name": "season", "type": "integer", "x-example": 10}], "path": "/faceit/player-rank", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["cs2", "csgo", "ow2", "valorant", "pubg", "tf2", "krunker", "pubgmobile", "apex", "fortnite", "wow", "brawl_stars", "insidia", "dota2", "hearthstone", "wildrift", "clash_royale", "smite", "lol_NA", "lol_EUW", "lol_EUN", "overwatch_EU", "wot_EU", "wot_RU", "rainbow_6", "csdz", "battalion"], "in": "query", "name": "game", "required": true, "type": "string"}, {"in": "query", "name": "region", "required": true, "type": "string"}, {"in": "query", "name": "nickname", "type": "string"}, {"in": "query", "name": "user_id", "type": "string"}, {"in": "query", "name": "season", "type": "integer"}], "security": ["ApiKeyAuth"]}, "faceit-regions": {"bodyParam": null, "bodyRequired": false, "id": "faceit-regions", "method": "GET", "params": [], "path": "/faceit/regions", "pathParams": [], "produces": ["application/json"], "queryParams": [], "security": ["ApiKeyAuth"]}, "faceit-rule": {"bodyParam": null, "bodyRequired": false, "id": "faceit-rule", "method": "GET", "params": [{"description": "Rule UUID from faceit-rules.", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "43e07c2c-c0b2-4872-9826-6812eba70463"}], "path": "/faceit/rule", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "faceit-rules": {"bodyParam": null, "bodyRequired": false, "id": "faceit-rules", "method": "GET", "params": [{"description": "Optional page size, 1-100; default 20.", "in": "query", "name": "limit", "type": "integer", "x-example": 20}, {"description": "Optional non-negative row offset.", "in": "query", "name": "offset", "type": "integer", "x-example": 0}], "path": "/faceit/rules", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "offset", "type": "integer"}], "security": ["ApiKeyAuth"]}, "faceit-skill-levels": {"bodyParam": null, "bodyRequired": false, "id": "faceit-skill-levels", "method": "GET", "params": [{"description": "Game slug, one of the values returned by faceit-games.", "enum": ["cs2", "csgo", "ow2", "valorant", "pubg", "tf2", "krunker", "pubgmobile", "apex", "fortnite", "wow", "brawl_stars", "insidia", "dota2", "hearthstone", "wildrift", "clash_royale", "smite", "lol_NA", "lol_EUW", "lol_EUN", "overwatch_EU", "wot_EU", "wot_RU", "rainbow_6", "csdz", "battalion"], "in": "query", "name": "game", "required": true, "type": "string", "x-example": "cs2,csgo,ow2,valorant,pubg,tf2,krunker,pubgmobile,apex,fortnite,wow,brawl_stars,insidia,dota2,hearthstone,wildrift,clash_royale,smite,lol_NA,lol_EUW,lol_EUN,overwatch_EU,wot_EU,wot_RU,rainbow_6,csdz,battalion"}], "path": "/faceit/skill-levels", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["cs2", "csgo", "ow2", "valorant", "pubg", "tf2", "krunker", "pubgmobile", "apex", "fortnite", "wow", "brawl_stars", "insidia", "dota2", "hearthstone", "wildrift", "clash_royale", "smite", "lol_NA", "lol_EUW", "lol_EUN", "overwatch_EU", "wot_EU", "wot_RU", "rainbow_6", "csdz", "battalion"], "in": "query", "name": "game", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "faceit-standings": {"bodyParam": null, "bodyRequired": false, "id": "faceit-standings", "method": "GET", "params": [{"description": "Championship UUID from faceit-championship-search.", "in": "query", "name": "entity_id", "required": true, "type": "string", "x-example": "9888a3f4-e292-4c3a-a511-15d5d2fb112b"}, {"description": "Group number.", "in": "query", "name": "group", "required": true, "type": "integer", "x-example": 1}, {"description": "Round number, or a comma-separated list such as 1,2.", "in": "query", "name": "round", "required": true, "type": "string", "x-example": "1"}, {"description": "Optional segment number; provide segment or match.", "in": "query", "name": "segment", "type": "integer", "x-example": 1}, {"description": "Optional match number; provide segment or match.", "in": "query", "name": "match", "type": "integer", "x-example": 1}], "path": "/faceit/standings", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "entity_id", "required": true, "type": "string"}, {"in": "query", "name": "group", "required": true, "type": "integer"}, {"in": "query", "name": "round", "required": true, "type": "string"}, {"in": "query", "name": "segment", "type": "integer"}, {"in": "query", "name": "match", "type": "integer"}], "security": ["ApiKeyAuth"]}, "faceit-team": {"bodyParam": null, "bodyRequired": false, "id": "faceit-team", "method": "GET", "params": [{"description": "Team UUID from a premade bracket faction id.", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "3279bf46-2cd3-43d1-b4d7-2dfd24d1d843"}], "path": "/faceit/team", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "faceit-tournaments-past": {"bodyParam": null, "bodyRequired": false, "id": "faceit-tournaments-past", "method": "GET", "params": [{"description": "FACEIT nickname.", "in": "query", "name": "nickname", "required": true, "type": "string", "x-example": "dem0nnnnnnnn"}, {"description": "Optional page size, 1-100; default 20.", "in": "query", "name": "limit", "type": "integer", "x-example": 20}, {"description": "Optional non-negative row offset.", "in": "query", "name": "offset", "type": "integer", "x-example": 0}], "path": "/faceit/tournaments-past", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "nickname", "required": true, "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "offset", "type": "integer"}], "security": ["ApiKeyAuth"]}, "faceit-user-skills": {"bodyParam": null, "bodyRequired": false, "id": "faceit-user-skills", "method": "GET", "params": [{"collectionFormat": "multi", "description": "Required FACEIT user UUIDs; repeat the parameter for up to 10 users.", "in": "query", "items": {"type": "string"}, "name": "user_ids", "required": true, "type": "array", "x-example": "74df0e6b-5b41-42d7-93b4-05dc78b9a699"}, {"description": "Game slug, one of the values returned by faceit-games.", "in": "query", "name": "game", "required": true, "type": "string", "x-example": "cs2,csgo,ow2,valorant,pubg,tf2,krunker,pubgmobile,apex,fortnite,wow,brawl_stars,insidia,dota2,hearthstone,wildrift,clash_royale,smite,lol_NA,lol_EUW,lol_EUN,overwatch_EU,wot_EU,wot_RU,rainbow_6,csdz,battalion"}], "path": "/faceit/user-skills", "pathParams": [], "produces": ["application/json"], "queryParams": [{"collectionFormat": "multi", "in": "query", "name": "user_ids", "required": true, "type": "array"}, {"in": "query", "name": "game", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}}
23
+ JSON
24
+ OPERATION_IDS = JSON.parse(<<~'JSON').freeze
25
+ ["faceit-ban-reasons", "faceit-banlist", "faceit-banlist-stats", "faceit-best-clips", "faceit-championship", "faceit-championship-bracket", "faceit-championship-participants", "faceit-championship-search", "faceit-clip", "faceit-clips", "faceit-competition-matches", "faceit-fpl", "faceit-game-modes", "faceit-games", "faceit-hub", "faceit-hub-categories", "faceit-hub-memberships", "faceit-hubs", "faceit-hubs-detailed", "faceit-leaderboard", "faceit-leaderboard-detail", "faceit-leaderboard-statuses", "faceit-maps", "faceit-match-clips", "faceit-organizer", "faceit-player", "faceit-player-rank", "faceit-regions", "faceit-rule", "faceit-rules", "faceit-skill-levels", "faceit-standings", "faceit-team", "faceit-tournaments-past", "faceit-user-skills"]
26
+ JSON
27
+ OPERATION_COUNT = OPERATION_IDS.length
28
+
29
+ class Client
30
+ attr_reader :base_url
31
+
32
+ def initialize(api_key: ENV["CRAWLORA_API_KEY"], base_url: "https://api.crawlora.net/api/v1", timeout: 30, user_agent: "crawlora-faceit-ruby/0.1.1", transport: nil)
33
+ @api_key = api_key
34
+ @base_url = base_url.to_s.sub(%r{/+$}, "")
35
+ @timeout = Float(timeout)
36
+ @user_agent = user_agent
37
+ @transport = transport
38
+ @closed = false
39
+ end
40
+
41
+ def request(operation_id, params = {}, response_type: :auto)
42
+ raise Errors::ClientError, "client is closed" if @closed
43
+ operation_id = operation_id.to_s
44
+ operation = OPERATIONS[operation_id]
45
+ raise Errors::ClientError.new("unknown operation: #{operation_id}", operation_id: operation_id) unless operation
46
+ raise Errors::ClientError.new("Crawlora API key is required", operation_id: operation_id) if @api_key.nil? || @api_key.to_s.empty?
47
+ normalized = params.each_with_object({}) { |(key, value), out| out[key.to_s] = value }
48
+ payload = request_body(operation, normalized)
49
+ url = build_url(operation, normalized)
50
+ uri = URI.parse(url)
51
+ request = operation["method"] == "POST" ? Net::HTTP::Post.new(uri) : Net::HTTP::Get.new(uri)
52
+ unless payload.nil?
53
+ request.body = payload
54
+ request["Content-Type"] = "application/json"
55
+ end
56
+ request["x-api-key"] = @api_key
57
+ request["User-Agent"] = @user_agent
58
+ request["Accept"] = operation["produces"].include?("text/plain") ? "application/json, text/plain" : "application/json"
59
+ begin
60
+ if @transport
61
+ response = if operation["method"] == "POST"
62
+ @transport.call(url, request.to_hash, @timeout, "POST", payload)
63
+ else
64
+ @transport.call(url, request.to_hash, @timeout)
65
+ end
66
+ status = Integer(response.fetch(:status) { response.fetch("status") })
67
+ body = response.fetch(:body) { response.fetch("body", "") }
68
+ headers = response.fetch(:headers) { response.fetch("headers", {}) }
69
+ content_type = headers["content-type"] || headers["Content-Type"]
70
+ else
71
+ http = Net::HTTP.new(uri.host, uri.port)
72
+ http.use_ssl = uri.scheme == "https"
73
+ http.open_timeout = @timeout
74
+ http.read_timeout = @timeout
75
+ response = http.start { |connection| connection.request(request) }
76
+ status = response.code.to_i
77
+ body = response.body
78
+ content_type = response["content-type"]
79
+ end
80
+ rescue Timeout::Error, SocketError, SystemCallError, IOError, EOFError, Net::HTTPBadResponse, Net::ProtocolError, OpenSSL::SSL::SSLError => error
81
+ raise Errors::NetworkError.new("Crawlora request failed: #{error.message}", operation_id: operation_id)
82
+ end
83
+ unless status >= 200 && status < 300
84
+ klass = status >= 500 ? Errors::ServerError : Errors::ClientError
85
+ raise klass.new("Crawlora returned HTTP #{status}", status: status, operation_id: operation_id, body: body)
86
+ end
87
+ parse_response(body, content_type, operation, normalized, response_type)
88
+ end
89
+
90
+ def close
91
+ @closed = true
92
+ end
93
+
94
+ def closed?
95
+ @closed
96
+ end
97
+
98
+ def with
99
+ return self unless block_given?
100
+ yield self
101
+ ensure
102
+ close if block_given?
103
+ end
104
+
105
+ def self.operation_count
106
+ OPERATION_COUNT
107
+ end
108
+
109
+ def self.operation_ids
110
+ OPERATION_IDS
111
+ end
112
+
113
+ def self.operations
114
+ OPERATIONS
115
+ end
116
+
117
+ define_method('ban_reasons') do |**params|
118
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
119
+ request('faceit-ban-reasons', params, response_type: response_type)
120
+ end
121
+ define_method('banlist') do |**params|
122
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
123
+ request('faceit-banlist', params, response_type: response_type)
124
+ end
125
+ define_method('banlist_stats') do |**params|
126
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
127
+ request('faceit-banlist-stats', params, response_type: response_type)
128
+ end
129
+ define_method('best_clips') do |**params|
130
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
131
+ request('faceit-best-clips', params, response_type: response_type)
132
+ end
133
+ define_method('championship') do |**params|
134
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
135
+ request('faceit-championship', params, response_type: response_type)
136
+ end
137
+ define_method('championship_bracket') do |**params|
138
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
139
+ request('faceit-championship-bracket', params, response_type: response_type)
140
+ end
141
+ define_method('championship_participants') do |**params|
142
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
143
+ request('faceit-championship-participants', params, response_type: response_type)
144
+ end
145
+ define_method('championship_search') do |**params|
146
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
147
+ request('faceit-championship-search', params, response_type: response_type)
148
+ end
149
+ define_method('clip') do |**params|
150
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
151
+ request('faceit-clip', params, response_type: response_type)
152
+ end
153
+ define_method('clips') do |**params|
154
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
155
+ request('faceit-clips', params, response_type: response_type)
156
+ end
157
+ define_method('competition_matches') do |**params|
158
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
159
+ request('faceit-competition-matches', params, response_type: response_type)
160
+ end
161
+ define_method('fpl') do |**params|
162
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
163
+ request('faceit-fpl', params, response_type: response_type)
164
+ end
165
+ define_method('game_modes') do |**params|
166
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
167
+ request('faceit-game-modes', params, response_type: response_type)
168
+ end
169
+ define_method('games') do |**params|
170
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
171
+ request('faceit-games', params, response_type: response_type)
172
+ end
173
+ define_method('hub') do |**params|
174
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
175
+ request('faceit-hub', params, response_type: response_type)
176
+ end
177
+ define_method('hub_categories') do |**params|
178
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
179
+ request('faceit-hub-categories', params, response_type: response_type)
180
+ end
181
+ define_method('hub_memberships') do |**params|
182
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
183
+ request('faceit-hub-memberships', params, response_type: response_type)
184
+ end
185
+ define_method('hubs') do |**params|
186
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
187
+ request('faceit-hubs', params, response_type: response_type)
188
+ end
189
+ define_method('hubs_detailed') do |**params|
190
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
191
+ request('faceit-hubs-detailed', params, response_type: response_type)
192
+ end
193
+ define_method('leaderboard') do |**params|
194
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
195
+ request('faceit-leaderboard', params, response_type: response_type)
196
+ end
197
+ define_method('leaderboard_detail') do |**params|
198
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
199
+ request('faceit-leaderboard-detail', params, response_type: response_type)
200
+ end
201
+ define_method('leaderboard_statuses') do |**params|
202
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
203
+ request('faceit-leaderboard-statuses', params, response_type: response_type)
204
+ end
205
+ define_method('maps') do |**params|
206
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
207
+ request('faceit-maps', params, response_type: response_type)
208
+ end
209
+ define_method('match_clips') do |**params|
210
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
211
+ request('faceit-match-clips', params, response_type: response_type)
212
+ end
213
+ define_method('organizer') do |**params|
214
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
215
+ request('faceit-organizer', params, response_type: response_type)
216
+ end
217
+ define_method('player') do |**params|
218
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
219
+ request('faceit-player', params, response_type: response_type)
220
+ end
221
+ define_method('player_rank') do |**params|
222
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
223
+ request('faceit-player-rank', params, response_type: response_type)
224
+ end
225
+ define_method('regions') do |**params|
226
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
227
+ request('faceit-regions', params, response_type: response_type)
228
+ end
229
+ define_method('rule') do |**params|
230
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
231
+ request('faceit-rule', params, response_type: response_type)
232
+ end
233
+ define_method('rules') do |**params|
234
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
235
+ request('faceit-rules', params, response_type: response_type)
236
+ end
237
+ define_method('skill_levels') do |**params|
238
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
239
+ request('faceit-skill-levels', params, response_type: response_type)
240
+ end
241
+ define_method('standings') do |**params|
242
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
243
+ request('faceit-standings', params, response_type: response_type)
244
+ end
245
+ define_method('team') do |**params|
246
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
247
+ request('faceit-team', params, response_type: response_type)
248
+ end
249
+ define_method('tournaments_past') do |**params|
250
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
251
+ request('faceit-tournaments-past', params, response_type: response_type)
252
+ end
253
+ define_method('user_skills') do |**params|
254
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
255
+ request('faceit-user-skills', params, response_type: response_type)
256
+ end
257
+
258
+ private
259
+
260
+ # POST operations take their JSON body under the body parameter name or "body".
261
+ def request_body(operation, params)
262
+ name = operation["bodyParam"]
263
+ return nil if name.nil?
264
+ value = params.key?(name) ? params[name] : params["body"]
265
+ if value.nil?
266
+ raise Errors::ClientError.new("missing request body: #{name}", operation_id: operation["id"]) if operation["bodyRequired"]
267
+ return nil
268
+ end
269
+ value.is_a?(String) ? value : JSON.generate(value)
270
+ end
271
+
272
+ def build_url(operation, params)
273
+ known = operation["params"].map { |param| param["name"] }
274
+ known << "body" if operation["bodyParam"]
275
+ unknown = params.keys - known
276
+ raise Errors::ClientError.new("unknown parameters: #{unknown.join(', ')}", operation_id: operation["id"]) unless unknown.empty?
277
+ path = operation["path"].dup
278
+ operation["params"].select { |param| param["in"] == "path" }.each do |param|
279
+ value = params[param["name"]]
280
+ raise Errors::ClientError.new("missing path parameter: #{param['name']}", operation_id: operation["id"]) if value.nil?
281
+ path.sub!("{" + param["name"] + "}", percent_encode(value.to_s))
282
+ end
283
+ pairs = []
284
+ operation["queryParams"].each do |param|
285
+ name = param["name"]
286
+ value = params.key?(name) ? params[name] : param["default"]
287
+ if value.nil?
288
+ raise Errors::ClientError.new("missing query parameter: #{name}", operation_id: operation["id"]) if param["required"]
289
+ next
290
+ end
291
+ enum_values = param["enum"] || (param["items"] && param["items"]["enum"])
292
+ if enum_values && !(value.is_a?(Array) ? value : [value]).all? { |item| enum_values.map(&:to_s).include?(item.to_s) }
293
+ raise Errors::ClientError.new("invalid value for #{name}", operation_id: operation["id"])
294
+ end
295
+ if value.is_a?(Array)
296
+ format = param["collectionFormat"] || "csv"
297
+ if format == "multi"
298
+ value.each { |item| pairs << [name, scalar(item)] }
299
+ else
300
+ separator = {"csv" => ",", "ssv" => " ", "tsv" => "\t", "pipes" => "|"}[format] || ","
301
+ pairs << [name, value.map { |item| scalar(item) }.join(separator)]
302
+ end
303
+ else
304
+ pairs << [name, scalar(value)]
305
+ end
306
+ end
307
+ query = pairs.map { |name, value| "#{percent_encode(name)}=#{percent_encode(value)}" }.join("&")
308
+ @base_url + path + (query.empty? ? "" : "?" + query)
309
+ end
310
+
311
+ def scalar(value)
312
+ value == true ? "true" : (value == false ? "false" : value.to_s)
313
+ end
314
+
315
+ def percent_encode(value)
316
+ URI::DEFAULT_PARSER.escape(value.to_s, /[^A-Za-z0-9\-._~]/)
317
+ end
318
+
319
+ def parse_response(body, content_type, operation, params, response_type)
320
+ type = response_type.to_s
321
+ raise Errors::ClientError.new("response_type must be auto, json, or text", operation_id: operation["id"]) unless %w[auto json text].include?(type)
322
+ format = operation["params"].find { |param| param["name"] == "format" }
323
+ text_formats = format && format["enum"] ? format["enum"].reject { |value| %w[json application/json].include?(value.to_s.downcase) } : []
324
+ raw_format = params["format"] && text_formats.include?(params["format"].to_s)
325
+ json_format = format && format["enum"] && format["enum"].any? { |value| %w[json application/json].include?(value.to_s.downcase) } && %w[json application/json].include?(params["format"].to_s.downcase)
326
+ is_json = json_format || content_type.to_s.downcase.include?("json") || operation["produces"] == ["application/json"]
327
+ return body if type == "text" || raw_format || (type == "auto" && !is_json)
328
+ JSON.parse(body)
329
+ rescue JSON::ParserError => error
330
+ raise Errors::Error.new("invalid JSON response from Crawlora: #{error.message}", operation_id: operation["id"], body: body)
331
+ end
332
+
333
+ public
334
+ end
335
+ end
336
+ end
@@ -0,0 +1,5 @@
1
+ module Crawlora
2
+ module Faceit
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require_relative "faceit/version"
2
+ require_relative "faceit/client"
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crawlora-faceit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Crawlora
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-11-28 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Ruby client for Crawlora's hosted FACEIT API. Covers leaderboards, players,
14
+ teams, matches, tournaments, clips, hubs, and public game modes across 35 endpoints.
15
+ email:
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - CHANGELOG.md
21
+ - LICENSE
22
+ - README.md
23
+ - lib/crawlora/faceit.rb
24
+ - lib/crawlora/faceit/client.rb
25
+ - lib/crawlora/faceit/version.rb
26
+ homepage: https://crawlora.net/?utm_source=rubygems&utm_medium=referral&utm_campaign=platform-clients&utm_content=faceit-ruby-homepage
27
+ licenses:
28
+ - MIT
29
+ metadata:
30
+ source_code_uri: https://github.com/Crawlora-org/crawlora-faceit
31
+ documentation_uri: https://github.com/Crawlora-org/crawlora-faceit/blob/main/ruby/README.md
32
+ rubygems_mfa_required: 'true'
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '2.6'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubygems_version: 3.4.19
49
+ signing_key:
50
+ specification_version: 4
51
+ summary: FACEIT API client for Crawlora (35 endpoints)
52
+ test_files: []