Class: Easytobookr::Request

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(function_name, params = {}) ⇒ Request

Returns a new instance of Request.



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

def initialize(function_name,params={})
  @function_name = function_name
  @params = params
end

Instance Attribute Details

#function_nameObject

Returns the value of attribute function_name.



4
5
6
# File 'lib/easytobookr/request.rb', line 4

def function_name
  @function_name
end

#paramsObject

Returns the value of attribute params.



4
5
6
# File 'lib/easytobookr/request.rb', line 4

def params
  @params
end

Instance Method Details

#configObject

Convenience method to returns the common config.



36
37
38
# File 'lib/easytobookr/request.rb', line 36

def config
  Easytobookr.config
end

#responseObject



15
16
17
18
19
# File 'lib/easytobookr/request.rb', line 15

def response
  http = Net::HTTP.new(uri.host,uri.port)
  response = http.post(uri.path,self.to_xml)
  Nokogiri.XML(response.body)
end

#to_xmlObject



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

def to_xml
  request_builder.to_xml
end

#uriObject

Convenience method to returns the endpoint uri.



41
42
43
# File 'lib/easytobookr/request.rb', line 41

def uri
  config.uri
end