-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsupport_chat_api.php
More file actions
68 lines (57 loc) · 1.59 KB
/
support_chat_api.php
File metadata and controls
68 lines (57 loc) · 1.59 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/*
Purpose - Provide a JSON Api Class.
Methods Suppported = create_administrator, create_organization
*/
include ("users.php");
include ("create_instance.php");
class support_chat_api
{
var $valid_methods = array('create_administrator','create_organization');
var $data = '';
var $record_id = '';
var $org_id = '';
var $unique_key= '';
function __construct(){
}
function json_action($json_string)
{
$data = json_decode($json_string,true);
if($data === null) {
throw new Exception('Invalid JSON');
}
$this->action($data['method'], $data['parameters']);
}
function action($method, $parameters)
{
if(!in_array($method, $this->valid_methods))
{
throw new Exception('Invalid Method');
}
$method_action = "action_" . $method;
$this->$method_action($parameters);
}
function action_create_administrator($parameters){
$registeration = new users();
foreach ($parameters as $key => $value) {
$setmthd = "set".$key;
$registeration->$setmthd($value);
}
$registeration->create_user_in_db();
$this->record_id = $registeration->record_id;
}
function action_create_organization($parameters){
$organization = new create_instance();
$organization->setuser_id($this->record_id);
foreach ($parameters as $key => $value) {
$setmthd = "set".$key;
$organization->$setmthd($value);
}
$organization->create_organization();
$this ->org_id = $organization->org_id;
$organization->setorg_id($this->org_id);
$organization->create_link();
$this->unique_key = $organization->unique_key;
}
}
?>