Sha256: dadef63f2f1ce8d2ad85f3ff041281cec8170d0cea9aa4f7b4ba3bcff66f49c7

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 KB

Contents

require_relative "base_client"

module PortalConnectors
  class LiquidityClient < BaseClient
    def self.singleton
      @singleton ||= new
    end

    def submit_order(
      ref:,
      order_type: "market",
      source_coin:,
      source_amount:,
      destination_coin:,
      expected_destination_amount: nil,
      limit_price: nil,
      min_destination_amount: nil
    )
      params = {
        ref: ref,
        source_coin: source_coin,
        source_amount: source_amount,
        destination_coin: destination_coin,
        expected_destination_amount: expected_destination_amount,
        limit_price: limit_price,
        order_type: order_type,
        min_destination_amount: min_destination_amount
      }
      url = "#{host}/api/v1/orders"
      res = post_with_signature(url, params)
      [JSON.parse(res.body_str), res.response_code == 201]
    rescue => e
      return_error e
    end

    def fetch_order(ref:)
      url = "#{host}/api/v1/orders/#{ref}"
      res = get_with_signature(url)
      [JSON.parse(res.body_str), res.response_code == 200]
    rescue => e
      return_error e
    end

    def request_stop_order(ref:)
      url = "#{host}/api/v1/orders/#{ref}/stop"
      res = post_with_signature(url)
      [JSON.parse(res.body_str), res.response_code == 201]
    rescue => e
      return_error e
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
portal-connectors-0.58.39xc lib/portal-connectors/liquidity_client.rb
portal-connectors-0.58.39xb lib/portal-connectors/liquidity_client.rb
portal-connectors-0.58.39xa lib/portal-connectors/liquidity_client.rb
portal-connectors-0.58.39fj lib/portal-connectors/liquidity_client.rb
portal-connectors-0.58.39fg lib/portal-connectors/liquidity_client.rb
portal-connectors-0.58.38xn lib/portal-connectors/liquidity_client.rb