Class: PayuZa::Client
- Inherits:
-
Object
- Object
- PayuZa::Client
- Defined in:
- lib/payu_za/client.rb
Instance Method Summary collapse
- #client ⇒ Object
-
#execute(*args) ⇒ Object
execute(:method, ‘message’|Struct) or execute(Struct).
- #new_struct(name, attributes = {}) ⇒ Object
- #operations ⇒ Object
- #request(name, struct) ⇒ Object
Instance Method Details
#client ⇒ Object
32 33 34 35 36 37 |
# File 'lib/payu_za/client.rb', line 32 def client @client ||= Savon.client( wsdl: PayuZa.wsdl_endpoint, wsse_auth: wsse_auth ) end |
#execute(*args) ⇒ Object
execute(:method, ‘message’|Struct) or execute(Struct)
10 11 12 13 14 15 16 17 18 19 20 21 |
# 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 = struct.respond_to?(:to_hash) ? struct.to_hash : struct client.call(operation_name, message: ) end |
#new_struct(name, attributes = {}) ⇒ Object
23 24 25 26 |
# 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 ⇒ Object
3 4 5 |
# File 'lib/payu_za/client.rb', line 3 def operations client.operations end |
#request(name, struct) ⇒ Object
28 29 30 |
# File 'lib/payu_za/client.rb', line 28 def request(name, struct) client.operation(name).request(message: struct.to_hash) end |