-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathQueueitBase.php
More file actions
97 lines (80 loc) · 2.08 KB
/
Copy pathQueueitBase.php
File metadata and controls
97 lines (80 loc) · 2.08 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/**
* Base class implementing Queue-it platform.
*/
class QueueitBase {
/* Protected variables */
protected $intMethod; // Integration method (integration, js, code).
protected $customerID; // Customer ID.
/* Other variables */
protected $isDebug; // Debug mode.
/* Constants */
const QI_API_DOMAIN = 'queue-it.net';
const QI_JS_CLIENT_URL = '//static.queue-it.net/script/queueclient.min.js';
const QI_JS_LOADER_URL = '//static.queue-it.net/script/queueconfigloader.min.js';
/**
* Class constructor.
*/
public function __construct($int_method = 'js', $customer_id = '') {
// Initialize base class constructor.
$this->intMethod = $int_method
?: variable_get('queueit_mode');
$this->customerID = $customer_id
?: variable_get('queueit_customer_id');
$this->isDebug = variable_get('queueit_debug', FALSE);
}
/**
* Validate config.
*
* @return bools
* Returns TRUE if config is valid (e.g. credentials aren't empty).
*/
public function validateConfig() {
return $this->getCustomerId();
}
/**
* Validate JS endpoints.
*/
static public function validateJsEndpoints() {
return file_get_contents('http:' . self::QI_JS_CLIENT_URL)
&& file_get_contents('http:' . self::QI_JS_LOADER_URL);
}
/* Setters */
/**
* Set integration method.
*/
public function setIntegrationMethod($method) {
return $this->intMethod = $method;
}
/**
* Set customer ID.
*/
public function setCustomerId($customer_id) {
return $this->customerID = $customer_id;
}
/* Getters */
/**
* Get customer ID.
*/
public function getCustomerId() {
return $this->customerID;
}
/**
* Get integration method.
*/
public function getIntegrationMethod() {
return $this->intMethod;
}
/**
* Get a queue token.
*/
public function getQueueToken() {
return filter_input(INPUT_GET, 'queueittoken');
}
/**
* Helper method to get the current URL.
*/
public function getFullRequestUri() {
return $GLOBALS['base_url'] . request_uri();
}
}