Tf::Application.routes.draw do

  constraints :subdomain => 'www' do
    scope :module => 'www', :as => 'www' do
      defaults :subdomain => 'www' do

        root :to => 'applicatives#index'

        resources :applicatives do
          collection do
            get :yo_reporto
            get :subscribe
          end
        end
        resources :pages do
          member do
            get :attachment_category
          end
        end

        resources :institutions

        resources :contact_messages

        resources :information_rankings do
          collection do
            post :get_rankings
          end
        end
        resources :information_requests do
          collection do
            get :new2
            post :create2
          end
          #Tambien para nuevo SGS
          collection do
            get :thanks
          end
          collection do
            get :please_confirm
          end
          member do
            get :confirm
          end
        end

        resources :complaints do
          collection do
            get :please_confirm
          end
          member do
            get :confirm
          end
        end
        resources :accountabilities, only: [:index, :show] do
          member do
            get :citizen_evaluations
            get :institution_evaluations
          end
        end
        resources :users
        resources :courses
        resources :hackathon
        resources :ta_discussions do
          member do
            get :new_ta_discussion_form
            post :create_ta_discussion_form
          end
        end
        resources :directories, only: [:index] do
          collection do
            get :organizations
          end
          member do
            get :organization
            get :get_cities
          end
        end

        #resources :responsibilities
      end
    end
  end

  constraints :subdomain => 'admin' do
    scope :module => 'admin', :as => 'admin' do
      defaults :subdomain => 'admin' do
        resources :information_requests do
          collection do
            get 'statistics'
          end
        end
      end
    end
  end

  constraints :subdomain => 'api' do
    scope :module => 'api', :as => 'api' do
      defaults :subdomain => 'api' do

        DynamicApiRouter.load

        resources :complaints, only: [:create]

        resources :denouncements do
          collection do
            match :vehicles
            match :request_notifications
            match :services
          end
        end

        resources :informations do
          collection do
            match :requests
            match :coords
            match :contacts
          end
          member do
            match :gas_establishments
          end
        end

        resources :informations do
          collection do
            match :request
            match :coords
          end
        end

        resources :dropdowns do
          member do
            match :state_cities
            match :information_standard_document_categories
            match :product_product_brand_product_presentations
            match :fetch_model_records
          end
        end

        resources :documents do
          member do
            match :download
          end
        end

        resources :attachments do
          member do
            match :download
          end
        end

        resources :information_officers do
          member do
            match :coords
          end
        end

        resources :institutions do
          member do
            get :information_officer
            get :institution_dependences
          end
        end

        resources :institution_services do
          collection do
            get :institutions
          end
          member do
            get :institution_service
            get :institution_service_categories
            get :institution_service_steps
          end
        end

      end
    end
  end

  constraints :subdomain => 'agenda' do
    scope :module => 'agenda', :as => 'agenda' do
      defaults :subdomain => 'agenda' do
        root :to => 'institution_events#index'
        resources :institution_events, only: [:index] do
          collection do
            get :week
            get :month
            get :list
          end
        #   member do
        #     get :confirm
        #     get :subscribe
        #   end
        end
        # resources :users
      end
    end
  end

  root :to => 'www/applicatives#index'

end
