Sha256: 2892dd5e5f965be6d2fefea1c8249c9afaf868c8358bdbebd838ab4611cfcc92
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
require 'plissken' require 'smartsheet/error' module Smartsheet module API class ResponseNetClientDecorator def initialize(client, json_output: false, logger: MuteRequestLogger.new) @json_output = json_output @client = client @logger = logger end def make_request(request) parse(request, client.make_request(request)) end private attr_reader :json_output, :client, :logger def parse(request, response) if response.success? logger.log_successful_response(response) parse_success(response) else logger.log_error_response(request, response) parse_failure(response) end end def parse_success(response) if json_output response.result.to_json elsif response.result.respond_to? :to_snake_keys response.result.to_snake_keys else response.result end end def parse_failure(response) raise Smartsheet::ApiError.new(response) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
smartsheet-1.0.0.beta.2 | lib/smartsheet/api/response_net_client_decorator.rb |
smartsheet-1.0.0.beta.0 | lib/smartsheet/api/response_net_client_decorator.rb |