Skip to content

Commit

Permalink
create agent code added again
Browse files Browse the repository at this point in the history
  • Loading branch information
DevMagnataur committed Oct 18, 2024
1 parent cd46ecc commit 0c7be19
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/cores/agents/create_agent.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module Agents
class CreateAgent
include Wisper::Publisher

def call(support_agent_details:)
# Reuse any existing agent for the e-mail address supplied as login only uses the first one it finds; newer ones are ignored
existing_agent = Support::Agent.find_by(email: support_agent_details.slice(:email, :first_name, :last_name)[:email])
if existing_agent
existing_agent
else
agent = Support::Agent.create!(support_agent_details.slice(:email, :first_name, :last_name))
broadcast(:agent_created, agent.id)
agent
end
end
end
end

0 comments on commit 0c7be19

Please sign in to comment.