Initial commit

This commit is contained in:
Yaser
2026-08-13 19:50:53 +03:30
commit 38084458fe
879 changed files with 95198 additions and 0 deletions

View 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

View File

@@ -0,0 +1,13 @@
# encoding: UTF-8
# frozen_string_literal: true
module API
module V2
module Entities
class Base < Grape::Entity
format_with(:iso8601) {|t| t.to_time.in_time_zone(::Rails.configuration.time_zone).iso8601 if t }
format_with(:decimal) {|d| d.to_s('F') if d }
end
end
end
end

View File

@@ -0,0 +1,88 @@
# encoding: UTF-8
# frozen_string_literal: true
module API
module V2
module Entities
class Beneficiary < Base
expose(
:id,
documentation: {
desc: 'Beneficiary Identifier in Database',
type: Integer
}
)
expose(
:currency_id,
as: :currency,
documentation: {
desc: 'Beneficiary currency code.',
type: String
}
)
expose(
:uid,
documentation: {
desc: 'Beneficiary owner',
type: String
}
) { |b| b.member.uid }
expose(
:name,
documentation: {
desc: 'Human rememberable name which refer beneficiary.',
type: String
}
)
expose(
:description,
documentation: {
desc: 'Human rememberable description of beneficiary.',
type: String
}
)
# expose(
# :data,
# documentation: {
# desc: 'Bank Account details for fiat Beneficiary in JSON format.'\
# 'For crypto it\'s blockchain address.',
# type: JSON
# }
# ) do |beneficiary|
# beneficiary.currency.fiat? ? beneficiary.masked_data : beneficiary.data
# end
expose(
:data,
documentation: {
desc: 'Bank Account details for fiat Beneficiary in JSON format.'\
'For crypto it\'s blockchain address.',
type: JSON
}
)
expose(
:state,
documentation: {
desc: 'Defines either beneficiary active - user can use it to withdraw money'\
'or pending - requires beneficiary activation with pin.',
type: String
}
)
expose(
:sent_at,
format_with: :iso8601,
documentation: {
desc: 'Time when last pin was sent',
type: String
}
)
end
end
end
end

View File

@@ -0,0 +1,38 @@
# encoding: UTF-8
# frozen_string_literal: true
module API
module V2
module Entities
class Bonus < Base
expose(
:bonus_member_id,
as: :uid,
documentation: {
desc: 'user_uid.',
type: String
}
)
expose(
:amount,
format_with: :decimal,
documentation: {
desc: 'Bonus account',
type: BigDecimal
}
)
expose(
:created_at,
as: :date,
format_with: :iso8601,
documentation: {
desc: 'created date',
type: Date
}
)
end
end
end
end

View File

