This repository has been archived by the owner on Jul 29, 2020. It is now read-only.
forked from crisp-im/php-crisp-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crisp.php
69 lines (61 loc) · 2.48 KB
/
crisp.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
<?php
/*
* Bundle: Crisp
* Project: Crisp - PHP API
* Author: Baptiste Jamin http://jamin.me/
* Copyright: 2016, Crisp IM
*/
require __DIR__ . '/ressources/UserSession.php';
require __DIR__ . '/ressources/UserAccount.php';
require __DIR__ . '/ressources/UserAvailability.php';
require __DIR__ . '/ressources/UserNotification.php';
require __DIR__ . '/ressources/UserProfile.php';
require __DIR__ . '/ressources/UserWebsites.php';
require __DIR__ . '/ressources/Website.php';
require __DIR__ . '/ressources/WebsiteSettings.php';
require __DIR__ . '/ressources/WebsiteOperators.php';
require __DIR__ . '/ressources/WebsiteConversations.php';
require __DIR__ . '/ressources/WebsitePeople.php';
require __DIR__ . '/ressources/PluginSubscriptions.php';
class Crisp
{
//Rest default configuration
public $DEFAULT_REST_HOST = "https://api.crisp.chat";
public $DEFAULT_REST_BASE_PATH = "/v1/";
public function __construct() {
$this->auth = array();
$this->_rest = new RestClient(array(
"base_url" => $this->DEFAULT_REST_HOST . $this->DEFAULT_REST_BASE_PATH,
"headers" => ["Content-Type" => "application/json"],
"content_type" => "application/json"
));
$this->_rest->register_decoder("json", function($data) {
return json_decode($data, TRUE);
});
$this->userSession = new CrispUserSession($this);
$this->userAvailability = new CrispUserAvailability($this);
$this->userAccount = new CrispUserAccount($this);
$this->userNotification = new CrispUserNotification($this);
$this->userProfile = new CrispUserProfile($this);
$this->userWebsites = new CrispUserWebsites($this);
$this->website = new CrispWebsite($this);
$this->websiteSettings = new CrispWebsiteSettings($this);
$this->websiteConversations = new CrispWebsiteConversations($this);
$this->websitePeople = new CrispWebsitePeople($this);
$this->websiteOperators = new CrispWebsiteOperators($this);
$this->pluginSubscriptions = new CrispPluginSubscriptions($this);
}
public function setRestHost($host) {
$this->_rest->set_option('base_url', $host);
}
public function authenticate($identifier, $key) {
$this->_rest->set_option('username', $identifier);
$this->_rest->set_option('password', $key);
}
public function setTier($tier) {
$headers = $this->_rest->options["headers"];
$headers["X-Crisp-Tier"] = $tier;
$this->_rest->set_option('headers', $headers);
}
}
?>