Class: Harkness::Client
- Inherits:
-
Object
- Object
- Harkness::Client
- Defined in:
- lib/harkness/client.rb
Constant Summary collapse
- BASE_URL =
The base URL for the Marvel API.
"https://gateway.marvel.com/v1/public"
Instance Attribute Summary collapse
-
#private_key ⇒ String
readonly
The private key for the Marvel API.
-
#public_key ⇒ String
readonly
The public key for the Marvel API.
Instance Method Summary collapse
-
#characters ⇒ Harkness::CharacterResource
The character resource.
-
#comics ⇒ Harkness::ComicResource
The comics resource.
-
#connection ⇒ Object
The Faraday connection to use for API requests.
-
#creators ⇒ Harkness::CreatorResource
The creators resource.
-
#events ⇒ Harkness::EventResource
The events resource.
-
#initialize(public_key:, private_key:, logger: false) ⇒ Client
constructor
Initialize a client.
-
#series ⇒ Harkness::SeriesResource
The series resource.
-
#stories ⇒ Harkness::StoryResource
The stories resource.
Constructor Details
#initialize(public_key:, private_key:, logger: false) ⇒ Client
Initialize a client.
19 20 21 22 23 |
# File 'lib/harkness/client.rb', line 19 def initialize(public_key:, private_key:, logger: false) @public_key = public_key @private_key = private_key @logger = logger end |
Instance Attribute Details
#private_key ⇒ String (readonly)
The private key for the Marvel API.
13 14 15 |
# File 'lib/harkness/client.rb', line 13 def private_key @private_key end |
#public_key ⇒ String (readonly)
The public key for the Marvel API.
10 11 12 |
# File 'lib/harkness/client.rb', line 10 def public_key @public_key end |
Instance Method Details
#characters ⇒ Harkness::CharacterResource
The character resource.
27 28 29 |
# File 'lib/harkness/client.rb', line 27 def characters CharacterResource.new(self) end |
#comics ⇒ Harkness::ComicResource
The comics resource.
33 34 35 |
# File 'lib/harkness/client.rb', line 33 def comics ComicResource.new(self) end |
#connection ⇒ Object
The Faraday connection to use for API requests.
62 63 64 65 66 67 68 |
# File 'lib/harkness/client.rb', line 62 def connection @connection ||= Faraday.new(BASE_URL) do |conn| conn.request :json conn.response :logger if @logger end end |
#creators ⇒ Harkness::CreatorResource
The creators resource.
39 40 41 |
# File 'lib/harkness/client.rb', line 39 def creators CreatorResource.new(self) end |
#events ⇒ Harkness::EventResource
The events resource.
45 46 47 |
# File 'lib/harkness/client.rb', line 45 def events EventResource.new(self) end |
#series ⇒ Harkness::SeriesResource
The series resource.
51 52 53 |
# File 'lib/harkness/client.rb', line 51 def series SeriesResource.new(self) end |
#stories ⇒ Harkness::StoryResource
The stories resource.
57 58 59 |
# File 'lib/harkness/client.rb', line 57 def stories StoryResource.new(self) end |