Module: Cryptum::API::Products

Defined in:
lib/cryptum/api/products.rb

Overview

Module specifically related to orders history retrieval.

Class Method Summary collapse

Class Method Details

.get(opts = {}) ⇒ Object

Obtain latest order history



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cryptum/api/products.rb', line 9

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 Interrupt, StandardError => e
  Cryptum::Log.append(level: :error, msg: e, which_self: self)
end

.helpObject

Display Usage for this Module



55
56
57
58
59
60
61
62
# File 'lib/cryptum/api/products.rb', line 55

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

.list_and_exit(opts = {}) ⇒ Object

List Supported Cryptum Products and Exit



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/cryptum/api/products.rb', line 35

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 Interrupt, StandardError => e
  Cryptum::Log.append(level: :error, msg: e, which_self: self)
end