class JoinRequest
  attr_reader :user, :list, :created_at, :updated_at
  def id
    "jr-#{user_id}"
  end
  alias _id id

  def list_id
    list.try(:id)
  end

  def initialize(user: nil, list: nil, created_at: Time.now, updated_at: Time.now)
    @user, @list, @created_at, @updated_at = [user, list, created_at, updated_at]
  end

  def user_id
    user.id
  end

  def user_email
    user.email
  end

  def user_facebook_id
    user.uid
  end

  def list_id
    list.id
  end

  def read_attribute_for_serialization(a)
    serializable_hash[a]
  end

  def object
    self
  end

  def serializable_hash
    {
      id: id,
      _id: id,
      user_id: user.id,
      user_facebook_id: user.uid,
      user_email: user.email,
      list_id: list.id
    }
  end
end
