lib/mambanation.rb in mambanation-0.1.5 vs lib/mambanation.rb in mambanation-0.1.6

- old
+ new

@@ -1,59 +1,58 @@ require "forwardable" require "hashie" require "httparty" -require "json" require "yajl" module MambaNation include HTTParty API_VERSION = "2".freeze format :json - + class MambaNationError < StandardError attr_reader :data - + def initialize(data) @data = data super end end - + class RateLimitExceeded < MambaNationError; end class Unauthorized < MambaNationError; end class General < MambaNationError; end - + class Unavailable < StandardError; end class InformMambaNation < StandardError; end class NotFound < StandardError; end def self.api_endpoint - @api_endpoint ||= "api.mambanation.com/v#{API_VERSION}" + @api_endpoint ||= "api.mambanation.com" end def self.api_endpoint=(value) @api_endpoint = value end private - + def self.perform_get(uri, options = {}) base_uri(self.api_endpoint) make_friendly(get(uri, options)) end - + def self.make_friendly(response) raise_errors(response) data = parse(response) # Don't mash arrays of integers if data && data.is_a?(Array) && data.first.is_a?(Integer) data else mash(data) end end - + def self.raise_errors(response) case response.code.to_i when 400 data = parse(response) raise RateLimitExceeded.new(data), "(#{response.code}): #{response.message} - #{data['error'] if data}" @@ -117,7 +116,6 @@ directory = File.expand_path(File.dirname(__FILE__)) require File.join(directory, "mambanation", "base") require File.join(directory, "mambanation", "httpauth") -#require File.join(directory, "mambanation", "oauth") require File.join(directory, "mambanation", "request")