class PayuZa::Client

Public Instance Methods

client() click to toggle source
# File lib/payu_za/client.rb, line 32
def client
  @client ||= Savon.client(
    wsdl: PayuZa.wsdl_endpoint,
    wsse_auth: wsse_auth
  )
end
execute(*args) click to toggle source

execute(:method, {my: 'message'}|Struct) or execute(Struct)

# File lib/payu_za/client.rb, line 10
def execute(*args)
  if args.length > 1
    operation_name, struct = args
  else
    struct = args.first
    operation_name = struct.operation_name
  end

  message = struct.respond_to?(:to_hash) ? struct.to_hash : struct

  client.call(operation_name, message: message)
end
new_struct(name, attributes = {}) click to toggle source
# File lib/payu_za/client.rb, line 23
def new_struct(name, attributes = {})
  klass = name.to_s.camelize
  "PayuZa::Structs::#{klass}".constantize.create(attributes)
end
operations() click to toggle source
# File lib/payu_za/client.rb, line 3
def operations
  client.operations
end
request(name, struct) click to toggle source
# File lib/payu_za/client.rb, line 28
def request(name, struct)
  client.operation(name).request(message: struct.to_hash)
end

Private Instance Methods

wsse_auth() click to toggle source
# File lib/payu_za/client.rb, line 41
def wsse_auth
  [PayuZa.soap_username, PayuZa.soap_password, PayuZa.password_digest]
end