lib/viabtc/helpers.rb in viabtc-1.2.0 vs lib/viabtc/helpers.rb in viabtc-1.3.0
- old
+ new
@@ -1,8 +1,9 @@
+# frozen_string_literal: true
+
module ViaBTC
module Helpers
-
def response_invalid?(response)
!response['error'].nil?
end
def amount_valid?(amount)
@@ -20,28 +21,28 @@
def raise_exchange_error(response)
error_code = response['error']['code']
error_message = response['error']['message']
case error_code
- when 1 then raise ViaBTC::Error::InvalidArgument.new(response)
- when 2 then raise ViaBTC::Error::InternalError.new(response)
- when 3 then raise ViaBTC::Error::ServiceUnavailable.new(response)
- when 4 then raise ViaBTC::Error::MethodNotFound.new(response)
- when 5 then raise ViaBTC::Error::ServiceTimeout.new(response)
- when 6 then raise ViaBTC::Error::RequireAuthentication.new(response)
+ when 1 then raise ViaBTC::Error::InvalidArgument, response
+ when 2 then raise ViaBTC::Error::InternalError, response
+ when 3 then raise ViaBTC::Error::ServiceUnavailable, response
+ when 4 then raise ViaBTC::Error::MethodNotFound, response
+ when 5 then raise ViaBTC::Error::ServiceTimeout, response
+ when 6 then raise ViaBTC::Error::RequireAuthentication, response
when 10
case error_message
- when 'balance not enough' then raise ViaBTC::Error::LimitOrderBalanceNotEnough.new(response)
- when 'repeat update' then raise ViaBTC::Error::RepeatBalanceUpdate.new(response)
- else raise ViaBTC::Error::ExchangeError.new(response)
+ when 'balance not enough' then raise ViaBTC::Error::LimitOrderBalanceNotEnough, response
+ when 'repeat update' then raise ViaBTC::Error::RepeatBalanceUpdate, response
+ else raise ViaBTC::Error::ExchangeError, response
end
when 11
case error_message
- when 'amount too small' then raise ViaBTC::Error::LimitOrderAmountTooSmall.new(response)
- when 'balance not enough' then raise ViaBTC::Error::BalanceNotEnough.new(response)
+ when 'amount too small' then raise ViaBTC::Error::LimitOrderAmountTooSmall, response
+ when 'balance not enough' then raise ViaBTC::Error::BalanceNotEnough, response
end
- when 12 then raise ViaBTC::Error::LimitOrderNoEnoughTrader.new(response)
- else raise ViaBTC::Error::ExchangeError.new(response)
+ when 12 then raise ViaBTC::Error::LimitOrderNoEnoughTrader, response
+ else raise ViaBTC::Error::ExchangeError, response
end
end
end
end