subaccount.rb
1# frozen_string_literal: true
2
3class Subaccount
4 value_semantics do
5 customer_id String
6 end
7
8 def self.get_subaccounts(parent_id)
9 DB.query_defer(<<~SQL, [parent_id])
10 SELECT customer_id FROM customer_plans WHERE parent_customer_id=$1
11 SQL
12 .then { |rows|
13 rows.map { |row| Subaccount.new(customer_id: row["customer_id"]) }
14 }
15 end
16end