crawlora-rottentomatoes 0.1.0

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: 061f815532fd400f55a188c15cfb35ce62ac6cb3faedc05c4536e5ee14ac6e41
4
+ data.tar.gz: 1a91036accadc424beb5f3e6611f99ef715c6faea591fe63fbcffb25145b78a8
5
+ SHA512:
6
+ metadata.gz: 20329a9dae4ee54e7d6838c8d0b1f0d51b239a832d11970ed010ea00cc0fbe8573edf4f49a6e528848137054d3deb1a85045684a6d7e251cd63177822eda3d27
7
+ data.tar.gz: f8da9d4c4ac0a0d45502ce4711f7934fb31dc48ba9583b881c59d8b0a8eb28d354367bcf87fd887156f3eaa7ae342cf74b75493d8c2b365b44b8ca3a689db8c1
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ - Initial focused Rotten Tomatoes 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,69 @@
1
+ # Crawlora Rotten Tomatoes API client for Ruby (`crawlora-rottentomatoes`)
2
+
3
+ This Ruby gem calls Crawlora's hosted Rotten Tomatoes API at `https://api.crawlora.net/api/v1`. It exposes 29 endpoints covering movie and TV discovery, browse filters, critic profiles, reviews, and title details; it does not call or scrape Rotten Tomatoes directly. Requests require your Crawlora API key and use your account's service plan.
4
+
5
+ ## Install
6
+
7
+ ```ruby
8
+ gem "crawlora-rottentomatoes"
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=rottentomatoes-ruby-signup), open the [Crawlora console](https://crawlora.net/app?utm_source=rubygems&utm_medium=referral&utm_campaign=platform-clients&utm_content=rottentomatoes-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/rottentomatoes"
16
+
17
+ client = Crawlora::Rottentomatoes::Client.new
18
+ result = client.request("rottentomatoes-search", JSON.parse("{\"query\": \"sample\"}"))
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 29 API operations.
24
+
25
+ ```ruby
26
+ client = Crawlora::Rottentomatoes::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 Rotten Tomatoes API endpoints
34
+
35
+ Browse every route included in this gem. The [endpoint reference](https://github.com/Crawlora-org/crawlora-rottentomatoes/blob/main/docs/usage.md) includes parameter and response details.
36
+
37
+ | Method | Endpoint | API operation | Description |
38
+ | --- | --- | --- | --- |
39
+ | `GET` | `/rottentomatoes/browse/filters` | `rottentomatoes-browse-filters` | Rotten Tomatoes browse filter discovery |
40
+ | `GET` | `/rottentomatoes/browse/movies` | `rottentomatoes-browse-movies` | Rotten Tomatoes movie discovery rows |
41
+ | `GET` | `/rottentomatoes/browse/tv` | `rottentomatoes-browse-tv` | Rotten Tomatoes TV discovery rows |
42
+ | `GET` | `/rottentomatoes/critic` | `rottentomatoes-critic` | Rotten Tomatoes critic profile |
43
+ | `GET` | `/rottentomatoes/critic/publications` | `rottentomatoes-critic-publications` | Rotten Tomatoes critic publications |
44
+ | `GET` | `/rottentomatoes/critic/reviews` | `rottentomatoes-critic-reviews` | Rotten Tomatoes reviews by one critic |
45
+ | `GET` | `/rottentomatoes/critics/authors` | `rottentomatoes-critics-authors` | Rotten Tomatoes critic directory |
46
+ | `GET` | `/rottentomatoes/editorial/content` | `rottentomatoes-editorial-content` | Rotten Tomatoes editorial content listing |
47
+ | `GET` | `/rottentomatoes/editorial/detail` | `rottentomatoes-editorial-detail` | Rotten Tomatoes editorial article detail |
48
+ | `GET` | `/rottentomatoes/editorial/search` | `rottentomatoes-editorial-search` | Rotten Tomatoes editorial search |
49
+ | `GET` | `/rottentomatoes/editorial/section` | `rottentomatoes-editorial-section` | Rotten Tomatoes editorial section archive |
50
+ | `GET` | `/rottentomatoes/editorial/taxonomies` | `rottentomatoes-editorial-taxonomies` | Rotten Tomatoes editorial taxonomy discovery |
51
+ | `GET` | `/rottentomatoes/editorial/terms` | `rottentomatoes-editorial-terms` | Rotten Tomatoes editorial taxonomy terms |
52
+ | `GET` | `/rottentomatoes/editorial/types` | `rottentomatoes-editorial-types` | Rotten Tomatoes editorial content types |
53
+ | `GET` | `/rottentomatoes/episode` | `rottentomatoes-episode` | Rotten Tomatoes episode detail |
54
+ | `GET` | `/rottentomatoes/episode/reviews` | `rottentomatoes-episode-reviews` | Rotten Tomatoes TV episode critic reviews |
55
+ | `GET` | `/rottentomatoes/movie` | `rottentomatoes-movie` | Rotten Tomatoes movie detail |
56
+ | `GET` | `/rottentomatoes/movie/reviews` | `rottentomatoes-movie-reviews` | Rotten Tomatoes movie reviews |
57
+ | `GET` | `/rottentomatoes/movie/videos` | `rottentomatoes-movie-videos` | Rotten Tomatoes movie videos and trailers |
58
+ | `GET` | `/rottentomatoes/movies` | `rottentomatoes-movies` | Rotten Tomatoes movie details, several at once |
59
+ | `GET` | `/rottentomatoes/person` | `rottentomatoes-person` | Rotten Tomatoes person detail and filmography |
60
+ | `GET` | `/rottentomatoes/publication` | `rottentomatoes-publication` | Rotten Tomatoes publication profile |
61
+ | `GET` | `/rottentomatoes/publication/reviews` | `rottentomatoes-publication-reviews` | Rotten Tomatoes publication reviews |
62
+ | `GET` | `/rottentomatoes/search` | `rottentomatoes-search` | Rotten Tomatoes movie search |
63
+ | `GET` | `/rottentomatoes/season` | `rottentomatoes-season` | Rotten Tomatoes season detail |
64
+ | `GET` | `/rottentomatoes/season/reviews` | `rottentomatoes-season-reviews` | Rotten Tomatoes TV season critic reviews |
65
+ | `GET` | `/rottentomatoes/series` | `rottentomatoes-series` | Rotten Tomatoes series detail |
66
+ | `GET` | `/rottentomatoes/sitemap/urls` | `rottentomatoes-sitemap-urls` | Rotten Tomatoes sitemap URL page |
67
+ | `GET` | `/rottentomatoes/sitemaps` | `rottentomatoes-sitemaps` | Rotten Tomatoes sitemap discovery |
68
+
69
+ See [Crawlora](https://crawlora.net/?utm_source=rubygems&utm_medium=referral&utm_campaign=platform-clients&utm_content=rottentomatoes-ruby-homepage), the [API documentation](https://crawlora.net/docs?utm_source=rubygems&utm_medium=referral&utm_campaign=platform-clients&utm_content=rottentomatoes-ruby-api-docs), and [the package repository](https://github.com/Crawlora-org/crawlora-rottentomatoes) for account setup, the API operation reference, and release history.
@@ -0,0 +1,312 @@
1
+ require "json"
2
+ require "net/http"
3
+ require "uri"
4
+
5
+ module Crawlora
6
+ module Rottentomatoes
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
+ {"rottentomatoes-browse-filters": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-browse-filters", "method": "GET", "params": [{"description": "Browse list: movies_in_theaters, movies_at_home, movies_coming_soon, tv_series_browse", "enum": ["movies_in_theaters", "movies_at_home", "movies_coming_soon", "tv_series_browse"], "in": "query", "name": "list", "type": "string", "x-example": "movies_in_theaters"}], "path": "/rottentomatoes/browse/filters", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["movies_in_theaters", "movies_at_home", "movies_coming_soon", "tv_series_browse"], "in": "query", "name": "list", "type": "string"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-browse-movies": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-browse-movies", "method": "GET", "params": [{"description": "Movie browse list: movies_in_theaters, movies_at_home, movies_coming_soon", "enum": ["movies_in_theaters", "movies_at_home", "movies_coming_soon"], "in": "query", "name": "list", "type": "string", "x-example": "movies_in_theaters"}, {"description": "Sort value from the selected list's browse/filters response", "enum": ["popular", "newest", "top_box_office", "a_z", "critic_highest", "critic_lowest", "audience_highest", "audience_lowest"], "in": "query", "name": "sort", "type": "string", "x-example": "popular"}, {"description": "Comma-separated genre values from browse/filters", "enum": ["action", "adventure", "animation", "anime", "biography", "comedy", "crime", "documentary", "drama", "entertainment", "faith_and_spirituality", "fantasy", "game_show", "lgbtq", "health_and_wellness", "history", "holiday", "horror", "house_and_garden", "kids_and_family", "music", "musical", "mystery_and_thriller", "nature", "news", "reality", "romance", "sci_fi", "short", "soap", "special_interest", "sports", "stand_up", "talk_show", "travel", "variety", "war", "western"], "in": "query", "name": "genres", "type": "string", "x-example": "action,drama"}, {"description": "Comma-separated content ratings from browse/filters", "enum": ["g", "pg", "pg_13", "r", "nc_17", "nr", "ur"], "in": "query", "name": "ratings", "type": "string", "x-example": "pg_13"}, {"description": "Comma-separated Popcornmeter values from browse/filters", "enum": ["verified_hot", "upright", "spilled"], "in": "query", "name": "audience", "type": "string", "x-example": "upright"}, {"description": "Comma-separated Tomatometer values from browse/filters", "enum": ["certified_fresh", "fresh", "rotten"], "in": "query", "name": "critics", "type": "string", "x-example": "certified_fresh"}, {"description": "Comma-separated streaming/service values from browse/filters", "enum": ["theaters", "fandango", "apple-tv-plus", "netflix", "prime-video", "disney-plus", "max", "peacock", "hulu", "paramount-plus", "amc-plus", "acorn-tv", "apple-tv"], "in": "query", "name": "affiliates", "type": "string", "x-example": "netflix"}, {"description": "Opaque next-page cursor returned in data.page_info.end_cursor", "in": "query", "name": "after", "type": "string", "x-example": "Mjk="}, {"description": "Rows to return, default 30 (one full page), max 30. The cursor always moves past the whole 30-row page, so keep the default when paging", "in": "query", "name": "limit", "type": "integer", "x-example": 30}], "path": "/rottentomatoes/browse/movies", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["movies_in_theaters", "movies_at_home", "movies_coming_soon"], "in": "query", "name": "list", "type": "string"}, {"enum": ["popular", "newest", "top_box_office", "a_z", "critic_highest", "critic_lowest", "audience_highest", "audience_lowest"], "in": "query", "name": "sort", "type": "string"}, {"enum": ["action", "adventure", "animation", "anime", "biography", "comedy", "crime", "documentary", "drama", "entertainment", "faith_and_spirituality", "fantasy", "game_show", "lgbtq", "health_and_wellness", "history", "holiday", "horror", "house_and_garden", "kids_and_family", "music", "musical", "mystery_and_thriller", "nature", "news", "reality", "romance", "sci_fi", "short", "soap", "special_interest", "sports", "stand_up", "talk_show", "travel", "variety", "war", "western"], "in": "query", "name": "genres", "type": "string"}, {"enum": ["g", "pg", "pg_13", "r", "nc_17", "nr", "ur"], "in": "query", "name": "ratings", "type": "string"}, {"enum": ["verified_hot", "upright", "spilled"], "in": "query", "name": "audience", "type": "string"}, {"enum": ["certified_fresh", "fresh", "rotten"], "in": "query", "name": "critics", "type": "string"}, {"enum": ["theaters", "fandango", "apple-tv-plus", "netflix", "prime-video", "disney-plus", "max", "peacock", "hulu", "paramount-plus", "amc-plus", "acorn-tv", "apple-tv"], "in": "query", "name": "affiliates", "type": "string"}, {"in": "query", "name": "after", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-browse-tv": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-browse-tv", "method": "GET", "params": [{"description": "TV browse list: tv_series_browse", "enum": ["tv_series_browse"], "in": "query", "name": "list", "type": "string", "x-example": "tv_series_browse"}, {"description": "Sort value from browse/filters", "enum": ["popular", "newest", "a_z", "critic_highest", "critic_lowest", "audience_highest", "audience_lowest"], "in": "query", "name": "sort", "type": "string", "x-example": "popular"}, {"description": "Comma-separated genre values from browse/filters", "enum": ["action", "adventure", "animation", "anime", "biography", "comedy", "crime", "documentary", "drama", "entertainment", "faith_and_spirituality", "fantasy", "game_show", "lgbtq", "health_and_wellness", "history", "holiday", "horror", "house_and_garden", "kids_and_family", "music", "musical", "mystery_and_thriller", "nature", "news", "reality", "romance", "sci_fi", "short", "soap", "special_interest", "sports", "stand_up", "talk_show", "travel", "variety", "war", "western"], "in": "query", "name": "genres", "type": "string", "x-example": "action,drama"}, {"description": "Comma-separated content ratings from browse/filters", "enum": ["tvy", "tvy7", "tvg", "tvpg", "tv14", "tvma"], "in": "query", "name": "ratings", "type": "string", "x-example": "tv14"}, {"description": "Comma-separated Popcornmeter values from browse/filters", "enum": ["upright", "spilled"], "in": "query", "name": "audience", "type": "string", "x-example": "upright"}, {"description": "Comma-separated Tomatometer values from browse/filters", "enum": ["fresh", "rotten"], "in": "query", "name": "critics", "type": "string", "x-example": "fresh"}, {"description": "Comma-separated streaming/service values from browse/filters", "enum": ["theaters", "fandango", "apple-tv-plus", "netflix", "prime-video", "disney-plus", "max", "peacock", "hulu", "paramount-plus", "amc-plus", "acorn-tv", "apple-tv"], "in": "query", "name": "affiliates", "type": "string", "x-example": "netflix"}, {"description": "Opaque next-page cursor returned in data.page_info.end_cursor", "in": "query", "name": "after", "type": "string", "x-example": "Mjk="}, {"description": "Rows to return, default 30 (one full page), max 30. The cursor always moves past the whole 30-row page, so keep the default when paging", "in": "query", "name": "limit", "type": "integer", "x-example": 30}], "path": "/rottentomatoes/browse/tv", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["tv_series_browse"], "in": "query", "name": "list", "type": "string"}, {"enum": ["popular", "newest", "a_z", "critic_highest", "critic_lowest", "audience_highest", "audience_lowest"], "in": "query", "name": "sort", "type": "string"}, {"enum": ["action", "adventure", "animation", "anime", "biography", "comedy", "crime", "documentary", "drama", "entertainment", "faith_and_spirituality", "fantasy", "game_show", "lgbtq", "health_and_wellness", "history", "holiday", "horror", "house_and_garden", "kids_and_family", "music", "musical", "mystery_and_thriller", "nature", "news", "reality", "romance", "sci_fi", "short", "soap", "special_interest", "sports", "stand_up", "talk_show", "travel", "variety", "war", "western"], "in": "query", "name": "genres", "type": "string"}, {"enum": ["tvy", "tvy7", "tvg", "tvpg", "tv14", "tvma"], "in": "query", "name": "ratings", "type": "string"}, {"enum": ["upright", "spilled"], "in": "query", "name": "audience", "type": "string"}, {"enum": ["fresh", "rotten"], "in": "query", "name": "critics", "type": "string"}, {"enum": ["theaters", "fandango", "apple-tv-plus", "netflix", "prime-video", "disney-plus", "max", "peacock", "hulu", "paramount-plus", "amc-plus", "acorn-tv", "apple-tv"], "in": "query", "name": "affiliates", "type": "string"}, {"in": "query", "name": "after", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-critic": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-critic", "method": "GET", "params": [{"description": "Rotten Tomatoes critic path: /critic/{slug}. /critics/{slug} (the form critics/authors returns) and /profiles/critic/{slug} are accepted too", "in": "query", "name": "path", "type": "string", "x-example": "/critic/mark-kermode"}, {"description": "Absolute https://www.rottentomatoes.com critic URL", "in": "query", "name": "url", "type": "string", "x-example": "https://www.rottentomatoes.com/critic/mark-kermode"}], "path": "/rottentomatoes/critic", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "path", "type": "string"}, {"in": "query", "name": "url", "type": "string"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-critic-publications": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-critic-publications", "method": "GET", "params": [{"description": "Rotten Tomatoes critic path: /critic/{slug}. /critics/{slug} (the form critics/authors returns) and /profiles/critic/{slug} are accepted too", "in": "query", "name": "path", "type": "string", "x-example": "/critic/mark-kermode"}, {"description": "Absolute https://www.rottentomatoes.com critic URL", "in": "query", "name": "url", "type": "string", "x-example": "https://www.rottentomatoes.com/critic/mark-kermode"}], "path": "/rottentomatoes/critic/publications", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "path", "type": "string"}, {"in": "query", "name": "url", "type": "string"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-critic-reviews": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-critic-reviews", "method": "GET", "params": [{"description": "Rotten Tomatoes critic path: /critic/{slug}. /critics/{slug} (the form critics/authors returns) and /profiles/critic/{slug} are accepted too", "in": "query", "name": "path", "type": "string", "x-example": "/critic/mark-kermode"}, {"description": "Absolute https://www.rottentomatoes.com critic URL", "in": "query", "name": "url", "type": "string", "x-example": "https://www.rottentomatoes.com/critic/mark-kermode"}, {"description": "Reviews per page, default 10, max 20. Keep it the same on every page of one walk: the cursor is a page index times this value.", "in": "query", "name": "limit", "type": "integer", "x-example": 10}, {"description": "Pagination cursor: pass data.page_info.end_cursor from the previous response, with the same limit. Lists can be paged through the available reviews.", "in": "query", "name": "after", "type": "string", "x-example": "MQ=="}], "path": "/rottentomatoes/critic/reviews", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "path", "type": "string"}, {"in": "query", "name": "url", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "after", "type": "string"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-critics-authors": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-critics-authors", "method": "GET", "params": [{"description": "Directory letter. Omit when using search; default a.", "enum": ["#", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"], "in": "query", "name": "letter", "type": "string", "x-example": "a"}, {"description": "Search critics by name; cannot be combined with letter", "in": "query", "name": "search", "type": "string", "x-example": "Mae Abdulbaki"}, {"description": "Include the site's inactive critics list", "in": "query", "name": "inactive", "type": "boolean", "x-example": false}, {"description": "Opaque cursor from data.next_cursor", "in": "query", "name": "after", "type": "string", "x-example": "MQ=="}, {"description": "Opaque cursor from data.previous_cursor; cannot be combined with after", "in": "query", "name": "before", "type": "string", "x-example": "MA=="}, {"description": "Rows per page, default 100, range 1 to 100", "in": "query", "name": "limit", "type": "integer", "x-example": 100}], "path": "/rottentomatoes/critics/authors", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["#", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"], "in": "query", "name": "letter", "type": "string"}, {"in": "query", "name": "search", "type": "string"}, {"in": "query", "name": "inactive", "type": "boolean"}, {"in": "query", "name": "after", "type": "string"}, {"in": "query", "name": "before", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-editorial-content": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-editorial-content", "method": "GET", "params": [{"description": "Editorial content type", "enum": ["article", "guide", "gallery", "hub-subpage", "non-rt-publication", "rt-hub", "how-to", "otg-article", "prev", "rt_poll", "pages"], "in": "query", "name": "type", "required": true, "type": "string", "x-example": "guide"}, {"description": "Optional text filter; maximum 200 bytes", "in": "query", "name": "query", "type": "string", "x-example": "horror"}, {"description": "One-based result page from 1 to 10000; default 1", "in": "query", "name": "page", "type": "integer", "x-example": 1}, {"description": "Rows per page, default 20, range 1 to 100", "in": "query", "name": "limit", "type": "integer", "x-example": 20}, {"description": "Optional editorial taxonomy; discover type support from /rottentomatoes/editorial/taxonomies", "enum": ["categories", "tags", "related-movie-id", "related-tv-season-id", "related-tv-series-id", "related-tv-episode-id", "related-celebrity-id", "publication", "franchise", "coauthors"], "in": "query", "name": "taxonomy", "type": "string", "x-example": "related-movie-id"}, {"description": "Comma-separated positive term IDs; required with taxonomy", "in": "query", "name": "term_ids", "type": "string", "x-example": "121877,121876"}, {"description": "Whether any or all selected terms must match; default OR", "enum": ["AND", "OR"], "in": "query", "name": "operator", "type": "string", "x-example": "OR"}, {"description": "For categories only, include child categories; default false", "in": "query", "name": "include_children", "type": "boolean", "x-example": false}], "path": "/rottentomatoes/editorial/content", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["article", "guide", "gallery", "hub-subpage", "non-rt-publication", "rt-hub", "how-to", "otg-article", "prev", "rt_poll", "pages"], "in": "query", "name": "type", "required": true, "type": "string"}, {"in": "query", "name": "query", "type": "string"}, {"in": "query", "name": "page", "type": "integer"}, {"in": "query", "name": "limit", "type": "integer"}, {"enum": ["categories", "tags", "related-movie-id", "related-tv-season-id", "related-tv-series-id", "related-tv-episode-id", "related-celebrity-id", "publication", "franchise", "coauthors"], "in": "query", "name": "taxonomy", "type": "string"}, {"in": "query", "name": "term_ids", "type": "string"}, {"enum": ["AND", "OR"], "in": "query", "name": "operator", "type": "string"}, {"in": "query", "name": "include_children", "type": "boolean"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-editorial-detail": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-editorial-detail", "method": "GET", "params": [{"description": "Discovered Editorial content path", "in": "query", "name": "path", "required": true, "type": "string", "x-example": "/guide/all-brad-pitt-movies-ranked-by-tomatometer/"}], "path": "/rottentomatoes/editorial/detail", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "path", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-editorial-search": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-editorial-search", "method": "GET", "params": [{"description": "Editorial search text; maximum 200 bytes", "in": "query", "name": "query", "required": true, "type": "string", "x-example": "horror"}, {"description": "One-based result page from 1 to 10000; default 1", "in": "query", "name": "page", "type": "integer", "x-example": 1}, {"description": "Rows per page, default 10, range 1 to 100", "in": "query", "name": "limit", "type": "integer", "x-example": 10}], "path": "/rottentomatoes/editorial/search", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "query", "required": true, "type": "string"}, {"in": "query", "name": "page", "type": "integer"}, {"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-editorial-section": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-editorial-section", "method": "GET", "params": [{"description": "Discovered editorial section path", "in": "query", "name": "path", "required": true, "type": "string", "x-example": "/countdown/"}, {"description": "One-based page, default 1", "in": "query", "name": "page", "type": "integer", "x-example": 2}], "path": "/rottentomatoes/editorial/section", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "path", "required": true, "type": "string"}, {"in": "query", "name": "page", "type": "integer"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-editorial-taxonomies": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-editorial-taxonomies", "method": "GET", "params": [], "path": "/rottentomatoes/editorial/taxonomies", "pathParams": [], "produces": ["application/json"], "queryParams": [], "security": ["ApiKeyAuth"]}, "rottentomatoes-editorial-terms": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-editorial-terms", "method": "GET", "params": [{"description": "Editorial taxonomy value", "enum": ["categories", "tags", "related-movie-id", "related-tv-season-id", "related-tv-series-id", "related-tv-episode-id", "related-celebrity-id", "publication", "franchise", "coauthors"], "in": "query", "name": "taxonomy", "required": true, "type": "string", "x-example": "coauthors"}, {"description": "Optional term search; maximum 200 bytes", "in": "query", "name": "search", "type": "string", "x-example": "RT Staff"}, {"description": "One-based page, default 1", "in": "query", "name": "page", "type": "integer", "x-example": 1}, {"description": "Terms per page, default 20, range 1 to 100", "in": "query", "name": "limit", "type": "integer", "x-example": 20}, {"description": "When true, omit terms with no assigned content", "in": "query", "name": "hide_empty", "type": "boolean", "x-example": true}, {"description": "Term sort direction", "enum": ["asc", "desc"], "in": "query", "name": "order", "type": "string", "x-example": "desc"}, {"description": "Term sort key", "enum": ["id", "include", "name", "slug", "include_slugs", "term_group", "description", "count"], "in": "query", "name": "orderby", "type": "string", "x-example": "count"}, {"description": "Comma-separated positive term IDs to include", "in": "query", "name": "include", "type": "string", "x-example": "10732,10733"}, {"description": "Comma-separated positive term IDs to exclude", "in": "query", "name": "exclude", "type": "string", "x-example": "10733"}, {"description": "Optional term slug or comma-separated slugs", "in": "query", "name": "slug", "type": "string", "x-example": "cap-rt-staff"}, {"description": "Filter to terms assigned to this content record", "in": "query", "name": "post", "type": "integer", "x-example": 297765}, {"description": "Zero-based offset; accepted except for categories", "in": "query", "name": "offset", "type": "integer", "x-example": 100}, {"description": "Category parent ID; accepted only for categories", "in": "query", "name": "parent", "type": "integer", "x-example": 0}], "path": "/rottentomatoes/editorial/terms", "pathParams": [], "produces": ["application/json"], "queryParams": [{"enum": ["categories", "tags", "related-movie-id", "related-tv-season-id", "related-tv-series-id", "related-tv-episode-id", "related-celebrity-id", "publication", "franchise", "coauthors"], "in": "query", "name": "taxonomy", "required": true, "type": "string"}, {"in": "query", "name": "search", "type": "string"}, {"in": "query", "name": "page", "type": "integer"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "hide_empty", "type": "boolean"}, {"enum": ["asc", "desc"], "in": "query", "name": "order", "type": "string"}, {"enum": ["id", "include", "name", "slug", "include_slugs", "term_group", "description", "count"], "in": "query", "name": "orderby", "type": "string"}, {"in": "query", "name": "include", "type": "string"}, {"in": "query", "name": "exclude", "type": "string"}, {"in": "query", "name": "slug", "type": "string"}, {"in": "query", "name": "post", "type": "integer"}, {"in": "query", "name": "offset", "type": "integer"}, {"in": "query", "name": "parent", "type": "integer"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-editorial-types": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-editorial-types", "method": "GET", "params": [], "path": "/rottentomatoes/editorial/types", "pathParams": [], "produces": ["application/json"], "queryParams": [], "security": ["ApiKeyAuth"]}, "rottentomatoes-episode": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-episode", "method": "GET", "params": [{"description": "Rotten Tomatoes episode path", "in": "query", "name": "path", "type": "string", "x-example": "/tv/breaking_bad/s01/e01"}, {"description": "Absolute https://www.rottentomatoes.com episode URL", "in": "query", "name": "url", "type": "string", "x-example": "https://www.rottentomatoes.com/tv/breaking_bad/s01/e01"}], "path": "/rottentomatoes/episode", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "path", "type": "string"}, {"in": "query", "name": "url", "type": "string"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-episode-reviews": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-episode-reviews", "method": "GET", "params": [{"description": "Rotten Tomatoes episode path", "in": "query", "name": "path", "type": "string", "x-example": "/tv/breaking_bad/s01/e01"}, {"description": "Absolute https://www.rottentomatoes.com episode URL", "in": "query", "name": "url", "type": "string", "x-example": "https://www.rottentomatoes.com/tv/breaking_bad/s01/e01"}, {"description": "Review list: critics (default), top-critics or audience.", "enum": ["critics", "top-critics", "audience"], "in": "query", "name": "type", "type": "string", "x-example": "critics"}, {"description": "Reviews per page, default 10, max 20. Keep it the same on every page of one walk: the cursor is a page index times this value.", "in": "query", "name": "limit", "type": "integer", "x-example": 10}, {"description": "Pagination cursor: pass data.page_info.end_cursor from the previous response, with the same limit. Critic cursors are base64 page indexes; audience cursors are opaque keyset values that should be passed back unchanged. The feed has no 500-review ceiling; browser fallback is capped at five pages.", "in": "query", "name": "after", "type": "string", "x-example": "MQ=="}], "path": "/rottentomatoes/episode/reviews", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "path", "type": "string"}, {"in": "query", "name": "url", "type": "string"}, {"enum": ["critics", "top-critics", "audience"], "in": "query", "name": "type", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "after", "type": "string"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-movie": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-movie", "method": "GET", "params": [{"description": "Rotten Tomatoes movie path", "in": "query", "name": "path", "type": "string", "x-example": "/m/inception"}, {"description": "Absolute https://www.rottentomatoes.com movie URL", "in": "query", "name": "url", "type": "string", "x-example": "https://www.rottentomatoes.com/m/inception"}], "path": "/rottentomatoes/movie", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "path", "type": "string"}, {"in": "query", "name": "url", "type": "string"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-movie-reviews": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-movie-reviews", "method": "GET", "params": [{"description": "Rotten Tomatoes movie path", "in": "query", "name": "path", "type": "string", "x-example": "/m/inception"}, {"description": "Absolute https://www.rottentomatoes.com movie URL", "in": "query", "name": "url", "type": "string", "x-example": "https://www.rottentomatoes.com/m/inception"}, {"description": "Review type: critics, top-critics, audience, verified-audience", "enum": ["critics", "top-critics", "audience", "verified-audience"], "in": "query", "name": "type", "type": "string", "x-example": "critics"}, {"description": "Reviews per page, default 10, max 20. Keep it the same on every page of one walk: the critic cursor is a page index times this value.", "in": "query", "name": "limit", "type": "integer", "x-example": 10}, {"description": "Pagination cursor: pass data.page_info.end_cursor from the previous response. Critic cursors are base64 page indexes; audience cursors are opaque keyset values that should be passed back unchanged. The feed has no 500-review ceiling; browser fallback is capped at five pages. Invalid cursors are rejected before upstream work.", "in": "query", "name": "after", "type": "string", "x-example": "MQ=="}], "path": "/rottentomatoes/movie/reviews", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "path", "type": "string"}, {"in": "query", "name": "url", "type": "string"}, {"enum": ["critics", "top-critics", "audience", "verified-audience"], "in": "query", "name": "type", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "after", "type": "string"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-movie-videos": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-movie-videos", "method": "GET", "params": [{"description": "Rotten Tomatoes movie path", "in": "query", "name": "path", "type": "string", "x-example": "/m/clayface"}, {"description": "Absolute https://www.rottentomatoes.com movie URL", "in": "query", "name": "url", "type": "string", "x-example": "https://www.rottentomatoes.com/m/clayface"}], "path": "/rottentomatoes/movie/videos", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "path", "type": "string"}, {"in": "query", "name": "url", "type": "string"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-movies": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-movies", "method": "GET", "params": [{"description": "Comma-separated Rotten Tomatoes ems_id values, 1 to 20", "in": "query", "name": "ids", "type": "string", "x-example": "d5639ed5-2dfe-44a3-8ed2-1cb3ea99855f"}, {"description": "Comma-separated Rotten Tomatoes movie paths or URLs, 1 to 20", "in": "query", "name": "paths", "type": "string", "x-example": "/m/clayface"}], "path": "/rottentomatoes/movies", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "ids", "type": "string"}, {"in": "query", "name": "paths", "type": "string"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-person": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-person", "method": "GET", "params": [{"description": "Rotten Tomatoes person path", "in": "query", "name": "path", "type": "string", "x-example": "/celebrity/christopher_nolan"}, {"description": "Absolute https://www.rottentomatoes.com person URL", "in": "query", "name": "url", "type": "string", "x-example": "https://www.rottentomatoes.com/celebrity/christopher_nolan"}, {"description": "Filmography list to page: movie or tv. Omit to use the page's embedded first page.", "enum": ["movie", "tv"], "in": "query", "name": "media_type", "type": "string", "x-example": "movie"}, {"description": "Filmography sort order. Omit for newest.", "enum": ["newest", "oldest", "audience_highest", "audience_lowest", "critic_highest", "critic_lowest"], "in": "query", "name": "sort", "type": "string", "x-example": "newest"}, {"description": "Filmography pagination cursor: pass data.page_info.end_cursor from the previous response.", "in": "query", "name": "after", "type": "string", "x-example": "MjM="}, {"description": "Filmography page size. Defaults to 20; a value above 100 is lowered to 100; a negative value is rejected.", "in": "query", "name": "limit", "type": "integer", "x-example": 20}], "path": "/rottentomatoes/person", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "path", "type": "string"}, {"in": "query", "name": "url", "type": "string"}, {"enum": ["movie", "tv"], "in": "query", "name": "media_type", "type": "string"}, {"enum": ["newest", "oldest", "audience_highest", "audience_lowest", "critic_highest", "critic_lowest"], "in": "query", "name": "sort", "type": "string"}, {"in": "query", "name": "after", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-publication": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-publication", "method": "GET", "params": [{"description": "Publication id: encrypted_publication_id or publication_id", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "ld6ANN0Z"}], "path": "/rottentomatoes/publication", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-publication-reviews": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-publication-reviews", "method": "GET", "params": [{"description": "Publication id: encrypted_publication_id", "in": "query", "name": "id", "required": true, "type": "string", "x-example": "ld6ANN0Z"}, {"description": "Reviews per page, default 10, max 20. Keep it the same on every page of one walk.", "in": "query", "name": "limit", "type": "integer", "x-example": 10}, {"description": "Pagination cursor: pass data.page_info.end_cursor from the previous response", "in": "query", "name": "after", "type": "string", "x-example": "MQ=="}], "path": "/rottentomatoes/publication/reviews", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "id", "required": true, "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "after", "type": "string"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-search": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-search", "method": "GET", "params": [{"description": "Search query", "in": "query", "name": "query", "required": true, "type": "string", "x-example": "inception"}, {"description": "Rows to return, default 10, max 20", "in": "query", "name": "limit", "type": "integer", "x-example": 10}], "path": "/rottentomatoes/search", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "query", "required": true, "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-season": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-season", "method": "GET", "params": [{"description": "Rotten Tomatoes season path", "in": "query", "name": "path", "type": "string", "x-example": "/tv/breaking_bad/s01"}, {"description": "Absolute https://www.rottentomatoes.com season URL", "in": "query", "name": "url", "type": "string", "x-example": "https://www.rottentomatoes.com/tv/breaking_bad/s01"}], "path": "/rottentomatoes/season", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "path", "type": "string"}, {"in": "query", "name": "url", "type": "string"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-season-reviews": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-season-reviews", "method": "GET", "params": [{"description": "Rotten Tomatoes season path", "in": "query", "name": "path", "type": "string", "x-example": "/tv/breaking_bad/s01"}, {"description": "Absolute https://www.rottentomatoes.com season URL", "in": "query", "name": "url", "type": "string", "x-example": "https://www.rottentomatoes.com/tv/breaking_bad/s01"}, {"description": "Review list: critics (default), top-critics or audience.", "enum": ["critics", "top-critics", "audience"], "in": "query", "name": "type", "type": "string", "x-example": "critics"}, {"description": "Reviews per page, default 10, max 20. Keep it the same on every page of one walk: the cursor is a page index times this value.", "in": "query", "name": "limit", "type": "integer", "x-example": 10}, {"description": "Pagination cursor: pass data.page_info.end_cursor from the previous response. Critic cursors are base64 page indexes; audience cursors are opaque keyset values that should be passed back unchanged. The feed has no 500-review ceiling; browser fallback is capped at five pages.", "in": "query", "name": "after", "type": "string", "x-example": "MQ=="}], "path": "/rottentomatoes/season/reviews", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "path", "type": "string"}, {"in": "query", "name": "url", "type": "string"}, {"enum": ["critics", "top-critics", "audience"], "in": "query", "name": "type", "type": "string"}, {"in": "query", "name": "limit", "type": "integer"}, {"in": "query", "name": "after", "type": "string"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-series": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-series", "method": "GET", "params": [{"description": "Rotten Tomatoes series path", "in": "query", "name": "path", "type": "string", "x-example": "/tv/breaking_bad"}, {"description": "Absolute https://www.rottentomatoes.com series URL", "in": "query", "name": "url", "type": "string", "x-example": "https://www.rottentomatoes.com/tv/breaking_bad"}], "path": "/rottentomatoes/series", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "path", "type": "string"}, {"in": "query", "name": "url", "type": "string"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-sitemap-urls": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-sitemap-urls", "method": "GET", "params": [{"description": "Sitemap name returned by /rottentomatoes/sitemaps", "in": "query", "name": "name", "required": true, "type": "string", "x-example": "movie_0"}, {"description": "Zero-based offset, default 0", "in": "query", "name": "offset", "type": "integer", "x-example": 0}, {"description": "URLs to return, default 100, max 500", "in": "query", "name": "limit", "type": "integer", "x-example": 100}], "path": "/rottentomatoes/sitemap/urls", "pathParams": [], "produces": ["application/json"], "queryParams": [{"in": "query", "name": "name", "required": true, "type": "string"}, {"in": "query", "name": "offset", "type": "integer"}, {"in": "query", "name": "limit", "type": "integer"}], "security": ["ApiKeyAuth"]}, "rottentomatoes-sitemaps": {"bodyParam": null, "bodyRequired": false, "id": "rottentomatoes-sitemaps", "method": "GET", "params": [], "path": "/rottentomatoes/sitemaps", "pathParams": [], "produces": ["application/json"], "queryParams": [], "security": ["ApiKeyAuth"]}}
23
+ JSON
24
+ OPERATION_IDS = JSON.parse(<<~'JSON').freeze
25
+ ["rottentomatoes-browse-filters", "rottentomatoes-browse-movies", "rottentomatoes-browse-tv", "rottentomatoes-critic", "rottentomatoes-critic-publications", "rottentomatoes-critic-reviews", "rottentomatoes-critics-authors", "rottentomatoes-editorial-content", "rottentomatoes-editorial-detail", "rottentomatoes-editorial-search", "rottentomatoes-editorial-section", "rottentomatoes-editorial-taxonomies", "rottentomatoes-editorial-terms", "rottentomatoes-editorial-types", "rottentomatoes-episode", "rottentomatoes-episode-reviews", "rottentomatoes-movie", "rottentomatoes-movie-reviews", "rottentomatoes-movie-videos", "rottentomatoes-movies", "rottentomatoes-person", "rottentomatoes-publication", "rottentomatoes-publication-reviews", "rottentomatoes-search", "rottentomatoes-season", "rottentomatoes-season-reviews", "rottentomatoes-series", "rottentomatoes-sitemap-urls", "rottentomatoes-sitemaps"]
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-rottentomatoes-ruby/0.1.0", 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('browse_filters') do |**params|
118
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
119
+ request('rottentomatoes-browse-filters', params, response_type: response_type)
120
+ end
121
+ define_method('browse_movies') do |**params|
122
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
123
+ request('rottentomatoes-browse-movies', params, response_type: response_type)
124
+ end
125
+ define_method('browse_tv') do |**params|
126
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
127
+ request('rottentomatoes-browse-tv', params, response_type: response_type)
128
+ end
129
+ define_method('critic') do |**params|
130
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
131
+ request('rottentomatoes-critic', params, response_type: response_type)
132
+ end
133
+ define_method('critic_publications') do |**params|
134
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
135
+ request('rottentomatoes-critic-publications', params, response_type: response_type)
136
+ end
137
+ define_method('critic_reviews') do |**params|
138
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
139
+ request('rottentomatoes-critic-reviews', params, response_type: response_type)
140
+ end
141
+ define_method('critics_authors') do |**params|
142
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
143
+ request('rottentomatoes-critics-authors', params, response_type: response_type)
144
+ end
145
+ define_method('editorial_content') do |**params|
146
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
147
+ request('rottentomatoes-editorial-content', params, response_type: response_type)
148
+ end
149
+ define_method('editorial_detail') do |**params|
150
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
151
+ request('rottentomatoes-editorial-detail', params, response_type: response_type)
152
+ end
153
+ define_method('editorial_search') do |**params|
154
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
155
+ request('rottentomatoes-editorial-search', params, response_type: response_type)
156
+ end
157
+ define_method('editorial_section') do |**params|
158
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
159
+ request('rottentomatoes-editorial-section', params, response_type: response_type)
160
+ end
161
+ define_method('editorial_taxonomies') do |**params|
162
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
163
+ request('rottentomatoes-editorial-taxonomies', params, response_type: response_type)
164
+ end
165
+ define_method('editorial_terms') do |**params|
166
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
167
+ request('rottentomatoes-editorial-terms', params, response_type: response_type)
168
+ end
169
+ define_method('editorial_types') do |**params|
170
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
171
+ request('rottentomatoes-editorial-types', params, response_type: response_type)
172
+ end
173
+ define_method('episode') do |**params|
174
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
175
+ request('rottentomatoes-episode', params, response_type: response_type)
176
+ end
177
+ define_method('episode_reviews') do |**params|
178
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
179
+ request('rottentomatoes-episode-reviews', params, response_type: response_type)
180
+ end
181
+ define_method('movie') do |**params|
182
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
183
+ request('rottentomatoes-movie', params, response_type: response_type)
184
+ end
185
+ define_method('movie_reviews') do |**params|
186
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
187
+ request('rottentomatoes-movie-reviews', params, response_type: response_type)
188
+ end
189
+ define_method('movie_videos') do |**params|
190
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
191
+ request('rottentomatoes-movie-videos', params, response_type: response_type)
192
+ end
193
+ define_method('movies') do |**params|
194
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
195
+ request('rottentomatoes-movies', params, response_type: response_type)
196
+ end
197
+ define_method('person') do |**params|
198
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
199
+ request('rottentomatoes-person', params, response_type: response_type)
200
+ end
201
+ define_method('publication') do |**params|
202
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
203
+ request('rottentomatoes-publication', params, response_type: response_type)
204
+ end
205
+ define_method('publication_reviews') do |**params|
206
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
207
+ request('rottentomatoes-publication-reviews', params, response_type: response_type)
208
+ end
209
+ define_method('search') do |**params|
210
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
211
+ request('rottentomatoes-search', params, response_type: response_type)
212
+ end
213
+ define_method('season') do |**params|
214
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
215
+ request('rottentomatoes-season', params, response_type: response_type)
216
+ end
217
+ define_method('season_reviews') do |**params|
218
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
219
+ request('rottentomatoes-season-reviews', params, response_type: response_type)
220
+ end
221
+ define_method('series') do |**params|
222
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
223
+ request('rottentomatoes-series', params, response_type: response_type)
224
+ end
225
+ define_method('sitemap_urls') do |**params|
226
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
227
+ request('rottentomatoes-sitemap-urls', params, response_type: response_type)
228
+ end
229
+ define_method('sitemaps') do |**params|
230
+ response_type = params.delete(:response_type) || params.delete(:_response_type) || :auto
231
+ request('rottentomatoes-sitemaps', params, response_type: response_type)
232
+ end
233
+
234
+ private
235
+
236
+ # POST operations take their JSON body under the body parameter name or "body".
237
+ def request_body(operation, params)
238
+ name = operation["bodyParam"]
239
+ return nil if name.nil?
240
+ value = params.key?(name) ? params[name] : params["body"]
241
+ if value.nil?
242
+ raise Errors::ClientError.new("missing request body: #{name}", operation_id: operation["id"]) if operation["bodyRequired"]
243
+ return nil
244
+ end
245
+ value.is_a?(String) ? value : JSON.generate(value)
246
+ end
247
+
248
+ def build_url(operation, params)
249
+ known = operation["params"].map { |param| param["name"] }
250
+ known << "body" if operation["bodyParam"]
251
+ unknown = params.keys - known
252
+ raise Errors::ClientError.new("unknown parameters: #{unknown.join(', ')}", operation_id: operation["id"]) unless unknown.empty?
253
+ path = operation["path"].dup
254
+ operation["params"].select { |param| param["in"] == "path" }.each do |param|
255
+ value = params[param["name"]]
256
+ raise Errors::ClientError.new("missing path parameter: #{param['name']}", operation_id: operation["id"]) if value.nil?
257
+ path.sub!("{" + param["name"] + "}", percent_encode(value.to_s))
258
+ end
259
+ pairs = []
260
+ operation["queryParams"].each do |param|
261
+ name = param["name"]
262
+ value = params.key?(name) ? params[name] : param["default"]
263
+ if value.nil?
264
+ raise Errors::ClientError.new("missing query parameter: #{name}", operation_id: operation["id"]) if param["required"]
265
+ next
266
+ end
267
+ enum_values = param["enum"] || (param["items"] && param["items"]["enum"])
268
+ if enum_values && !(value.is_a?(Array) ? value : [value]).all? { |item| enum_values.map(&:to_s).include?(item.to_s) }
269
+ raise Errors::ClientError.new("invalid value for #{name}", operation_id: operation["id"])
270
+ end
271
+ if value.is_a?(Array)
272
+ format = param["collectionFormat"] || "csv"
273
+ if format == "multi"
274
+ value.each { |item| pairs << [name, scalar(item)] }
275
+ else
276
+ separator = {"csv" => ",", "ssv" => " ", "tsv" => "\t", "pipes" => "|"}[format] || ","
277
+ pairs << [name, value.map { |item| scalar(item) }.join(separator)]
278
+ end
279
+ else
280
+ pairs << [name, scalar(value)]
281
+ end
282
+ end
283
+ query = pairs.map { |name, value| "#{percent_encode(name)}=#{percent_encode(value)}" }.join("&")
284
+ @base_url + path + (query.empty? ? "" : "?" + query)
285
+ end
286
+
287
+ def scalar(value)
288
+ value == true ? "true" : (value == false ? "false" : value.to_s)
289
+ end
290
+
291
+ def percent_encode(value)
292
+ URI::DEFAULT_PARSER.escape(value.to_s, /[^A-Za-z0-9\-._~]/)
293
+ end
294
+
295
+ def parse_response(body, content_type, operation, params, response_type)
296
+ type = response_type.to_s
297
+ raise Errors::ClientError.new("response_type must be auto, json, or text", operation_id: operation["id"]) unless %w[auto json text].include?(type)
298
+ format = operation["params"].find { |param| param["name"] == "format" }
299
+ text_formats = format && format["enum"] ? format["enum"].reject { |value| %w[json application/json].include?(value.to_s.downcase) } : []
300
+ raw_format = params["format"] && text_formats.include?(params["format"].to_s)
301
+ 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)
302
+ is_json = json_format || content_type.to_s.downcase.include?("json") || operation["produces"] == ["application/json"]
303
+ return body if type == "text" || raw_format || (type == "auto" && !is_json)
304
+ JSON.parse(body)
305
+ rescue JSON::ParserError => error
306
+ raise Errors::Error.new("invalid JSON response from Crawlora: #{error.message}", operation_id: operation["id"], body: body)
307
+ end
308
+
309
+ public
310
+ end
311
+ end
312
+ end
@@ -0,0 +1,5 @@
1
+ module Crawlora
2
+ module Rottentomatoes
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require_relative "rottentomatoes/version"
2
+ require_relative "rottentomatoes/client"
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crawlora-rottentomatoes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Crawlora
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-11-29 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Ruby client for Crawlora's hosted Rotten Tomatoes API. Covers movie and
14
+ TV discovery, browse filters, critic profiles, reviews, and title details across
15
+ 29 endpoints.
16
+ email:
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - CHANGELOG.md
22
+ - LICENSE
23
+ - README.md
24
+ - lib/crawlora/rottentomatoes.rb
25
+ - lib/crawlora/rottentomatoes/client.rb
26
+ - lib/crawlora/rottentomatoes/version.rb
27
+ homepage: https://crawlora.net/?utm_source=rubygems&utm_medium=referral&utm_campaign=platform-clients&utm_content=rottentomatoes-ruby-homepage
28
+ licenses:
29
+ - MIT
30
+ metadata:
31
+ source_code_uri: https://github.com/Crawlora-org/crawlora-rottentomatoes
32
+ documentation_uri: https://github.com/Crawlora-org/crawlora-rottentomatoes/blob/main/ruby/README.md
33
+ rubygems_mfa_required: 'true'
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '2.6'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubygems_version: 3.4.19
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: Rotten Tomatoes API client for Crawlora (29 endpoints)
53
+ test_files: []