From 67fdba5f4e4fa4f8882838b76b402525ab7c9396 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 29 Jan 2024 13:18:11 -0500 Subject: [PATCH] Pass already extracted custoemr_id --- lib/cdr.rb | 4 ++-- test/test_cdr.rb | 1 + web.rb | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/cdr.rb b/lib/cdr.rb index c67a5dcd20586eaeec85021c12f3e70893b8a0b3..bbd1de1f3e4fee2e1f8cd9f740502855caefb734 100644 --- a/lib/cdr.rb +++ b/lib/cdr.rb @@ -71,10 +71,10 @@ class CDR ) end - def self.for_outbound(event) + def self.for_outbound(customer_id, event) self.for( event, - customer_id: event["from"].sub(/^\+/, ""), + customer_id: customer_id, tel: event["to"], direction: :outbound ) diff --git a/test/test_cdr.rb b/test/test_cdr.rb index 3d6e8581b9907cc3175bf5204fd762f78aa30ed7..9fa636e631094fa536efd2e5d5f648149950e081 100644 --- a/test/test_cdr.rb +++ b/test/test_cdr.rb @@ -24,6 +24,7 @@ class CDRTest < Minitest::Test def test_for_outbound cdr = CDR.for_outbound( + "test", "to" => "+15551234567", "from" => "+test", "startTime" => "2020-01-01T00:00:00Z", diff --git a/web.rb b/web.rb index 602bf1d0ab53ba455b29f1bba49d9e1e5839d026..3246daface66f41b93c6d2c624e07ba506985983 100644 --- a/web.rb +++ b/web.rb @@ -385,7 +385,9 @@ class Web < Roda customer_id = params["from"].sub(/^(?:\+|c)/, "") customer_id = from.sub(/^1/, "") if customer_id.length > 10 call_attempt_repo.ending_call(customer_id, params["callId"]) - cdr_repo.put(CDR.for_outbound(params)).catch(&method(:log_error)) + cdr_repo + .put(CDR.for_outbound(customer_id, params)) + .catch(&method(:log_error)) end "OK" end