Class: Maestrano::Account::GroupsController

Inherits:
Rails::WebHookController
  • Object
show all
Defined in:
lib/generators/maestrano/templates/groups_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject

DELETE /maestrano/account/groups/cld-1/:tenant Delete an entire group



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/generators/maestrano/templates/groups_controller.rb', line 5

def destroy
  group_uid = params[:id]
  tenant = params[:tenant]
  
  # Perform deletion steps here
  # --
  # If you need to perform a final checkout
  # then you can call Maestrano::Account::Bill.create({.. final checkout details ..})
  # --
  # If Maestrano.param('sso.creation_mode') is set to virtual
  # then you might want to delete/cancel/block all users under
  # that group
  # --
  # E.g:
  # organization = Organization.find_by_tenant_and_uid(tenant, group_uid)
  #
  # amount_cents = organization.calculate_total_due_remaining
  # Maestrano::Account::Bill.create({
  #   group_id: group_uid, 
  #   price_cents: amount_cents, 
  #   description: "Final Payout"
  # })
  # 
  # if Maestrano.param('sso.creation_mode') == 'virtual'
  #   organization.members.where(provider:'maestrano').each do |user|
  #   user.destroy
  # end
  #
  # organization.destroy
  # render json: {success: true}
  #
end