Sha256: c42a3d4cef3400b8cd915baeeae2fb4a0080bcba0065eb9d3debeb69fd1b7123

Contents?: true

Size: 793 Bytes

Versions: 1

Compression:

Stored size: 793 Bytes

Contents

# frozen_string_literal: true

require 'oj'
require_relative '../cache/redis.rb'

module EodFacade
  class Fundamentals < ::EodFacade::Base
    class << self
      def call(symbol)
        unless Cache::Redis.get(redis_key(symbol))
          response = make_request(url_path(symbol))
          
          unless response.success?
            raise ArgumentError, "Error fetching fundamentals data for #{symbol}"
          end

          EodRedis::Service.set(
            redis_key(symbol),
            response.parsed_response
          )
        end

        Oj.load(Cache::Redis.get(redis_key(symbol)))
      end

      private

      def url_path(symbol)
        "/fundamentals/#{symbol}"
      end

      def redis_key(sybmol)
        "#{symbol}_fundamentals"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sensei_eod_utils-0.0.32 lib/eod_facade/fundamentals.rb