Class: Cryptopay::Channels

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

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Channels

Returns a new instance of Channels.



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

def initialize(connection)
  @connection = connection
end

Instance Method Details

#create(channel_params, _opts = {}) ⇒ ChannelResult

Create a channel

Parameters:

  • channel_params (ChannelParams)
  • opts (Hash)

    the optional parameters

Returns:



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

def create(channel_params, _opts = {})
  path = '/api/channels'

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

  connection.call(req, return_type: ChannelResult)
end

#list(opts = {}) ⇒ ChannelListResult

List channels

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:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cryptopay/api/channels.rb', line 33

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

  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: ChannelListResult)
end

#list_payments(channel_id, opts = {}) ⇒ ChannelPaymentListResult

List channel payments

Parameters:

  • channel_id (String)

    Channel ID

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

    the optional parameters

Options Hash (opts):

  • :starting_after (String)

    Pagination parameter. ID to start after

Returns:



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/cryptopay/api/channels.rb', line 54

def list_payments(channel_id, opts = {})
  path = '/api/channels/{channel_id}/payments'
  path = path.sub('{channel_id}', CGI.escape(channel_id.to_s))

  query_params = {}
  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: ChannelPaymentListResult)
end

#retrieve(channel_id, _opts = {}) ⇒ ChannelResult

Retrieve a channel

Parameters:

  • channel_id (String)

    Channel ID

  • opts (Hash)

    the optional parameters

Returns:



74
75
76
77
78
79
80
81
82
83
84
# File 'lib/cryptopay/api/channels.rb', line 74

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

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

  connection.call(req, return_type: ChannelResult)
end

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

Retrieve a channel by custom id

Parameters:

  • custom_id (String)
  • opts (Hash)

    the optional parameters

Returns:



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

def retrieve_by_custom_id(custom_id, _opts = {})
  path = '/api/channels/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: ChannelResult)
end

#retrieve_payment(channel_id, channel_payment_id, _opts = {}) ⇒ ChannelPaymentResult

Retrieve a channel payment

Parameters:

  • channel_id (String)

    Channel ID

  • channel_payment_id (String)

    Channel payment ID

  • opts (Hash)

    the optional parameters

Returns:



107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/cryptopay/api/channels.rb', line 107

def retrieve_payment(channel_id, channel_payment_id, _opts = {})
  path = '/api/channels/{channel_id}/payments/{channel_payment_id}'
  path = path.sub('{channel_id}', CGI.escape(channel_id.to_s))
  path = path.sub('{channel_payment_id}', CGI.escape(channel_payment_id.to_s))

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

  connection.call(req, return_type: ChannelPaymentResult)
end

#update(channel_id, channel_update_params, _opts = {}) ⇒ ChannelResult

Update a channel

Parameters:

  • channel_id (String)

    Channel ID

  • channel_update_params (ChannelUpdateParams)
  • opts (Hash)

    the optional parameters

Returns:



125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/cryptopay/api/channels.rb', line 125

def update(channel_id, channel_update_params, _opts = {})
  path = '/api/channels/{channel_id}'
  path = path.sub('{channel_id}', CGI.escape(channel_id.to_s))

  req = Request.new(
    method: :patch,
    path: path,
    body_params: channel_update_params
  )

  connection.call(req, return_type: ChannelResult)
end