Class: Lago::Api::Resources::WalletTransaction

Inherits:
Base
  • Object
show all
Defined in:
lib/lago/api/resources/wallet_transaction.rb

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#create, #destroy, #get, #initialize, #update

Constructor Details

This class inherits a constructor from Lago::Api::Resources::Base

Instance Method Details

#api_resourceObject



9
10
11
# File 'lib/lago/api/resources/wallet_transaction.rb', line 9

def api_resource
  'wallet_transactions'
end

#get_all(wallet_id, options = {}) ⇒ Object



17
18
19
20
21
22
# File 'lib/lago/api/resources/wallet_transaction.rb', line 17

def get_all(wallet_id, options = {})
  path = "/api/v1/wallets/#{wallet_id}/wallet_transactions"
  response = connection.get_all(options, path)

  JSON.parse(response.to_json, object_class: OpenStruct)
end

#payment_url(wallet_transaction_id) ⇒ Object



24
25
26
27
28
29
# File 'lib/lago/api/resources/wallet_transaction.rb', line 24

def payment_url(wallet_transaction_id)
  path = "/api/v1/wallet_transactions/#{wallet_transaction_id}/payment_url"
  response = connection.post({}, path)['wallet_transaction_payment_details']

  JSON.parse(response.to_json, object_class: OpenStruct)
end

#root_nameObject



13
14
15
# File 'lib/lago/api/resources/wallet_transaction.rb', line 13

def root_name
  'wallet_transactions'
end

#whitelist_params(params) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/lago/api/resources/wallet_transaction.rb', line 31

def whitelist_params(params)
  {
    'wallet_transaction' => params.compact.slice(
      :wallet_id,
      :name,
      :paid_credits,
      :granted_credits,
      :voided_credits,
      :invoice_requires_successful_payment,
      :ignore_paid_top_up_limits,
      :metadata,
    )
  }
end