Class: IActionable::Request

Inherits:
Struct
  • Object
show all
Defined in:
lib/iactionable/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(settings) ⇒ Request

Returns a new instance of Request.



9
10
11
12
13
14
15
# File 'lib/iactionable/connection.rb', line 9

def initialize(settings)
  @settings = settings
  self.path = nil
  self.params = {}
  self.headers = {}
  self.body = {}
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



6
7
8
# File 'lib/iactionable/connection.rb', line 6

def body
  @body
end

#headersObject

Returns the value of attribute headers

Returns:

  • (Object)

    the current value of headers



6
7
8
# File 'lib/iactionable/connection.rb', line 6

def headers
  @headers
end

#paramsObject

Returns the value of attribute params

Returns:

  • (Object)

    the current value of params



6
7
8
# File 'lib/iactionable/connection.rb', line 6

def params
  @params
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



6
7
8
# File 'lib/iactionable/connection.rb', line 6

def path
  @path
end

#settingsObject (readonly)

Returns the value of attribute settings.



7
8
9
# File 'lib/iactionable/connection.rb', line 7

def settings
  @settings
end

Instance Method Details

#to(path) ⇒ Object



17
18
19
20
# File 'lib/iactionable/connection.rb', line 17

def to(path)
  self.path = path unless path.nil? || path.empty?
  self
end

#with_api_keyObject



22
23
24
# File 'lib/iactionable/connection.rb', line 22

def with_api_key
  (self.headers[:Authorization] = @settings.api_key) and self
end

#with_app_keyObject



26
27
28
# File 'lib/iactionable/connection.rb', line 26

def with_app_key
  (self.params[:appKey] = @settings.app_key) and self
end

#with_body(body = {}) ⇒ Object



34
35
36
# File 'lib/iactionable/connection.rb', line 34

def with_body(body={})
  self.body.merge!(body) and self
end

#with_params(params = {}) ⇒ Object



30
31
32
# File 'lib/iactionable/connection.rb', line 30

def with_params(params={})
  self.params.merge!(params) and self
end