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