@@ -0,0 +1,188 @@
# encoding: UTF-8
# frozen_string_literal: true
module API
module V2
module Entities
class Currency < Base
expose(
:id,
documentation: {
desc: 'Currency code.',
type: String,
values: -> { ::Currency.visible.codes },
example: -> { ::Currency.visible.first.id }
}
)
expose(
:name,
documentation: {
type: String,
desc: 'Currency name',
example: -> { ::Currency.visible.first.name }
},
if: -> (currency){ currency.name.present? }
)
expose(
:description,
documentation: {
type: String,
desc: 'Currency description',
example: -> { ::Currency.visible.first.id }
}
)
expose(
:homepage,
documentation: {
type: String,
desc: 'Currency homepage',
example: -> { ::Currency.visible.first.id }
}
)
expose(
:price,
documentation: {
desc: 'Currency current price'
}
)
expose(
:explorer_transaction,
documentation: {
desc: 'Currency transaction exprorer url template',
example: 'https://testnet.blockchain.info/tx/'
},
if: -> (currency){ currency.coin? }
)
expose(
:explorer_address,
documentation: {
desc: 'Currency address exprorer url template',
example: 'https://testnet.blockchain.info/address/'
},
if: -> (currency){ currency.coin? }
)
expose(
:type,
documentation: {
type: String,
values: -> { ::Currency.types },
desc: 'Currency type',
example: -> { ::Currency.visible.first.type }
}
)
expose(
:deposit_enabled,
documentation: {
type: String,
desc: 'Currency deposit possibility status (true/false).'
}
)
expose(
:withdrawal_enabled,
documentation: {
type: String,
desc: 'Currency withdrawal possibility status (true/false).'
}
)
expose(
:deposit_fee,
documentation: {
desc: 'Currency deposit fee',
example: -> { ::Currency.visible.first.deposit_fee }
}
)
expose(
:min_deposit_amount,
documentation: {
desc: 'Minimal deposit amount',
example: -> { ::Currency.visible.first.min_deposit_amount }
}
)
expose(
:withdraw_fee,
documentation: {
desc: 'Currency withdraw fee',
example: -> { ::Currency.visible.first.withdraw_fee }
}
)
expose(
:min_withdraw_amount,
documentation: {
desc: 'Minimal withdraw amount',
example: -> { ::Currency.visible.first.min_withdraw_amount }
}
)
expose(
:withdraw_limit_24h,
documentation: {
desc: 'Currency 24h withdraw limit',
example: -> { ::Currency.visible.first.withdraw_limit_24h }
}
)
expose(
:withdraw_limit_72h,
documentation: {
desc: 'Currency 72h withdraw limit',
example: -> { ::Currency.visible.first.withdraw_limit_72h }
}
)
expose(
:base_factor,
documentation: {
desc: 'Currency base factor',
example: -> { ::Currency.visible.first.base_factor }
}
)
expose(
:precision,
documentation: {
desc: 'Currency precision',
example: -> { ::Currency.visible.first.precision }
}
)
expose(
:position,
documentation: {
desc: 'Position used for defining currencies order',
example: -> { ::Currency.visible.first.precision }
}
)
expose(
:icon_url,
documentation: {
desc: 'Currency icon',
example: 'https://upload.wikimedia.org/wikipedia/commons/0/05/Ethereum_logo_2014.svg'
},
if: -> (currency){ currency.icon_url.present? }
)
expose(
:min_confirmations,
if: ->(currency) { currency.coin? },
documentation: {
desc: 'Number of confirmations required for confirming deposit or withdrawal'
}
) { |c| c.blockchain.min_confirmations }
end
end
end
end

View File

@@ -0,0 +1,104 @@
# encoding: UTF-8
# frozen_string_literal: true
module API
module V2
module Entities
class Deposit < Base
expose(
:id,
documentation: {
type: Integer,
desc: 'Unique deposit id.'
}
)
expose(
:currency_id,
as: :currency,
documentation: {
type: String,
desc: 'Deposit currency id.'
}
)
expose(
:amount,
format_with: :decimal,
documentation: {
type: BigDecimal,
desc: 'Deposit amount.'
}
)
expose(
:fee,
documentation: {
type: BigDecimal,
desc: 'Deposit fee.'
}
)
expose(
:txid,
documentation: {
type: String,
desc: 'Deposit transaction id.'
}
)
expose(
:confirmations,
documentation: {
type: Integer,
desc: 'Number of deposit confirmations.'
},
if: ->(deposit) { deposit.currency.coin? }
)
expose(
:aasm_state,
as: :state,
documentation: {
type: String,
desc: 'Deposit state.'
}
)
expose(
:transfer_type,
documentation: {
type: String,
desc: 'Deposit transfer type'
}
)
expose(
:created_at,
format_with: :iso8601,
documentation: {
type: String,
desc: 'The datetime when deposit was created.'
}
)
expose(
:completed_at,
format_with: :iso8601,
documentation: {
type: String,
desc: 'The datetime when deposit was completed..'
}
)
expose(
:tid,
documentation: {
type: String,
desc: 'The shared transaction ID'
}
)
end
end
end
end

View File

@@ -0,0 +1,73 @@
module API
module V2
module Entities
class DepositLimit < API::V2::Entities::Base
expose(
:id,
documentation:{
type: Integer,
desc: 'Unique deposit limit table identifier in database.'
}
)
expose(
:group,
documentation:{
type: String,
desc: 'Member group for define deposit limits.'
}
)
expose(
:kyc_level,
documentation:{
type: String,
desc: 'KYC level for define deposit limits.'
}
)
expose(
:kind,
documentation:{
type: String,
desc: 'kind for define deposit limits.'
}
)
expose(
:limit_24_hour,
documentation:{
type: BigDecimal,
desc: '24 hours deposit limit.'
}
)
expose(
:limit_1_month,
documentation:{
type: BigDecimal,
desc: '1 month deposit limit.'
}
)
expose(
:created_at,
format_with: :iso8601,
documentation: {
type: String,
desc: 'deposit limit table created time in iso8601 format.'
}
)
expose(
:updated_at,
format_with: :iso8601,
documentation: {
type: String,
desc: 'deposit limit table updated time in iso8601 format.'
}
)
end
end
end
end

