Sha256: 858b6d4dbe83debeb6bcdfcfcd8f67bc61259e1b934be861a1e30fbb4b63fb3c
Contents?: true
Size: 1.15 KB
Versions: 9
Compression:
Stored size: 1.15 KB
Contents
require "forwardable" module Duracloud class Client extend Forwardable extend RestMethods include RestMethods def self.execute(request_class, http_method, url, **options) new.execute(request_class, http_method, url, **options) end def self.configure yield Configuration end attr_reader :config delegate [:host, :port, :user, :password, :base_url, :logger] => :config def initialize(**options) @config = Configuration.new(**options) end def execute(request_class, http_method, url, **options) request = request_class.new(self, http_method, url, **options) response = request.execute handle_response(response) response end private def handle_response(response) logger.debug([self.class.to_s, response.request_method, response.url, response.status, response.reason].join(' ')) if response.error? ErrorHandler.call(response) elsif %w(POST PUT DELETE).include?(response.request_method) && response.plain_text? && response.has_body? logger.info(response.body) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems