rawg_api 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +97 -0
- data/LICENSE.txt +21 -0
- data/README.md +234 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/rawg_api/boot.rb +39 -0
- data/lib/rawg_api/clients/base_client.rb +31 -0
- data/lib/rawg_api/clients/creator_roles.rb +12 -0
- data/lib/rawg_api/clients/creators.rb +16 -0
- data/lib/rawg_api/clients/developers.rb +16 -0
- data/lib/rawg_api/clients/game/achievements.rb +14 -0
- data/lib/rawg_api/clients/game/additions.rb +14 -0
- data/lib/rawg_api/clients/game/details.rb +14 -0
- data/lib/rawg_api/clients/game/development_team.rb +14 -0
- data/lib/rawg_api/clients/game/parent_games.rb +14 -0
- data/lib/rawg_api/clients/game/reddit.rb +14 -0
- data/lib/rawg_api/clients/game/screenshots.rb +14 -0
- data/lib/rawg_api/clients/game/series.rb +14 -0
- data/lib/rawg_api/clients/game/stores.rb +14 -0
- data/lib/rawg_api/clients/game/suggested_games.rb +14 -0
- data/lib/rawg_api/clients/game/trailers.rb +14 -0
- data/lib/rawg_api/clients/game/twich.rb +14 -0
- data/lib/rawg_api/clients/game/youtube.rb +14 -0
- data/lib/rawg_api/clients/games.rb +51 -0
- data/lib/rawg_api/clients/genres.rb +16 -0
- data/lib/rawg_api/clients/parent_platforms.rb +11 -0
- data/lib/rawg_api/clients/platforms.rb +16 -0
- data/lib/rawg_api/clients/publishers.rb +16 -0
- data/lib/rawg_api/clients/stores.rb +16 -0
- data/lib/rawg_api/clients/tag_details.rb +12 -0
- data/lib/rawg_api/clients/tags.rb +12 -0
- data/lib/rawg_api/configuration.rb +47 -0
- data/lib/rawg_api/entities/base_entity.rb +54 -0
- data/lib/rawg_api/entities/creator.rb +9 -0
- data/lib/rawg_api/entities/creator_role.rb +9 -0
- data/lib/rawg_api/entities/developer.rb +9 -0
- data/lib/rawg_api/entities/game/achievements.rb +11 -0
- data/lib/rawg_api/entities/game/additions.rb +13 -0
- data/lib/rawg_api/entities/game/details.rb +20 -0
- data/lib/rawg_api/entities/game/development_team.rb +11 -0
- data/lib/rawg_api/entities/game/entity.rb +25 -0
- data/lib/rawg_api/entities/game/parent_games.rb +13 -0
- data/lib/rawg_api/entities/game/reddit.rb +11 -0
- data/lib/rawg_api/entities/game/screenshots.rb +11 -0
- data/lib/rawg_api/entities/game/series.rb +13 -0
- data/lib/rawg_api/entities/game/stores.rb +11 -0
- data/lib/rawg_api/entities/game/suggested_games.rb +11 -0
- data/lib/rawg_api/entities/game/trailers.rb +11 -0
- data/lib/rawg_api/entities/game/twitch.rb +12 -0
- data/lib/rawg_api/entities/game/youtube.rb +13 -0
- data/lib/rawg_api/entities/genre.rb +9 -0
- data/lib/rawg_api/entities/parent_platform.rb +9 -0
- data/lib/rawg_api/entities/platform.rb +9 -0
- data/lib/rawg_api/entities/publisher.rb +9 -0
- data/lib/rawg_api/entities/store.rb +9 -0
- data/lib/rawg_api/entities/tag.rb +11 -0
- data/lib/rawg_api/entities/tag_details.rb +9 -0
- data/lib/rawg_api/extensions/dry_monads.rb +12 -0
- data/lib/rawg_api/version.rb +3 -0
- data/lib/rawg_api.rb +6 -0
- data/rawg_api.gemspec +43 -0
- metadata +311 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 56bed91b0a89c745a1ccf5cda9cf9eabba95a610116596fc4616561bf30d8bd1
|
4
|
+
data.tar.gz: 96f5a0f131659d1d79748ed74c69e3e11ad61256e15d539a3f89182f73521130
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f4aabcecdbf465b46ebd9d4a8f284699a54eb075b6dc9d11a9f526c1a85121ecff9d332c8d777318f93664b0db0bd9b1c2d5ae398e474f34501dd5b4a0cb6c2c
|
7
|
+
data.tar.gz: 972879b2b6a9da10a288cd3a0b31a077c26bbe2698e49cc8cb067cab9cd391adc34feb169294f74b45893a2b5927e276e875822e97514b32dd326eabf4a50d3a
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at TODO: Write your email address. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rawg_api (0.1.1)
|
5
|
+
api_struct (~> 1.0, >= 1.0.5)
|
6
|
+
dotenv
|
7
|
+
dry-configurable (~> 0.9.0)
|
8
|
+
dry-monads (~> 1.3, >= 1.3.5)
|
9
|
+
hashie (~> 4.1)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
addressable (2.7.0)
|
15
|
+
public_suffix (>= 2.0.2, < 5.0)
|
16
|
+
api_struct (1.0.5)
|
17
|
+
dry-configurable
|
18
|
+
dry-inflector
|
19
|
+
dry-monads (~> 1)
|
20
|
+
hashie
|
21
|
+
http
|
22
|
+
byebug (11.1.2)
|
23
|
+
coderay (1.1.2)
|
24
|
+
concurrent-ruby (1.1.6)
|
25
|
+
crack (0.4.3)
|
26
|
+
safe_yaml (~> 1.0.0)
|
27
|
+
domain_name (0.5.20190701)
|
28
|
+
unf (>= 0.0.5, < 1.0.0)
|
29
|
+
dotenv (2.7.5)
|
30
|
+
dry-configurable (0.9.0)
|
31
|
+
concurrent-ruby (~> 1.0)
|
32
|
+
dry-core (~> 0.4, >= 0.4.7)
|
33
|
+
dry-core (0.4.9)
|
34
|
+
concurrent-ruby (~> 1.0)
|
35
|
+
dry-equalizer (0.3.0)
|
36
|
+
dry-inflector (0.2.0)
|
37
|
+
dry-monads (1.3.5)
|
38
|
+
concurrent-ruby (~> 1.0)
|
39
|
+
dry-core (~> 0.4, >= 0.4.4)
|
40
|
+
dry-equalizer
|
41
|
+
ffi (1.12.2)
|
42
|
+
ffi-compiler (1.0.1)
|
43
|
+
ffi (>= 1.0.0)
|
44
|
+
rake
|
45
|
+
hashdiff (1.0.1)
|
46
|
+
hashie (4.1.0)
|
47
|
+
http (4.4.1)
|
48
|
+
addressable (~> 2.3)
|
49
|
+
http-cookie (~> 1.0)
|
50
|
+
http-form_data (~> 2.2)
|
51
|
+
http-parser (~> 1.2.0)
|
52
|
+
http-cookie (1.0.3)
|
53
|
+
domain_name (~> 0.5)
|
54
|
+
http-form_data (2.3.0)
|
55
|
+
http-parser (1.2.1)
|
56
|
+
ffi-compiler (>= 1.0, < 2.0)
|
57
|
+
httplog (1.4.2)
|
58
|
+
rack (>= 1.0)
|
59
|
+
rainbow (>= 2.0.0)
|
60
|
+
method_source (1.0.0)
|
61
|
+
minitest (5.14.0)
|
62
|
+
pry (0.13.1)
|
63
|
+
coderay (~> 1.1)
|
64
|
+
method_source (~> 1.0)
|
65
|
+
pry-byebug (3.9.0)
|
66
|
+
byebug (~> 11.0)
|
67
|
+
pry (~> 0.13.0)
|
68
|
+
public_suffix (4.0.4)
|
69
|
+
rack (2.2.2)
|
70
|
+
rainbow (3.0.0)
|
71
|
+
rake (12.3.3)
|
72
|
+
safe_yaml (1.0.5)
|
73
|
+
unf (0.1.4)
|
74
|
+
unf_ext
|
75
|
+
unf_ext (0.0.7.7)
|
76
|
+
vcr (3.0.3)
|
77
|
+
webmock (3.8.3)
|
78
|
+
addressable (>= 2.3.6)
|
79
|
+
crack (>= 0.3.2)
|
80
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
81
|
+
|
82
|
+
PLATFORMS
|
83
|
+
ruby
|
84
|
+
|
85
|
+
DEPENDENCIES
|
86
|
+
bundler (~> 2.1)
|
87
|
+
httplog
|
88
|
+
minitest (~> 5.0)
|
89
|
+
pry
|
90
|
+
pry-byebug (~> 3.7)
|
91
|
+
rake (~> 12.3)
|
92
|
+
rawg_api!
|
93
|
+
vcr (~> 3.0, >= 3.0.1)
|
94
|
+
webmock
|
95
|
+
|
96
|
+
BUNDLED WITH
|
97
|
+
2.1.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Harry Georgilas
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,234 @@
|
|
1
|
+
# RawgApi
|
2
|
+
|
3
|
+
RawgApi gem is a ruby wrapper for the [rawg.io](https://rawg.io/) REST API.
|
4
|
+
|
5
|
+
It exposes every endpoint through the `RawgApi::Clients` interface
|
6
|
+
that returns raw responses from the API.
|
7
|
+
|
8
|
+
Moreover it provides a `RawgApi::Entities` interface that will return serialized data
|
9
|
+
for every endpoint using the [Hashie](https://github.com/hashie/hashie) gem
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Ruby required: `>= 2.5.0`
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'rawg_api'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle install
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install rawg_api
|
28
|
+
|
29
|
+
## Configuration
|
30
|
+
You can configure your default settings using
|
31
|
+
```
|
32
|
+
RawgApi.configure do |config|
|
33
|
+
# No need to change the endpoint, this option was provided
|
34
|
+
# to override the endpoint in the future
|
35
|
+
# if there is a need to do so
|
36
|
+
config.endpoint = 'https://api.rawg.io/api'
|
37
|
+
|
38
|
+
# This is mandatory and going to be appended
|
39
|
+
# to the headers of each request
|
40
|
+
config.app_name = 'Your app name'
|
41
|
+
|
42
|
+
# Any custom headers in JSON format
|
43
|
+
config.headers = {}
|
44
|
+
|
45
|
+
# Default page size for results returned by the API
|
46
|
+
config.page_size = 50
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
## Usage
|
51
|
+
|
52
|
+
#### Clients
|
53
|
+
You can access any resource on [rawg.io](https://rawg.io/) using the `RawgApi::Clients` interface
|
54
|
+
Most of these clients expose `#find` and `#all` methods, with the exception of the `RawgApi::Clients::Games`
|
55
|
+
which also exposes a `#search` method.
|
56
|
+
|
57
|
+
Responses are wrapped around `Success` or `Failure` structures provided by [dry-monads](https://github.com/dry-rb/dry-monads)
|
58
|
+
In order to fetch the actual values as `Hash` you will have to call `#value!` on the response
|
59
|
+
#### Using Clients
|
60
|
+
```
|
61
|
+
# General Usage
|
62
|
+
response = RawgApi::Clients::{CLIENT_NAME}.new.{METHOD} # returns Success/Failure
|
63
|
+
result = response.value! # returns Hash
|
64
|
+
|
65
|
+
# Get all games
|
66
|
+
response = RawgApi::Clients::Games.new.all
|
67
|
+
result = response.value!
|
68
|
+
|
69
|
+
# Set page and page_size.
|
70
|
+
# Returns the second page of the results with a limit of 20 resources per page
|
71
|
+
# page_size defaults to the page_size you have set on your configuration
|
72
|
+
response = RawgApi::Clients::Games.new.all(page:2, page_size: 20)
|
73
|
+
|
74
|
+
# Search for a game
|
75
|
+
response = RawgApi::Clients::Games.new.search(title: 'Portal 2')
|
76
|
+
result = response.value!
|
77
|
+
|
78
|
+
# Get game by id
|
79
|
+
# Get The Witcher 3 details
|
80
|
+
response = RawgApi::Clients::Games::Details.new.find(3328)
|
81
|
+
result = response.value!
|
82
|
+
|
83
|
+
# Find with pagination
|
84
|
+
RawgApi::Clients::Games::Additions.new.find(3328, page:1, page_size:1)
|
85
|
+
```
|
86
|
+
#### Using `Rawg::Api::Clients::Games#search` with multiple filters criteria
|
87
|
+
`#search` accepts the following arguments
|
88
|
+
- `page`:`Integer`
|
89
|
+
- `page_size`:`Integer`
|
90
|
+
- `title`:`String`
|
91
|
+
- `exclude_collection`:`Boolean`
|
92
|
+
- `exclude_parents`:`Boolean`
|
93
|
+
- `exclude_game_series`:`Boolean`
|
94
|
+
- `parent_platforms`:`Array`
|
95
|
+
- `platforms`:`Array`
|
96
|
+
- `stores`:`Array`
|
97
|
+
- `developers`:`Array`
|
98
|
+
- `publishers`:`Array`
|
99
|
+
- `genres`:`Array`
|
100
|
+
- `tags`:`Array`
|
101
|
+
- `creators`:`Array`
|
102
|
+
- `dates`:`Array`
|
103
|
+
- `platforms_count`:`Array`
|
104
|
+
- `order`:`String`
|
105
|
+
- Ascending: `name`, `release`, `added`, `created`, `rating`
|
106
|
+
- Descending: `-name`, `-release`, `-added`, `-created`, `-rating`
|
107
|
+
|
108
|
+
|
109
|
+
#### List of clients and methods
|
110
|
+
- `RawgApi::Clients::Genres`: `#find`,`#all`
|
111
|
+
- `RawgApi::Clients::Publishers`: `#find`,`#all`
|
112
|
+
- `RawgApi::Clients::Platforms`: `#find`,`#all`
|
113
|
+
- `RawgApi::Clients::Creators`: `#find`,`#all`
|
114
|
+
- `RawgApi::Clients::Developers`: `#find`,`#all`
|
115
|
+
- `RawgApi::Clients::Stores`: `#find`,`#all`
|
116
|
+
- `RawgApi::Clients::CreatorRoles`: `#all`
|
117
|
+
- `RawgApi::Clients::Tags`: `#all`
|
118
|
+
- `RawgApi::Clients::ParentPlatforms`: `#all`
|
119
|
+
- `RawgApi::Clients::TagDetails`: `#find`
|
120
|
+
- `RawgApi::Clients::Games`: `#all`, `#search`
|
121
|
+
- `RawgApi::Clients::Games::Achievements`: `#find`
|
122
|
+
- `RawgApi::Clients::Games::Twitch`: `#find`
|
123
|
+
- `RawgApi::Clients::Games::SuggestedGames`: `#find`
|
124
|
+
- `RawgApi::Clients::Games::Stores`: `#find`
|
125
|
+
- `RawgApi::Clients::Games::DevelopmentTeam`: `#find`
|
126
|
+
- `RawgApi::Clients::Games::Series`: `#find`
|
127
|
+
- `RawgApi::Clients::Games::Trailers`: `#find`
|
128
|
+
- `RawgApi::Clients::Games::ParentGames`: `#find`
|
129
|
+
- `RawgApi::Clients::Games::Additions`: `#find`
|
130
|
+
- `RawgApi::Clients::Games::Details`: `#find`
|
131
|
+
- `RawgApi::Clients::Games::Youtube`: `#find`
|
132
|
+
- `RawgApi::Clients::Games::Screenshots`: `#find`
|
133
|
+
- `RawgApi::Clients::Games::Reddit`: `#find`
|
134
|
+
|
135
|
+
#### Using Entities
|
136
|
+
You can also use `Entities` to receive a serialized response.
|
137
|
+
|
138
|
+
All methods declared in the clients can be invoked as class methods on the `Entity` class
|
139
|
+
and accept the same parameters as their `Client` counterpart.
|
140
|
+
```
|
141
|
+
# General Usage
|
142
|
+
response = RawgApi::Entities::{ENTITY_NAME}.{METHOD} # returns Hashie Object
|
143
|
+
# If response is a collection
|
144
|
+
results = response.results
|
145
|
+
# Returns info regarding the request, such as current page, page size etc...
|
146
|
+
metadata = response.metadata
|
147
|
+
|
148
|
+
# Get all games
|
149
|
+
response = RawgApi::Entities::Game::Entity.all
|
150
|
+
result = response.results
|
151
|
+
|
152
|
+
# Set page and page_size.
|
153
|
+
# Returns the second page of the results with a limit of 20 resources per page
|
154
|
+
# page_size defaults to the page_size you have set on your configuration
|
155
|
+
response = RawgApi::Entities::Entity.all(page:2, page_size: 20)
|
156
|
+
|
157
|
+
# Search for a game
|
158
|
+
response = RawgApi::Clients::Game::Entity.search(title: 'Portal 2')
|
159
|
+
|
160
|
+
# Get game by id
|
161
|
+
# Get The Witcher 3 details
|
162
|
+
response = RawgApi::Entities::Game::Additions.find(3328)
|
163
|
+
|
164
|
+
# Access value by attribute
|
165
|
+
response.name # => "The Witcher 3: Wild Hunt"
|
166
|
+
|
167
|
+
# Find with pagination
|
168
|
+
RawgApi::Entities::Game::Additions.find(3328, page:1, page_size:1)
|
169
|
+
```
|
170
|
+
|
171
|
+
`RawgApi::Entities::Game::Entity` has the ability to delegate methods to other entities
|
172
|
+
|
173
|
+
```
|
174
|
+
# Get additions through RawgApi::Entities::Game::Entity class
|
175
|
+
|
176
|
+
# Returns game additions for The Witcher 3
|
177
|
+
RawgApi::Entities::Game::Entity.find_additions(3328)
|
178
|
+
|
179
|
+
# Returns tags for The Witcher 3
|
180
|
+
RawgApi::Entities::Game::Entity.find_tags(3328)
|
181
|
+
|
182
|
+
```
|
183
|
+
#### List of entities and methods
|
184
|
+
|
185
|
+
- `RawgApi::Entities::Genres`: `#find`,`#all`
|
186
|
+
- `RawgApi::Entities::TagDetails`: `#find`
|
187
|
+
- `RawgApi::Entities::Developer`: `#find`,`#all`
|
188
|
+
- `RawgApi::Entities::Creator`: `#find`,`#all`
|
189
|
+
- `RawgApi::Entities::CreatorRole`: `#all`
|
190
|
+
- `RawgApi::Entities::Store`: `#find`,`#all`
|
191
|
+
- `RawgApi::Entities::Platform`: `#find`,`#all`
|
192
|
+
- `RawgApi::Entities::Publisher`: `#find`,`#all`
|
193
|
+
- `RawgApi::Entities::Tag`: `#all`,`#find`
|
194
|
+
- `RawgApi::Entities::Game::Achievements`: `#find`
|
195
|
+
- `RawgApi::Entities::Game::YouTube`: `#find`
|
196
|
+
- `RawgApi::Entities::Game::Twitch`: `#find`
|
197
|
+
- `RawgApi::Entities::Game::SuggestedGames`: `#find`
|
198
|
+
- `RawgApi::Entities::Game::Stores`: `#find`
|
199
|
+
- `RawgApi::Entities::Game::DevelopmentTeam`: `#find`
|
200
|
+
- `RawgApi::Entities::Game::Series`: `#find`
|
201
|
+
- `RawgApi::Entities::Game::Entity`:
|
202
|
+
- `#find`,`#all`,`#find_suggested_games`,`#find_series`,`#find_screenshots`,`#find_stores`,`#find_reddit`,`#find_additions`,`#find_youtube`,`#find_twitch`
|
203
|
+
- `RawgApi::Entities::Game::Details`: `#find`
|
204
|
+
- `RawgApi::Entities::Game::Trailers`: `#find`
|
205
|
+
- `RawgApi::Entities::Game::ParentGames`: `#find`
|
206
|
+
- `RawgApi::Entities::Game::Additions`: `#find`
|
207
|
+
- `RawgApi::Entities::Game::Screenshots`: `#find`
|
208
|
+
- `RawgApi::Entities::Game::Reddit`: `#find`
|
209
|
+
|
210
|
+
|
211
|
+
## Development
|
212
|
+
|
213
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
214
|
+
|
215
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
216
|
+
|
217
|
+
## Debugging
|
218
|
+
Create an `.env` file on your root directory and add the following variable
|
219
|
+
```
|
220
|
+
ENVIRONMENT=development
|
221
|
+
```
|
222
|
+
|
223
|
+
## Contributing
|
224
|
+
|
225
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/hgeorgilas/rawg_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/rawg_api/blob/master/CODE_OF_CONDUCT.md).
|
226
|
+
|
227
|
+
|
228
|
+
## License
|
229
|
+
|
230
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
231
|
+
|
232
|
+
## Code of Conduct
|
233
|
+
|
234
|
+
Everyone interacting in the RawgApi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/hgeorgilas/rawg_api/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rawg_api"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative 'version'
|
2
|
+
require 'dotenv/load'
|
3
|
+
require 'api_struct'
|
4
|
+
require_relative "configuration"
|
5
|
+
if ENV.fetch('ENVIRONMENT', 'production') == 'development'
|
6
|
+
require 'pry'
|
7
|
+
require 'httplog'
|
8
|
+
end
|
9
|
+
ENTITIES_LOAD_ORDER = %w(
|
10
|
+
entities/game/additions
|
11
|
+
entities/game/suggested_games
|
12
|
+
entities/game/stores
|
13
|
+
entities/game/development_team
|
14
|
+
entities/game/series
|
15
|
+
entities/game/trailers
|
16
|
+
entities/game/twitch
|
17
|
+
entities/game/parent_games
|
18
|
+
entities/game/youtube
|
19
|
+
entities/game/screenshots
|
20
|
+
entities/game/reddit
|
21
|
+
entities/game/achievements
|
22
|
+
entities/game/details
|
23
|
+
entities/game/entity
|
24
|
+
entities/developer
|
25
|
+
entities/creator
|
26
|
+
entities/base_entity
|
27
|
+
entities/creator_role
|
28
|
+
entities/genre
|
29
|
+
entities/platform
|
30
|
+
entities/publisher
|
31
|
+
entities/store
|
32
|
+
entities/tag_details
|
33
|
+
entities/tag)
|
34
|
+
|
35
|
+
Dir[File.join(__dir__, 'extensions', '*.rb')].each { |f| require_relative f }
|
36
|
+
require_relative "clients/base_client"
|
37
|
+
Dir[File.join(__dir__, 'clients', '**', '*.rb')].each { |f| require_relative f }
|
38
|
+
require_relative "entities/base_entity"
|
39
|
+
ENTITIES_LOAD_ORDER.each { |f| require_relative "#{f}.rb" }
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module RawgApi
|
2
|
+
module Clients
|
3
|
+
class BaseClient < ::ApiStruct::Client
|
4
|
+
|
5
|
+
DEFAULT_PAGE_SIZE = RawgApi.configuration.page_size
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def transform_key(key)
|
10
|
+
keys_transformer.dig(key) || key
|
11
|
+
end
|
12
|
+
|
13
|
+
def transform_value(key, value)
|
14
|
+
return value unless self.respond_to?(:transformer_) && values_transformer.key?(key)
|
15
|
+
value.public_send(values_transformer[key][:method], *values_transformer[key][:args])
|
16
|
+
end
|
17
|
+
|
18
|
+
def key_params_to_hash(m_binding)
|
19
|
+
m_binding.local_variables.map { |x| [x, m_binding.local_variable_get(x)] }.to_h.compact
|
20
|
+
end
|
21
|
+
|
22
|
+
def array_join_transformer(delimiter: ',')
|
23
|
+
{
|
24
|
+
method: :join,
|
25
|
+
args: [delimiter]
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module RawgApi
|
2
|
+
module Clients
|
3
|
+
class Creators < BaseClient
|
4
|
+
rawg_api :creators
|
5
|
+
|
6
|
+
def all(page: 1, page_size: DEFAULT_PAGE_SIZE)
|
7
|
+
get(params: {page: page, page_size: page_size})
|
8
|
+
end
|
9
|
+
|
10
|
+
def find(id)
|
11
|
+
get(id)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module RawgApi
|
2
|
+
module Clients
|
3
|
+
class Developers < BaseClient
|
4
|
+
rawg_api :developers
|
5
|
+
|
6
|
+
def all(page: 1, page_size: DEFAULT_PAGE_SIZE)
|
7
|
+
get(params: {page: page, page_size: page_size})
|
8
|
+
end
|
9
|
+
|
10
|
+
def find(id)
|
11
|
+
get(id)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module RawgApi
|
2
|
+
module Clients
|
3
|
+
class Games
|
4
|
+
class Achievements < Clients::BaseClient
|
5
|
+
rawg_api :achievements
|
6
|
+
|
7
|
+
def find(id, page: 1, page_size: DEFAULT_PAGE_SIZE)
|
8
|
+
get(prefix: [:games, id], params: {page: page, page_size: page_size})
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module RawgApi
|
2
|
+
module Clients
|
3
|
+
class Games
|
4
|
+
class Additions < Clients::BaseClient
|
5
|
+
rawg_api :additions
|
6
|
+
|
7
|
+
def find(id, page: 1, page_size: DEFAULT_PAGE_SIZE)
|
8
|
+
get(prefix: [:games, id], params: {page: page, page_size: page_size})
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module RawgApi
|
2
|
+
module Clients
|
3
|
+
class Games
|
4
|
+
class DevelopmentTeam < Clients::BaseClient
|
5
|
+
rawg_api :'development-team'
|
6
|
+
|
7
|
+
def find(id, page: 1, page_size: DEFAULT_PAGE_SIZE)
|
8
|
+
get(prefix: [:games, id], params: {page: page, page_size: page_size})
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|