class DeGiro::FindProducts

Public Class Methods

new(connection) click to toggle source
# File lib/degiro_client/find_products.rb, line 5
def initialize(connection)
  @connection = connection
end

Public Instance Methods

find_products(search_text:, limit: 7) click to toggle source
# File lib/degiro_client/find_products.rb, line 9
def find_products(search_text:, limit: 7)
  params = URI.encode_www_form(searchText: search_text, limit: limit)
  parse_products(JSON.parse(@connection.get(url(params)).body))
end

Private Instance Methods

parse_products(response) click to toggle source
# File lib/degiro_client/find_products.rb, line 16
def parse_products(response)
  response['products'].map do |product|
    {
      id:          product['id'].to_s,
      ticker:      product['symbol'],
      exchange_id: product['exchangeId'],
      isin:        product['isin']
    }
  end
end
url(params) click to toggle source
# File lib/degiro_client/find_products.rb, line 27
def url(params)
  "#{@connection.urls_map['product_search_url']}/v5/products/lookup" \
  "?intAccount=#{@connection.user_data['int_account']}" \
  "&sessionId=#{@connection.session_id}" \
  "&#{params}"
end