class ApiInvitedUsersController < ApiController

  # have to be signed in currently to see this screen
  before_filter :api_signed_in_user

  respond_to :json

  def index
    @invited_users = InvitedUser.index(current_user)
  end

  def show
    @invited_user = InvitedUser.find(params[:id])
  end

  def create
    @invited_user = InvitedUser.new
    @invited_user.sender = current_user
    @invited_user.email = params[:email]
    @invited_user.autofriend = true
    @invited_user.note = params[:note].blank? ? nil : params[:note]
    @invited_user.save

    unless @invited_user.errors.any?
      respond_with @invited_user, :responder => ApiResponder, :location => api_invited_user_detail_url(@invited_user)
    else
      response.status = :unprocessable_entity
      respond_with @invited_user
    end
  end

end
