# frozen_string_literal: true require 'oj' module EodFacade class Options < ::EodFacade::Base class << self def call(symbol) underlying = EodServices::Contract.underlying_symbol(symbol) expiry = EodServices::Contract.contract_expiry(symbol) unless expiry raise ArgumentError, "Invalid expiration date for option #{symbol}" end make_request(url_path(underlying), params(expiry)) end private def params(expiry) { from: expiry.to_s, to: expiry.to_s } end def url_path(underlying) "/options/#{underlying}" end end end end