View File

@@ -0,0 +1,98 @@
# encoding: UTF-8
# frozen_string_literal: true
module API
module V2
module Entities
class InternalTransfer < Base
expose(
:currency_id,
as: :currency,
documentation: {
type: String,
desc: 'The currency code.'
}
)
expose(
:sender_username,
documentation: {
type: String,
desc: 'The internal transfer sender.'
}
) do |transfer|
transfer.sender&.username
end
expose(
:receiver_username,
documentation: {
type: String,
desc: 'The internal transfer receiver.'
}
) do |transfer|
transfer.receiver&.username
end
expose(
:sender_uid,
documentation: {
type: String,
desc: 'The internal transfer sender.'
}
) do |transfer|
transfer.sender.uid
end
expose(
:receiver_uid,
documentation: {
type: String,
desc: 'The internal transfer receiver.'
}
) do |transfer|
transfer.receiver.uid
end
expose(
:direction, ## call method from model
documentation: {
type: String,
desc: 'The internal transfer direction (incoming or outcoming internal transfer).'
}
) do |transfer, options|
transfer.direction(options[:current_user])
end
expose(
:amount,
format_with: :decimal,
documentation: {
type: BigDecimal,
desc: 'Internal transfer Amount.'
}
)
expose(
:state,
as: :status,
documentation: {
type: String,
desc: 'The internal transfer state.'
}
)
expose(
:created_at,
:updated_at,
format_with: :iso8601,
documentation: {
type: String,
desc: 'The datetimes for the internal transfer.'
}
)
end
end
end
end

View File

@@ -0,0 +1,93 @@
# encoding: UTF-8
# frozen_string_literal: true
module API
module V2
module Entities
class Market < Base
expose(
:id,
documentation: {
type: String,
desc: "Unique market id. It's always in the form of xxxyyy,"\
"where xxx is the base currency code, yyy is the quote"\
"currency code, e.g. 'btcusd'. All available markets can"\
"be found at /api/v2/markets."
}
)
expose(
:name,
documentation: {
type: String,
desc: 'Market name.'
}
)
expose(
:base_unit,
documentation: {
type: String,
desc: "Market Base unit."
}
)
expose(
:quote_unit,
documentation: {
type: String,
desc: "Market Quote unit."
}
)
expose(
:min_price,
documentation: {
type: BigDecimal,
desc: "Minimum order price."
}
)
expose(
:max_price,
documentation: {
type: BigDecimal,
desc: "Maximum order price."
}
)
expose(
:min_amount,
documentation: {
type: BigDecimal,
desc: "Minimum order amount."
}
)
expose(
:amount_precision,
documentation: {
type: BigDecimal,
desc: "Precision for order amount."
}
)
expose(
:price_precision,
documentation: {
type: BigDecimal,
desc: "Precision for order price."
}
)
expose(
:state,
documentation: {
type: String,
desc: "Market state defines if user can see/trade on current market."
}
)
end
end
end
end

View File

@@ -0,0 +1,38 @@
# encoding: UTF-8
# frozen_string_literal: true
module API
module V2
module Entities
class Member < Base
expose(
:uid,
documentation: {
type: String,
desc: 'Member UID.'
}
)
expose(
:email,
documentation: {
type: String,
desc: 'Member email.'
}
)
expose(
:accounts,
using: API::V2::Entities::Account,
documentation: {
type: 'API::V2::Entities::Account',
is_array: true,
desc: 'Member accounts.'
}
) do |m|
m.accounts.includes(:currency)
end
end
end
end
end

View File

