Class: SynapsePayments::Transactions

Inherits:
Object
  • Object
show all
Defined in:
lib/synapse_payments/transactions.rb

Instance Method Summary collapse

Constructor Details

#initialize(client, user_id, node_id, oauth_key, fingerprint) ⇒ Transactions



4
5
6
7
8
9
10
# 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

Instance Method Details

#allObject



12
13
14
# 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:, **args) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/synapse_payments/transactions.rb', line 16

def create(node_id:, node_type:, amount:, currency:, ip_address:, **args)
  data = {
    to: {
      type: node_type,
      id: node_id
    },
    amount: {
      amount: amount,
      currency: currency
    },
    extra: {
      ip: ip_address
    }.merge(args)
  }

  @client.post(path: "/users/#{@user_id}/nodes/#{@node_id}/trans", oauth_key: @oauth_key, fingerprint: @fingerprint, json: data)
end

#delete(id) ⇒ Object



34
35
36
# 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) ⇒ Object



38
39
40
# 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) ⇒ Object



42
43
44
# 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