Class: PensioAPI::Responses::Base

Inherits:
Object
  • Object
show all
Includes:
Mixins::MethodMissing
Defined in:
lib/pensio_api/responses/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixins::MethodMissing

#method_missing

Constructor Details

#initialize(request) ⇒ Base

Returns a new instance of Base.



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

def initialize(request)
  @raw = request.body
  @headers = request.headers
  unless success?
    raise PensioAPI::Errors::BadRequest.new(request) unless header_ok?
    raise PensioAPI::Errors::GatewayError.new(request) unless body_ok? || chargeback?
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class PensioAPI::Mixins::MethodMissing

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



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

def raw
  @raw
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


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

def success?
  header_ok? && (body_ok? || chargeback?)
end