gameopedia-client 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 810d71e66cd53b0c39273e81e9f5627ad37a59f2ab26157f13226217ea7a2311
4
+ data.tar.gz: '019b5f1550cbb6bb2604529debfb8a6e7ea350205c4d12ef42d7bd403ed95241'
5
+ SHA512:
6
+ metadata.gz: 6a34ac0964ab9ad54094cc99523b9de475011923a49cf933b15ff69d2bba899738d4da3cfd506b589889e5ae12f7b9c3fb45dfc7fa0fc95287d3453e5ebc2792
7
+ data.tar.gz: 0bd7fb00974ba132b251d8b6d808b900a5bbbd56dca05989600a886924275700e52c466454a8c6eee686b48a79c4433a103e1e16bd3a0efee8f1b9a8c86644a7
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'gameopedia/configuration'
4
+ require 'gameopedia/client'
5
+
6
+ module Gameopedia # :nodoc:
7
+ def self.configure
8
+ yield(configuration)
9
+ end
10
+
11
+ def self.configuration
12
+ @configuration ||= Configuration.new
13
+ end
14
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'gameopedia'
4
+ require 'gameopedia/configuration'
5
+ require 'gameopedia/response'
6
+ require 'typhoeus'
7
+
8
+ module Gameopedia
9
+ class Client # :nodoc:
10
+ BASE_URI = 'https://api.gameopedia.com/consumer/api/data/europe/GB/retail2'
11
+
12
+ def get_full_dump(page:)
13
+ get('/dump/full.json', params: { page: page })
14
+ end
15
+
16
+ private
17
+
18
+ private_constant :BASE_URI
19
+
20
+ def get(endpoint, params:)
21
+ gameopedia_response = Typhoeus.get(BASE_URI + endpoint, params: { **authentication_params, **params })
22
+ Response.new(code: gameopedia_response.code, body: gameopedia_response.body)
23
+ end
24
+
25
+ def authentication_params
26
+ @authentication_params ||= {
27
+ auth_logon: Gameopedia.configuration.auth_logon,
28
+ auth_key: Gameopedia.configuration.auth_key
29
+ }
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gameopedia
4
+ class MissingConfiguration < StandardError; end
5
+
6
+ class Configuration # :nodoc:
7
+ attr_writer :auth_logon, :auth_key
8
+
9
+ def auth_logon
10
+ @auth_logon || (raise MissingConfiguration, 'Auth logon must be set')
11
+ end
12
+
13
+ def auth_key
14
+ @auth_key || (raise MissingConfiguration, 'Auth key must be set')
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gameopedia
4
+ class Response # :nodoc:
5
+ def initialize(code:, body:)
6
+ @code = code
7
+ @body = body
8
+ end
9
+
10
+ attr_reader :code, :body
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gameopedia-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Playload
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-11-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: typhoeus
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.4'
55
+ description: A client for the Gameopedia consumer JSON API
56
+ email:
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - lib/gameopedia.rb
62
+ - lib/gameopedia/client.rb
63
+ - lib/gameopedia/configuration.rb
64
+ - lib/gameopedia/response.rb
65
+ homepage: https://rubygems.org/gems/gameopedia_client
66
+ licenses:
67
+ - MIT
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '2.7'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubygems_version: 3.1.2
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: A client for the Gameopedia consumer JSON API
88
+ test_files: []