This repository has been archived by the owner on Dec 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-zendesk-talk-api.php
94 lines (76 loc) · 1.77 KB
/
wp-zendesk-talk-api.php
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
<?php
/* Check if Class Exists. */
if ( ! class_exists( 'Zendesk_Talk_Wordpress_API' ) ) {
/**
* Zendesk_Talk_Wordpress_API class.
*/
class Zendesk_Talk_Wordpress_API {
/**
* api_url
*
* (default value: '')
*
* @var string
* @access private
*/
private $api_url = '';
/**
* username
*
* (default value: false)
*
* @var bool
* @access private
*/
private $username = false;
/**
* password
*
* (default value: false)
*
* @var bool
* @access private
*/
private $password = false;
/**
* api_key
*
* (default value: false)
*
* @var bool
* @access private
*/
private $api_key = false;
/**
* __construct function.
*
* The only parameter is the API url, together with the protocol.
* (generally http or https). The trailing slash is appended during.
* API calls if one doesn't exist.
*
* @access public
* @param mixed $subdomain Subdomain.
* @param string $email (default: '') Email.
* @param string $api_key (default: '') API Key.
* @return void
*/
public function __construct( $subdomain, $email = '', $api_key = '' ) {
$this->api_url = 'https://' . $subdomain . '.zendesk.com/api/v2';
if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) {
$this->cache_timeout = 60;
$this->cache_timeout_views = 60 * 60;
$this->cache_timeout_ticket_fields = 60 * 60;
$this->cache_timeout_user = 60 * 60;
} else {
$this->cache_timeout = 5;
$this->cache_timeout_views = 5;
$this->cache_timeout_ticket_fields = 5;
$this->cache_timeout_user = 5;
}
if ( $email != '' && $api_key != '' ) {
$this->username = $email;
$this->api_key = $api_key;
}
}
}
} // end if.