Class: CFoundry::BaseClient

Inherits:
Object
  • Object
show all
Defined in:
lib/cfoundry/baseclient.rb

Overview

:nodoc:

Direct Known Subclasses

Client, UAAClient, V1::Base, V2::Base

Instance Method Summary collapse

Constructor Details

#initialize(target, token = nil) ⇒ BaseClient

Returns a new instance of BaseClient.



6
7
8
9
# File 'lib/cfoundry/baseclient.rb', line 6

def initialize(target, token = nil)
  @target = target
  @token = token
end

Instance Method Details

#request_path(method, path, types = {}, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cfoundry/baseclient.rb', line 11

def request_path(method, path, types = {}, options = {})
  path = url(path) if path.is_a?(Array)

  unless types.empty?
    if params = types.delete(:params)
      options[:params] = params
    end

    if types.size > 1
      raise "request types must contain only one Content-Type => Accept"
    end

    options[:type] = types.keys.first
    options[:accept] = types.values.first
  end

  request(method, path, options)
end