# frozen_string_literal: true

class Subaccount
	value_semantics do
		customer_id String
	end

	def initialize(customer_id)
		@customer_id = customer_id
	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 { |customer_id| Subaccount.new(customer_id) } }
	end
end
