trivial_backend_sgx_repo.rb

 1# frozen_string_literal: true
 2
 3require_relative "backend_sgx"
 4require_relative "not_loaded"
 5
 6class TrivialBackendSgxRepo
 7	def initialize(
 8		jid: CONFIG[:sgx],
 9		creds: CONFIG[:creds],
10		component_jid: CONFIG[:component][:jid],
11		**with
12	)
13		@jid = Blather::JID.new(jid)
14		@creds = creds
15		@component_jid = component_jid
16		@with = with
17	end
18
19	def get(customer_id, tel: nil)
20		BackendSgx.new(
21			jid: @jid, creds: @creds,
22			from_jid: Blather::JID.new("customer_#{customer_id}", @component_jid),
23			ogm_url: NotLoaded.new(:ogm_url),
24			fwd: NotLoaded.new(:fwd_timeout),
25			transcription_enabled: NotLoaded.new(:transcription_enabled),
26			registered?: tel ? ibr_for(tel) : NotLoaded.new(:registered?)
27		).with(@with)
28	end
29
30protected
31
32	def ibr_for(tel)
33		ibr = Blather::Stanza::Iq::IBR.new
34		ibr.registered = true
35		ibr.phone = tel
36		ibr
37	end
38end