Class: Smartpay::Responses::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/smartpay/responses/base.rb

Direct Known Subclasses

CheckoutSession

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_response) ⇒ Base



8
9
10
11
12
13
14
15
# File 'lib/smartpay/responses/base.rb', line 8

def initialize(raw_response)
  @raw_response = raw_response
  @response = begin
    JSON.parse(@raw_response.body, symbolize_names: true)
  rescue JSON::ParserError
    { body: @raw_response.body }
  end if @raw_response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



6
7
8
# File 'lib/smartpay/responses/base.rb', line 6

def response
  @response
end

Instance Method Details

#as_hashObject



17
18
19
# File 'lib/smartpay/responses/base.rb', line 17

def as_hash
  @response
end

#as_jsonObject



21
22
23
# File 'lib/smartpay/responses/base.rb', line 21

def as_json
  @response.to_json
end

#http_codeObject



25
26
27
# File 'lib/smartpay/responses/base.rb', line 25

def http_code
  @raw_response.code
end