~singpolyma/sgx-jmp

51b5926f513569807fcd0576fb2d124368961da3 — Stephen Paul Weber 9 months ago 690a17e
Show CNAM in customer info
3 files changed, 10 insertions(+), 1 deletions(-)

M lib/customer.rb
M lib/customer_info.rb
M test/test_customer_info.rb
M lib/customer.rb => lib/customer.rb +2 -0
@@ 85,6 85,8 @@ class Customer
	end

	def tndetails
		return unless registered?

		@tndetails ||=
			BandwidthIris::Tn.new(telephone_number: registered?.phone).get_details
	end

M lib/customer_info.rb => lib/customer_info.rb +4 -1
@@ 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,

M test/test_customer_info.rb => test/test_customer_info.rb +4 -0
@@ 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,