class Ribose::CLI::Commands::Member

Public Instance Methods

add() click to toggle source
# File lib/ribose/cli/commands/member.rb, line 19
def add
  add_member_to_space(options)
  say("Invitation has been sent successfully!")
rescue Ribose::UnprocessableEntity
  say("Something went wrong! Please check required attributes")
end
list() click to toggle source
# File lib/ribose/cli/commands/member.rb, line 9
def list
  say(build_output(Ribose::Member.all(options[:space_id]), options))
end
remove() click to toggle source
# File lib/ribose/cli/commands/member.rb, line 42
def remove
  Ribose::Member.delete(options[:space_id], options[:member_id])
  say("The member has been removed from this space")
rescue Ribose::UnprocessableEntity
  say("Something went wrong! Please provide a valid id/uuid")
end
update() click to toggle source
# File lib/ribose/cli/commands/member.rb, line 31
def update
  update_member_role(options)
  say("Member has been updated with new role!")
rescue Ribose::UnprocessableEntity
  say("Something went wrong! Please check required attributes")
end

Private Instance Methods

add_member_to_space(attributes) click to toggle source
# File lib/ribose/cli/commands/member.rb, line 51
def add_member_to_space(attributes)
  Ribose::SpaceInvitation.mass_create(
    attributes[:space_id],
    body: attributes[:message] || "",
    emails: (attributes[:email] || {}).keys,
    user_ids: (attributes[:user_id] || {}).keys,
    role_ids: (attributes[:email] || {}).merge(
      attributes[:user_id] || {},
    ),
  )
end
table_headers() click to toggle source
# File lib/ribose/cli/commands/member.rb, line 69
def table_headers
  ["ID", "Name", "Role Name"]
end
table_rows(members) click to toggle source
# File lib/ribose/cli/commands/member.rb, line 73
def table_rows(members)
  members.map do |member|
    [member.user_id, member.user.name, member.role_name_in_space]
  end
end
update_member_role(attributes) click to toggle source
# File lib/ribose/cli/commands/member.rb, line 63
def update_member_role(attributes)
  Ribose::MemberRole.assign(
    attributes[:space_id], attributes[:member_id], attributes[:role_id]
  )
end