2019-08-14 09:48:44 +00:00
|
|
|
Rails.application.routes.draw do
|
2019-10-20 08:47:26 +00:00
|
|
|
# AUTH STARTS
|
2019-08-14 09:48:44 +00:00
|
|
|
match 'auth/:provider/callback', to: 'home#callback', via: [:get, :post]
|
2020-02-02 17:22:38 +00:00
|
|
|
mount_devise_token_auth_for 'User', at: 'auth', controllers: {
|
|
|
|
confirmations: 'devise_overrides/confirmations',
|
|
|
|
passwords: 'devise_overrides/passwords',
|
|
|
|
sessions: 'devise_overrides/sessions',
|
|
|
|
token_validations: 'devise_overrides/token_validations'
|
|
|
|
}, via: [:get, :post]
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2021-05-27 14:37:21 +00:00
|
|
|
## renders the frontend paths only if its not an api only server
|
|
|
|
if ActiveModel::Type::Boolean.new.cast(ENV.fetch('CW_API_ONLY_SERVER', false))
|
|
|
|
root to: 'api#index'
|
|
|
|
else
|
|
|
|
root to: 'dashboard#index'
|
2019-08-25 14:29:28 +00:00
|
|
|
|
2021-05-27 14:37:21 +00:00
|
|
|
get '/app', to: 'dashboard#index'
|
|
|
|
get '/app/*params', to: 'dashboard#index'
|
|
|
|
get '/app/accounts/:account_id/settings/inboxes/new/twitter', to: 'dashboard#index', as: 'app_new_twitter_inbox'
|
|
|
|
get '/app/accounts/:account_id/settings/inboxes/new/:inbox_id/agents', to: 'dashboard#index', as: 'app_twitter_inbox_agents'
|
2019-08-25 14:29:28 +00:00
|
|
|
|
2021-05-27 14:37:21 +00:00
|
|
|
resource :widget, only: [:show]
|
2021-08-03 12:52:50 +00:00
|
|
|
namespace :survey do
|
|
|
|
resources :responses, only: [:show]
|
|
|
|
end
|
2021-05-27 14:37:21 +00:00
|
|
|
end
|
2019-10-29 07:20:54 +00:00
|
|
|
|
2020-04-16 09:35:01 +00:00
|
|
|
get '/api', to: 'api#index'
|
2019-12-23 06:46:46 +00:00
|
|
|
namespace :api, defaults: { format: 'json' } do
|
2019-08-14 09:48:44 +00:00
|
|
|
namespace :v1 do
|
2020-03-09 17:57:10 +00:00
|
|
|
# ----------------------------------
|
|
|
|
# start of account scoped api routes
|
2020-06-07 08:28:05 +00:00
|
|
|
resources :accounts, only: [:create, :show, :update] do
|
2020-05-26 17:08:48 +00:00
|
|
|
member do
|
|
|
|
post :update_active_at
|
|
|
|
end
|
2020-02-14 17:49:17 +00:00
|
|
|
|
2020-06-07 08:28:05 +00:00
|
|
|
scope module: :accounts do
|
|
|
|
namespace :actions do
|
|
|
|
resource :contact_merge, only: [:create]
|
2020-03-09 17:57:10 +00:00
|
|
|
end
|
2020-06-07 08:28:05 +00:00
|
|
|
|
2022-02-23 11:23:36 +00:00
|
|
|
resource :bulk_actions, only: [:create]
|
2021-10-07 07:51:46 +00:00
|
|
|
resources :agents, only: [:index, :create, :update, :destroy]
|
2021-06-01 17:04:25 +00:00
|
|
|
resources :agent_bots, only: [:index, :create, :show, :update, :destroy]
|
2022-05-23 13:54:07 +00:00
|
|
|
resources :assignable_agents, only: [:index]
|
2020-06-07 08:28:05 +00:00
|
|
|
resources :callbacks, only: [] do
|
|
|
|
collection do
|
|
|
|
post :register_facebook_page
|
|
|
|
get :register_facebook_page
|
|
|
|
post :facebook_pages
|
|
|
|
post :reauthorize_page
|
|
|
|
end
|
2020-03-09 17:57:10 +00:00
|
|
|
end
|
2022-03-25 19:13:44 +00:00
|
|
|
resources :canned_responses, only: [:index, :create, :update, :destroy]
|
|
|
|
resources :automation_rules, only: [:index, :create, :show, :update, :destroy] do
|
2022-01-20 23:30:21 +00:00
|
|
|
post :clone
|
2022-04-24 06:32:40 +00:00
|
|
|
post :attach_file, on: :collection
|
2022-01-20 23:30:21 +00:00
|
|
|
end
|
2021-06-15 08:44:59 +00:00
|
|
|
resources :campaigns, only: [:index, :create, :show, :update, :destroy]
|
2022-06-01 05:43:10 +00:00
|
|
|
resources :dashboard_apps, only: [:index, :show, :create, :update, :destroy]
|
2020-06-07 08:28:05 +00:00
|
|
|
namespace :channels do
|
|
|
|
resource :twilio_channel, only: [:create]
|
|
|
|
end
|
|
|
|
resources :conversations, only: [:index, :create, :show] do
|
2021-10-20 12:44:56 +00:00
|
|
|
collection do
|
|
|
|
get :meta
|
|
|
|
get :search
|
2021-11-01 08:27:04 +00:00
|
|
|
post :filter
|
2021-10-20 12:44:56 +00:00
|
|
|
end
|
2020-06-07 08:28:05 +00:00
|
|
|
scope module: :conversations do
|
2020-12-28 18:06:50 +00:00
|
|
|
resources :messages, only: [:index, :create, :destroy]
|
2020-06-07 08:28:05 +00:00
|
|
|
resources :assignments, only: [:create]
|
|
|
|
resources :labels, only: [:create, :index]
|
2022-03-16 08:24:18 +00:00
|
|
|
resource :direct_uploads, only: [:create]
|
2020-06-07 08:28:05 +00:00
|
|
|
end
|
|
|
|
member do
|
|
|
|
post :mute
|
2020-10-08 06:32:08 +00:00
|
|
|
post :unmute
|
2020-08-17 05:55:13 +00:00
|
|
|
post :transcript
|
2020-06-07 08:28:05 +00:00
|
|
|
post :toggle_status
|
|
|
|
post :toggle_typing_status
|
|
|
|
post :update_last_seen
|
2021-09-22 05:16:48 +00:00
|
|
|
post :custom_attributes
|
2020-06-07 08:28:05 +00:00
|
|
|
end
|
2020-03-09 17:57:10 +00:00
|
|
|
end
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2021-09-23 07:22:49 +00:00
|
|
|
resources :contacts, only: [:index, :show, :update, :create, :destroy] do
|
2020-08-10 06:45:29 +00:00
|
|
|
collection do
|
2020-10-05 18:00:27 +00:00
|
|
|
get :active
|
2020-08-10 06:45:29 +00:00
|
|
|
get :search
|
2021-11-01 08:27:04 +00:00
|
|
|
post :filter
|
2021-02-03 13:54:51 +00:00
|
|
|
post :import
|
2020-08-10 06:45:29 +00:00
|
|
|
end
|
2021-04-15 09:43:01 +00:00
|
|
|
member do
|
|
|
|
get :contactable_inboxes
|
2021-11-11 09:53:33 +00:00
|
|
|
post :destroy_custom_attributes
|
2021-04-15 09:43:01 +00:00
|
|
|
end
|
2020-06-07 08:28:05 +00:00
|
|
|
scope module: :contacts do
|
|
|
|
resources :conversations, only: [:index]
|
2020-08-10 06:45:29 +00:00
|
|
|
resources :contact_inboxes, only: [:create]
|
2021-01-03 14:37:57 +00:00
|
|
|
resources :labels, only: [:create, :index]
|
2021-10-24 07:10:30 +00:00
|
|
|
resources :notes
|
2020-06-07 08:28:05 +00:00
|
|
|
end
|
2020-03-09 17:57:10 +00:00
|
|
|
end
|
2021-07-14 04:50:06 +00:00
|
|
|
resources :csat_survey_responses, only: [:index] do
|
|
|
|
collection do
|
|
|
|
get :metrics
|
2022-05-17 15:31:45 +00:00
|
|
|
get :download
|
2021-07-14 04:50:06 +00:00
|
|
|
end
|
|
|
|
end
|
2021-07-23 11:34:33 +00:00
|
|
|
resources :custom_attribute_definitions, only: [:index, :show, :create, :update, :destroy]
|
2021-06-29 13:59:57 +00:00
|
|
|
resources :custom_filters, only: [:index, :show, :create, :update, :destroy]
|
2021-09-04 12:26:46 +00:00
|
|
|
resources :inboxes, only: [:index, :show, :create, :update, :destroy] do
|
2021-04-20 08:16:20 +00:00
|
|
|
get :assignable_agents, on: :member
|
2021-04-29 16:53:32 +00:00
|
|
|
get :campaigns, on: :member
|
2021-06-01 17:04:25 +00:00
|
|
|
get :agent_bot, on: :member
|
2020-06-07 08:28:05 +00:00
|
|
|
post :set_agent_bot, on: :member
|
2021-08-31 09:42:05 +00:00
|
|
|
delete :avatar, on: :member
|
2020-06-07 08:28:05 +00:00
|
|
|
end
|
2021-09-14 06:25:02 +00:00
|
|
|
resources :inbox_members, only: [:create, :show], param: :inbox_id do
|
|
|
|
collection do
|
|
|
|
delete :destroy
|
|
|
|
patch :update
|
|
|
|
end
|
|
|
|
end
|
2020-06-07 08:28:05 +00:00
|
|
|
resources :labels, only: [:index, :show, :create, :update, :destroy]
|
2020-03-09 17:57:10 +00:00
|
|
|
|
2020-06-09 12:12:18 +00:00
|
|
|
resources :notifications, only: [:index, :update] do
|
|
|
|
collection do
|
|
|
|
post :read_all
|
2021-01-17 17:15:31 +00:00
|
|
|
get :unread_count
|
2020-06-09 12:12:18 +00:00
|
|
|
end
|
|
|
|
end
|
2020-06-07 08:28:05 +00:00
|
|
|
resource :notification_settings, only: [:show, :update]
|
2020-03-09 17:57:10 +00:00
|
|
|
|
2021-01-17 18:26:56 +00:00
|
|
|
resources :teams do
|
|
|
|
resources :team_members, only: [:index, :create] do
|
|
|
|
collection do
|
|
|
|
delete :destroy
|
2021-02-09 13:51:31 +00:00
|
|
|
patch :update
|
2021-01-17 18:26:56 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-02-16 14:05:10 +00:00
|
|
|
namespace :twitter do
|
|
|
|
resource :authorization, only: [:create]
|
|
|
|
end
|
|
|
|
|
2022-03-25 19:13:44 +00:00
|
|
|
resources :webhooks, only: [:index, :create, :update, :destroy]
|
2020-06-16 14:09:57 +00:00
|
|
|
namespace :integrations do
|
|
|
|
resources :apps, only: [:index, :show]
|
2021-05-17 05:02:59 +00:00
|
|
|
resources :hooks, only: [:create, :update, :destroy]
|
2020-06-22 07:49:26 +00:00
|
|
|
resource :slack, only: [:create, :update, :destroy], controller: 'slack'
|
2020-06-16 14:09:57 +00:00
|
|
|
end
|
2020-10-31 18:44:33 +00:00
|
|
|
resources :working_hours, only: [:update]
|
2020-09-25 21:02:34 +00:00
|
|
|
|
2022-05-16 08:29:59 +00:00
|
|
|
resources :portals do
|
|
|
|
member do
|
|
|
|
post :archive
|
|
|
|
end
|
|
|
|
resources :categories do
|
|
|
|
resources :folders
|
2020-09-25 21:02:34 +00:00
|
|
|
end
|
2022-06-13 10:26:49 +00:00
|
|
|
resources :articles
|
2020-09-25 21:02:34 +00:00
|
|
|
end
|
2020-06-07 08:28:05 +00:00
|
|
|
end
|
2020-01-13 05:47:03 +00:00
|
|
|
end
|
2020-03-09 17:57:10 +00:00
|
|
|
# end of account scoped api routes
|
|
|
|
# ----------------------------------
|
|
|
|
|
2020-06-12 17:42:47 +00:00
|
|
|
namespace :integrations do
|
|
|
|
resources :webhooks, only: [:create]
|
|
|
|
end
|
|
|
|
|
2021-10-07 07:51:46 +00:00
|
|
|
resource :profile, only: [:show, :update] do
|
2021-11-26 19:26:07 +00:00
|
|
|
delete :avatar, on: :collection
|
2021-10-07 07:51:46 +00:00
|
|
|
member do
|
|
|
|
post :availability
|
|
|
|
end
|
|
|
|
end
|
2021-11-26 19:26:07 +00:00
|
|
|
|
2022-01-06 16:10:43 +00:00
|
|
|
resource :notification_subscriptions, only: [:create, :destroy]
|
2020-03-09 17:57:10 +00:00
|
|
|
|
|
|
|
namespace :widget do
|
2022-03-16 08:24:18 +00:00
|
|
|
resource :direct_uploads, only: [:create]
|
2021-07-20 19:56:32 +00:00
|
|
|
resource :config, only: [:create]
|
2021-05-03 14:53:09 +00:00
|
|
|
resources :campaigns, only: [:index]
|
2020-04-10 11:12:37 +00:00
|
|
|
resources :events, only: [:create]
|
|
|
|
resources :messages, only: [:index, :create, :update]
|
2021-02-15 18:44:13 +00:00
|
|
|
resources :conversations, only: [:index, :create] do
|
2020-05-04 17:37:56 +00:00
|
|
|
collection do
|
2020-07-07 18:34:44 +00:00
|
|
|
post :update_last_seen
|
2020-05-04 17:37:56 +00:00
|
|
|
post :toggle_typing
|
2020-08-17 05:55:13 +00:00
|
|
|
post :transcript
|
2022-03-15 16:37:30 +00:00
|
|
|
get :toggle_status
|
2020-05-04 17:37:56 +00:00
|
|
|
end
|
|
|
|
end
|
2021-11-11 09:53:33 +00:00
|
|
|
resource :contact, only: [:show, :update] do
|
|
|
|
collection do
|
2021-11-15 09:26:35 +00:00
|
|
|
post :destroy_custom_attributes
|
2021-11-11 09:53:33 +00:00
|
|
|
end
|
|
|
|
end
|
2020-03-09 17:57:10 +00:00
|
|
|
resources :inbox_members, only: [:index]
|
2020-04-03 07:34:58 +00:00
|
|
|
resources :labels, only: [:create, :destroy]
|
2020-02-17 02:21:45 +00:00
|
|
|
end
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|
2020-03-28 06:21:42 +00:00
|
|
|
|
|
|
|
namespace :v2 do
|
2020-03-18 11:23:35 +00:00
|
|
|
resources :accounts, only: [], module: :accounts do
|
2021-08-27 17:16:32 +00:00
|
|
|
resources :reports, only: [:index] do
|
2020-03-18 11:23:35 +00:00
|
|
|
collection do
|
2021-08-27 17:16:32 +00:00
|
|
|
get :summary
|
2020-11-16 14:11:52 +00:00
|
|
|
get :agents
|
|
|
|
get :inboxes
|
2021-08-27 17:16:32 +00:00
|
|
|
get :labels
|
2021-09-27 15:42:08 +00:00
|
|
|
get :teams
|
2022-03-29 05:01:52 +00:00
|
|
|
get :conversations
|
2020-03-18 11:23:35 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|
|
|
|
|
2021-01-14 15:05:22 +00:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# Routes for platform APIs
|
|
|
|
namespace :platform, defaults: { format: 'json' } do
|
|
|
|
namespace :api do
|
|
|
|
namespace :v1 do
|
|
|
|
resources :users, only: [:create, :show, :update, :destroy] do
|
|
|
|
member do
|
|
|
|
get :login
|
|
|
|
end
|
|
|
|
end
|
2021-06-01 17:04:25 +00:00
|
|
|
resources :agent_bots, only: [:index, :create, :show, :update, :destroy]
|
2021-01-14 15:05:22 +00:00
|
|
|
resources :accounts, only: [:create, :show, :update, :destroy] do
|
|
|
|
resources :account_users, only: [:index, :create] do
|
|
|
|
collection do
|
|
|
|
delete :destroy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-04-05 16:41:27 +00:00
|
|
|
end
|
|
|
|
|
2021-06-15 14:39:17 +00:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# Routes for inbox APIs Exposed to contacts
|
|
|
|
namespace :public, defaults: { format: 'json' } do
|
|
|
|
namespace :api do
|
|
|
|
namespace :v1 do
|
|
|
|
resources :inboxes do
|
|
|
|
scope module: :inboxes do
|
|
|
|
resources :contacts, only: [:create, :show, :update] do
|
|
|
|
resources :conversations, only: [:index, :create] do
|
|
|
|
resources :messages, only: [:index, :create, :update]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-07-28 09:29:13 +00:00
|
|
|
resources :csat_survey, only: [:show, :update]
|
2021-06-15 14:39:17 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-03-09 17:57:10 +00:00
|
|
|
# ----------------------------------------------------------------------
|
2019-12-23 06:46:46 +00:00
|
|
|
# Used in mailer templates
|
|
|
|
resource :app, only: [:index] do
|
2020-03-29 04:04:57 +00:00
|
|
|
resources :accounts do
|
|
|
|
resources :conversations, only: [:show]
|
|
|
|
end
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|
|
|
|
|
2020-03-09 17:57:10 +00:00
|
|
|
# ----------------------------------------------------------------------
|
2021-01-14 15:05:22 +00:00
|
|
|
# Routes for channel integrations
|
2019-08-14 09:48:44 +00:00
|
|
|
mount Facebook::Messenger::Server, at: 'bot'
|
2020-02-02 19:09:00 +00:00
|
|
|
get 'webhooks/twitter', to: 'api/v1/webhooks#twitter_crc'
|
|
|
|
post 'webhooks/twitter', to: 'api/v1/webhooks#twitter_events'
|
2021-09-10 20:01:17 +00:00
|
|
|
post 'webhooks/line/:line_channel_id', to: 'webhooks/line#process_payload'
|
2021-09-09 18:30:52 +00:00
|
|
|
post 'webhooks/telegram/:bot_token', to: 'webhooks/telegram#process_payload'
|
2021-10-05 18:05:06 +00:00
|
|
|
post 'webhooks/whatsapp/:phone_number', to: 'webhooks/whatsapp#process_payload'
|
2022-02-03 23:22:13 +00:00
|
|
|
post 'webhooks/sms/:phone_number', to: 'webhooks/sms#process_payload'
|
2021-10-12 07:16:27 +00:00
|
|
|
get 'webhooks/instagram', to: 'webhooks/instagram#verify'
|
|
|
|
post 'webhooks/instagram', to: 'webhooks/instagram#events'
|
2020-02-02 19:09:00 +00:00
|
|
|
|
2021-01-14 15:05:22 +00:00
|
|
|
namespace :twitter do
|
|
|
|
resource :callback, only: [:show]
|
|
|
|
end
|
|
|
|
|
|
|
|
namespace :twilio do
|
|
|
|
resources :callback, only: [:create]
|
|
|
|
end
|
2020-01-05 17:56:22 +00:00
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
2020-05-03 06:46:11 +00:00
|
|
|
# Routes for external service verifications
|
|
|
|
get 'apple-app-site-association' => 'apple_app#site_association'
|
2021-06-02 15:46:45 +00:00
|
|
|
get '.well-known/assetlinks.json' => 'android_app#assetlinks'
|
2020-05-03 06:46:11 +00:00
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
2020-01-05 17:56:22 +00:00
|
|
|
# Internal Monitoring Routes
|
|
|
|
require 'sidekiq/web'
|
2021-01-11 12:04:41 +00:00
|
|
|
require 'sidekiq/cron/web'
|
2020-01-05 17:56:22 +00:00
|
|
|
|
2020-05-11 17:37:22 +00:00
|
|
|
devise_for :super_admins, path: 'super_admin', controllers: { sessions: 'super_admin/devise/sessions' }
|
|
|
|
devise_scope :super_admin do
|
|
|
|
get 'super_admin/logout', to: 'super_admin/devise/sessions#destroy'
|
|
|
|
namespace :super_admin do
|
2020-06-02 18:20:39 +00:00
|
|
|
root to: 'dashboard#index'
|
|
|
|
|
2022-01-04 16:20:16 +00:00
|
|
|
resource :app_config, only: [:show, :create]
|
|
|
|
|
2020-06-02 18:20:39 +00:00
|
|
|
# order of resources affect the order of sidebar navigation in super admin
|
2020-05-11 17:37:22 +00:00
|
|
|
resources :accounts
|
2020-06-02 18:20:39 +00:00
|
|
|
resources :users, only: [:index, :new, :create, :show, :edit, :update]
|
2020-05-24 17:14:26 +00:00
|
|
|
resources :access_tokens, only: [:index, :show]
|
2021-01-15 07:51:53 +00:00
|
|
|
resources :installation_configs, only: [:index, :new, :create, :show, :edit, :update]
|
2022-01-26 23:59:48 +00:00
|
|
|
resources :agent_bots, only: [:index, :new, :create, :show, :edit, :update]
|
|
|
|
resources :platform_apps, only: [:index, :new, :create, :show, :edit, :update]
|
2020-05-11 17:37:22 +00:00
|
|
|
|
2020-06-02 18:20:39 +00:00
|
|
|
# resources that doesn't appear in primary navigation in super admin
|
|
|
|
resources :account_users, only: [:new, :create, :destroy]
|
2020-05-11 17:37:22 +00:00
|
|
|
end
|
|
|
|
authenticated :super_admin do
|
|
|
|
mount Sidekiq::Web => '/monitoring/sidekiq'
|
2020-01-05 17:56:22 +00:00
|
|
|
end
|
|
|
|
end
|
2020-02-23 07:24:29 +00:00
|
|
|
|
2021-01-17 08:37:18 +00:00
|
|
|
namespace :installation do
|
|
|
|
get 'onboarding', to: 'onboarding#index'
|
|
|
|
post 'onboarding', to: 'onboarding#create'
|
|
|
|
end
|
|
|
|
|
2020-03-09 17:57:10 +00:00
|
|
|
# ---------------------------------------------------------------------
|
2020-02-23 07:24:29 +00:00
|
|
|
# Routes for swagger docs
|
|
|
|
get '/swagger/*path', to: 'swagger#respond'
|
|
|
|
get '/swagger', to: 'swagger#respond'
|
2021-01-14 15:05:22 +00:00
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# Routes for testing
|
|
|
|
resources :widget_tests, only: [:index] unless Rails.env.production?
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|