module OandaApiV20::Pricing
Public Instance Methods
pricing(options)
click to toggle source
GET /v3/accounts/:account_id/pricing
# File lib/oanda_api_v20/pricing.rb, line 5 def pricing(options) Client.send(http_verb, "#{base_uri}/accounts/#{account_id}/pricing", headers: headers, query: options) end
pricing_stream(options, &block)
click to toggle source
GET /v3/accounts/:account_id/pricing/stream
# File lib/oanda_api_v20/pricing.rb, line 10 def pricing_stream(options, &block) buffer = String.new Client.send(http_verb, "#{base_uri}/accounts/#{account_id}/pricing/stream", headers: headers, query: options, stream_body: true) do |fragment| if !fragment.empty? buffer << fragment parse(buffer, fragment, &block) if fragment.match(/\n\Z/) end end end
Private Instance Methods
parse(buffer, fragment) { |parse| ... }
click to toggle source
# File lib/oanda_api_v20/pricing.rb, line 23 def parse(buffer, fragment, &block) buffer.split("\n").each do |message| cleaned_message = message.strip next if cleaned_message.empty? yield JSON.parse(cleaned_message) end rescue JSON::ParserError => e raise OandaApiV20::ParseError, "#{e.message} in '#{fragment}'" ensure buffer.clear end