Sha256: 58e466230ec4d1a33bd0bd3358ad42df270faca21b13f963367abd8909496584

Contents?: true

Size: 836 Bytes

Versions: 1

Compression:

Stored size: 836 Bytes

Contents

# frozen_string_literal: true

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

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

          Cache::RedisCache.set(
            redis_key(symbol),
            response.parsed_response.to_json
          )
        end

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

      private

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

      def redis_key(symbol)
        "#{symbol}_bond_fundamentals"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sensei_eod_utils-0.0.53 lib/eod_facade/bond_fundamentals.rb