Class: Doodle::ConversationsController
Instance Method Summary
collapse
#auth_params, #authenticate, #authenticate_user
Instance Method Details
#channel_finder_service ⇒ Object
17
18
19
|
# File 'app/controllers/doodle/conversations_controller.rb', line 17
def channel_finder_service
@channel_finder_service ||= Channel::FinderService.new({name: params.require(:channel)})
end
|
#conversation_creator_service(participants) ⇒ Object
25
26
27
|
# File 'app/controllers/doodle/conversations_controller.rb', line 25
def conversation_creator_service(participants)
@conversation_creator_service ||= ::Layer::Conversation::CreatorService.new(participants)
end
|
#create ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
|
# File 'app/controllers/doodle/conversations_controller.rb', line 5
def create
channel = channel_finder_service.call.first
if channel.present?
conversation = conversation_creator_service([params.require(:login)]).call
protocol = protocol_creator_service(channel, conversation).call
render json: { protocol_id: protocol.id, prococol_status: protocol.status, channel: channel.name, conversation_id: conversation.id }, status: 201
else
render json: { error: 'Channel dont found, Please create channel with this name first' }
end
end
|
#protocol_creator_service(channel, conversation) ⇒ Object
21
22
23
|
# File 'app/controllers/doodle/conversations_controller.rb', line 21
def protocol_creator_service(channel, conversation)
@protocol_creator_service ||= Protocol::CreatorService.new(params.require(:login), channel, conversation)
end
|