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.



11
12
13
14
15
# File 'lib/facebook_ads/api_response.rb', line 11

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.



9
10
11
# File 'lib/facebook_ads/api_response.rb', line 9

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



9
10
11
# File 'lib/facebook_ads/api_response.rb', line 9

def headers
  @headers
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



9
10
11
# File 'lib/facebook_ads/api_response.rb', line 9

def status_code
  @status_code
end

Instance Method Details

#fb_trace_idObject



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

def fb_trace_id
  @headers[:x_fb_trace_id]
end

#raw_bodyObject



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

def raw_body
  @body
end

#resultObject



17
18
19
# File 'lib/facebook_ads/api_response.rb', line 17

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