Class: Transfirst::API

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

Constant Summary collapse

ADD_ENTITY =
0
UPDATE_ENTITY =
1
STATUS_ACTIVE =
1
STATUS_INACTIVE =
0
NO_API_ERROR =
'No API object configured'
RECURRING =
1
VERSION =
'v1'
MERCHANT_WEB_SERVICE =
1
MERCHANT_PROD_TYPE =

4 = ACH, 5 = Debit Card/Credit Card

5
XSD_PATH =
'http://postilion/realtime/merchantframework/xsd/v1/'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(credentials = {}) ⇒ API

Returns a new instance of API.



22
23
24
25
# File 'lib/transfirst.rb', line 22

def initialize(credentials = {})
  @gateway_id = credentials.fetch(:gateway_id)
  @registration_key = credentials.fetch(:registration_key)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



20
21
22
# File 'lib/transfirst.rb', line 20

def client
  @client
end

#gateway_idObject (readonly)

Returns the value of attribute gateway_id.



20
21
22
# File 'lib/transfirst.rb', line 20

def gateway_id
  @gateway_id
end

#registration_keyObject (readonly)

Returns the value of attribute registration_key.



20
21
22
# File 'lib/transfirst.rb', line 20

def registration_key
  @registration_key
end

Instance Method Details

#make_request(opname, body) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/transfirst.rb', line 27

def make_request(opname, body)
  begin
    response = soap_client.call(opname, xml: body, soap_action: nil)
    response.body
  rescue Savon::SOAPFault => e
    Transfirst::TransfirstError.new(e).message
  end
end

#registerObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/transfirst.rb', line 37

def register
  case self.class.name
    when 'Transfirst::Customer', 'Transfirst::Wallet'
      @resp = api.make_request(:updt_recurr_prof, @body)
    when 'Transfirst::WalletSale', 'Transfirst::WalletRefund', 'Transfirst::AccountVerification'
      @resp = api.make_request(:send_tran, @body)
    else
  end
  @resp
end