Rails.application.routes.draw do
  mount ActionCable.server => '/cable'
  mount Sidekiq::Web => '/sidekiq'

  use_doorkeeper do
    skip_controllers :authorizations, :applications, :authorized_applications
    controllers tokens: 'admin/oauth/tokens'
  end

  concern :batch_create do
    post :batch_create, on: :collection
  end

  concern :batch_update do
    patch :batch_update, on: :collection
  end

  concern :batch_delete do
    delete :batch_delete, on: :collection
  end

  resource :password, only: :update do
    get :token_valid, on: :collection
    post :reset, on: :collection
    post :recover, on: :collection
  end

  resource :session, only: [:create, :destroy]
  resource :site_setting, only: :show
  resource :terms_of_service, only: :update
  resource :user, only: :show, controller: :user

  resources :notifications, only: [:index, :update]

  resources :registrations, only: [:create, :show] do
    get :valid, on: :collection
    post :create_account, on: :member
  end

  resources :schools do
    get :valid, on: :collection
  end

  namespace :admin do
    draw :admin
  end

  namespace :one_roster, path: 'ims/oneroster/v1p1' do
    draw :one_roster
  end

  namespace :employee do
    draw :employee
  end

  namespace :family do
    draw :family
  end

  namespace :school do
    draw :school
  end

  namespace :student do
    draw :student
  end

  namespace :support do
    draw :support
  end

  namespace :user do
    resource :menus, only: :show
    resource :google_sso, only: [:show, :update], controller: :google_sso
  end

  namespace :webhook do
    namespace :tep do
      resource :payment, only: :create
    end
  end

  namespace :internal do
    draw :internal
  end

  namespace :webhooks do
    resource :sparkpost, only: :create, controller: :sparkpost do
      post :oauth, on: :collection
    end
  end
end
