Sha256: c72a653148d6003c47bf62785bda48a1d62d84e62890f574fe9f177f0b675d82

Contents?: true

Size: 937 Bytes

Versions: 1

Compression:

Stored size: 937 Bytes

Contents

require_relative "connection"
require_relative "response"
require_relative "request_options"

module Duracloud
  class Request
    attr_reader :client, :url, :http_method, :options

    def initialize(client, http_method, url, **options)
      @client      = client
      @http_method = http_method
      @url         = url
      @options = RequestOptions.new(**options)
    end

    def execute
      original_response = connection.send(http_method,
                                          url,
                                          body: options.payload,
                                          query: options.query,
                                          header: options.headers)
      response_class.new(original_response)
    end

    private

    def base_path
      '/'
    end

    def response_class
      Response
    end

    def connection
      @connection ||= Connection.new(client, base_path)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
duracloud-client-0.0.1 lib/duracloud/request.rb