Sha256: ea53d20eeb7f9122d555aaea69e0df3507bce874e310c886732056259712dc4c
Contents?: true
Size: 726 Bytes
Versions: 8
Compression:
Stored size: 726 Bytes
Contents
require 'json' require 'hashie' module Echonest class Response attr_reader :json def initialize(body) @json = Hashie::Mash.new(JSON.parse(body)) end def status @status ||= Status.new(body) end def success? status.code == Status::SUCCESS end def body json.response end class Status UNKNOWN_ERROR = -1 SUCCESS = 0 INVALID_API_KEY = 1 PERMISSION_DENIED = 2 RATE_LIMIT_EXCEEDED = 3 MISSING_PARAMETER = 4 INVALID_PARAMETER = 5 attr_reader :code, :message def initialize(response_body) @code = response_body.status.code @message = response_body.status.message end end end end
Version data entries
8 entries across 8 versions & 2 rubygems