1# frozen_string_literal: true
2
3class AdminAction
4 class CancelCustomer
5 def self.call(customer, customer_repo:, **)
6 m = Blather::Stanza::Message.new
7 m.from = CONFIG[:notify_from]
8 m.body = "Your JMP account has been cancelled."
9 raise "Customer not registered" unless customer.registered?
10 customer.stanza_to(m).then {
11 EMPromise.all([
12 Churnbuster.new.cancellation(customer),
13 customer.stanza_to(Blather::Stanza::Iq::IBR.new(:set).tap(&:remove!)),
14 customer.deregister!, customer_repo.disconnect_tel(customer)
15 ])
16 }
17 end
18 end
19end