Class: FacebookAds::APIResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/facebook_ads/api_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status_code, headers, body) ⇒ APIResponse

Returns a new instance of APIResponse.



23
24
25
26
27
# File 'lib/facebook_ads/api_response.rb', line 23

def initialize(status_code, headers, body)
  @status_code = status_code
  @headers = headers
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



21
22
23
# File 'lib/facebook_ads/api_response.rb', line 21

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



21
22
23
# File 'lib/facebook_ads/api_response.rb', line 21

def headers
  @headers
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



21
22
23
# File 'lib/facebook_ads/api_response.rb', line 21

def status_code
  @status_code
end

Instance Method Details

#fb_trace_idObject



33
34
35
# File 'lib/facebook_ads/api_response.rb', line 33

def fb_trace_id
  @headers[:x_fb_trace_id]
end

#raw_bodyObject



37
38
39
# File 'lib/facebook_ads/api_response.rb', line 37

def raw_body
  @body
end

#resultObject



29
30
31
# File 'lib/facebook_ads/api_response.rb', line 29

def result
  is_json_response? ? JSON.parse(body) : body
end