From 9c9eb9171c3dc3f3106bd46ca0c6f32e7f9ab517 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 28 May 2024 12:58:08 -0500 Subject: [PATCH] Include sgx jid in JSON format for calls --- lib/call_attempt.rb | 20 ++++++-------------- lib/customer.rb | 4 ++++ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/call_attempt.rb b/lib/call_attempt.rb index 3676cdfd5d0c26599454d2a21e333e73e3e6174e..05644cdca3899aba2b13d334596db6cf74270a2b 100644 --- a/lib/call_attempt.rb +++ b/lib/call_attempt.rb @@ -41,6 +41,7 @@ class CallAttempt customer_id String from String to(/\A\+\d+\Z/) + sgx Blather::JID call_id String direction Either(:inbound, :outbound) limit_remaining Integer @@ -60,13 +61,7 @@ class CallAttempt end def as_json(*) - { - from: from, - to: to, - customer_id: customer_id, - limit_remaining: limit_remaining, - max_minutes: max_minutes - } + to_h end def to_json(*args) @@ -78,7 +73,7 @@ class CallAttempt if rate&.zero? new( **kwargs - .merge(customer_id: customer.customer_id) + .merge(customer_id: customer.customer_id, sgx: customer.sgx) .slice(*value_semantics.attributes.map(&:name)) ) end @@ -88,6 +83,7 @@ class CallAttempt customer_id String from String to(/\A\+\d+\Z/) + sgx Blather::JID call_id String direction Either(:inbound, :outbound) end @@ -105,11 +101,7 @@ class CallAttempt end def as_json(*) - { - from: from, - to: to, - customer_id: customer_id - }.compact + to_h end def to_json(*args) @@ -302,7 +294,7 @@ class CallAttempt register do |customer:, **kwargs| new( **kwargs - .merge(customer_id: customer.customer_id) + .merge(customer_id: customer.customer_id, sgx: customer.sgx) .slice(*value_semantics.attributes.map(&:name)) ) end diff --git a/lib/customer.rb b/lib/customer.rb index a348ecc59d378d71448ee71d7854d1ce7e70f36b..0b16d7fcd5b4a8e966f6f3f524bc111dea43b16e 100644 --- a/lib/customer.rb +++ b/lib/customer.rb @@ -122,6 +122,10 @@ class Customer SipAccount.find(customer_id) end + def sgx + @sgx.jid + end + def reset_sip_account sip_account.with_random_password.put end