Class: LadyGaga::Request

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/lady_gaga/request.rb

Direct Known Subclasses

DialAZip

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#credentialsObject

Returns the value of attribute credentials.



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

def credentials
  @credentials
end

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

#xml_pathObject

Returns the value of attribute xml_path.



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

def xml_path
  @xml_path
end

#xml_rootObject

Returns the value of attribute xml_root.



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

def xml_root
  @xml_root
end

Instance Method Details

#<<(hash) ⇒ Object



25
26
27
# File 'lib/lady_gaga/request.rb', line 25

def <<(hash)
  options.merge!(hash)
end

#bodyObject



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

def body
  {xml_param => options.merge(credentials).to_xml(:root => xml_root, :skip_instruct => true)}
end

#default_optionsObject



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

def default_options
  {}
end

#getObject



37
38
39
40
# File 'lib/lady_gaga/request.rb', line 37

def get
  response = self.class.get(path, :query => body)
  Response.new(response)
end

#optionsObject



21
22
23
# File 'lib/lady_gaga/request.rb', line 21

def options
  @options ||= default_options
end

#postObject



42
43
44
45
# File 'lib/lady_gaga/request.rb', line 42

def post
  response = self.class.post(path, :body => body)
  Response.new(response)
end

#reset!Object



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

def reset!
  @options = default_options
end