Class: Orchestrate::API::Request

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

Overview

Uses HTTParty to make the HTTP calls,

and returns a Response object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, url, user) {|_self| ... } ⇒ Request

Sets the universal attributes from the params; any additional attributes are set from the block.

Yields:

  • (_self)

Yield Parameters:



31
32
33
34
35
# File 'lib/orchestrate_api/request.rb', line 31

def initialize(method, url, user)
  @method, @url, @user = method, url, user
  @data = {}
  yield self if block_given?
end

Instance Attribute Details

#dataObject

The json document for creating or updating a key.



20
21
22
# File 'lib/orchestrate_api/request.rb', line 20

def data
  @data
end

#methodObject

The HTTP method - must be one of: [ :get, :put, :delete ].



11
12
13
# File 'lib/orchestrate_api/request.rb', line 11

def method
  @method
end

#refObject

The ref value associated with a key.



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

def ref
  @ref
end

#urlObject

The url for the HTTP request.



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

def url
  @url
end

#userObject

The api key for HTTP Basic Authentication over SSL.



17
18
19
# File 'lib/orchestrate_api/request.rb', line 17

def user
  @user
end

#verboseObject

Boolean



26
27
28
# File 'lib/orchestrate_api/request.rb', line 26

def verbose
  @verbose
end

Instance Method Details

#performObject

Sends the HTTP request and returns a Response object.



38
39
40
41
# File 'lib/orchestrate_api/request.rb', line 38

def perform
  puts "\n------- #{method.to_s.upcase} \"#{url}\" ------" if verbose?
  Response.new HTTParty.send(method, url, options)
end