Class: Twilio::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/twilio-ruby/framework/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status_code, body, headers: nil) ⇒ Response

Returns a new instance of Response.



7
8
9
10
11
12
# File 'lib/twilio-ruby/framework/response.rb', line 7

def initialize(status_code, body, headers: nil)
  @status_code = status_code
  body = '{}' if !body || body.empty?
  @body = JSON.parse(body)
  @headers = !headers ? {} : headers.to_hash
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



5
6
7
# File 'lib/twilio-ruby/framework/response.rb', line 5

def body
  @body
end

#headersObject

Returns the value of attribute headers.



5
6
7
# File 'lib/twilio-ruby/framework/response.rb', line 5

def headers
  @headers
end

#status_codeObject

Returns the value of attribute status_code.



5
6
7
# File 'lib/twilio-ruby/framework/response.rb', line 5

def status_code
  @status_code
end

Instance Method Details

#to_sObject



14
15
16
# File 'lib/twilio-ruby/framework/response.rb', line 14

def to_s
  "[#{status_code}] #{body}"
end