Class: SmartyStreets::Response
- Inherits:
-
Object
- Object
- SmartyStreets::Response
- Defined in:
- lib/smartystreets_ruby_sdk/response.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
-
#header ⇒ Object
Returns the value of attribute header.
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#status_code ⇒ Object
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#find_header(name) ⇒ Object
Case-insensitive lookup that works on both plain Hash (used by mocks) and Net::HTTPResponse (returned by the live HTTP transport, which exposes each_header but not each_pair).
-
#initialize(payload, status_code, header = nil, error = nil) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(payload, status_code, header = nil, error = nil) ⇒ Response
Returns a new instance of Response.
5 6 7 8 9 10 |
# File 'lib/smartystreets_ruby_sdk/response.rb', line 5 def initialize(payload, status_code, header = nil, error = nil) @payload = payload @status_code = status_code @header = header @error = error end |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
3 4 5 |
# File 'lib/smartystreets_ruby_sdk/response.rb', line 3 def error @error end |
#header ⇒ Object
Returns the value of attribute header.
3 4 5 |
# File 'lib/smartystreets_ruby_sdk/response.rb', line 3 def header @header end |
#payload ⇒ Object
Returns the value of attribute payload.
3 4 5 |
# File 'lib/smartystreets_ruby_sdk/response.rb', line 3 def payload @payload end |
#status_code ⇒ Object
Returns the value of attribute status_code.
3 4 5 |
# File 'lib/smartystreets_ruby_sdk/response.rb', line 3 def status_code @status_code end |
Instance Method Details
#find_header(name) ⇒ Object
Case-insensitive lookup that works on both plain Hash (used by mocks) and Net::HTTPResponse (returned by the live HTTP transport, which exposes each_header but not each_pair).
15 16 17 18 19 20 21 22 23 |
# File 'lib/smartystreets_ruby_sdk/response.rb', line 15 def find_header(name) return nil if @header.nil? target = name.to_s.downcase iterator = @header.respond_to?(:each_header) ? :each_header : :each_pair @header.send(iterator) do |k, v| return v if k.to_s.downcase == target end nil end |