# frozen_string_literal: true
class AltTopUpForm
def self.for(customer)
customer.btc_addresses.then do |addrs|
AltTopUpForm.new(customer, addrs)
end
end
def initialize(customer, btc_addresses)
@balance = customer.balance
@currency = customer.currency
@btc_addresses = btc_addresses
end
def form
FormTemplate.render(
"alt_top_up",
balance: @balance,
currency: @currency,
btc_addresses: @btc_addresses
)
end
def parse(form)
{
add_btc_address: ["1", "true"].include?(
form.field("add_btc_address")&.value.to_s
)
}
end
end