Sha256: a8f645b4a568a6ae1c6a4aa40954669c6977950a42dae71a82af6d340d4af13f
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
module Reviewed class Client include ::Reviewed::Configurable attr_accessor :api_key, :base_uri, :api_version def initialize Reviewed::Configurable.options.each do |key, value| instance_variable_set(:"@#{key}", value) end end # Perform an HTTP DELETE request def delete(path, params={}) request(:delete, path, params) end # Perform an HTTP GET request def get(path, params={}) request(:get, path, params) end # Perform an HTTP POST request def post(path, params={}) request(:post, path, params) end # Perform an HTTP PUT request def put(path, params={}) request(:put, path, params) end def url [base_uri, api_version].join('/') end private def request(method, path, params={}) verify_key! connection.send(method.to_sym, path, params) do |request| request.headers['X-Reviewed-Authorization'] ||= Reviewed.api_key end end def connection @connection ||= ::Faraday.new(url: url) do |faraday| faraday.response :mashify faraday.response :json faraday.request :url_encoded faraday.adapter Faraday.default_adapter end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
reviewed-0.0.8 | lib/reviewed/client.rb |
reviewed-0.0.7 | lib/reviewed/client.rb |