class Ribose::CLI::Commands::JoinSpace

Public Instance Methods

accept() click to toggle source
# File lib/ribose/cli/commands/join_space.rb, line 38
def accept
  Ribose::JoinSpaceRequest.accept(options[:request_id])
  say("Join space request has been accepted!")
end
add() click to toggle source
# File lib/ribose/cli/commands/join_space.rb, line 28
def add
  create_join_request(options)
  say("Join space request 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/join_space.rb, line 9
def list
  say(build_output(Ribose::JoinSpaceRequest.all(options), options))
end
reject() click to toggle source
# File lib/ribose/cli/commands/join_space.rb, line 46
def reject
  Ribose::JoinSpaceRequest.reject(options[:request_id])
  say("Join space request has been rejected!")
end
show() click to toggle source
# File lib/ribose/cli/commands/join_space.rb, line 17
def show
  join_space = Ribose::JoinSpaceRequest.fetch(options[:request_id])
  say(build_resource_output(join_space, options))
end

Private Instance Methods

create_join_request(attributes) click to toggle source
# File lib/ribose/cli/commands/join_space.rb, line 53
def create_join_request(attributes)
  Ribose::JoinSpaceRequest.create(
    state: attributes[:state] || 0,
    space_id: attributes[:space_id],
    body: attributes[:message] || "",
    type: attributes[:type] || "Invitation::JoinSpaceRequest",
  )
end
table_field_names() click to toggle source
# File lib/ribose/cli/commands/join_space.rb, line 66
def table_field_names
  %w(id email body state type)
end
table_headers() click to toggle source
# File lib/ribose/cli/commands/join_space.rb, line 62
def table_headers
  ["ID", "Inviter", "Type", "Space Name"]
end
table_rows(requests) click to toggle source
# File lib/ribose/cli/commands/join_space.rb, line 70
def table_rows(requests)
  requests.map do |req|
    [req.id, req.inviter.name, req.type, req.space.name]
  end
end