Class: Baidu::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/baidu/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, name_response_sym) ⇒ Response

Returns a new instance of Response.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/baidu/response.rb', line 4

def initialize(response,name_response_sym)
  name_response_sym =
  case name_response_sym
    when 'getAllCampaign'
      'GetAllCampaign'
    when 'getCampaignByCampaignId'
      'GetCampaignByCampaignId'
    when 'addCampaign'
      'AddCampaign'
    when 'updateCampaign'
      'UpdateCampaign'
    when 'deleteCampaign'
      'DeleteCampaign'
    when 'getCampaignByCampaignId'
      'GetCampaignByCampaignId'
    else
      name_response_sym
  end
  @header = response.header[:res_header]
  @body = response.body[name_response_sym] if(response.body and response.body.has_key?name_response_sym)
  @rquota = @header[:rquota].to_i
  @quota = @header[:quota].to_i
  @status = @header[:status].to_i
  @desc = @header[:desc]
  @oprs = @header[:oprs]
  @oprtime = @header[:oprtime]
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



3
4
5
# File 'lib/baidu/response.rb', line 3

def body
  @body
end

#descObject

Returns the value of attribute desc.



3
4
5
# File 'lib/baidu/response.rb', line 3

def desc
  @desc
end

#headerObject

Returns the value of attribute header.



3
4
5
# File 'lib/baidu/response.rb', line 3

def header
  @header
end

#oprsObject

Returns the value of attribute oprs.



3
4
5
# File 'lib/baidu/response.rb', line 3

def oprs
  @oprs
end

#oprtimeObject

Returns the value of attribute oprtime.



3
4
5
# File 'lib/baidu/response.rb', line 3

def oprtime
  @oprtime
end

#quotaObject

Returns the value of attribute quota.



3
4
5
# File 'lib/baidu/response.rb', line 3

def quota
  @quota
end

#rquotaObject

Returns the value of attribute rquota.



3
4
5
# File 'lib/baidu/response.rb', line 3

def rquota
  @rquota
end

#statusObject

Returns the value of attribute status.



3
4
5
# File 'lib/baidu/response.rb', line 3

def status
  @status
end