class DropboxApi::Metadata::Member

Examples of serialized {AddMember} objects:

“`json [

{
  ".tag": "email",
  "email": "justin@example.com"
},  {
  ".tag": "dropbox_id",
  "dropbox_id": "dbid:AAEufNrMPSPe0dMQijRP0N_aZtBJRm26W4Q"
}

] “`

Public Class Methods

new(member) click to toggle source
# File lib/dropbox_api/metadata/member.rb, line 17
def initialize(member)
  @member_hash = case member
    when Hash
      member
    when String
      hash_from_email_or_dropbox_id member
    when DropboxApi::Metadata::Member
      member.to_hash
    else
      raise ArgumentError, "Invalid object for Member: #{member.inspect}"
    end
end

Public Instance Methods

to_hash() click to toggle source
# File lib/dropbox_api/metadata/member.rb, line 30
def to_hash
  @member_hash
end

Private Instance Methods

hash_from_dropbox_id(dropbox_id) click to toggle source
# File lib/dropbox_api/metadata/member.rb, line 46
def hash_from_dropbox_id(dropbox_id)
  {
    ".tag": :dropbox_id,
    dropbox_id: dropbox_id
  }
end
hash_from_email(email) click to toggle source
# File lib/dropbox_api/metadata/member.rb, line 53
def hash_from_email(email)
  {
    ".tag": :email,
    email: email
  }
end
hash_from_email_or_dropbox_id(email_or_id) click to toggle source
# File lib/dropbox_api/metadata/member.rb, line 36
def hash_from_email_or_dropbox_id(email_or_id)
  if email_or_id.start_with? 'dbid:'
    hash_from_dropbox_id email_or_id
  elsif email_or_id =~ /\A[^@\s]+@[^@\s]+\z/
    hash_from_email email_or_id
  else
    raise ArgumentError, "Invalid email or Dropbox ID: #{email_or_id}"
  end
end