Class: DiscountNetwork::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



7
8
9
# File 'lib/discountnetwork/response.rb', line 7

def initialize(response)
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



5
6
7
# File 'lib/discountnetwork/response.rb', line 5

def response
  @response
end

Instance Method Details

#parseObject



11
12
13
14
15
# File 'lib/discountnetwork/response.rb', line 11

def parse
  JSON.parse(response, object_class: ResponseObject)
rescue JSON::ParserError => error
  ResponseObject.new(error: error, content: "")
end