@@ -0,0 +1,166 @@
# encoding: UTF-8
# frozen_string_literal: true
module API
module V2
module Entities
class Order < Base
expose(
:id,
documentation:{
type: Integer,
desc: "Unique order id."
}
)
expose(
:uuid,
documentation:{
type: String,
desc: "Unique order UUID."
}
)
expose(
:side,
documentation: {
type: String,
desc: "Either 'sell' or 'buy'."
}
)
expose(
:ord_type,
documentation: {
type: String,
desc: "Type of order, either 'limit' or 'market'."
}
)
expose(
:price,
documentation: {
type: BigDecimal,
desc: "Price for each unit. e.g."\
"If you want to sell/buy 1 btc at 3000 usd, the price is '3000.0'"
}
)
expose(
:avg_price,
documentation: {
type: BigDecimal,
desc: "Average execution price, average of price in trades."
}
)
expose(
:state,
documentation: {
type: String,
desc: "One of 'wait', 'done', or 'cancel'."\
"An order in 'wait' is an active order, waiting fulfillment;"\
"a 'done' order is an order fulfilled;"\
"'cancel' means the order has been canceled."
}
)
expose(
:market_id,
as: :market,
documentation: {
type: String,
desc: "The market in which the order is placed, e.g. 'btcusd'."\
"All available markets can be found at /api/v2/markets."
}
)
expose(
:created_at,
format_with: :iso8601,
documentation: {
type: String,
desc: "Order create time in iso8601 format."
}
)
expose(
:updated_at,
format_with: :iso8601,
documentation: {
type: String,
desc: "Order updated time in iso8601 format."
}
)
expose(
:origin_volume,
documentation: {
type: BigDecimal,
desc: "The amount user want to sell/buy."\
"An order could be partially executed,"\
"e.g. an order sell 5 btc can be matched with a buy 3 btc order,"\
"left 2 btc to be sold; in this case the order's volume would be '5.0',"\
"its remaining_volume would be '2.0', its executed volume is '3.0'."
}
)
expose(
:volume,
as: :remaining_volume,
documentation: {
type: BigDecimal,
desc: "The remaining volume, see 'volume'."
}
)
expose(
:executed_volume,
documentation: {
type: BigDecimal,
desc: "The executed volume, see 'volume'."
}
) do |order, _options|
order.origin_volume - order.volume
end
expose(
:maker_fee,
documentation: {
type: BigDecimal,
desc: "Fee for maker."
}
)
expose(
:taker_fee,
documentation: {
type: BigDecimal,
desc: "Fee for taker."
}
)
expose(
:trades_count,
documentation: {
type: Integer,
desc: "Count of trades."
}
)
expose(
:trades,
documentation: {
type: 'API::V2::Entities::Trade',
is_array: true,
desc: "Trades wiht this order."
},
if: { type: :full }
) do |order, _options|
API::V2::Entities::Trade.represent order.trades, side: order.side
end
end
end
end
end

View File

@@ -0,0 +1,32 @@
# encoding: UTF-8
# frozen_string_literal: true
require_dependency 'v2/entities/order'
module API
module V2
module Entities
class OrderBook < Base
expose(
:asks,
using: Order,
documentation: {
type: 'API::V2::Entities::Order',
is_array: true,
desc: 'Asks in orderbook'
}
)
expose(
:bids,
using: Order,
documentation: {
type: 'API::V2::Entities::Order',
is_array: true,
desc: 'Bids in orderbook'
}
)
end
end
end
end

View File

@@ -0,0 +1,41 @@
# encoding: UTF-8
# frozen_string_literal: true
module API
module V2
module Entities
class PaymentAddress < Base
expose(
:currencies,
documentation: {
desc: 'Currencies codes.',
is_array: true,
example: -> { ::Currency.visible.codes }
}
) do |pa|
pa.wallet.currencies.codes
end
expose(
:address,
documentation: {
desc: 'Payment address.',
type: String
}
) do |pa, options|
options[:address_format] ? pa.format_address(options[:address_format]) : pa.address
end
expose(
:state,
documentation: {
desc: 'Payment address state.',
type: String
}
) do |pa|
pa.address.present? ? 'active' : 'pending'
end
end
end
end
end

View File

