summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts/dialplan/tenant.lua
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:01:45 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:01:45 +0100
commitb80bd744ad873f6fc43018bc4bfb90677de167bd (patch)
tree072c4b0e33d442528555b82c415f5e7a1712b2b0 /misc/freeswitch/scripts/dialplan/tenant.lua
parent3e706c2025ecc5523e81ad649639ef2ff75e7bac (diff)
Start of GS5.
Diffstat (limited to 'misc/freeswitch/scripts/dialplan/tenant.lua')
-rw-r--r--misc/freeswitch/scripts/dialplan/tenant.lua51
1 files changed, 51 insertions, 0 deletions
diff --git a/misc/freeswitch/scripts/dialplan/tenant.lua b/misc/freeswitch/scripts/dialplan/tenant.lua
new file mode 100644
index 0000000..8d6436c
--- /dev/null
+++ b/misc/freeswitch/scripts/dialplan/tenant.lua
@@ -0,0 +1,51 @@
+-- Gemeinschaft 5 module: user class
+-- (c) AMOOMA GmbH 2012
+--
+
+module(...,package.seeall)
+
+Tenant = {}
+
+-- Create Tenant object
+function Tenant.new(self, arg)
+ arg = arg or {}
+ object = arg.object or {}
+ setmetatable(object, self)
+ self.__index = self;
+ self.class = 'tenant';
+ self.log = arg.log;
+ self.database = arg.database;
+ self.record = arg.record;
+ return object;
+end
+
+-- find tenant by id
+function Tenant.find_by_id(self, id)
+ local sql_query = 'SELECT * FROM `tenants` WHERE `id`= ' .. tonumber(id) .. ' LIMIT 1';
+ local tenant = nil;
+
+ self.database:query(sql_query, function(account_entry)
+ tenant = Tenant:new(self);
+ tenant.record = account_entry;
+ tenant.id = tonumber(account_entry.id);
+ tenant.uuid = account_entry.uuid;
+ end);
+
+ return tenant;
+end
+
+-- find tenant by uuid
+function Tenant.find_by_uuid(self, uuid)
+ tenant_id = tonumber(tenant_id)
+ local sql_query = 'SELECT * FROM `tenants` WHERE `id`= "' .. uuid .. '" LIMIT 1';
+ local tenant = nil;
+
+ self.database:query(sql_query, function(account_entry)
+ tenant = Tenant:new(self);
+ tenant.record = account_entry;
+ tenant.id = tonumber(account_entry.id);
+ tenant.uuid = account_entry.uuid;
+ end);
+
+ return tenant;
+end