~singpolyma/sgx-jmp

sgx-jmp/lib/trivial_backend_sgx_repo.rb -rw-r--r-- 843 bytes
94298f5dStephen Paul Weber Refactor alt top up to use FormTemplate 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true

require_relative "backend_sgx"
require_relative "not_loaded"

class TrivialBackendSgxRepo
	def initialize(
		jid: CONFIG[:sgx],
		creds: CONFIG[:creds],
		component_jid: CONFIG[:component][:jid],
		**with
	)
		@jid = Blather::JID.new(jid)
		@creds = creds
		@component_jid = component_jid
		@with = with
	end

	def get(customer_id, tel: nil)
		BackendSgx.new(
			jid: @jid, creds: @creds,
			from_jid: Blather::JID.new("customer_#{customer_id}", @component_jid),
			ogm_url: NotLoaded.new(:ogm_url),
			fwd: NotLoaded.new(:fwd_timeout),
			transcription_enabled: NotLoaded.new(:transcription_enabled),
			registered?: tel ? ibr_for(tel) : NotLoaded.new(:registered?)
		).with(@with)
	end

protected

	def ibr_for(tel)
		ibr = Blather::Stanza::Iq::IBR.new
		ibr.registered = true
		ibr.phone = tel
		ibr
	end
end