Class: Marver::API::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/marver/api/client.rb

Constant Summary collapse

API_VERSION =
"v1"
API_ENDPOINT =
"http://gateway.marvel.com"

Instance Method Summary collapse

Instance Method Details

#credentialsObject



25
26
27
# File 'lib/marver/api/client.rb', line 25

def credentials
  Credentials.get
end

#endpointObject



21
22
23
# File 'lib/marver/api/client.rb', line 21

def endpoint
  "#{API_ENDPOINT}/#{API_VERSION}/public"
end

#get(entity, options) ⇒ Object



10
11
12
13
14
# File 'lib/marver/api/client.rb', line 10

def get(entity, options)
  url = "#{endpoint}/#{entity.to_s}"
  json = RestClient.get url, { params: options.merge(credentials) }
  Marver::API::Response.new(json)
end

#get_uri(uri) ⇒ Object



16
17
18
19
# File 'lib/marver/api/client.rb', line 16

def get_uri(uri)
  response = RestClient.get uri, { params: credentials }
  Marver::API::Response.new(response)
end