Class: QuidaxBeneficiary

Inherits:
QuidaxBaseObject show all
Defined in:
lib/quidax/objects/beneficiary.rb

Overview

Beneficiary object

Instance Attribute Summary

Attributes inherited from QuidaxBaseObject

#quidax

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from QuidaxBaseObject

get_request, #initialize, post_request, put_request, url

Constructor Details

This class inherits a constructor from QuidaxBaseObject

Class Method Details

.create(q_object:, user_id:, body:) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/quidax/objects/beneficiary.rb', line 34

def self.create(q_object:, user_id:, body:)
  body.stringify_keys!
  expected_query_keys = %w[currency uid extra]
  Utils.check_missing_keys(required_keys: expected_query_keys, keys: body.keys, field: "body")

  path = "#{API::USER_PATH}/#{user_id}#{API::BENEFICIARY_PATH}"

  post_request(q_object, path, body)
end

.edit_account(q_object:, user_id:, beneficiary_id:, body:) ⇒ Object



50
51
52
53
54
55
56
57
# File 'lib/quidax/objects/beneficiary.rb', line 50

def self.(q_object:, user_id:, beneficiary_id:, body:)
  body.stringify_keys!
  path = "#{API::USER_PATH}/#{user_id}#{API::BENEFICIARY_PATH}/#{beneficiary_id}"

  Utils.check_missing_keys(required_keys: %w[uid], keys: body.keys, field: "body")

  put_request(q_object, path, body)
end

.get_account(q_object:, user_id:, beneficiary_id:) ⇒ Object



44
45
46
47
48
# File 'lib/quidax/objects/beneficiary.rb', line 44

def self.(q_object:, user_id:, beneficiary_id:)
  path = "#{API::USER_PATH}/#{user_id}#{API::BENEFICIARY_PATH}/#{beneficiary_id}"

  get_request(q_object, path)
end

.get_all(q_object:, user_id:, query:) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/quidax/objects/beneficiary.rb', line 21

def self.get_all(q_object:, user_id:, query:)
  query.stringify_keys!
  allowed_currencies = %w[btc ltc xrp dash trx doge]
  Utils.check_missing_keys(required_keys: %w[currency], keys: query.keys, field: "query")

  currency = query["currency"]
  Utils.validate_value_in_array(array: allowed_currencies, value: currency, field: "currency")

  path = "#{API::USER_PATH}/#{user_id}#{API::BENEFICIARY_PATH}"

  get_request(q_object, path, query)
end

Instance Method Details

#create(user_id:, body:) ⇒ Object



9
10
11
# File 'lib/quidax/objects/beneficiary.rb', line 9

def create(user_id:, body:)
  QuidaxBeneficiary.create(q_object: @quidax, user_id: user_id, body: body)
end

#edit_account(user_id:, beneficiary_id:, body:) ⇒ Object



17
18
19
# File 'lib/quidax/objects/beneficiary.rb', line 17

def (user_id:, beneficiary_id:, body:)
  QuidaxBeneficiary.(q_object: @quidax, user_id: user_id, beneficiary_id: beneficiary_id, body: body)
end

#get_account(user_id:, beneficiary_id:) ⇒ Object



13
14
15
# File 'lib/quidax/objects/beneficiary.rb', line 13

def (user_id:, beneficiary_id:)
  QuidaxBeneficiary.(q_object: @quidax, user_id: user_id, beneficiary_id: beneficiary_id)
end

#get_all(user_id:, query:) ⇒ Object



5
6
7
# File 'lib/quidax/objects/beneficiary.rb', line 5

def get_all(user_id:, query:)
  QuidaxBeneficiary.get_all(q_object: @quidax, user_id: user_id, query: query)
end