# frozen_string_literal: true

class Subaccount
	value_semantics do
		customer_id String
	end

	def self.get_subaccounts(parent_id)
		DB.query_defer(<<~SQL, [parent_id])
			SELECT customer_id FROM customer_plans WHERE parent_customer_id=$1
	  SQL
			.then { |rows|
				rows.map { |row| Subaccount.new(customer_id: row["customer_id"]) }
			}
	end
end
