Class: Nifcloud::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/nifcloud/request.rb

Direct Known Subclasses

API

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Request

Returns a new instance of Request.



8
9
10
11
# File 'lib/nifcloud/request.rb', line 8

def initialize(options={})
  @client = HTTPClient.new default_header: {"User-Agent" => @user_agent}
  @client.debug_dev = $stderr if @debug
end

Instance Attribute Details

#access_keyObject

Returns the value of attribute access_key.



6
7
8
# File 'lib/nifcloud/request.rb', line 6

def access_key
  @access_key
end

#endpointObject

Returns the value of attribute endpoint.



6
7
8
# File 'lib/nifcloud/request.rb', line 6

def endpoint
  @endpoint
end

#secret_keyObject

Returns the value of attribute secret_key.



6
7
8
# File 'lib/nifcloud/request.rb', line 6

def secret_key
  @secret_key
end

Class Method Details

.set_proxy_config(address = nil, port = nil, username = nil, password = nil) ⇒ Object



33
34
35
36
# File 'lib/nifcloud/request.rb', line 33

def self.set_proxy_config(address=nil, port=nil, username=nil, password=nil)
  @client.proxy = "http://#{address}:#{port}"
  @client.set_proxy_auth(username, password) if username
end

Instance Method Details

#delete(path, options = {}) ⇒ Object



28
29
30
31
# File 'lib/nifcloud/request.rb', line 28

def delete(path, options={})
  set_query(options)
  validate @client.delete(@endpoint + path, options)
end

#get(path, options = {}) ⇒ Object



13
14
15
16
# File 'lib/nifcloud/request.rb', line 13

def get(path, options={})
  set_query(options)
  validate @client.get(@endpoint + path, options)
end

#post(path, options = {}) ⇒ Object



18
19
20
21
# File 'lib/nifcloud/request.rb', line 18

def post(path, options={})
  set_query(options)
  validate @client.post(@endpoint + path, options)
end

#put(path, options = {}) ⇒ Object



23
24
25
26
# File 'lib/nifcloud/request.rb', line 23

def put(path, options={})
  set_query(options)
  validate @client.put(@endpoint + path, options)
end