@@ -0,0 +1,91 @@
# frozen_string_literal: true
module API
module V2
module Entities
class Pnl < Base
expose(
:currency_id,
as: :currency,
documentation: {
type: String,
desc: 'Currency code.'
}
)
expose(
:pnl_currency_id,
as: :pnl_currency,
documentation: {
type: String,
desc: 'PnL currency code.'
}
)
expose(
:total_credit,
documentation: {
type: BigDecimal,
desc: 'Total credit amount.'
}
)
expose(
:total_debit,
documentation: {
type: BigDecimal,
desc: 'Total debit amount.'
}
)
expose(
:total_credit_value,
documentation: {
type: BigDecimal,
desc: 'Total credit value in pnl currency.'
}
)
expose(
:total_debit_value,
documentation: {
type: BigDecimal,
desc: 'Total debit value in pnl currency.'
}
)
expose(
:average_buy_price,
documentation: {
type: BigDecimal,
desc: 'Average buy price.'
}
)
expose(
:average_sell_price,
documentation: {
type: BigDecimal,
desc: 'Average sell price.'
}
)
expose(
:average_balance_price,
documentation: {
type: BigDecimal,
desc: 'Average balance price.'
}
)
expose(
:total_balance_value,
documentation: {
type: BigDecimal,
desc: 'Total balance value in pnl currency.'
}
)
end
end
end
end

View File

@@ -0,0 +1,66 @@
# encoding: UTF-8
# frozen_string_literal: true
module API
module V2
module Entities
class PublicTrade < Base
expose(
:id,
documentation: {
type: String,
desc: 'Trade ID.'
}
)
expose(
:price,
documentation: {
type: BigDecimal,
desc: 'Trade price.'
}
)
expose(
:amount,
documentation: {
type: BigDecimal,
desc: 'Trade amount.'
}
)
expose(
:total,
documentation: {
type: BigDecimal,
desc: 'Trade total (Amount * Price).'
}
)
expose(
:market,
documentation: {
type: String,
desc: 'Trade market id.'
}
)
expose(
:created_at,
documentation: {
type: String,
desc: 'Trade create time in iso8601 format.'
}
)
expose(
:taker_type,
documentation: {
type: String,
desc: 'Trade taker order type (sell or buy).'
}
)
end
end
end
end

View File

@@ -0,0 +1,111 @@
# encoding: UTF-8
# frozen_string_literal: true
module API
module V2
module Entities
class Ticker < Base
class TickerEntry < Base
expose(
:low,
documentation: {
type: BigDecimal,
desc: 'The lowest trade price during last 24 hours (0.0 if no trades executed during last 24 hours)'
}
)
expose(
:high,
documentation: {
type: BigDecimal,
desc: 'The highest trade price during last 24 hours (0.0 if no trades executed during last 24 hours)'
}
)
expose(
:open,
documentation: {
type: BigDecimal,
desc: 'Price of the first trade executed 24 hours ago or less'
}
)
expose(
:last,
documentation: {
type: BigDecimal,
desc: 'The last executed trade price'
}
)
expose(
:volume,
documentation: {
type: BigDecimal,
desc: 'Total volume of trades executed during last 24 hours'
}
)
expose(
:amount,
documentation: {
type: BigDecimal,
desc: 'Total amount of trades executed during last 24 hours'
}
)
expose(
:vol,
documentation: {
type: BigDecimal,
desc: 'Alias to volume'
}
)
expose(
:avg_price,
documentation: {
type: BigDecimal,
desc: 'Average price more precisely VWAP is calculated by adding up the total traded for every transaction'\
'(price multiplied by the number of shares traded) and then dividing by the total shares traded'
}
)
expose(
:price_change_percent,
documentation: {
type: String,
desc: 'Price change in the next format +3.19%.'\
'Price change is calculated using next formula (last - open) / open * 100%'
}
)
expose(
:at,
documentation: {
type: Integer,
desc: 'Timestamp of ticker'
}
)
end
expose(
:at,
documentation: {
type: Integer,
desc: 'Timestamp of ticker'
}
)
expose(
:ticker,
using: TickerEntry,
documentation: {
type: TickerEntry,
desc: 'Ticker entry for specified time'
}
)
end
end
end
end

View File

