diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 7a34368..763f639 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: [2.6, 2.7, 3.0, 3.1] + ruby: [3.0, 3.1, 3.2, 3.3] runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index bfb3bdf..8e4fc51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,36 @@ ## 1.5.0 - 2024-04-10 +### Added +- Support Ruby 3.2 and 3.3 +- New endpoint for Simple Earn: + - `GET /sapi/v1/simple-earn/flexible/list` to query available Simple Earn flexible product list + - `GET /sapi/v1/simple-earn/locked/list` to query available Simple Earn locked product list + - `POST /sapi/v1/simple-earn/flexible/subscribe` to subscribe to a flexible product + - `POST /sapi/v1/simple-earn/locked/subscribe` to subscribe to a locked product + - `POST /sapi/v1/simple-earn/flexible/redeem` to redeem a flexible product + - `POST /sapi/v1/simple-earn/locked/redeem` to redeem a locked product + - `GET /sapi/v1/simple-earn/flexible/position` to get a flexible product position + - `GET /sapi/v1/simple-earn/locked/position` to get a locked product position + - `GET /sapi/v1/simple-earn/account` to get a simple account balances + - `GET /sapi/v1/simple-earn/flexible/history/subscriptionRecord` to get flexible subscription records + - `GET /sapi/v1/simple-earn/locked/history/subscriptionRecord` to get locked subscription records + - `GET /sapi/v1/simple-earn/flexible/history/redemptionRecord` to retrieve flexible redemption records + - `GET /sapi/v1/simple-earn/locked/history/redemptionRecord` to retrieve locked redemption records + - `GET /sapi/v1/simple-earn/flexible/history/rewardsRecord` to get flexible rewards history + - `GET /sapi/v1/simple-earn/locked/history/rewardsRecord` to get locked rewards history + - `POST /sapi/v1/simple-earn/flexible/setAutoSubscribe` to set an auto-subscription to a flexible product + - `POST /sapi/v1/simple-earn/locked/setAutoSubscribe` to set an auto-subscription to a locked product + - `GET /sapi/v1/simple-earn/flexible/personalLeftQuota` to get flexible personal left quota + - `GET /sapi/v1/simple-earn/locked/personalLeftQuota` to get locked personal left quota + - `GET /sapi/v1/simple-earn/flexible/subscriptionPreview` to get flexible subscription preview + - `GET /sapi/v1/simple-earn/locked/subscriptionPreview` to get locked subscription previews + - `GET /sapi/v1/simple-earn/flexible/history/rateHistory` to get a rate history + - `GET /sapi/v1/simple-earn/flexible/history/collateralRecord` to get collateral records + ### Changed - Update dependencies +- Drop support of Ruby 2.6 and 2.7 ### Removed - Deprecated Savings endpoints: diff --git a/examples/spot/simple_earn/collateral_record.rb b/examples/spot/simple_earn/collateral_record.rb new file mode 100755 index 0000000..1bee4e0 --- /dev/null +++ b/examples/spot/simple_earn/collateral_record.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.collateral_record) diff --git a/examples/spot/simple_earn/flexible_auto_subscribe.rb b/examples/spot/simple_earn/flexible_auto_subscribe.rb new file mode 100755 index 0000000..f69d52f --- /dev/null +++ b/examples/spot/simple_earn/flexible_auto_subscribe.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.flexible_auto_subscribe(productId: '1234', autoSubscribe: true)) diff --git a/examples/spot/simple_earn/flexible_personal_left_quota.rb b/examples/spot/simple_earn/flexible_personal_left_quota.rb new file mode 100755 index 0000000..2fe8ab0 --- /dev/null +++ b/examples/spot/simple_earn/flexible_personal_left_quota.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.flexible_personal_left_quota(productId: 'BTC001')) diff --git a/examples/spot/simple_earn/flexible_product_list.rb b/examples/spot/simple_earn/flexible_product_list.rb new file mode 100755 index 0000000..f4af0b0 --- /dev/null +++ b/examples/spot/simple_earn/flexible_product_list.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.flexible_product_list) diff --git a/examples/spot/simple_earn/flexible_product_position.rb b/examples/spot/simple_earn/flexible_product_position.rb new file mode 100755 index 0000000..5d78aca --- /dev/null +++ b/examples/spot/simple_earn/flexible_product_position.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.flexible_product_position) diff --git a/examples/spot/simple_earn/flexible_redeem_product.rb b/examples/spot/simple_earn/flexible_redeem_product.rb new file mode 100755 index 0000000..934f592 --- /dev/null +++ b/examples/spot/simple_earn/flexible_redeem_product.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.flexible_redeem_product(productId: 'BTC001')) diff --git a/examples/spot/simple_earn/flexible_redemption_record.rb b/examples/spot/simple_earn/flexible_redemption_record.rb new file mode 100755 index 0000000..7ae56dc --- /dev/null +++ b/examples/spot/simple_earn/flexible_redemption_record.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.flexible_redemption_record) diff --git a/examples/spot/simple_earn/flexible_rewards_history.rb b/examples/spot/simple_earn/flexible_rewards_history.rb new file mode 100755 index 0000000..eabe894 --- /dev/null +++ b/examples/spot/simple_earn/flexible_rewards_history.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.flexible_rewards_history(type: 'BONUS')) diff --git a/examples/spot/simple_earn/flexible_subscribe.rb b/examples/spot/simple_earn/flexible_subscribe.rb new file mode 100755 index 0000000..1e3f768 --- /dev/null +++ b/examples/spot/simple_earn/flexible_subscribe.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.flexible_subscribe(productId: 'BTC001', amount: 0.01)) diff --git a/examples/spot/simple_earn/flexible_subscription_preview.rb b/examples/spot/simple_earn/flexible_subscription_preview.rb new file mode 100755 index 0000000..525f847 --- /dev/null +++ b/examples/spot/simple_earn/flexible_subscription_preview.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.flexible_subscription_preview(productId: 'BTC001', amount: 1.0)) diff --git a/examples/spot/simple_earn/flexible_subscription_record.rb b/examples/spot/simple_earn/flexible_subscription_record.rb new file mode 100755 index 0000000..43c0fa1 --- /dev/null +++ b/examples/spot/simple_earn/flexible_subscription_record.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.flexible_subscription_record) diff --git a/examples/spot/simple_earn/locked_auto_subscribe.rb b/examples/spot/simple_earn/locked_auto_subscribe.rb new file mode 100755 index 0000000..9d16d1f --- /dev/null +++ b/examples/spot/simple_earn/locked_auto_subscribe.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.locked_auto_subscribe(positionId: '1234', autoSubscribe: true)) diff --git a/examples/spot/simple_earn/locked_personal_left_quota.rb b/examples/spot/simple_earn/locked_personal_left_quota.rb new file mode 100755 index 0000000..8414c78 --- /dev/null +++ b/examples/spot/simple_earn/locked_personal_left_quota.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.locked_personal_left_quota(projectId: 'Bnb*120')) diff --git a/examples/spot/simple_earn/locked_product_list.rb b/examples/spot/simple_earn/locked_product_list.rb new file mode 100755 index 0000000..6f7dcfc --- /dev/null +++ b/examples/spot/simple_earn/locked_product_list.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.locked_product_list) diff --git a/examples/spot/simple_earn/locked_product_position.rb b/examples/spot/simple_earn/locked_product_position.rb new file mode 100755 index 0000000..98c18b4 --- /dev/null +++ b/examples/spot/simple_earn/locked_product_position.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.locked_product_position) diff --git a/examples/spot/simple_earn/locked_redeem_product.rb b/examples/spot/simple_earn/locked_redeem_product.rb new file mode 100755 index 0000000..caa8832 --- /dev/null +++ b/examples/spot/simple_earn/locked_redeem_product.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.locked_redeem_product(positionId: '1234')) diff --git a/examples/spot/simple_earn/locked_redemption_record.rb b/examples/spot/simple_earn/locked_redemption_record.rb new file mode 100755 index 0000000..e036f88 --- /dev/null +++ b/examples/spot/simple_earn/locked_redemption_record.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.locked_redemption_record) diff --git a/examples/spot/simple_earn/locked_rewards_history.rb b/examples/spot/simple_earn/locked_rewards_history.rb new file mode 100755 index 0000000..de7d68c --- /dev/null +++ b/examples/spot/simple_earn/locked_rewards_history.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.locked_rewards_history) diff --git a/examples/spot/simple_earn/locked_subscribe.rb b/examples/spot/simple_earn/locked_subscribe.rb new file mode 100755 index 0000000..44c6ff2 --- /dev/null +++ b/examples/spot/simple_earn/locked_subscribe.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.locked_subscribe(projectId: 'Bnb*120', amount: 1.0)) diff --git a/examples/spot/simple_earn/locked_subscription_preview.rb b/examples/spot/simple_earn/locked_subscription_preview.rb new file mode 100755 index 0000000..a36dad1 --- /dev/null +++ b/examples/spot/simple_earn/locked_subscription_preview.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.locked_subscription_preview(projectId: 'Bnb*120', amount: 1.0)) diff --git a/examples/spot/simple_earn/locked_subscription_record.rb b/examples/spot/simple_earn/locked_subscription_record.rb new file mode 100755 index 0000000..d0f084a --- /dev/null +++ b/examples/spot/simple_earn/locked_subscription_record.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.locked_subscription_record) diff --git a/examples/spot/simple_earn/rate_history.rb b/examples/spot/simple_earn/rate_history.rb new file mode 100755 index 0000000..1903fb1 --- /dev/null +++ b/examples/spot/simple_earn/rate_history.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.rate_history(productId: 'BTC001')) diff --git a/examples/spot/simple_earn/simple_earn_account.rb b/examples/spot/simple_earn/simple_earn_account.rb new file mode 100755 index 0000000..22a4f9f --- /dev/null +++ b/examples/spot/simple_earn/simple_earn_account.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +$LOAD_PATH.unshift('./lib') + +require 'binance' +require_relative '../../common' + +logger = Common.setup_logger + +client = Binance::Spot.new(key: '', secret: '') +logger.info(client.simple_earn_account) diff --git a/lib/binance/spot.rb b/lib/binance/spot.rb index 1f53b9f..f926e8b 100644 --- a/lib/binance/spot.rb +++ b/lib/binance/spot.rb @@ -32,6 +32,7 @@ module Binance # - Margin # - Market # - Mining + # - SimpleEarn # - Stream # - Subaccount # - Trade diff --git a/lib/binance/spot/simple_earn.rb b/lib/binance/spot/simple_earn.rb index a39df17..9312f02 100644 --- a/lib/binance/spot/simple_earn.rb +++ b/lib/binance/spot/simple_earn.rb @@ -5,11 +5,145 @@ class Spot # all wallet endpoints # @see https://binance-docs.github.io/apidocs/spot/en/#wallet-endpoints module SimpleEarn - # All Coins' Information on 'simple earn' (USER_DATA) + # Get Simple Earn Flexible Product List (USER_DATA) # - # GET /sapi/v1/simple-earn/account' + # GET /sapi/v1/simple-earn/flexible/list + # + # @param kwargs [Hash] + # @option kwargs [String] :asset + # @option kwargs [Integer] :current Currently querying page. Start from 1. Default:1 + # @option kwargs [Integer] :size Default:10, Max:100 + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#get-simple-earn-flexible-product-list-user_data + def flexible_product_list(**kwargs) + @session.sign_request(:get, '/sapi/v1/simple-earn/flexible/list', params: kwargs) + end + + # Get Simple Earn Locked Product List (USER_DATA) + # + # GET /sapi/v1/simple-earn/locked/list + # + # @param kwargs [Hash] + # @option kwargs [String] :asset + # @option kwargs [Integer] :current Currently querying page. Start from 1. Default:1 + # @option kwargs [Integer] :size Default:10, Max:100 + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#get-simple-earn-locked-product-list-user_data + def locked_product_list(**kwargs) + @session.sign_request(:get, '/sapi/v1/simple-earn/locked/list', params: kwargs) + end + + # Subscribe Flexible Product (TRADE) + # + # POST /sapi/v1/simple-earn/flexible/subscribe + # + # @param productId [String] + # @param amount [Float] + # @param kwargs [Hash] + # @option kwargs [Boolean] :autoSubscribe true or false, default true + # @option kwargs [String] :sourceAccount SPOT,FUND,ALL, default SPOT + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#subscribe-flexible-product-trade + def flexible_subscribe(productId:, amount:, **kwargs) + Binance::Utils::Validation.require_param('productId', productId) + Binance::Utils::Validation.require_param('amount', amount) + + @session.sign_request(:post, '/sapi/v1/simple-earn/flexible/subscribe', params: kwargs.merge( + productId: productId, + amount: amount + )) + end + + # Subscribe Locked Product (TRADE) # - # Get information of coins (in simple earn) for user. + # POST /sapi/v1/simple-earn/locked/subscribe + # + # @param projectId [String] + # @param amount [Float] + # @param kwargs [Hash] + # @option kwargs [Boolean] :autoSubscribe true or false, default true + # @option kwargs [String] :sourceAccount SPOT,FUND,ALL, default SPOT + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#subscribe-locked-product-trade + def locked_subscribe(projectId:, amount:, **kwargs) + Binance::Utils::Validation.require_param('projectId', projectId) + Binance::Utils::Validation.require_param('amount', amount) + + @session.sign_request(:post, '/sapi/v1/simple-earn/locked/subscribe', params: kwargs.merge( + projectId: projectId, + amount: amount + )) + end + + # Redeem Flexible Product (TRADE) + # + # POST /sapi/v1/simple-earn/flexible/redeem + # + # @param productId [String] + # @param kwargs [Hash] + # @option kwargs [Boolean] :redeemAll true or false, default true + # @option kwargs [Float] :amount if redeemAll is false, amount is mandatory + # @option kwargs [String] :destAccount SPOT,FUND,ALL, default SPOT + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#redeem-flexible-product-trade + def flexible_redeem_product(productId:, **kwargs) + Binance::Utils::Validation.require_param('productId', productId) + + @session.sign_request(:post, '/sapi/v1/simple-earn/flexible/redeem', params: kwargs.merge( + productId: productId + )) + end + + # Redeem Locked Product (TRADE) + # + # POST /sapi/v1/simple-earn/locked/redeem + # + # @param positionId [String] + # @param kwargs [Hash] + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#redeem-locked-product-trade + def locked_redeem_product(positionId:, **kwargs) + Binance::Utils::Validation.require_param('positionId', positionId) + + @session.sign_request(:post, '/sapi/v1/simple-earn/locked/redeem', params: kwargs.merge( + positionId: positionId + )) + end + + # Get Flexible Product Position (USER_DATA) + # + # GET /sapi/v1/simple-earn/flexible/position + # + # @param kwargs [Hash] + # @option kwargs [String] :asset + # @option kwargs [String] :productId + # @option kwargs [Integer] :current Currently querying the page. Start from 1. Default:1 + # @option kwargs [Integer] :size Default:10, Max:100 + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#get-flexible-product-position-user_data + def flexible_product_position(**kwargs) + @session.sign_request(:get, '/sapi/v1/simple-earn/flexible/position', params: kwargs) + end + + # Get Locked Product Position (USER_DATA) + # + # GET /sapi/v1/simple-earn/locked/position + # + # @param kwargs [Hash] + # @option kwargs [String] :asset + # @option kwargs [String] :positionId + # @option kwargs [String] :projectId + # @option kwargs [Integer] :current Currently querying the page. Start from 1. Default:1 + # @option kwargs [Integer] :size Default:10, Max:100 + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#get-locked-product-position-user_data + def locked_product_position(**kwargs) + @session.sign_request(:get, '/sapi/v1/simple-earn/locked/position', params: kwargs) + end + + # Simple Account(USER_DATA) + # + # GET /sapi/v1/simple-earn/account' # # @param kwargs [Hash] # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 @@ -17,7 +151,253 @@ module SimpleEarn def simple_earn_account(**kwargs) @session.sign_request(:get, '/sapi/v1/simple-earn/account', params: kwargs) end - + + # Get Flexible Subscription Record (USER_DATA) + # + # GET /sapi/v1/simple-earn/flexible/history/subscriptionRecord + # + # @param kwargs [Hash] + # @option kwargs [String] :productId + # @option kwargs [String] :purchaseId + # @option kwargs [String] :asset + # @option kwargs [Integer] :startTime + # @option kwargs [Integer] :endTime + # @option kwargs [Integer] :current Currently querying the page. Start from 1. Default:1 + # @option kwargs [Integer] :size Default:10, Max:100 + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#get-flexible-subscription-record-user_data + def flexible_subscription_record(**kwargs) + @session.sign_request(:get, '/sapi/v1/simple-earn/flexible/history/subscriptionRecord', params: kwargs) + end + + # Get Locked Subscription Record (USER_DATA) + # + # GET /sapi/v1/simple-earn/locked/history/subscriptionRecord + # + # @param kwargs [Hash] + # @option kwargs [String] :purchaseId + # @option kwargs [String] :asset + # @option kwargs [Integer] :startTime + # @option kwargs [Integer] :endTime + # @option kwargs [Integer] :current Currently querying the page. Start from 1. Default:1 + # @option kwargs [Integer] :size Default:10, Max:100 + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#get-locked-subscription-record-user_data + def locked_subscription_record(**kwargs) + @session.sign_request(:get, '/sapi/v1/simple-earn/locked/history/subscriptionRecord', params: kwargs) + end + + # Get Flexible Redemption Record (USER_DATA) + # + # GET /sapi/v1/simple-earn/flexible/history/redemptionRecord + # + # @param kwargs [Hash] + # @option kwargs [String] :productId + # @option kwargs [String] :redeemId + # @option kwargs [String] :asset + # @option kwargs [Integer] :startTime + # @option kwargs [Integer] :endTime + # @option kwargs [Integer] :current Currently querying the page. Start from 1. Default:1 + # @option kwargs [Integer] :size Default:10, Max:100 + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#get-flexible-redemption-record-user_data + def flexible_redemption_record(**kwargs) + @session.sign_request(:get, '/sapi/v1/simple-earn/flexible/history/redemptionRecord', params: kwargs) + end + + # Get Locked Redemption Record (USER_DATA) + # + # GET /sapi/v1/simple-earn/locked/history/redemptionRecord + # + # @param kwargs [Hash] + # @option kwargs [String] :positionId + # @option kwargs [String] :redeemId + # @option kwargs [String] :asset + # @option kwargs [Integer] :startTime + # @option kwargs [Integer] :endTime + # @option kwargs [Integer] :current Currently querying the page. Start from 1. Default:1 + # @option kwargs [Integer] :size Default:10, Max:100 + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#get-locked-redemption-record-user_data + def locked_redemption_record(**kwargs) + @session.sign_request(:get, '/sapi/v1/simple-earn/locked/history/redemptionRecord', params: kwargs) + end + + # Get Flexible Rewards History (USER_DATA) + # + # GET /sapi/v1/simple-earn/flexible/history/rewardsRecord + # + # @param type [String] BONUS - Bonus tiered APR, REALTIME Real-time APR, REWARDS Historical rewards + # @param kwargs [Hash] + # @option kwargs [String] :productId + # @option kwargs [String] :asset + # @option kwargs [Integer] :startTime + # @option kwargs [Integer] :endTime + # @option kwargs [Integer] :current Currently querying the page. Start from 1. Default:1 + # @option kwargs [Integer] :size Default:10, Max:100 + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#get-flexible-rewards-history-user_data + def flexible_rewards_history(type:, **kwargs) + Binance::Utils::Validation.require_param('type', type) + + @session.sign_request(:get, '/sapi/v1/simple-earn/flexible/history/rewardsRecord', params: kwargs.merge(type: type)) + end + + # Get Locked Rewards History (USER_DATA) + # + # GET /sapi/v1/simple-earn/locked/history/rewardsRecord + # + # @param kwargs [Hash] + # @option kwargs [String] :positionId + # @option kwargs [String] :asset + # @option kwargs [Integer] :startTime + # @option kwargs [Integer] :endTime + # @option kwargs [Integer] :current Currently querying the page. Start from 1. Default:1 + # @option kwargs [Integer] :size Default:10, Max:100 + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#get-locked-rewards-history-user_data + def locked_rewards_history(**kwargs) + @session.sign_request(:get, '/sapi/v1/simple-earn/locked/history/rewardsRecord', params: kwargs) + end + + # Set Flexible Auto Subscribe (USER_DATA) + # + # POST /sapi/v1/simple-earn/flexible/setAutoSubscribe + # + # @param productId [String] + # @param autoSubscribe [Boolean] true or false + # @param kwargs [Hash] + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#set-flexible-auto-subscribe-user_data + def flexible_auto_subscribe(productId:, autoSubscribe:, **kwargs) + Binance::Utils::Validation.require_param('productId', productId) + Binance::Utils::Validation.require_param('autoSubscribe', autoSubscribe) + + @session.sign_request(:post, '/sapi/v1/simple-earn/flexible/setAutoSubscribe', params: kwargs.merge( + productId: productId, + autoSubscribe: autoSubscribe + )) + end + + # Set Locked Auto Subscribe (USER_DATA) + # + # POST /sapi/v1/simple-earn/locked/setAutoSubscribe + # + # @param positionId [String] + # @param autoSubscribe [Boolean] true or false + # @param kwargs [Hash] + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#set-locked-auto-subscribe-user_data + def locked_auto_subscribe(positionId:, autoSubscribe:, **kwargs) + Binance::Utils::Validation.require_param('positionId', positionId) + Binance::Utils::Validation.require_param('autoSubscribe', autoSubscribe) + + @session.sign_request(:post, '/sapi/v1/simple-earn/locked/setAutoSubscribe', params: kwargs.merge( + positionId: positionId, + autoSubscribe: autoSubscribe + )) + end + + # Get Flexible Personal Left Quota (USER_DATA) + # + # GET /sapi/v1/simple-earn/flexible/personalLeftQuota + # + # @param productId [String] + # @param kwargs [Hash] + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#get-flexible-personal-left-quota-user_data + def flexible_personal_left_quota(productId:, **kwargs) + Binance::Utils::Validation.require_param('productId', productId) + + @session.sign_request(:get, '/sapi/v1/simple-earn/flexible/personalLeftQuota', params: kwargs.merge(productId: productId)) + end + + # Get Locked Personal Left Quota (USER_DATA) + # + # GET /sapi/v1/simple-earn/locked/personalLeftQuota + # + # @param projectId [String] + # @param kwargs [Hash] + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#get-locked-personal-left-quota-user_data + def locked_personal_left_quota(projectId:, **kwargs) + Binance::Utils::Validation.require_param('projectId', projectId) + + @session.sign_request(:get, '/sapi/v1/simple-earn/locked/personalLeftQuota', params: kwargs.merge(projectId: projectId)) + end + + # Get Flexible Subscription Preview (USER_DATA) + # + # GET /sapi/v1/simple-earn/flexible/subscriptionPreview + # + # @param productId [String] + # @param amount [Float] + # @param kwargs [Hash] + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#get-flexible-subscription-preview-user_data + def flexible_subscription_preview(productId:, amount:, **kwargs) + Binance::Utils::Validation.require_param('productId', productId) + Binance::Utils::Validation.require_param('amount', amount) + + @session.sign_request(:get, '/sapi/v1/simple-earn/flexible/subscriptionPreview', params: kwargs.merge( + productId: productId, + amount: amount + )) + end + + # Get Locked Subscription Preview (USER_DATA) + # + # GET /sapi/v1/simple-earn/locked/subscriptionPreview + # + # @param projectId [String] + # @param amount [Float] + # @param kwargs [Hash] + # @option kwargs [Boolean] :autoSubscribe true or false, default true + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#get-locked-subscription-preview-user_data + def locked_subscription_preview(projectId:, amount:, **kwargs) + Binance::Utils::Validation.require_param('projectId', projectId) + Binance::Utils::Validation.require_param('amount', amount) + + @session.sign_request(:get, '/sapi/v1/simple-earn/locked/subscriptionPreview', params: kwargs.merge( + projectId: projectId, + amount: amount + )) + end + + # Get Rate History (USER_DATA) + # + # GET /sapi/v1/simple-earn/flexible/history/rateHistory + # + # @param productId [String] + # @param kwargs [Hash] + # @option kwargs [Integer] :startTime + # @option kwargs [Integer] :endTime + # @option kwargs [Integer] :current Currently querying the page. Start from 1. Default:1 + # @option kwargs [Integer] :size Default:10, Max:100 + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#get-rate-history-user_data + def rate_history(productId:, **kwargs) + Binance::Utils::Validation.require_param('productId', productId) + + @session.sign_request(:get, '/sapi/v1/simple-earn/flexible/history/rateHistory', params: kwargs.merge(productId: productId)) + end + + # Get Collateral Record (USER_DATA) + # + # GET /sapi/v1/simple-earn/flexible/history/collateralRecord + # + # @param kwargs [Hash] + # @option kwargs [String] :productId + # @option kwargs [Integer] :startTime + # @option kwargs [Integer] :endTime + # @option kwargs [Integer] :current Currently querying the page. Start from 1. Default:1 + # @option kwargs [Integer] :size Default:10, Max:100 + # @option kwargs [Integer] :recvWindow The value cannot be greater than 60000 + # @see https://binance-docs.github.io/apidocs/spot/en/#get-collateral-record-user_data + def collateral_record(**kwargs) + @session.sign_request(:get, '/sapi/v1/simple-earn/flexible/history/collateralRecord', params: kwargs) + end end end end diff --git a/spec/binance/spot/simple_earn/collateral_record_spec.rb b/spec/binance/spot/simple_earn/collateral_record_spec.rb new file mode 100644 index 0000000..0272955 --- /dev/null +++ b/spec/binance/spot/simple_earn/collateral_record_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#collateral_record' do + let(:path) { '/sapi/v1/simple-earn/flexible/history/collateralRecord' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:params) { {} } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:get, path, status, body, params) + end + + it 'should return collateral record' do + spot_client_signed.collateral_record(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + size: 10, + recvWindow: 10_000 + } + end + + it 'should return collateral record' do + spot_client_signed.collateral_record(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/flexible_auto_subscribe_spec.rb b/spec/binance/spot/simple_earn/flexible_auto_subscribe_spec.rb new file mode 100644 index 0000000..edb3e9f --- /dev/null +++ b/spec/binance/spot/simple_earn/flexible_auto_subscribe_spec.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#flexible_auto_subscribe' do + let(:path) { '/sapi/v1/simple-earn/flexible/setAutoSubscribe' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:ts) { '1708632518001' } + let(:params) { { productId: '1234', autoSubscribe: true } } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:post, path, status, body, params) + end + + context 'validation productId' do + let(:params) { { productId: '', autoSubscribe: true } } + it 'should raise validation error without productId' do + expect { spot_client_signed.flexible_auto_subscribe(**params) }.to raise_error(Binance::RequiredParameterError) + end + end + + context 'validation autoSubscribe' do + let(:params) { { productId: '1234', autoSubscribe: '' } } + it 'should raise validation error without autoSubscribe' do + expect { spot_client_signed.flexible_auto_subscribe(**params) }.to raise_error(Binance::RequiredParameterError) + end + end + + it 'should set flexible auto subscribe' do + spot_client_signed.flexible_auto_subscribe(**params) + expect(send_a_request_with_signature(:post, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + productId: '1234', + autoSubscribe: true, + recvWindow: 10_000 + } + end + + it 'should set flexible auto subscribe' do + spot_client_signed.flexible_auto_subscribe(**params) + expect(send_a_request_with_signature(:post, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/flexible_personal_left_quota_spec.rb b/spec/binance/spot/simple_earn/flexible_personal_left_quota_spec.rb new file mode 100644 index 0000000..92facbb --- /dev/null +++ b/spec/binance/spot/simple_earn/flexible_personal_left_quota_spec.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#flexible_personal_left_quota' do + let(:path) { '/sapi/v1/simple-earn/flexible/personalLeftQuota' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:ts) { '1708632518001' } + let(:params) { { productId: 'BTC001' } } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:get, path, status, body, params) + end + + context 'validation productId' do + let(:params) { { productId: '' } } + it 'should raise validation error without productId' do + expect { spot_client_signed.flexible_personal_left_quota(**params) }.to raise_error(Binance::RequiredParameterError) + end + end + + it 'should return flexible personal left quota' do + spot_client_signed.flexible_personal_left_quota(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + productId: 'BTC001', + recvWindow: 10_000 + } + end + + it 'should return flexible personal left quota' do + spot_client_signed.flexible_personal_left_quota(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/flexible_product_list_spec.rb b/spec/binance/spot/simple_earn/flexible_product_list_spec.rb new file mode 100644 index 0000000..2d1541a --- /dev/null +++ b/spec/binance/spot/simple_earn/flexible_product_list_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#flexible_product_list' do + let(:path) { '/sapi/v1/simple-earn/flexible/list' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:ts) { '1708632518001' } + let(:params) { {} } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:get, path, status, body, params) + end + + it 'should return simple earn flexible product list' do + spot_client_signed.flexible_product_list(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + size: 10, + recvWindow: 10_000 + } + end + + it 'should return simple earn flexible product list' do + spot_client_signed.flexible_product_list(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/flexible_product_position_spec.rb b/spec/binance/spot/simple_earn/flexible_product_position_spec.rb new file mode 100644 index 0000000..7763ccf --- /dev/null +++ b/spec/binance/spot/simple_earn/flexible_product_position_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#flexible_product_position' do + let(:path) { '/sapi/v1/simple-earn/flexible/position' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:params) { {} } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:get, path, status, body, params) + end + + it 'should return simple earn flexible product position' do + spot_client_signed.flexible_product_position(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + current: 1, + size: 10, + recvWindow: 10_000 + } + end + + it 'should return simple earn flexible product position' do + spot_client_signed.flexible_product_position(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/flexible_redeem_product_spec.rb b/spec/binance/spot/simple_earn/flexible_redeem_product_spec.rb new file mode 100644 index 0000000..374248d --- /dev/null +++ b/spec/binance/spot/simple_earn/flexible_redeem_product_spec.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#flexible_redeem_product' do + let(:path) { '/sapi/v1/simple-earn/flexible/redeem' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:ts) { '1708632518001' } + let(:params) { { productId: 'BTC001' } } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:post, path, status, body, params) + end + + context 'validation productId' do + let(:params) { { productId: '' } } + it 'should raise validation error without productId' do + expect { spot_client_signed.flexible_redeem_product(**params) }.to raise_error(Binance::RequiredParameterError) + end + end + + it 'should redeem flexible product' do + spot_client_signed.flexible_redeem_product(**params) + expect(send_a_request_with_signature(:post, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + productId: 'BTC001', + recvWindow: 10_000 + } + end + + it 'should redeem flexible product' do + spot_client_signed.flexible_redeem_product(**params) + expect(send_a_request_with_signature(:post, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/flexible_redemption_record_spec.rb b/spec/binance/spot/simple_earn/flexible_redemption_record_spec.rb new file mode 100644 index 0000000..d34fdfe --- /dev/null +++ b/spec/binance/spot/simple_earn/flexible_redemption_record_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#flexible_redemption_record' do + let(:path) { '/sapi/v1/simple-earn/flexible/history/redemptionRecord' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:params) { {} } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:get, path, status, body, params) + end + + it 'should return flexible redemption record' do + spot_client_signed.flexible_redemption_record(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + current: 1, + size: 10, + recvWindow: 10_000 + } + end + + it 'should return flexible redemption record' do + spot_client_signed.flexible_redemption_record(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/flexible_rewards_history_spec.rb b/spec/binance/spot/simple_earn/flexible_rewards_history_spec.rb new file mode 100644 index 0000000..1ffd3ea --- /dev/null +++ b/spec/binance/spot/simple_earn/flexible_rewards_history_spec.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#flexible_rewards_history' do + let(:path) { '/sapi/v1/simple-earn/flexible/history/rewardsRecord' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:ts) { '1708632518001' } + let(:params) { { type: 'BONUS' } } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:get, path, status, body, params) + end + + context 'validation type' do + let(:params) { { type: '' } } + it 'should raise validation error without type' do + expect { spot_client_signed.flexible_rewards_history(**params) }.to raise_error(Binance::RequiredParameterError) + end + end + + it 'should return flexible reward history' do + spot_client_signed.flexible_rewards_history(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + type: 'BONUS', + recvWindow: 10_000 + } + end + + it 'should return flexible reward history' do + spot_client_signed.flexible_rewards_history(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/flexible_subscribe_spec.rb b/spec/binance/spot/simple_earn/flexible_subscribe_spec.rb new file mode 100644 index 0000000..9cf487c --- /dev/null +++ b/spec/binance/spot/simple_earn/flexible_subscribe_spec.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#flexible_subscribe' do + let(:path) { '/sapi/v1/simple-earn/flexible/subscribe' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:ts) { '1708632518001' } + let(:params) { { productId: 'BTC001', amount: 0.01 } } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:post, path, status, body, params) + end + + context 'validation productId' do + let(:params) { { productId: '', amount: 0.01 } } + it 'should raise validation error without productId' do + expect { spot_client_signed.flexible_subscribe(**params) }.to raise_error(Binance::RequiredParameterError) + end + end + + context 'validation amount' do + let(:params) { { productId: 'BTC001', amount: '' } } + it 'should raise validation error without amount' do + expect { spot_client_signed.flexible_subscribe(**params) }.to raise_error(Binance::RequiredParameterError) + end + end + + it 'should subscribe to flexible product' do + spot_client_signed.flexible_subscribe(**params) + expect(send_a_request_with_signature(:post, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + productId: 'BTC001', + amount: 0.01, + recvWindow: 10_000 + } + end + + it 'should subscribe to flexible product' do + spot_client_signed.flexible_subscribe(**params) + expect(send_a_request_with_signature(:post, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/flexible_subscription_preview_spec.rb b/spec/binance/spot/simple_earn/flexible_subscription_preview_spec.rb new file mode 100644 index 0000000..3f42429 --- /dev/null +++ b/spec/binance/spot/simple_earn/flexible_subscription_preview_spec.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#flexible_subscription_preview' do + let(:path) { '/sapi/v1/simple-earn/flexible/subscriptionPreview' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:ts) { '1708632518001' } + let(:params) { { productId: 'BTC001', amount: 0.01 } } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:get, path, status, body, params) + end + + context 'validation productId' do + let(:params) { { productId: '', amount: 0.01 } } + it 'should raise validation error without productId' do + expect { spot_client_signed.flexible_subscription_preview(**params) }.to raise_error(Binance::RequiredParameterError) + end + end + + context 'validation amount' do + let(:params) { { productId: 'BTC001', amount: '' } } + it 'should raise validation error without amount' do + expect { spot_client_signed.flexible_subscription_preview(**params) }.to raise_error(Binance::RequiredParameterError) + end + end + + it 'should return locked subscription preview' do + spot_client_signed.flexible_subscription_preview(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + productId: 'BTC001', + amount: 0.01, + recvWindow: 10_000 + } + end + + it 'should return locked subscription preview' do + spot_client_signed.flexible_subscription_preview(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/flexible_subscription_record_spec.rb b/spec/binance/spot/simple_earn/flexible_subscription_record_spec.rb new file mode 100644 index 0000000..5256d81 --- /dev/null +++ b/spec/binance/spot/simple_earn/flexible_subscription_record_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#flexible_subscription_record' do + let(:path) { '/sapi/v1/simple-earn/flexible/history/subscriptionRecord' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:params) { {} } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:get, path, status, body, params) + end + + it 'should return flexible subscription record' do + spot_client_signed.flexible_subscription_record(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + current: 1, + size: 10, + recvWindow: 10_000 + } + end + + it 'should return flexible subscription record' do + spot_client_signed.flexible_subscription_record(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/locked_auto_subscribe_spec.rb b/spec/binance/spot/simple_earn/locked_auto_subscribe_spec.rb new file mode 100644 index 0000000..7820ec3 --- /dev/null +++ b/spec/binance/spot/simple_earn/locked_auto_subscribe_spec.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#locked_auto_subscribe' do + let(:path) { '/sapi/v1/simple-earn/locked/setAutoSubscribe' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:ts) { '1708632518001' } + let(:params) { { positionId: '1234', autoSubscribe: true } } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:post, path, status, body, params) + end + + context 'validation positionId' do + let(:params) { { positionId: '', autoSubscribe: true } } + it 'should raise validation error without positionId' do + expect { spot_client_signed.locked_auto_subscribe(**params) }.to raise_error(Binance::RequiredParameterError) + end + end + + context 'validation autoSubscribe' do + let(:params) { { positionId: '1234', autoSubscribe: '' } } + it 'should raise validation error without autoSubscribe' do + expect { spot_client_signed.locked_auto_subscribe(**params) }.to raise_error(Binance::RequiredParameterError) + end + end + + it 'should set locked auto subscribe' do + spot_client_signed.locked_auto_subscribe(**params) + expect(send_a_request_with_signature(:post, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + positionId: '1234', + autoSubscribe: true, + recvWindow: 10_000 + } + end + + it 'should set locked auto subscribe' do + spot_client_signed.locked_auto_subscribe(**params) + expect(send_a_request_with_signature(:post, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/locked_personal_left_quota_spec.rb b/spec/binance/spot/simple_earn/locked_personal_left_quota_spec.rb new file mode 100644 index 0000000..23d95e3 --- /dev/null +++ b/spec/binance/spot/simple_earn/locked_personal_left_quota_spec.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#locked_personal_left_quota' do + let(:path) { '/sapi/v1/simple-earn/locked/personalLeftQuota' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:ts) { '1708632518001' } + let(:params) { { projectId: 'Bnb*120' } } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:get, path, status, body, params) + end + + context 'validation projectId' do + let(:params) { { projectId: '' } } + it 'should raise validation error without projectId' do + expect { spot_client_signed.locked_personal_left_quota(**params) }.to raise_error(Binance::RequiredParameterError) + end + end + + it 'should return locked personal left quota' do + spot_client_signed.locked_personal_left_quota(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + projectId: 'Bnb*120', + recvWindow: 10_000 + } + end + + it 'should return locked personal left quota' do + spot_client_signed.locked_personal_left_quota(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/locked_product_list_spec.rb b/spec/binance/spot/simple_earn/locked_product_list_spec.rb new file mode 100644 index 0000000..596dc9d --- /dev/null +++ b/spec/binance/spot/simple_earn/locked_product_list_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#locked_product_list_spec' do + let(:path) { '/sapi/v1/simple-earn/locked/list' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:params) { {} } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:get, path, status, body, params) + end + + it 'should return simple earn locked product list' do + spot_client_signed.locked_product_list(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + size: 10, + recvWindow: 10_000 + } + end + + it 'should return simple earn locked product list' do + spot_client_signed.locked_product_list(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/locked_product_position_spec.rb b/spec/binance/spot/simple_earn/locked_product_position_spec.rb new file mode 100644 index 0000000..7a6a9fd --- /dev/null +++ b/spec/binance/spot/simple_earn/locked_product_position_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#locked_product_position' do + let(:path) { '/sapi/v1/simple-earn/locked/position' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:params) { {} } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:get, path, status, body, params) + end + + it 'should return simple earn locked product position' do + spot_client_signed.locked_product_position(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + size: 10, + recvWindow: 10_000 + } + end + + it 'should return simple earn locked product position' do + spot_client_signed.locked_product_position(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/locked_redeem_product_spec.rb b/spec/binance/spot/simple_earn/locked_redeem_product_spec.rb new file mode 100644 index 0000000..05aaad3 --- /dev/null +++ b/spec/binance/spot/simple_earn/locked_redeem_product_spec.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#locked_redeem_product' do + let(:path) { '/sapi/v1/simple-earn/locked/redeem' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:ts) { '1708632518001' } + let(:params) { { positionId: '1234' } } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:post, path, status, body, params) + end + + context 'validation positionId' do + let(:params) { { positionId: '' } } + it 'should raise validation error without positionId' do + expect { spot_client_signed.locked_redeem_product(**params) }.to raise_error(Binance::RequiredParameterError) + end + end + + it 'should redeem locked product' do + spot_client_signed.locked_redeem_product(**params) + expect(send_a_request_with_signature(:post, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + positionId: '1234', + recvWindow: 10_000 + } + end + + it 'should redeem locked product' do + spot_client_signed.locked_redeem_product(**params) + expect(send_a_request_with_signature(:post, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/locked_redemption_record_spec.rb b/spec/binance/spot/simple_earn/locked_redemption_record_spec.rb new file mode 100644 index 0000000..8f8af75 --- /dev/null +++ b/spec/binance/spot/simple_earn/locked_redemption_record_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#locked_redemption_record' do + let(:path) { '/sapi/v1/simple-earn/locked/history/redemptionRecord' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:params) { {} } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:get, path, status, body, params) + end + + it 'should return locked redemption record' do + spot_client_signed.locked_redemption_record(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + size: 10, + recvWindow: 10_000 + } + end + + it 'should return locked redemption record' do + spot_client_signed.locked_redemption_record(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/locked_rewards_history_spec.rb b/spec/binance/spot/simple_earn/locked_rewards_history_spec.rb new file mode 100644 index 0000000..ff0b7b3 --- /dev/null +++ b/spec/binance/spot/simple_earn/locked_rewards_history_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#locked_rewards_history' do + let(:path) { '/sapi/v1/simple-earn/locked/history/rewardsRecord' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:params) { {} } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:get, path, status, body, params) + end + + it 'should return locked rewards history' do + spot_client_signed.locked_rewards_history(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + size: 10, + recvWindow: 10_000 + } + end + + it 'should return locked rewards history' do + spot_client_signed.locked_rewards_history(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/locked_subscribe_spec.rb b/spec/binance/spot/simple_earn/locked_subscribe_spec.rb new file mode 100644 index 0000000..deebdac --- /dev/null +++ b/spec/binance/spot/simple_earn/locked_subscribe_spec.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#locked_subscribe' do + let(:path) { '/sapi/v1/simple-earn/locked/subscribe' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:ts) { '1708632518001' } + let(:params) { { projectId: 'Bnb*120', amount: 1.0 } } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:post, path, status, body, params) + end + + context 'validation projectId' do + let(:params) { { projectId: '', amount: 1.0 } } + it 'should raise validation error without projectId' do + expect { spot_client_signed.locked_subscribe(**params) }.to raise_error(Binance::RequiredParameterError) + end + end + + context 'validation amount' do + let(:params) { { projectId: 'Bnb*120', amount: '' } } + it 'should raise validation error without amount' do + expect { spot_client_signed.locked_subscribe(**params) }.to raise_error(Binance::RequiredParameterError) + end + end + + it 'should subscribe to locked product' do + spot_client_signed.locked_subscribe(**params) + expect(send_a_request_with_signature(:post, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + projectId: 'Bnb*120', + amount: 1.0, + recvWindow: 10_000 + } + end + + it 'should subscribe to locked product' do + spot_client_signed.locked_subscribe(**params) + expect(send_a_request_with_signature(:post, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/locked_subscription_preview_spec.rb b/spec/binance/spot/simple_earn/locked_subscription_preview_spec.rb new file mode 100644 index 0000000..9fb92cc --- /dev/null +++ b/spec/binance/spot/simple_earn/locked_subscription_preview_spec.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#locked_subscription_preview' do + let(:path) { '/sapi/v1/simple-earn/locked/subscriptionPreview' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:ts) { '1708632518001' } + let(:params) { { projectId: 'Bnb*120', amount: 1.0 } } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:get, path, status, body, params) + end + + context 'validation projectId' do + let(:params) { { projectId: '', amount: 1.0 } } + it 'should raise validation error without projectId' do + expect { spot_client_signed.locked_subscription_preview(**params) }.to raise_error(Binance::RequiredParameterError) + end + end + + context 'validation amount' do + let(:params) { { projectId: 'Bnb*120', amount: '' } } + it 'should raise validation error without amount' do + expect { spot_client_signed.locked_subscription_preview(**params) }.to raise_error(Binance::RequiredParameterError) + end + end + + it 'should return locked subscription preview' do + spot_client_signed.locked_subscription_preview(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + projectId: '1234', + amount: 1.0, + recvWindow: 10_000 + } + end + + it 'should return locked subscription preview' do + spot_client_signed.locked_subscription_preview(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/locked_subscription_record_spec.rb b/spec/binance/spot/simple_earn/locked_subscription_record_spec.rb new file mode 100644 index 0000000..5e724ab --- /dev/null +++ b/spec/binance/spot/simple_earn/locked_subscription_record_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#locked_subscription_record' do + let(:path) { '/sapi/v1/simple-earn/locked/history/subscriptionRecord' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:params) { {} } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:get, path, status, body, params) + end + + it 'should return locked subscription record' do + spot_client_signed.locked_subscription_record(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + size: 10, + recvWindow: 10_000 + } + end + + it 'should return locked subscription record' do + spot_client_signed.locked_subscription_record(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/rate_history_spec.rb b/spec/binance/spot/simple_earn/rate_history_spec.rb new file mode 100644 index 0000000..ce7c2f1 --- /dev/null +++ b/spec/binance/spot/simple_earn/rate_history_spec.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#rate_history' do + let(:path) { '/sapi/v1/simple-earn/flexible/history/rateHistory' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:ts) { '1708632518001' } + let(:params) { { productId: 'BTC001' } } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:get, path, status, body, params) + end + + context 'validation productId' do + let(:params) { { productId: '' } } + it 'should raise validation error without productId' do + expect { spot_client_signed.rate_history(**params) }.to raise_error(Binance::RequiredParameterError) + end + end + + it 'should return rate history' do + spot_client_signed.rate_history(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + productId: 'BTC001', + size: 10, + recvWindow: 10_000 + } + end + + it 'should return rate history' do + spot_client_signed.rate_history(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + end +end diff --git a/spec/binance/spot/simple_earn/simple_earn_account_spec.rb b/spec/binance/spot/simple_earn/simple_earn_account_spec.rb new file mode 100644 index 0000000..513f8ce --- /dev/null +++ b/spec/binance/spot/simple_earn/simple_earn_account_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Binance::Spot::SimpleEarn, '#simple_earn_account' do + let(:path) { '/sapi/v1/simple-earn/account' } + let(:body) { fixture('response.json') } + let(:status) { 200 } + let(:params) { {} } + + before do + mocking_signature_and_ts(**params) + stub_binance_sign_request(:get, path, status, body, params) + end + + it 'should return simple earn account information' do + spot_client_signed.simple_earn_account(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + + context 'with params' do + let(:params) do + { + recvWindow: 10_000 + } + end + + it 'should return simple earn account information' do + spot_client_signed.simple_earn_account(**params) + expect(send_a_request_with_signature(:get, path, params)).to have_been_made + end + end +end