class FireflyIIIClient::CurrencyExchangeRatesApi

Attributes

api_client[RW]

Public Class Methods

new(api_client = ApiClient.default) click to toggle source
# File lib/firefly_iii_client/api/currency_exchange_rates_api.rb, line 19
def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Public Instance Methods

get_exchange_rate(opts = {}) click to toggle source

Get an exchange rate. Get an exchange rate. If Firefly III doesn't know the rate it will set the rate to 1.0. @param [Hash] opts the optional parameters @option opts [String] :from The source currency code. If omitted, defaults to EUR. @option opts [String] :to The destination currency code. If omitted, defaults to USD. @option opts [Date] :date The date you want to know the exchange rate on. @option opts [Float] :amount The amount in the source currency. If added, Firefly III will calculate the amount in the destination currency. @return [ExchangeRate]

# File lib/firefly_iii_client/api/currency_exchange_rates_api.rb, line 30
def get_exchange_rate(opts = {})
  data, _status_code, _headers = get_exchange_rate_with_http_info(opts)
  data
end
get_exchange_rate_with_http_info(opts = {}) click to toggle source

Get an exchange rate. Get an exchange rate. If Firefly III doesn&#39;t know the rate it will set the rate to 1.0. @param [Hash] opts the optional parameters @option opts [String] :from The source currency code. If omitted, defaults to EUR. @option opts [String] :to The destination currency code. If omitted, defaults to USD. @option opts [Date] :date The date you want to know the exchange rate on. @option opts [Float] :amount The amount in the source currency. If added, Firefly III will calculate the amount in the destination currency. @return [Array<(ExchangeRate, Integer, Hash)>] ExchangeRate data, response status code and response headers

# File lib/firefly_iii_client/api/currency_exchange_rates_api.rb, line 43
def get_exchange_rate_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CurrencyExchangeRatesApi.get_exchange_rate ...'
  end
  # resource path
  local_var_path = '/api/v1/cer'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?
  query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil?
  query_params[:'date'] = opts[:'date'] if !opts[:'date'].nil?
  query_params[:'amount'] = opts[:'amount'] if !opts[:'amount'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ExchangeRate'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['firefly_iii_auth']

  new_options = opts.merge(
    :operation => :"CurrencyExchangeRatesApi.get_exchange_rate",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CurrencyExchangeRatesApi#get_exchange_rate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end