Class: Montabe::Client

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Galleries
Defined in:
lib/montabe/client.rb

Instance Method Summary collapse

Methods included from Galleries

#galleries, #gallery

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



9
10
# File 'lib/montabe/client.rb', line 9

def initialize(options={})
end

Instance Method Details

#api_urlObject

Base URL for api requests.



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

def api_url
  "http://demo.montabe.com"
end

#connectionObject

Sets up the connection to be used for all requests based on options passed during initialization.



14
15
16
17
18
19
20
21
# File 'lib/montabe/client.rb', line 14

def connection
  params = {}
  @connection ||= Faraday::Connection.new(:url => api_url, :params => params, :headers => default_headers) do |builder|
    builder.adapter Faraday.default_adapter
    builder.use Faraday::Response::Mashify
    builder.use Faraday::Response::ParseJson
  end
end

#return_error_or_body(response, response_body) ⇒ Object

Helper method to return errors or desired response data as appropriate.

Added just for convenience to avoid having to traverse farther down the response just to get to returned data.



33
34
35
# File 'lib/montabe/client.rb', line 33

def return_error_or_body(response, response_body)
  response.status == 200 ? response_body : response.body
end