# frozen_string_literal: true require "value_semantics/monkey_patched" require_relative "proxied_jid" class LegacyCustomer attr_reader :jid, :tel def initialize(jid, tel) @jid = jid @tel = tel end def customer_id nil end def info EMPromise.resolve(nil).then do Info.new(tel: tel) end end def admin_info EMPromise.all([ info, api ]).then do |info, api| AdminInfo.new(info: info, jid: jid, api: api) end end def api API.for(self) end class Info value_semantics do tel String end def form FormTemplate.render("legacy_customer_info", info: self) end end class AdminInfo value_semantics do info Info jid ProxiedJID, coerce: ProxiedJID.method(:new) api API end def form FormTemplate.render("legacy_customer_admin_info", admin_info: self) end end end