# frozen_string_literal: true

class SIMKind
	attr_reader :klass

	def initialize(variant)
		@klass =
			case variant
			when "sim"
				SIMOrder
			when "esim"
				SIMOrder::ESIM
			end
		@variant = variant
	end

	def self.from_form(form)
		new(form.field("sim_kind")&.value)
	end

	def cfg(currency)
		CONFIG.dig(:sims, @variant.to_sym, currency)
	end

	def price_dollars(currency)
		cfg = cfg(currency)
		return nil unless cfg

		cfg[:price] / 100.to_d
	end
end
