class Tacokit::Client

Attributes

last_response[RW]

Public Class Methods

new(options = {}) click to toggle source
# File lib/tacokit/client.rb, line 55
def initialize(options = {})
  configuration.options = options
end

Public Instance Methods

configuration() click to toggle source
# File lib/tacokit/client.rb, line 67
def configuration
  @configuration ||= Configuration.new
end
configure() { |configuration| ... } click to toggle source
# File lib/tacokit/client.rb, line 63
def configure
  yield configuration if block_given?
end
delete(url, options = {}) click to toggle source
# File lib/tacokit/client.rb, line 83
def delete(url, options = {})
  request :delete, url, options
end
get(url, options = {}) click to toggle source
# File lib/tacokit/client.rb, line 71
def get(url, options = {})
  request :get, url, options
end
inspect()
Alias for: to_s
paginated_get(*args) click to toggle source
# File lib/tacokit/client.rb, line 87
def paginated_get(*args)
  Collection.new(self, :get, *args)
end
post(url, options = {}) click to toggle source
# File lib/tacokit/client.rb, line 75
def post(url, options = {})
  request :post, url, options
end
put(url, options = {}) click to toggle source
# File lib/tacokit/client.rb, line 79
def put(url, options = {})
  request :put, url, options
end
request(method, url, data = nil, params = nil) click to toggle source
# File lib/tacokit/client.rb, line 91
def request(method, url, data = nil, params = nil)
  if [:get, :body].include?(method)
    params ||= data
    data = nil
  end

  response = connection.send method, url do |req|
    req.params.update serialize_params(params)
    req.body = serialize(data) if data
  end

  @last_response = last_response = Response.new(self, response)

  last_response.data
end
reset!() click to toggle source
# File lib/tacokit/client.rb, line 59
def reset!
  @configuration = nil
end
to_s() click to toggle source
# File lib/tacokit/client.rb, line 107
def to_s
  "<#{self.class}:#{object_id}>"
end
Also aliased as: inspect

Private Instance Methods

connection() click to toggle source
# File lib/tacokit/client.rb, line 126
def connection
  @connection ||= Faraday.new(connection_options) do |http|
    if configuration.user_authenticated?
      http.request :oauth, configuration.user_credentials
    elsif configuration.app_authenticated?
      http.params.update configuration.app_credentials
    end
  end
end
connection_options() click to toggle source
# File lib/tacokit/client.rb, line 118
def connection_options
  {
    url: api_endpoint,
    builder: configuration.stack,
    headers: { user_agent: "Tacokit #{Tacokit::VERSION}" }
  }
end
transform() click to toggle source
# File lib/tacokit/client.rb, line 114
def transform
  @transform ||= Transform.new
end