Class: MoexIssClient::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/moex_iss_client/client.rb

Constant Summary collapse

ROOT_ENDPOINT =
'https://iss.moex.com/iss'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



11
12
13
14
15
16
# File 'lib/moex_iss_client/client.rb', line 11

def initialize
  @client = Faraday.new(
    url: ROOT_ENDPOINT,
    headers: { 'Content-Type' => 'application/xml' }
  )
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



9
10
11
# File 'lib/moex_iss_client/client.rb', line 9

def client
  @client
end

Instance Method Details

#history(sec_id, options = {}) ⇒ Object

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
# File 'lib/moex_iss_client/client.rb', line 18

def history(sec_id, options = {})
  raise ArgumentError, 'Invalid security ID' if sec_id.to_s.empty?

  params = history_params(sec_id, options)

  client.get(params[:path], { from: params[:from], till: params[:till] }).body
end