Class: Marvel::Api
- Inherits:
-
Object
- Object
- Marvel::Api
- Includes:
- ApiMethods
- Defined in:
- lib/marvel/api.rb,
lib/marvel/api/request.rb,
lib/marvel/api/version.rb,
lib/marvel/api/response.rb,
lib/marvel/api/api_methods.rb,
lib/marvel/api/http_service.rb
Defined Under Namespace
Modules: ApiMethods, HTTPService Classes: Request, Response
Constant Summary collapse
- DEFAULT_SERVER =
'http://gateway.marvel.com'.freeze
- VERSION =
'0.1.0'.freeze
Constants included from ApiMethods
ApiMethods::METHODS, ApiMethods::SUBMETHODS
Class Attribute Summary collapse
-
.http_service ⇒ Object
Returns the value of attribute http_service.
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#private_key ⇒ Object
readonly
Returns the value of attribute private_key.
-
#public_key ⇒ Object
readonly
Returns the value of attribute public_key.
Instance Method Summary collapse
- #api_call(path, args, options = {}) ⇒ Object
- #comics(args = {}) ⇒ Object
-
#initialize(public_key, private_key, options = {}) ⇒ Api
constructor
A new instance of Api.
Constructor Details
#initialize(public_key, private_key, options = {}) ⇒ Api
Returns a new instance of Api.
21 22 23 24 25 |
# File 'lib/marvel/api.rb', line 21 def initialize(public_key, private_key, = {}) @public_key = public_key @private_key = private_key @options = end |
Class Attribute Details
.http_service ⇒ Object
Returns the value of attribute http_service.
12 13 14 |
# File 'lib/marvel/api.rb', line 12 def http_service @http_service end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
19 20 21 |
# File 'lib/marvel/api.rb', line 19 def @options end |
#private_key ⇒ Object (readonly)
Returns the value of attribute private_key.
19 20 21 |
# File 'lib/marvel/api.rb', line 19 def private_key @private_key end |
#public_key ⇒ Object (readonly)
Returns the value of attribute public_key.
19 20 21 |
# File 'lib/marvel/api.rb', line 19 def public_key @public_key end |
Instance Method Details
#api_call(path, args, options = {}) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/marvel/api.rb', line 27 def api_call(path, args, = {}) request = Request.new( path: path, args: args.merge(apikey: public_key, ts: ts, hash: request_hash), options: ) self.class.http_service.make_request(request) end |
#comics(args = {}) ⇒ Object
36 37 38 |
# File 'lib/marvel/api.rb', line 36 def comics(args = {}) api_call('comics', args) end |