Sha256: a14fdcd3dc1011a5e11ca29b91677051ac9a679aeed0666303c963526f49d824
Contents?: true
Size: 855 Bytes
Versions: 1
Compression:
Stored size: 855 Bytes
Contents
module XEClient class BaseResponse include Virtus.model attribute :raw_response attribute(:response_body, IndifferentHash, { lazy: true, default: :default_response_body, }) attribute :code, Integer, lazy: true, default: :default_code attribute :message, String, lazy: true, default: :default_message attribute :error, Object, lazy: true, default: :default_error def self.call(raw_response) response = self.new(raw_response: raw_response) raise response.error if response.error.present? response end private def default_code response_body[:code] end def default_message response_body[:message] end def default_error Error.new_from_response(self) end def default_response_body JSON.parse(raw_response.body) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
xe_client-0.2.1 | lib/xe_client/responses/base_response.rb |