SampleApp::Application.routes.draw do

  scope :as => 'jam_ruby' do
    resources :users
    resources :music_sessions
  end

  resources :users

  resources :sessions, only: [:new, :create, :destroy]

  #root to: 'static_pages#home'
  root to: 'clients#index'

  # This page is still here, and is under test. Keep a route to it.
  match '/oldhome', to: 'static_pages#home'

  # signup, and signup completed, related pages
  match '/signup',  to: 'users#new', :via => 'get'
  match '/signup',  to: 'users#create', :via => 'post'
  match '/congratulations_musician',  to: 'users#congratulations_musician'
  match '/congratulations_fan',  to: 'users#congratulations_fan'
  match '/downloads',  to: 'users#downloads'

  match '/signin',  to: 'sessions#new'
  match '/signout', to: 'sessions#destroy', via: :delete
  # oauth
  match '/auth/:provider/callback', :to => 'sessions#oauth_callback'
  match '/auth/failure', :to => 'sessions#failure'


  match '/isp', :to => 'users#isp'
  match '/isp/ping.jar', :to => redirect('/ping.jar')
  match '/isp/ping:isp', :to => 'users#jnlp', :constraints => {:format => :jnlp}, :as => 'isp_ping'

  match '/help',    to: 'static_pages#help'
  match '/about',   to: 'static_pages#about'
  match '/contact', to: 'static_pages#contact'
  match '/faders', to: 'static_pages#faders'

  match '/client', to: 'clients#index'

  match '/confirm/:signup_token', to: 'users#signup_confirm', as: 'signup_confirm'

  match '/test_connection',  to: 'sessions#connection_state', :as => :connection_state

  # spikes
  match '/facebook_invite', to: 'spikes#facebook_invite'
  match '/gmail_contacts', to: 'spikes#gmail_contacts'

  # password reset
  match '/request_reset_password' => 'users#request_reset_password', :via => :get
  match '/reset_password' => 'users#reset_password', :via => :post
  match '/reset_password_token' => 'users#reset_password_token', :via => :get
  match '/reset_password_complete' => 'users#reset_password_complete', :via => :post

  # email update
  match '/confirm_email' => 'users#finalize_update_email', :as => 'confirm_email' # NOTE: if you change this, you break outstanding email changes because links in user inboxes are broken


  scope '/corp' do
    match '/about',         to: 'corps#about',            as: 'corp_about'
    match '/contact',       to: 'corps#contact',          as: 'corp_contact'
    match '/help',          to: 'corps#help',             as: 'corp_help'
    match '/media_center',  to: 'corps#media_center',     as: 'corp_media_center'
    match '/news',          to: 'corps#news',             as: 'corp_news'
    match '/privacy',       to: 'corps#privacy',          as: 'corp_privacy'
    match '/terms',         to: 'corps#terms',            as: 'corp_terms'
    match '/cookies_policy',to: 'corps#cookie_policy',    as: 'corp_cookie_policy'
    match '/premium_accounts',to: 'corps#premium_accounts',    as: 'corp_premium_accounts'
  end

  scope '/api' do
    # music sessions
    match '/sessions/:id/participants' => 'api_music_sessions#participant_create', :via => :post
    match '/participants/:id' => 'api_music_sessions#participant_show', :via => :get, :as => 'api_session_participant_detail'
    match '/participants/:id' => 'api_music_sessions#participant_delete', :via => :delete
    match '/sessions/:id' => 'api_music_sessions#show', :via => :get, :as => 'api_session_detail'
    match '/sessions/:id' => 'api_music_sessions#update', :via => :put
    match '/sessions' => 'api_music_sessions#index', :via => :get
    match '/sessions' => 'api_music_sessions#create', :via => :post
    match '/sessions/:id/perf' => 'api_music_sessions#perf_upload', :via => :put

    # music session tracks
    match '/sessions/:id/tracks' => 'api_music_sessions#track_create', :via => :post
    match '/sessions/:id/tracks' => 'api_music_sessions#track_index', :via => :get
    match '/sessions/:id/tracks/:track_id' => 'api_music_sessions#track_update', :via => :post
    match '/sessions/:id/tracks/:track_id' => 'api_music_sessions#track_show', :via => :get, :as => 'api_session_track_detail'
    match '/sessions/:id/tracks/:track_id' => 'api_music_sessions#track_destroy', :via => :delete

    match '/participant_histories/:id/rating' => 'api_music_sessions#participant_rating', :via => :post

    # genres
    match '/genres' => 'api_genres#index', :via => :get

    # users
    match '/users/isp_scoring' => 'api_users#isp_scoring', :via => :post , :as => 'isp_scoring'

    match '/users' => 'api_users#index', :via => :get
    match '/users/:id' => 'api_users#show', :via => :get, :as => 'api_user_detail'
    #match '/users' => 'api_users#create', :via => :post 
    match '/users/:id' => 'api_users#update', :via => :post
    match '/users/:id' => 'api_users#delete', :via => :delete
    match '/users/confirm/:signup_token' => 'api_users#signup_confirm', :via => :post, :as => 'api_signup_confirmation'
    match '/users/complete/:signup_token' => 'api_users#complete', as: 'complete', via: 'post'

    match '/users/:id/set_password' => 'api_users#set_password', :via => :post

    # login/logout
    match '/auth_session' => 'api_users#auth_session_create', :via => :post
    match '/auth_session' => 'api_users#auth_session_delete', :via => :delete

    # session settings
    match '/users/:id/session_settings' => 'api_users#session_settings_show', :via => :get

    # session history
    match '/users/:id/session_history' => 'api_users#session_history_index', :via => :get
    match '/users/:id/session_history/:session_id/users' => 'api_users#session_user_history_index', :via => :get

    # user bands
    match '/users/:id/bands' => 'api_users#band_index', :via => :get

    # user likers
    match '/users/:id/likers' => 'api_users#liker_index', :via => :get

    # user likes
    match '/users/:id/likes' => 'api_users#like_index', :via => :get, :as => 'api_user_like_index'
    match '/users/:id/band_likes' => 'api_users#band_like_index', :via => :get, :as => 'api_band_like_index'
    match '/users/:id/likes' => 'api_users#like_create', :via => :post
    match '/users/:id/likes' => 'api_users#like_destroy', :via => :delete
    
    # user followers
    match '/users/:id/followers' => 'api_users#follower_index', :via => :get, :as => 'api_user_follower_index'

    # user followings
    match '/users/:id/followings' => 'api_users#following_index', :via => :get, :as => 'api_user_following_index'
    match '/users/:id/followings/:user_id' => 'api_users#following_show', :via => :get, :as => 'api_following_detail'
    
    match '/users/:id/band_followings' => 'api_users#band_following_index', :via => :get, :as => 'api_band_following_index'
    match '/users/:id/band_followings/:band_id' => 'api_users#band_following_show', :via => :get, :as => 'api_band_following_detail'
    
    match '/users/:id/followings' => 'api_users#following_create', :via => :post
    match '/users/:id/followings' => 'api_users#following_destroy', :via => :delete

    # favorites
    match '/users/:id/favorites' => 'api_users#favorite_index', :via => :get, :as => 'api_favorite_index'
    match '/users/:id/favorites' => 'api_users#favorite_create', :via => :post
    match '/users/:id/favorites/:recording_id' => 'api_users#favorite_destroy', :via => :delete

    # friend requests
    match '/users/:id/friend_requests' => 'api_users#friend_request_index', :via => :get
    match '/users/:id/friend_requests/:friend_request_id' => 'api_users#friend_request_show', :via => :get, :as => 'api_friend_request_detail'
    match '/users/:id/friend_requests' => 'api_users#friend_request_create', :via => :post
    match '/users/:id/friend_requests/:friend_request_id' => 'api_users#friend_request_update', :via => :post

    # friends
    match '/users/:id/friends' => 'api_users#friend_index', :via => :get
    match '/users/:id/friends/:friend_id' => 'api_users#friend_show', :via => :get, :as => 'api_friend_detail'
    match '/users/:id/friends/:friend_id' => 'api_users#friend_destroy', :via => :delete

    # notifications
    match '/users/:id/notifications' => 'api_users#notification_index', :via => :get
    match '/users/:id/notifications/:notification_id' => 'api_users#notification_destroy', :via => :delete

    # user band invitations
    match '/users/:id/band_invitations' => 'api_users#band_invitation_index', :via => :get
    match '/users/:id/band_invitations/:invitation_id' => 'api_users#band_invitation_show', :via => :get, :as => 'api_user_band_invitation_detail'
    match '/users/:id/band_invitations/:invitation_id' => 'api_users#band_invitation_update', :via => :post

    # user account settings
    match '/users/:id/update_email' => 'api_users#begin_update_email', :via => :post, :as => 'begin_update_email'
    match '/users/update_email/:token' => 'api_users#finalize_update_email', :via => :post, :as => 'finalize_update_email'

    # user profile
    match '/users/:id/avatar' => 'api_users#update_avatar', :via => :post
    match '/users/:id/avatar' => 'api_users#delete_avatar', :via => :delete
    match '/users/:id/filepicker_policy' => 'api_users#generate_filepicker_policy', :via => :get

    # user progression
    match '/users/progression/downloaded_client' => 'api_users#downloaded_client', :via => :post
    match '/users/progression/certified_gear' => 'api_users#qualified_gear', :via => :post
    match '/users/progression/social_promoted' => 'api_users#social_promoted', :via => :post

    # user recordings
    # match '/users/:id/recordings' => 'api_users#recording_index', :via => :get
    # match '/users/:id/recordings/:recording_id' => 'api_users#recording_show', :via => :get, :as => 'api_recording_detail'
    # match '/users/:id/recordings' => 'api_users#recording_create', :via => :post
    # match '/users/:id/recordings/:recording_id' => 'api_users#recording_update', :via => :post
    # match '/users/:id/recordings/:recording_id' => 'api_users#recording_destroy', :via => :delete

    # bands
    match '/bands' => 'api_bands#index', :via => :get
    match '/bands/:id' => 'api_bands#show', :via => :get, :as => 'api_band_detail'
    match '/bands' => 'api_bands#create', :via => :post
    match '/bands/:id' => 'api_bands#update', :via => :post

    # band members (NOT DONE)
    match '/bands/:id/musicians' => 'api_bands#musician_index', :via => :get
    match '/bands/:id/musicians' => 'api_bands#musician_create', :via => :post
    match '/bands/:id/musicians/:user_id' => 'api_bands#musician_destroy', :via => :delete

    # band likers
    match '/bands/:id/likers' => 'api_bands#liker_index', :via => :get
    
    # band followers
    match '/bands/:id/followers' => 'api_bands#follower_index', :via => :get

    # band recordings
    match '/bands/:id/recordings' => 'api_bands#recording_index', :via => :get
    match '/bands/:id/recordings/:recording_id' => 'api_bands#recording_show', :via => :get, :as => 'api_band_recording_detail'
    match '/bands/:id/recordings' => 'api_bands#recording_create', :via => :post
    match '/bands/:id/recordings/:recording_id' => 'api_bands#recording_update', :via => :post
    match '/bands/:id/recordings/:recording_id' => 'api_bands#recording_destroy', :via => :delete

    # band invitations
    match '/bands/:id/invitations' => 'api_bands#invitation_index', :via => :get
    match '/bands/:id/invitations/:invitation_id' => 'api_bands#invitation_show', :via => :get, :as => 'api_band_invitation_detail'
    match '/bands/:id/invitations' => 'api_bands#invitation_create', :via => :post
    match '/bands/:id/invitations/:invitation_id' => 'api_bands#invitation_destroy', :via => :delete

    # invitations
    match '/invitations/:id' => 'api_invitations#show', :via => :get, :as => 'api_invitation_detail'
    match '/invitations/:id' => 'api_invitations#delete', :via => :delete
    match '/invitations' => 'api_invitations#index', :via => :get
    match '/invitations' => 'api_invitations#create', :via => :post

    # invited users
    match '/invited_users/:id' => 'api_invited_users#show', :via => :get, :as => 'api_invited_user_detail'
    match '/invited_users' => 'api_invited_users#index', :via => :get
    match '/invited_users' => 'api_invited_users#create', :via => :post

    # instruments
    match '/instruments/:id' => 'api_instruments#show', :via => :get, :as => 'api_instrument_detail'
    match '/instruments' => 'api_instruments#index', :via => :get

    # search
    match '/search' => 'api_search#index', :via => :get

    # join requests
    match '/join_requests/:id' => 'api_join_requests#show', :via => :get, :as => 'api_join_request_detail'
    match '/join_requests/:id' => 'api_join_requests#delete', :via => :delete
    match '/join_requests' => 'api_join_requests#create', :via => :post
    match '/join_requests' => 'api_join_requests#index', :via => :get
    
    # Location lookups
    match '/countries' => 'api_maxmind_requests#countries', :via => :get
    match '/regions' => 'api_maxmind_requests#regions', :via => :get
    match '/cities' => 'api_maxmind_requests#cities', :via => :get
    match '/isps' => 'api_maxmind_requests#isps', :via => :get
    
    # Recordings
    match '/recordings/list' => 'api_recordings#list', :via => :get
    match '/recordings/start' => 'api_recordings#start', :via => :post
    match '/recordings/:id/stop' => 'api_recordings#stop', :via => :put
    match '/recordings/:id/claim' => 'api_recordings#claim', :via => :post
    match '/recordings/upload_next_part' => 'api_recordings#upload_next_part', :via => :get
    match '/recordings/upload_sign' => 'api_recordings#upload_sign', :via => :get
    match '/recordings/upload_part_complete' => 'api_recordings#upload_part_complete', :via => :put
    match '/recordings/upload_complete' => 'api_recordings#upload_complete', :via => :put

    # Claimed Recordings
    match '/claimed_recordings' => 'api_claimed_recordings#index', :via => :get
    match '/claimed_recordings/:id' => 'api_claimed_recordings#show', :via => :get
    match '/claimed_recordings/:id' => 'api_claimed_recordings#update', :via => :put
    match '/claimed_recordings/:id' => 'api_claimed_recordings#delete', :via => :delete

    # Mixes
    match '/mixes/schedule' => 'api_mixes#schedule', :via => :post
    match '/mixes/next' => 'api_mixes#next', :via => :get
    match '/mixes/finish' => 'api_mixes#finish', :via => :put

    # version check for JamClient
    match '/versioncheck' => 'artifacts#versioncheck'

    # list all uris for available clients on mac, windows, linux, if available
    match '/artifacts/clients' => 'artifacts#client_downloads'

    # crash logs
    match '/dumps' => 'api_users#crash_dump', :via => :put

    # feedback from corporate site api
    match '/feedback' => 'api_corporate#feedback', :via => :post


  end
end
