This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
module Transfer | |
class Listings < ServiceObject | |
TRANSFER_LIMIT = 500 | |
def initialize(to_brokerage, to_office, to_agents, listings, open_house_listing_agent: nil, user: nil) | |
super() | |
raise "Too many listings: #{listings.count}, limit is #{TRANSFER_LIMIT}" if listings.count > TRANSFER_LIMIT | |
@to_brokerage = to_brokerage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#@param agent_id | |
#@param user | |
# | |
#This method will simply update the listing_agent_id column for an openhouse, reindex and call the synchronizer | |
#The synchronizer has policies according to MLS to sync to external listing service | |
def transfer_listing_agent(agent_id, user: nil) | |
unless self.listing.agents.pluck(:id).include?(agent_id) | |
Rails.logger.info("Agent Id: #{agent_id} is invalid" | |
return | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#services/transfer/agent.rb | |
def initialize(agent:, office:, selected_listings: [], user:) | |
@agent = agent | |
@from_office = agent.office | |
@to_office = office | |
@to_brokerage = office.brokerage | |
@to_aor = office.aor | |
@user = user | |
@selected_listing_ids = selected_listing_ids.map(&:to_i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @param Agent_ID [Integer] ID of the agent being transferred | |
# @param Office_ID [Integer] ID of the new office the agent belongs to | |
# @param Listing_IDs [Array<Integer>] Ids of listings transferring | |
# | |
# @return render JSON | |
# /api/manage_people/v1/agents_controller(an RPC member route) | |
module API | |
module Transfer | |
module V1 |