# 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(jid: jid, tel: tel)
end
end
def admin_info
EMPromise.all([
info,
api
]).then do |info, api|
AdminInfo.new(info: info, api: api)
end
end
def api
API.for(self)
end
class Info
value_semantics do
jid ProxiedJID, coerce: ProxiedJID.method(:new)
tel String
end
def fields
[
{ var: "JID", value: jid.unproxied.to_s },
{ var: "Phone Number", value: tel }
]
end
end
class AdminInfo
value_semantics do
info Info
api API
end
def fields
info.fields + [
{ var: "Account Status", value: "Legacy" },
{ var: "Cheo JID", value: info.jid.to_s },
{ var: "API", value: api.to_s }
]
end
end
end