Class: SugarCRM::Request

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, method, json, debug = false) ⇒ Request

Returns a new instance of Request.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/sugarcrm/request.rb', line 11

def initialize(url, method, json, debug=false)
  @url      = url
  @method   = method
  @json     = json

  @request  = 'method=' << @method.to_s
  @request << '&input_type=JSON'
  @request << '&response_type=JSON'
  @request << '&rest_data=' << @json
  
  if debug
    puts "#{method}: Request:"
    pp @request 
    puts "\n"
  end
  self
end

Instance Attribute Details

#http_methodObject (readonly)

Returns the value of attribute http_method.



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

def http_method
  @http_method
end

#jsonObject

Returns the value of attribute json.



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

def json
  @json
end

#methodObject

Returns the value of attribute method.



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

def method
  @method
end

#requestObject

Returns the value of attribute request.



5
6
7
# File 'lib/sugarcrm/request.rb', line 5

def request
  @request
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

Instance Method Details

#lengthObject



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

def length
  self.to_s.length
end

#to_sObject



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

def to_s
  URI.escape(@request)
end