Sha256: d3e55b1efdf1b58f7d96262f9a19222c8d7e3d98c11a4e12f0b64c8c46a851d8
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
require 'httmultiparty' module Fourteeninch class Client def self.auth(email, password) begin request = HTTParty.post(Fourteeninch.api_url('auth'), {query: {email: email, password: password}}) return request.parsed_response # parse JSON rescue => e return 'error' => e.message # error end end def self.get(path, params = nil) self.execute(:get, path, params) end def self.post(path, params) self.execute(:post, path, params) end def self.put(path, params) self.execute(:put, path, params) end def self.delete(path, params = nil) self.execute(:delete, path, params) end def self.execute(method, path, params = nil) Fourteeninch.load_settings if !Fourteeninch.api_key begin request = HTTMultiParty.send(method, Fourteeninch.api_url(path), { :query => params, :basic_auth => {:username => Fourteeninch.api_key, :password => Fourteeninch.api_secret}, :timeout => 300 }) if request.respond_to?('parsed_response') return request.parsed_response # parse JSON else return request # raw end rescue => e return 'error' => e.message # error end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fourteeninch-0.1.0 | lib/fourteeninch/client.rb |