class SynapsePayments::Transactions

Public Class Methods

new(client, user_id, node_id, oauth_key, fingerprint) click to toggle source
# File lib/synapse_payments/transactions.rb, line 4
def initialize(client, user_id, node_id, oauth_key, fingerprint)
  @client = client
  @user_id = user_id
  @node_id = node_id
  @oauth_key = oauth_key
  @fingerprint = fingerprint
end

Public Instance Methods

all() click to toggle source
# File lib/synapse_payments/transactions.rb, line 12
def all
  @client.get(path: "/users/#{@user_id}/nodes/#{@node_id}/trans", oauth_key: @oauth_key, fingerprint: @fingerprint)
end
create(node_id:, node_type:, amount:, currency:, ip_address:, idempotency_key: nil, **args) click to toggle source
# File lib/synapse_payments/transactions.rb, line 16
def create(node_id:, node_type:, amount:, currency:, ip_address:, idempotency_key: nil, **args)
  data = {
    to: {
      type: node_type,
      id: node_id
    },
    amount: {
      amount: amount,
      currency: currency
    },
    extra: (args[:extra] || {}).merge({ ip: ip_address })
  }

  data = data.merge(fees: args[:fees]) if args[:fees]

  @client.post(path: "/users/#{@user_id}/nodes/#{@node_id}/trans", oauth_key: @oauth_key, fingerprint: @fingerprint, json: data, idempotency_key: idempotency_key)
end
delete(id) click to toggle source
# File lib/synapse_payments/transactions.rb, line 34
def delete(id)
  @client.delete(path: "/users/#{@user_id}/nodes/#{@node_id}/trans/#{id}", oauth_key: @oauth_key, fingerprint: @fingerprint)
end
find(id) click to toggle source
# File lib/synapse_payments/transactions.rb, line 38
def find(id)
  @client.get(path: "/users/#{@user_id}/nodes/#{@node_id}/trans/#{id}", oauth_key: @oauth_key, fingerprint: @fingerprint)
end
update(id, data) click to toggle source
# File lib/synapse_payments/transactions.rb, line 42
def update(id, data)
  @client.patch(path: "/users/#{@user_id}/nodes/#{@node_id}/trans/#{id}", oauth_key: @oauth_key, fingerprint: @fingerprint, json: data)
end