doodle_rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +37 -0
- data/app/assets/javascripts/doodle/application.js +13 -0
- data/app/assets/javascripts/doodle/auth.js +2 -0
- data/app/assets/javascripts/doodle/keywords.js +2 -0
- data/app/assets/javascripts/doodle/users.js +2 -0
- data/app/assets/stylesheets/doodle/application.css +15 -0
- data/app/assets/stylesheets/doodle/auth.css +4 -0
- data/app/assets/stylesheets/doodle/keywords.css +4 -0
- data/app/assets/stylesheets/doodle/users.css +4 -0
- data/app/controllers/doodle/application_controller.rb +15 -0
- data/app/controllers/doodle/auth_controller.rb +23 -0
- data/app/controllers/doodle/chat_controller.rb +50 -0
- data/app/controllers/doodle/conversations_controller.rb +30 -0
- data/app/controllers/doodle/keywords_controller.rb +32 -0
- data/app/controllers/doodle/users_controller.rb +35 -0
- data/app/helpers/doodle/application_helper.rb +4 -0
- data/app/helpers/doodle/auth_helper.rb +4 -0
- data/app/helpers/doodle/keywords_helper.rb +4 -0
- data/app/helpers/doodle/users_helper.rb +4 -0
- data/app/models/doodle/channel.rb +12 -0
- data/app/models/doodle/keyword/action.rb +4 -0
- data/app/models/doodle/keyword/text.rb +4 -0
- data/app/models/doodle/keyword.rb +4 -0
- data/app/models/doodle/protocol.rb +65 -0
- data/app/models/doodle/user/analyst.rb +18 -0
- data/app/models/doodle/user/customer.rb +4 -0
- data/app/models/doodle/user.rb +9 -0
- data/app/models/doodle/user_channel.rb +27 -0
- data/app/services/doodle/channel/finder_service.rb +15 -0
- data/app/services/doodle/chat/join_service.rb +23 -0
- data/app/services/doodle/keyword/finder_service.rb +15 -0
- data/app/services/doodle/protocol/creator_service.rb +16 -0
- data/app/services/doodle/protocol/finalizer_service.rb +11 -0
- data/app/services/doodle/protocol/finder_service.rb +13 -0
- data/app/services/layer/conversation/creator_service.rb +11 -0
- data/app/services/layer/token_creator_service.rb +13 -0
- data/app/views/layouts/doodle/application.html.erb +14 -0
- data/config/initializers/layer.rb +12 -0
- data/config/routes.rb +25 -0
- data/db/migrate/20160211170908_create_doodle_channels.rb +9 -0
- data/db/migrate/20160211202503_create_doodle_user_channels.rb +13 -0
- data/db/migrate/20160320142137_create_doodle_users.rb +11 -0
- data/db/migrate/20160320142142_create_doodle_keywords.rb +11 -0
- data/db/migrate/20160320175917_create_doodle_protocols.rb +16 -0
- data/lib/doodle/engine.rb +5 -0
- data/lib/doodle/version.rb +3 -0
- data/lib/doodle.rb +4 -0
- data/lib/tasks/doodle_tasks.rake +4 -0
- data/test/controllers/doodle/auth_controller_test.rb +13 -0
- data/test/controllers/doodle/keywords_controller_test.rb +13 -0
- data/test/controllers/doodle/users_controller_test.rb +13 -0
- data/test/doodle_test.rb +7 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config/application.rb +28 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/private_key.pem +15 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +66 -0
- data/test/dummy/log/development.log +7207 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/fixtures/doodle/keywords.yml +11 -0
- data/test/fixtures/doodle/users.yml +11 -0
- data/test/integration/navigation_test.rb +8 -0
- data/test/models/doodle/keyword_test.rb +9 -0
- data/test/models/doodle/user_test.rb +9 -0
- data/test/test_helper.rb +21 -0
- metadata +218 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: af2ea8a12cd16908d7f2afecc8f5bbdcb2f72d11
|
4
|
+
data.tar.gz: 81ee8369d7a1c904a43b8c18a724b9d82fe5003f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 198575898ddef68256d9b11dbae7231d95f1cbe8bb4286f74eb18c6d61e92e91a858ac26fb0e93a445255c0edef2a94665c5c79421d9642d30747e1b18935d9f
|
7
|
+
data.tar.gz: e91b49295a269c5be4901299463f02226411ab4bea4d6674ef593b167f5e72810ef59db429542847db591fdf6d424d18578fe6df39b4f436d3b85691689f9d35
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2016 Gabriel Malaquias
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Doodle'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
task default: :test
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Doodle
|
2
|
+
class ApplicationController < ActionController::Base
|
3
|
+
def authenticate
|
4
|
+
render json: { session_token: create_and_authenticate }
|
5
|
+
end
|
6
|
+
|
7
|
+
def authenticate_user
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
def auth_params
|
12
|
+
params.require(:auth).permit(:login, :pass)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_dependency "doodle/application_controller"
|
2
|
+
|
3
|
+
module Doodle
|
4
|
+
class AuthController < ApplicationController
|
5
|
+
def authenticate
|
6
|
+
@user = User.where(pass: auth_params[:pass], login: auth_params[:login], type: auth_params[:type]).first
|
7
|
+
|
8
|
+
if @user.present?
|
9
|
+
render json: { login: @user.login, session_token: token_creator_service.token }
|
10
|
+
else
|
11
|
+
render json: { error: "When authenticate user" }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def auth_params
|
16
|
+
@params ||= params.require(:auth).permit(:login, :pass, :type)
|
17
|
+
end
|
18
|
+
|
19
|
+
def token_creator_service
|
20
|
+
@creator_service ||= Layer::TokenCreatorService.new(@user.login)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_dependency "doodle/application_controller"
|
2
|
+
|
3
|
+
module Doodle
|
4
|
+
class ChatController < ApplicationController
|
5
|
+
|
6
|
+
def has_protocols?
|
7
|
+
protocols = Protocol.waiting_in_channel(params.require(:channel))
|
8
|
+
render json: { has_protocols: protocols.size }, status: 200
|
9
|
+
end
|
10
|
+
|
11
|
+
def next
|
12
|
+
protocol = protocol_finder_service.next
|
13
|
+
join_service = chat_join_service(protocol)
|
14
|
+
if join_service.break_limit? && protocol.blank?
|
15
|
+
render json: { error: 'Analyst already have limit of protocols in progress' }, status: 422
|
16
|
+
else
|
17
|
+
join_service.join(params.require(:channel))
|
18
|
+
render json: { conversation: protocol.conversation_id }, status: 200
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def finalize
|
23
|
+
user = User::Analyst.find_by_login(params.require(:login))
|
24
|
+
protocol = protocol_finder_service.find_by_conversation(params.require(:id))
|
25
|
+
|
26
|
+
if user.blank? || protocol.blank?
|
27
|
+
render json: { text: "Protocol or user dont found"}, status: 422
|
28
|
+
else
|
29
|
+
|
30
|
+
protocol_finalizer_service(protocol).call
|
31
|
+
chat_join_service(protocol, user).out(protocol.channel.name)
|
32
|
+
|
33
|
+
render json: { id: protocol.id, text: "Protocol finalized with success" }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def protocol_finalizer_service(protocol)
|
38
|
+
@protcol_finalizer_service ||= Protocol::FinalizerService.new(protocol)
|
39
|
+
end
|
40
|
+
|
41
|
+
def chat_join_service(protocol, user)
|
42
|
+
@chat_join_service ||= Chat::JoinService.new(user, protocol)
|
43
|
+
end
|
44
|
+
|
45
|
+
def protocol_finder_service
|
46
|
+
@finder_service ||= Protocol::FinderService.new
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_dependency "doodle/application_controller"
|
2
|
+
|
3
|
+
module Doodle
|
4
|
+
class ConversationsController < ApplicationController
|
5
|
+
def create
|
6
|
+
channel = channel_finder_service.call.first
|
7
|
+
|
8
|
+
if channel.present?
|
9
|
+
conversation = conversation_creator_service([params.require(:login)]).call
|
10
|
+
protocol = protocol_creator_service(channel, conversation).call
|
11
|
+
render json: { protocol_id: protocol.id, prococol_status: protocol.status, channel: channel.name, conversation_id: conversation.id }, status: 201
|
12
|
+
else
|
13
|
+
render json: { error: 'Channel dont found, Please create channel with this name first' }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def channel_finder_service
|
18
|
+
@channel_finder_service ||= Channel::FinderService.new({name: params.require(:channel)})
|
19
|
+
end
|
20
|
+
|
21
|
+
def protocol_creator_service(channel, conversation)
|
22
|
+
@protocol_creator_service ||= Protocol::CreatorService.new(params.require(:login), channel, conversation)
|
23
|
+
end
|
24
|
+
|
25
|
+
def conversation_creator_service(participants)
|
26
|
+
@conversation_creator_service ||= ::Layer::Conversation::CreatorService.new(participants)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_dependency "doodle/application_controller"
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
module Doodle
|
5
|
+
class KeywordsController < ApplicationController
|
6
|
+
|
7
|
+
def create
|
8
|
+
keyword = Keyword.new(keyword_params)
|
9
|
+
if keyword.save
|
10
|
+
render json: keyword.reload.to_json
|
11
|
+
else
|
12
|
+
render json: {error: 'When save keyword'}.to_json
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def index
|
17
|
+
if params[:keyword].present?
|
18
|
+
render json: finder_service.to_json
|
19
|
+
else
|
20
|
+
render json: Keyword.all.to_json
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def keyword_params
|
25
|
+
params.require(:keyword).permit(:name, :value, :type)
|
26
|
+
end
|
27
|
+
|
28
|
+
def finder_service
|
29
|
+
@finder_service || Doodle::Keyword::FinderService.new(keyword_params)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_dependency "doodle/application_controller"
|
2
|
+
|
3
|
+
module Doodle
|
4
|
+
class UsersController < ApplicationController
|
5
|
+
|
6
|
+
def join
|
7
|
+
user = User::Analyst.find_by_params(users_params[:login])
|
8
|
+
channel = params.require(:channel)
|
9
|
+
|
10
|
+
if user
|
11
|
+
if user.has_channels?
|
12
|
+
user.enter_in_channel(channel)
|
13
|
+
end
|
14
|
+
render json: { channel: channel }, status: 200
|
15
|
+
end
|
16
|
+
|
17
|
+
render json: { error: 'User not found' }, status: 404
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def create
|
23
|
+
user = User.new(users_params)
|
24
|
+
if user.save
|
25
|
+
render json: user.reload.to_json
|
26
|
+
else
|
27
|
+
render json: {error: 'When save keyword'}.to_json
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def users_params
|
32
|
+
params.require(:user).permit(:login, :pass, :type)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Doodle
|
2
|
+
class Protocol < ActiveRecord::Base
|
3
|
+
include AASM
|
4
|
+
belongs_to :channel
|
5
|
+
belongs_to :user
|
6
|
+
|
7
|
+
aasm column: :status do
|
8
|
+
state :waiting, initial: true
|
9
|
+
state :in_progress
|
10
|
+
state :finalized
|
11
|
+
|
12
|
+
after_all_transitions :log_status_change
|
13
|
+
|
14
|
+
event :progress do
|
15
|
+
before do
|
16
|
+
self.update(in_progress_at: Time.now)
|
17
|
+
end
|
18
|
+
|
19
|
+
transitions from: :waiting, to: :in_progress
|
20
|
+
end
|
21
|
+
|
22
|
+
event :finalize do
|
23
|
+
before do
|
24
|
+
self.update(finalized_at: Time.now)
|
25
|
+
end
|
26
|
+
|
27
|
+
transitions from: :in_progress, to: :finalized
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
scope :waiting_in_channel, -> (channel){ joins(:channel).where(status: :waiting, 'doodle_channels.name' => channel) }
|
32
|
+
|
33
|
+
def duration
|
34
|
+
(self.finalized_at - self.created_at).round
|
35
|
+
end
|
36
|
+
|
37
|
+
def log_status_change
|
38
|
+
Rails.logger.info "[DOODLE] [PROTOCOL] - Protocol #{self.id} of customer #{self.customer_login} changed from #{aasm.from_state} to #{aasm.to_state}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def add_analyst_into(user)
|
42
|
+
self.user = user
|
43
|
+
self.save
|
44
|
+
end
|
45
|
+
|
46
|
+
def add_participant_into_conversation(login)
|
47
|
+
conversation = Layer::Conversation.find(self.conversation_id)
|
48
|
+
conversation.participants << login
|
49
|
+
conversation.save
|
50
|
+
end
|
51
|
+
|
52
|
+
def remove_participant_from_conversation(login)
|
53
|
+
conversation = Layer::Conversation.find(self.conversation_id)
|
54
|
+
conversation.participants = conversation.participants - [login]
|
55
|
+
conversation.save
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.next(channel = 'corporativo')
|
59
|
+
protocol = self.waiting_in_channel(channel).first
|
60
|
+
protocol.progress!
|
61
|
+
protocol
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Doodle
|
2
|
+
class User::Analyst < User
|
3
|
+
|
4
|
+
def enter_in_channel(name)
|
5
|
+
user_channel = user_channel_by_name(name)
|
6
|
+
user_channel.turn_online! if user_channel.may_turn_online?
|
7
|
+
end
|
8
|
+
|
9
|
+
def out_of_channel(name)
|
10
|
+
user_channel = user_channel_by_name(name)
|
11
|
+
user_channel.turn_offline! if user_channel.may_turn_offline?
|
12
|
+
end
|
13
|
+
|
14
|
+
def user_channel_by_name(name)
|
15
|
+
self.user_channels.joins(:channel).where('doodle_channels.name' => name).first
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Doodle
|
2
|
+
class UserChannel < ActiveRecord::Base
|
3
|
+
include AASM
|
4
|
+
|
5
|
+
belongs_to :user
|
6
|
+
belongs_to :channel
|
7
|
+
|
8
|
+
aasm column: :status do
|
9
|
+
state :offline, initial: true
|
10
|
+
state :online
|
11
|
+
|
12
|
+
after_all_transitions :log_status_change
|
13
|
+
|
14
|
+
event :turn_online do
|
15
|
+
transitions from: :offline, to: :online
|
16
|
+
end
|
17
|
+
|
18
|
+
event :turn_offline do
|
19
|
+
transitions from: :online, to: :offline
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def log_status_change
|
24
|
+
Rails.logger.info "[POC] [CHANNEL] - Analyst #{self.user.login} change your status from #{aasm.from_state} to #{aasm.to_state}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Doodle
|
2
|
+
class Chat::JoinService
|
3
|
+
def initialize(user, protocol)
|
4
|
+
@protocol = protocol
|
5
|
+
@user = user
|
6
|
+
end
|
7
|
+
|
8
|
+
def join(channel)
|
9
|
+
@protocol.add_analyst_into(@user)
|
10
|
+
@protocol.add_participant_into_conversation(@user.login)
|
11
|
+
@user.enter_in_channel(channel)
|
12
|
+
end
|
13
|
+
|
14
|
+
def break_limit?
|
15
|
+
@user.break_limit_concurrent_protocols?
|
16
|
+
end
|
17
|
+
|
18
|
+
def out(channel)
|
19
|
+
@protocol.remove_participant_from_conversation(@user.login)
|
20
|
+
@user.out_of_channel(channel)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Doodle
|
2
|
+
class Protocol::CreatorService
|
3
|
+
def initialize(customer_login, channel, conversation)
|
4
|
+
@customer_login = customer_login
|
5
|
+
@channel = channel
|
6
|
+
@conversation = conversation
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
Protocol.create(customer_login: @customer_login,
|
11
|
+
channel: @channel,
|
12
|
+
conversation_id: @conversation.id,
|
13
|
+
phone: '(XX) XXXX-XXXX')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Doodle</title>
|
5
|
+
<%= stylesheet_link_tag "doodle/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "doodle/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Layer::Client.configure do |config|
|
2
|
+
config.app_id = "layer:///apps/staging/151aa76a-ce72-11e5-ac55-80e4720f6b18"
|
3
|
+
config.token = "H6EvCKXyPpXuQtBDU07TdgLguNMatEQcOKBmQqpJTVsg5Gdj"
|
4
|
+
end
|
5
|
+
|
6
|
+
Layer::IdentityToken.layer_provider_id = "layer:///providers/1519612a-ce72-11e5-ac55-80e4720f6b18"
|
7
|
+
Layer::IdentityToken.layer_key_id = "layer:///keys/0ff36abc-d0d2-11e5-b2af-61c9960f423b"
|
8
|
+
|
9
|
+
key = File.readlines("#{Rails.root}/config/private_key.pem").join('')
|
10
|
+
Layer::IdentityToken.layer_private_key = OpenSSL::PKey::RSA.new(key)
|
11
|
+
|
12
|
+
|