diff --git a/lib/call_attempt.rb b/lib/call_attempt.rb index 05644cdca3899aba2b13d334596db6cf74270a2b..c7dc0d01bd5e71849e3669b800b77a2e9793d314 100644 --- a/lib/call_attempt.rb +++ b/lib/call_attempt.rb @@ -68,47 +68,6 @@ class CallAttempt as_json.to_json(*args) end - class TollFree - CallAttempt.register do |rate:, customer:, **kwargs| - if rate&.zero? - new( - **kwargs - .merge(customer_id: customer.customer_id, sgx: customer.sgx) - .slice(*value_semantics.attributes.map(&:name)) - ) - end - end - - value_semantics do - customer_id String - from String - to(/\A\+\d+\Z/) - sgx Blather::JID - call_id String - direction Either(:inbound, :outbound) - end - - def to_render - ["#{direction}/connect", { locals: to_h }] - end - - def to_s - "TollFree" - end - - def create_call(fwd, *args, &block) - fwd.create_call(*args, &block) - end - - def as_json(*) - to_h - end - - def to_json(*args) - as_json.to_json(*args) - end - end - class Expired CallAttempt.register do |customer:, direction:, **| new(direction: direction) if customer.plan_name && !customer.active? @@ -298,4 +257,45 @@ class CallAttempt .slice(*value_semantics.attributes.map(&:name)) ) end + + class TollFree + CallAttempt.register do |rate:, customer:, **kwargs| + if rate&.zero? + new( + **kwargs + .merge(customer_id: customer.customer_id, sgx: customer.sgx) + .slice(*value_semantics.attributes.map(&:name)) + ) + end + end + + value_semantics do + customer_id String + from String + to(/\A\+\d+\Z/) + sgx Blather::JID + call_id String + direction Either(:inbound, :outbound) + end + + def to_render + ["#{direction}/connect", { locals: to_h }] + end + + def to_s + "TollFree" + end + + def create_call(fwd, *args, &block) + fwd.create_call(*args, &block) + end + + def as_json(*) + to_h + end + + def to_json(*args) + as_json.to_json(*args) + end + end end