@@ -0,0 +1,133 @@
# encoding: UTF-8
# frozen_string_literal: true
module API
module V2
module Entities
class Trade < Base
expose(
:id,
documentation: {
type: String,
desc: 'Trade ID.'
}
)
expose(
:price,
documentation: {
type: BigDecimal,
desc: 'Trade price.'
}
)
expose(
:amount,
documentation: {
type: BigDecimal,
desc: 'Trade amount.'
}
)
expose(
:total,
documentation: {
type: BigDecimal,
desc: 'Trade total (Amount * Price).'
}
)
expose(
:fee_currency,
documentation: {
type: BigDecimal,
desc: 'Currency user\'s fees were charged in.'
},
if: ->(_, options) { options[:current_user] }
) do |trade, options|
fee_currency(trade.order_for_member(options[:current_user]))
end
expose(
:fee,
documentation: {
type: BigDecimal,
desc: 'Percentage of fee user was charged for performed trade.'
},
if: ->(_, options) { options[:current_user] }
) do |trade, options|
trade.order_fee(trade.order_for_member(options[:current_user]))
end
expose(
:fee_amount,
documentation: {
type: BigDecimal,
desc: 'Amount of fee user was charged for performed trade.'
},
if: ->(_, options) { options[:current_user] }
) do |trade, options|
fee_amount(trade, trade.order_for_member(options[:current_user]))
end
expose(
:market_id,
as: :market,
documentation: {
type: String,
desc: 'Trade market id.'
}
)
expose(
:created_at,
format_with: :iso8601,
documentation: {
type: String,
desc: 'Trade create time in iso8601 format.'
}
)
expose(
:taker_type,
documentation: {
type: String,
desc: 'Trade taker order type (sell or buy).'
}
) do |trade, _options|
trade.taker_order.side
end
expose(
:side,
if: ->(trade, options) { options[:side] || options[:current_user] },
documentation: {
type: String,
desc: 'Trade side.'
}
) do |trade, options|
options[:side] || trade.side(options[:current_user])
end
expose(
:order_id,
documentation: {
type: Integer,
desc: 'Order id.'
},
if: ->(_, options) { options[:current_user] }
) do |trade, options|
trade.order_for_member(options[:current_user]).id
end
def fee_amount(trade, order)
trade.order_fee(order) * (order.side == 'buy' ? trade.amount : trade.total)
end
def fee_currency(order)
order.side == 'buy' ? order.ask : order.bid
end
end
end
end
end

View File

@@ -0,0 +1,65 @@
module API
module V2
module Entities
class TradingFee < API::V2::Entities::Base
expose(
:id,
documentation:{
type: Integer,
desc: 'Unique trading fee table identifier in database.'
}
)
expose(
:group,
documentation:{
type: String,
desc: 'Member group for define maker/taker fee.'
}
)
expose(
:market_id,
documentation:{
type: String,
desc: 'Market id for define maker/taker fee.'
}
)
expose(
:maker,
documentation:{
type: BigDecimal,
desc: 'Market maker fee.'
}
)
expose(
:taker,
documentation:{
type: BigDecimal,
desc: 'Market taker fee.'
}
)
expose(
:created_at,
format_with: :iso8601,
documentation: {
type: String,
desc: 'Trading fee table created time in iso8601 format.'
}
)
expose(
:updated_at,
format_with: :iso8601,
documentation: {
type: String,
desc: 'Trading fee table updated time in iso8601 format.'
}
)
end
end
end
end

View File

@@ -0,0 +1,105 @@
# encoding: UTF-8
# frozen_string_literal: true
module API
module V2
module Entities
class Transactions < Base
expose(
:address,
documentation: {
type: String,
desc: 'Recipient address of transaction.'
}
)
expose(
:currency_id,
as: :currency,
documentation: {
type: String,
desc: 'Transaction currency id.'
}
)
expose(
:amount,
documentation: {
type: BigDecimal,
desc: 'Transaction amount.'
}
)
expose(
:fee,
documentation: {
type: BigDecimal,
desc: 'Transaction fee.'
}
)
expose(
:txid,
documentation: {
type: String,
desc: 'Transaction id.'
}
)
expose(
:aasm_state,
as: :state,
documentation: {
type: String,
desc: 'Transaction state.'
}
)
expose(
:note,
documentation: {
type: String,
desc: 'Withdraw note.'
}
)
expose(
:confirmations,
expose_nil: false,
documentation: {
type: Integer,
desc: 'Number of confirmations.'
}
)
expose(
:created_at,
format_with: :iso8601,
documentation: {
type: String,
desc: "Transaction created time in iso8601 format."
}
)
expose(
:updated_at,
format_with: :iso8601,
documentation: {
type: String,
desc: "Transaction updated time in iso8601 format."
}
)
expose(
:type,
documentation: {
type: String,
desc: 'Type of transaction'
}
) do |transaction, _options|
transaction[:type].constantize.superclass.to_s
end
end
end
end
end

