@@ -52,6 +52,18 @@ class PortInOrder
"New port-in request for #{customer_id}: #{url}"
end
+ def already_inservice?
+ BandwidthIris::InServiceNumber.get(@params["BillingTelephoneNumber"])
+ Command.finish(
+ "That number is already in service with us. " \
+ "Please contact support if you need assistance.",
+ type: :error
+ )
+ true
+ rescue APIError
+ false
+ end
+
def complete_with
EMPromise.resolve(self)
end
@@ -862,15 +862,17 @@ Command.new(
}.then(&:form)
end
}.then do |order|
- order_id = BandwidthIris::PortIn.create(order.to_h)[:order_id]- customer.stanza_from(Blather::Stanza::Message.new(- "",- order.message(order_id)- ))- Command.finish(- "Your port-in request has been accepted, " \- "support will contact you with next steps"- )
+ unless order.already_inservice?
+ order_id = BandwidthIris::PortIn.create(order.to_h)[:order_id]
+ customer.stanza_from(Blather::Stanza::Message.new(
+ "",
+ order.message(order_id)
+ ))
+ Command.finish(
+ "Your port-in request has been accepted, " \
+ "support will contact you with next steps"
+ )
+ end
end
end
}.register(self).then(&CommandList.method(:register))