Sha256: 8866ce97601d4987f073d6d7cf00d8c65c55cab145db065807cf0844b33ba822
Contents?: true
Size: 1.2 KB
Versions: 3
Compression:
Stored size: 1.2 KB
Contents
module Majestic module Api class Response attr_accessor :response, :code, :success, :error_message, :full_error, :items, :parsed_items def initialize(response = nil) self.response = response self.success = false self.items = [] self.parsed_items = [] parse_response end def parse_response if self.response.is_a?(Faraday::Response) self.response = (self.response && self.response.body) ? self.response.body : nil if self.response self.code = self.response.fetch("Code", "") self.success = self.code.downcase.eql?("ok") self.error_message = self.response.fetch("ErrorMessage", "") self.full_error = self.response.fetch("FullError", "") if success? self.parsed_items = self.response.fetch("DataTables", {}).fetch("Results", {}).fetch("Data", []) end end end end def success? self.success end def stacktrace self.full_error end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
majestic-api-1.4.2 | lib/majestic/api/response.rb |
majestic-api-1.4.1 | lib/majestic/api/response.rb |
majestic-api-1.4.0 | lib/majestic/api/response.rb |