Sha256: 8da4583e11bc62e7f12b1c56bdf16860e103f41ce809c1b7d5caee8e16bbbe31

Contents?: true

Size: 823 Bytes

Versions: 4

Compression:

Stored size: 823 Bytes

Contents

# frozen_string_literal: true

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

module EodFacade
  class Fundamentals < ::EodFacade::Base
    class << self
      def call(symbol)
        raise Cache::Redis.inspect
        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

          Cache::Redis.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(symbol)
        "#{symbol}_fundamentals"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sensei_eod_utils-0.0.37 lib/eod_facade/fundamentals.rb
sensei_eod_utils-0.0.36 lib/eod_facade/fundamentals.rb
sensei_eod_utils-0.0.35 lib/eod_facade/fundamentals.rb
sensei_eod_utils-0.0.34 lib/eod_facade/fundamentals.rb