Class: Blockchain0x::Resources::Payments
- Inherits:
-
Object
- Object
- Blockchain0x::Resources::Payments
- Defined in:
- lib/blockchain0x/resources/payments.rb
Overview
‘client.payments.*` resource.
Instance Method Summary collapse
-
#create(body:, idempotency_key: nil) ⇒ Hash
Submit an outbound payment.
-
#initialize(client) ⇒ Payments
constructor
A new instance of Payments.
Constructor Details
#initialize(client) ⇒ Payments
Returns a new instance of Payments.
51 52 53 |
# File 'lib/blockchain0x/resources/payments.rb', line 51 def initialize(client) @client = client end |
Instance Method Details
#create(body:, idempotency_key: nil) ⇒ Hash
Submit an outbound payment.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/blockchain0x/resources/payments.rb', line 66 def create(body:, idempotency_key: nil) wire = if body.respond_to?(:to_h_wire) body.to_h_wire else body.to_h.transform_keys(&:to_s) end raise ArgumentError, 'agentId is required' if wire['agentId'].nil? || wire['agentId'].empty? raise ArgumentError, 'to is required' if wire['to'].nil? || wire['to'].empty? raise ArgumentError, 'amountWei is required' if wire['amountWei'].nil? || wire['amountWei'].empty? @client.post('/v1/payments', body: wire, idempotency_key: idempotency_key) end |