View File

@@ -0,0 +1,36 @@
# encoding: UTF-8
# frozen_string_literal: true
module API
module V2
module Entities
class Version < Base
expose(:git_sha,
documentation: {
type: String,
desc: 'Running Peatio git commit SHA.'
}
)
expose(:git_tag,
documentation: {
type: String,
desc: 'Running Peatio git tag.'
}
)
expose(:build_date,
format_with: :iso8601,
documentation: {
type: String,
desc: 'Running Peatio build date in iso8601 format'
}
)
expose(:version,
documentation: {
type: String,
desc: 'Running Peatio version'
}
)
end
end
end
end

View File

@@ -0,0 +1,139 @@
# encoding: UTF-8
# frozen_string_literal: true
module API
module V2
module Entities
class Withdraw < Base
expose(
:id,
documentation: {
type: Integer,
desc: 'The withdrawal id.'
}
)
expose(
:txid,
documentation: {
type: String,
desc: 'The withdrawal Transaction id.'
}
)
expose(
:currency_id,
as: :currency,
documentation: {
type: String,
desc: 'The currency code.'
}
)
expose(
:type,
documentation: {
type: String,
desc: 'The withdrawal type'
}
) { |w| w.currency.fiat? ? :fiat : :coin }
expose(
:sum,
as: :amount,
documentation: {
type: String,
desc: 'The withdrawal amount'
}
)
expose(
:fee,
documentation: {
type: BigDecimal,
desc: 'The exchange fee.'
}
)
expose(
:txid,
as: :blockchain_txid,
documentation: {
type: String,
desc: 'The withdrawal transaction id.'
}
)
expose(
:rid,
documentation: {
type: String,
desc: 'The beneficiary ID or wallet address on the Blockchain.'
}
)
expose(
:aasm_state,
as: :state,
documentation: {
type: String,
desc: 'The withdrawal state.'
}
)
expose(
:confirmations,
if: ->(withdraw) { withdraw.currency.coin? },
documentation: {
type: Integer,
desc: 'Number of confirmations.'
}
)
expose(
:note,
documentation: {
type: String,
desc: 'Withdraw note.'
}
)
expose(
:transfer_type,
documentation: {
type: String,
desc: 'Withdraw transfer type'
}
)
expose(
:created_at,
:updated_at,
format_with: :iso8601,
documentation: {
type: String,
desc: 'The datetimes for the withdrawal.'
}
)
expose(
:completed_at,
as: :done_at,
format_with: :iso8601,
documentation: {
type: String,
desc: 'The datetime when withdraw was completed'
}
)
expose(
:otp,
documentation: {
type: String,
desc: 'The active deactive 2fa'
}
) { |w| w.member.otp.present? ? :true : :false }
end
end
end
end

View File

@@ -0,0 +1,73 @@
module API
module V2
module Entities
class WithdrawLimit < API::V2::Entities::Base
expose(
:id,
documentation:{
type: Integer,
desc: 'Unique withdraw limit table identifier in database.'
}
)
expose(
:group,
documentation:{
type: String,
desc: 'Member group for define withdraw limits.'
}
)
expose(
:kyc_level,
documentation:{
type: String,
desc: 'KYC level for define withdraw limits.'
}
)
expose(
:kind,
documentation:{
type: String,
desc: 'kind for define deposit limits.'
}
)
expose(
:limit_24_hour,
documentation:{
type: BigDecimal,
desc: '24 hours withdraw limit.'
}
)
expose(
:limit_1_month,
documentation:{
type: BigDecimal,
desc: '1 month withdraw limit.'
}
)
expose(
:created_at,
format_with: :iso8601,
documentation: {
type: String,
desc: 'Withdraw limit table created time in iso8601 format.'
}
)
expose(
:updated_at,
format_with: :iso8601,
documentation: {
type: String,
desc: 'Withdraw limit table updated time in iso8601 format.'
}
)
end
end
end
end