Sha256: 5837c49ed21ccc655a72c9fd95cdaf49b1a71c14dbbe1a1b9ccd53cc095457b8

Contents?: true

Size: 1.75 KB

Versions: 6

Compression:

Stored size: 1.75 KB

Contents

# frozen_string_literal: true

module Cryptum
  # This module is used to Interact with the APIs
  module API
    # Module specifically related to orders history retrieval.
    module Products
      # Obtain latest order history
      public_class_method def self.get(opts = {})
        option_choice = opts[:option_choice]
        env = opts[:env]

        products = Cryptum::API::Rest.call(
          option_choice: option_choice,
          env: env,
          http_method: :GET,
          api_call: '/products'
        )

        if products.length.positive?
          supported_products_filter = products.select do |product|
            product[:id].match?(/USD$/) &&
              product[:status] == 'online' &&
              product[:fx_stablecoin] == false
          end
          sorted_products = supported_products_filter.sort_by { |hash| hash[:id] }
        end

        sorted_products
      rescue StandardError => e
        raise e
      end

      # List Supported Cryptum Products and Exit
      public_class_method def self.list_and_exit(opts = {})
        option_choice = opts[:option_choice]
        env = opts[:env]

        puts "\n#{option_choice.driver_name} Supports the Following Products:"
        products = get(
          option_choice: option_choice,
          env: env
        )

        products.map do |product|
          puts product[:id].downcase
        end

        exit 0
      rescue StandardError => e
        raise e
      end

      # Display Usage for this Module
      public_class_method def self.help
        puts "USAGE:
          fees = #{self}.get(
            env: 'required - Coinbase::Option::Environment.get Object',
            option_choice: 'required - Coinbase::Option::Choice Object'
          )
        "
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cryptum-0.0.386 lib/cryptum/api/products.rb
cryptum-0.0.385 lib/cryptum/api/products.rb
cryptum-0.0.384 lib/cryptum/api/products.rb
cryptum-0.0.383 lib/cryptum/api/products.rb
cryptum-0.0.382 lib/cryptum/api/products.rb
cryptum-0.0.381 lib/cryptum/api/products.rb