Initial commit
This commit is contained in:
50
app/api/v2/entities/account.rb
Normal file
50
app/api/v2/entities/account.rb
Normal file
@@ -0,0 +1,50 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
module API
|
||||
module V2
|
||||
module Entities
|
||||
class Account < Base
|
||||
expose(
|
||||
:currency_id,
|
||||
as: :currency,
|
||||
documentation: {
|
||||
desc: 'Currency code.',
|
||||
type: String
|
||||
}
|
||||
)
|
||||
|
||||
expose(
|
||||
:balance,
|
||||
format_with: :decimal,
|
||||
documentation: {
|
||||
desc: 'Account balance.',
|
||||
type: BigDecimal
|
||||
}
|
||||
)
|
||||
|
||||
expose(
|
||||
:locked,
|
||||
format_with: :decimal,
|
||||
documentation: {
|
||||
desc: 'Account locked funds.',
|
||||
type: BigDecimal
|
||||
}
|
||||
)
|
||||
|
||||
expose(
|
||||
:deposit_address,
|
||||
if: ->(account, _options) { account.currency.coin? },
|
||||
using: API::V2::Entities::PaymentAddress,
|
||||
documentation: {
|
||||
desc: 'User deposit address',
|
||||
type: String
|
||||
}
|
||||
) do |account, options|
|
||||
wallet = Wallet.deposit_wallet(account.currency_id)
|
||||
::PaymentAddress.find_by(wallet: wallet, member: options[:current_user], remote: false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user