Class: Cardflex::PlanGateway

Inherits:
Object
  • Object
show all
Defined in:
lib/cardflex/plan_gateway.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gateway) ⇒ PlanGateway

Returns a new instance of PlanGateway.



5
6
7
8
# File 'lib/cardflex/plan_gateway.rb', line 5

def initialize(gateway)
  @gateway = gateway
  @config = gateway.config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/cardflex/plan_gateway.rb', line 3

def config
  @config
end

Instance Method Details

#_handle_response(res) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/cardflex/plan_gateway.rb', line 15

def _handle_response(res)
  if res[:response][:result] == '1'
    SuccessResponse.new(:plan => Plan.new(@gateway, res[:response]))
  else
    ErrorResponse.new(@gatway, res[:response])
  end
end

#request(attributes) ⇒ Object



10
11
12
13
# File 'lib/cardflex/plan_gateway.rb', line 10

def request(attributes)
   res = config.http.post(attributes)
  _handle_response(res)
end