class CossApiRubyWrapper::ParamsValidations
Attributes
endpoint[R]
errors[R]
params[R]
Public Class Methods
new(endpoint, params)
click to toggle source
# File lib/coss_api_ruby_wrapper/params_validations.rb, line 8 def initialize(endpoint, params) @endpoint = endpoint @params = params @errors = [] end
Public Instance Methods
run!()
click to toggle source
# File lib/coss_api_ruby_wrapper/params_validations.rb, line 14 def run! case endpoint when '/order/add' @errors << '"symbol" parameter should be a string representing trading pair, for example: "COSS_ETH"' unless params[:order_symbol] =~ /\w+_\w+/ @errors << '"price" parameter should be convertable to float and be greater than zero' if params[:order_price] <= 0 @errors << '"side" parameter should be either BUY or SELL string' unless %w[BUY SELL].include?(params[:order_side]) @errors << '"amount" parameter should be convertable to float and be greater than zero' if params[:order_size] <= 0 when '/order/cancel' @errors << '"symbol" parameter should be a string representing trading pair, for example: "COSS_ETH"' unless params[:order_symbol] =~ /\w+_\w+/ @errors << '"order_id" parameter should be a non-empty string' if params[:order_id].empty? when '/order/details' @errors << '"order_id" parameter should be a non-empty string' if params[:order_id].empty? when '/order/trade-detail' @errors << '"order_id" parameter should be a non-empty string' if params[:order_id].empty? when '/order/list/open' @errors << '"limit" parameter should be a positive integer' if params[:limit] <= 0 @errors << '"symbol" parameter should be a string representing trading pair, for example: "COSS_ETH"' unless params[:symbol] =~ /\w+_\w+/ when '/order/list/completed' @errors << '"limit" parameter should be a positive integer' if params[:limit] <= 0 @errors << '"symbol" parameter should be a string representing trading pair, for example: "COSS_ETH"' unless params[:symbol] =~ /\w+_\w+/ when '/order/list/all' @errors << '"limit" parameter should be a positive integer' if params[:limit] <= 0 @errors << '"symbol" parameter should be a string representing trading pair, for example: "COSS_ETH"' unless params[:symbol] =~ /\w+_\w+/ @errors << '"from_order_id" parameter should be a non-empty string' if params[:from_order_id].empty? when '/market-price' @errors << '"symbol" parameter should be a string representing trading pair, for example: "COSS_ETH"' unless params[:symbol] =~ /\w+_\w+/ when '/dp' @errors << '"symbol" parameter should be a string representing trading pair, for example: "COSS_ETH"' unless params[:symbol] =~ /\w+_\w+/ when '/getmarketsummaries' @errors << '"symbol" parameter should be a string representing trading pair, for example: "COSS_ETH"' unless params[:symbol] =~ /\w+_\w+/ end end