Class: Cryptopay::CoinWithdrawals

Inherits:
Object
  • Object
show all
Defined in:
lib/cryptopay/api/coin_withdrawals.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ CoinWithdrawals

Returns a new instance of CoinWithdrawals.



8
9
10
# File 'lib/cryptopay/api/coin_withdrawals.rb', line 8

def initialize(connection)
  @connection = connection
end

Instance Method Details

#commit(coin_withdrawal_id, _opts = {}) ⇒ CoinWithdrawalResult

Commit a withdrawal

Parameters:

  • coin_withdrawal_id (String)

    Coin withdrawal ID

  • opts (Hash)

    the optional parameters

Returns:



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cryptopay/api/coin_withdrawals.rb', line 16

def commit(coin_withdrawal_id, _opts = {})
  path = '/api/coin_withdrawals/{coin_withdrawal_id}/commit'
  path = path.sub('{coin_withdrawal_id}', CGI.escape(coin_withdrawal_id.to_s))

  req = Request.new(
    method: :post,
    path: path
  )

  connection.call(req, return_type: CoinWithdrawalResult)
end

#create(coin_withdrawal_params, _opts = {}) ⇒ CoinWithdrawalResult

Create a withdrawal To create a withdrawal you need to use either `charged_amount`, `charged_amount_to_send` or `received_amount` parameters in your request body.

Parameters:

Returns:



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/cryptopay/api/coin_withdrawals.rb', line 33

def create(coin_withdrawal_params, _opts = {})
  path = '/api/coin_withdrawals'

  req = Request.new(
    method: :post,
    path: path,
    body_params: coin_withdrawal_params
  )

  connection.call(req, return_type: CoinWithdrawalResult)
end

#list(opts = {}) ⇒ CoinWithdrawalListResult

List withdrawals

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :customer_id (String)

    The internal ID of your customer that the transaction relates to

  • :starting_after (String)

    Pagination parameter. ID to start after

Returns:



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/cryptopay/api/coin_withdrawals.rb', line 50

def list(opts = {})
  path = '/api/coin_withdrawals'

  query_params = {}
  query_params[:customer_id] = opts[:customer_id] unless opts[:customer_id].nil?
  query_params[:starting_after] = opts[:starting_after] unless opts[:starting_after].nil?

  req = Request.new(
    method: :get,
    path: path,
    query_params: query_params
  )

  connection.call(req, return_type: CoinWithdrawalListResult)
end

#list_network_fees(opts = {}) ⇒ NetworkFeeListResult

List network fees

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :all_networks (Boolean)

    Is `false` if omitted. Set `true` to return network fees for all cryptocurrency networks

Returns:



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/cryptopay/api/coin_withdrawals.rb', line 70

def list_network_fees(opts = {})
  path = '/api/coin_withdrawals/network_fees'

  query_params = {}
  query_params[:all_networks] = opts[:all_networks] unless opts[:all_networks].nil?

  req = Request.new(
    method: :get,
    path: path,
    query_params: query_params
  )

  connection.call(req, return_type: NetworkFeeListResult)
end

#retrieve(coin_withdrawal_id, _opts = {}) ⇒ CoinWithdrawalResult

Retrieve a withdrawal

Parameters:

  • coin_withdrawal_id (String)

    Coin withdrawal ID

  • opts (Hash)

    the optional parameters

Returns:



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/cryptopay/api/coin_withdrawals.rb', line 89

def retrieve(coin_withdrawal_id, _opts = {})
  path = '/api/coin_withdrawals/{coin_withdrawal_id}'
  path = path.sub('{coin_withdrawal_id}', CGI.escape(coin_withdrawal_id.to_s))

  req = Request.new(
    method: :get,
    path: path
  )

  connection.call(req, return_type: CoinWithdrawalResult)
end

#retrieve_by_custom_id(custom_id, _opts = {}) ⇒ CoinWithdrawalResult

Retrieve a withdrawal by custom id

Parameters:

  • custom_id (String)
  • opts (Hash)

    the optional parameters

Returns:



105
106
107
108
109
110
111
112
113
114
115
# File 'lib/cryptopay/api/coin_withdrawals.rb', line 105

def retrieve_by_custom_id(custom_id, _opts = {})
  path = '/api/coin_withdrawals/custom_id/{custom_id}'
  path = path.sub('{custom_id}', CGI.escape(custom_id.to_s))

  req = Request.new(
    method: :get,
    path: path
  )

  connection.call(req, return_type: CoinWithdrawalResult)
end