Class: Centralpos::Core::Gateway

Inherits:
Object
  • Object
show all
Defined in:
lib/centralpos/core/gateway.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, password, mode = :sandbox) ⇒ Gateway

Returns a new instance of Gateway.



6
7
8
9
10
# File 'lib/centralpos/core/gateway.rb', line 6

def initialize(username, password, mode = :sandbox)
  @username = username
  @password = password
  @mode = mode
end

Instance Attribute Details

#modeObject (readonly)

Returns the value of attribute mode.



4
5
6
# File 'lib/centralpos/core/gateway.rb', line 4

def mode
  @mode
end

Instance Method Details

#call(method, extra_data = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/centralpos/core/gateway.rb', line 12

def call(method, extra_data = {})
  message = authentication_params.merge(extra_data)

  response = client.call(method, message: message)

  parse_result(response, method)
rescue Savon::Error, Errno::ENETUNREACH => error
  handle_exception(error)
end

#liveObject



27
28
29
30
# File 'lib/centralpos/core/gateway.rb', line 27

def live
  @client = nil
  @mode = :live
end

#sandboxObject



22
23
24
25
# File 'lib/centralpos/core/gateway.rb', line 22

def sandbox
  @client = nil
  @mode = :sandbox
end