Sha256: 7c977dad88f063cc0cd512ddc2e5f580398dbbd3a08c84b09a81ed961a3634ec
Contents?: true
Size: 940 Bytes
Versions: 2
Compression:
Stored size: 940 Bytes
Contents
module Lipseys class Response def initialize(response) @response = response case @response when Net::HTTPUnauthorized Lipseys::Error::NotAuthorized.new(@response.body) when Net::HTTPNotFound Lipseys::Error::NotFound.new(@response.body) when Net::HTTPNoContent Lipseys::Error::NoContent.new(@response.body) when Net::HTTPOK, Net::HTTPSuccess _data = (JSON.parse(@response.body) if @response.body.present?) @data = case when _data.is_a?(Hash) _data.deep_symbolize_keys when _data.is_a?(Array) _data.map(&:deep_symbolize_keys) end else raise Lipseys::Error::RequestError.new(@response.body) end end def [](key) @data&.[](key) end def body @data end def fetch(key) @data.fetch(key) end def success? !!self[:success] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lipseys-6.2.1 | lib/lipseys/response.rb |
lipseys-6.2.0 | lib/lipseys/response.rb |