Sha256: 7bfb612cbedbfe07383d473fc832acb9d76314d1df4eaed4944d0de8c921b72a
Contents?: true
Size: 1.29 KB
Versions: 6
Compression:
Stored size: 1.29 KB
Contents
require_relative "base_client" module PortalConnectors class EmployeeClient < BaseClient def fetch_shifts(method: :current_shifts, team: nil) url = "#{host}/shifts/#{method}" params = team.present? ? {team: team} : {} res = get_with_signature(url, params) shifts = JSON.parse(res.body_str) [shifts, res.response_code == 200] rescue => e return_error e end def self.cached_current_shifts(team=nil) Rails.cache.fetch(cached_key_for(["current_shifts", team].compact), expires_in: 5.minutes) do shifts, status = self.singleton.fetch_shifts(method: :current_shifts, team: team) return nil unless status shifts end end def self.cached_current_shifts_by_team(team=nil) Rails.cache.fetch(cached_key_for(["current_shifts_by_team", team].compact), expires_in: 5.minutes) do shifts, status = self.singleton.fetch_shifts(method: :current_shifts_by_team, team: team) return nil unless status shifts end end def self.cached_recent_shifts Rails.cache.fetch(cached_key_for(["recent_shifts"].compact), expires_in: 5.minutes) do shifts, status = self.singleton.fetch_shifts(method: :recent_shifts) return nil unless status shifts end end end end
Version data entries
6 entries across 6 versions & 1 rubygems