require_relative "base_client" module PortalConnectors class PartnerClient < BaseClient def fetch_stocks url = "#{host}/stocks" res = get_with_signature(url, {}) json_stocks = JSON.parse(res.body_str) self.class.cached_stocks = json_stocks [json_stocks, res.response_code == 200] rescue => e [e.inspect, false] end def self.cached_stocks=(json_stocks) PortalConnectors.redis.set(cached_key_for(["stocks"]), json_stocks.to_json) end def self.cached_stocks cached_key = cached_key_for(["stocks"]) return nil unless PortalConnectors.redis.exists(cached_key) JSON.parse(PortalConnectors.redis.get(cached_key)) rescue nil end end end