Block voice calls when account is expired
Stephen Paul Weber
created
Allow for "transitional" (no plan) users for now, because we still have a bunch
of those.
Change summary
lib/call_attempt.rb | 32 ++++++++++++++++++++++++++++++++
views/inbound/expired.slim | 3 +++
views/outbound/expired.slim | 3 +++
3 files changed, 38 insertions(+)
Detailed changes
@@ -66,6 +66,38 @@ class CallAttempt
as_json.to_json(*args)
end
+ class Expired
+ CallAttempt.register do |customer:, direction:, **|
+ new(direction: direction) if customer.plan_name && !customer.active?
+ end
+
+ value_semantics do
+ direction Either(:inbound, :outbound)
+ end
+
+ def view
+ "#{direction}/expired"
+ end
+
+ def tts
+ TTSTemplate.new(view).tts(self)
+ end
+
+ def to_render
+ [view]
+ end
+
+ def create_call(*); end
+
+ def as_json(*)
+ { tts: tts }
+ end
+
+ def to_json(*args)
+ as_json.to_json(*args)
+ end
+ end
+
class Unsupported
CallAttempt.register do |supported:, direction:, **|
new(direction: direction) unless supported
@@ -0,0 +1,3 @@
+doctype xml
+Response
+ Hangup /
@@ -0,0 +1,3 @@
+doctype xml
+Response
+ SpeakSentence Your account is expired, please top up soon to keep your number.