4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'app/models/zuora_connect/login.rb', line 4
def initialize (fields)
@clients = {}
if fields["tenant_type"] == "Zuora" && fields["entities"] && fields["entities"].size > 0
@clients["Default"] = ::ZuoraAPI::Login.new(fields.map{|k,v| [k.to_sym, v]}.to_h)
@default_entity = fields["entities"][0]["id"] if fields["entities"].size == 1
fields["entities"].each do |entity|
login_fields = fields.map{|k,v| [k.to_sym, v]}.to_h
login_fields[:entity_id] = entity["id"]
@clients[entity["id"]] = ::ZuoraAPI::Login.new(login_fields)
end
elsif fields["tenant_type"] == "Zuora"
@clients["Default"] = ::ZuoraAPI::Login.new(fields.map{|k,v| [k.to_sym, v]}.to_h)
end
self.attr_builder("available_entities",@clients.keys) if fields["tenant_type"] == "Zuora"
fields.each do |k,v|
self.attr_builder(k,v)
end
@default_entity ||= "Default"
end
|