From 51b5926f513569807fcd0576fb2d124368961da3 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Wed, 20 Oct 2021 19:11:31 -0500 Subject: [PATCH] Show CNAM in customer info --- lib/customer.rb | 2 ++ lib/customer_info.rb | 5 ++++- test/test_customer_info.rb | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/customer.rb b/lib/customer.rb index e34189e..f580bc1 100644 --- a/lib/customer.rb +++ b/lib/customer.rb @@ -85,6 +85,8 @@ class Customer end def tndetails + return unless registered? + @tndetails ||= BandwidthIris::Tn.new(telephone_number: registered?.phone).get_details end diff --git a/lib/customer_info.rb b/lib/customer_info.rb index c437ee2..435f044 100644 --- a/lib/customer_info.rb +++ b/lib/customer_info.rb @@ -12,6 +12,7 @@ class CustomerInfo tel Either(String, nil) balance BigDecimal expires_at Either(Time, nil) + cnam Either(String, nil) end def self.for(customer, plan, expires_at) @@ -21,7 +22,8 @@ class CustomerInfo auto_top_up_amount: auto_top_up_amount, tel: customer.registered? ? customer.registered?.phone : nil, balance: customer.balance, - expires_at: expires_at + expires_at: expires_at, + cnam: customer.tndetails&.dig(:features, :lidb, :subscriber_information) ) end end @@ -64,6 +66,7 @@ class CustomerInfo [ { var: "Account Status", value: account_status }, { var: "Phone Number", value: tel || "Not Registered" }, + ({ var: "lidb_name", label: "CNAM", value: cnam } if cnam), { var: "Balance", value: "$%.4f" % balance }, monthly_amount, next_renewal, diff --git a/test/test_customer_info.rb b/test/test_customer_info.rb index 3987ab1..c383dff 100644 --- a/test/test_customer_info.rb +++ b/test/test_customer_info.rb @@ -10,6 +10,7 @@ class CustomerInfoTest < Minitest::Test def test_info_does_not_crash sgx = Minitest::Mock.new sgx.expect(:registered?, false) + sgx.expect(:registered?, false) CustomerPlan::REDIS.expect( :get, @@ -26,6 +27,7 @@ class CustomerInfoTest < Minitest::Test def test_admin_info_does_not_crash sgx = Minitest::Mock.new sgx.expect(:registered?, false) + sgx.expect(:registered?, false) CustomerPlan::REDIS.expect( :get, @@ -42,6 +44,7 @@ class CustomerInfoTest < Minitest::Test def test_inactive_info_does_not_crash sgx = Minitest::Mock.new sgx.expect(:registered?, false) + sgx.expect(:registered?, false) CustomerPlan::REDIS.expect( :get, @@ -64,6 +67,7 @@ class CustomerInfoTest < Minitest::Test def test_inactive_admin_info_does_not_crash sgx = Minitest::Mock.new sgx.expect(:registered?, false) + sgx.expect(:registered?, false) CustomerPlan::REDIS.expect( :get, -- 2.45.2