class SyncwiseApi::Responses::V1_0::Base
Attributes
body_hash[R]
Public Class Methods
new(http_response_object)
click to toggle source
# File lib/syncwise_api/responses/V1_0/base.rb, line 6 def initialize(http_response_object) @http_response_object = http_response_object @body = @http_response_object.body @header_hash = @http_response_object.header.to_hash.symbolize_keys @body_hash = parse end
Public Instance Methods
valid?()
click to toggle source
# File lib/syncwise_api/responses/V1_0/base.rb, line 15 def valid? @body_hash[:sts] == '1' end
Private Instance Methods
parse()
click to toggle source
# File lib/syncwise_api/responses/V1_0/base.rb, line 21 def parse # if the response has a body, and the body is json, parse and store it in @body_hash; otherwise throw an error if @body.blank? fail SyncwiseApi::Errors::EmptyResponseBody.new(@http_response_object, @http_response_object.uri, @header_hash) elsif !@header_hash[:content_type].include?('application/json') fail SyncwiseApi::Errors::InvalidContentType.new(@http_response_object, @http_response_object.uri, @header_hash) else SyncwiseApi::ServiceUtils::Parsers::JSON.parse(@body).symbolize_keys end end