Completed
Push — master ( 5d5473...3f41e3 )
by Luca
02:37
created

SystemEndpoint::updateSystemProperty()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
/**
3
 * OpenFireRestAPI is based entirely on official documentation of the REST API
4
 * Plugin and you can extend it by following the directives of the documentation
5
 *
6
 * For the full copyright and license information, please read the LICENSE
7
 * file that was distributed with this source code. For the full list of
8
 * contributors, visit https://github.com/gnello/PHPOpenFireRestAPI/contributors
9
 *
10
 * @author Luca Agnello <[email protected]>
11
 * @link https://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html
12
 */
13
14
namespace Gnello\OpenFireRestAPI\Endpoints;
15
16
use \Gnello\OpenFireRestAPI\Dispatcher\Method;
17
use \Gnello\OpenFireRestAPI\Dispatcher\Dispatcher;
18
use \Gnello\OpenFireRestAPI\Payloads;
19
20
/**
21
 * System related REST Endpoint
22
 * Class SystemEndpoint
23
 * @package Gnello\OpenFireRestAPI\Endpoints
24
 * @link https://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html#system-related-rest-endpoints
25
 */
26
class SystemEndpoint extends Dispatcher
27
{
28
    public static $endpoint = '/system';
29
30
    /**
31
     * Get all system properties
32
     * @return array with System properties
33
     * @link https://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html#retrieve-all-system-properties
34
     */
35
    public static function retrieveAllSystemProperties()
36
    {
37
        $endpoint = self::$endpoint . '/properties';
38
        return self::sendRequest(Method::GET, $endpoint);
39
    }
40
41
    /**
42
     * Get information over specific system property
43
     * @param $propertyName
44
     * @return array with System property
45
     * @link https://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html#retrieve-system-property
46
     */
47
    public static function retrieveSystemProperty($propertyName)
48
    {
49
        $endpoint = self::$endpoint . '/properties/' . $propertyName;
50
        return self::sendRequest(Method::GET, $endpoint);
51
    }
52
53
    /**
54
     * Create a system property
55
     * @param $propertyName
56
     * @param $propertyValue
57
     * @return array with HTTP status 201 (Created)
58
     * @link https://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html#create-a-system-property
59
     */
60
    public static function createSystemProperty($propertyName, $propertyValue)
61
    {
62
        $payload = new Payloads\SystemPropertyPayload(compact('propertyName', 'propertyValue'));
63
        $endpoint = self::$endpoint . '/properties';
64
        return self::sendRequest(Method::POST, $endpoint, $payload);
65
    }
66
67
    /**
68
     * Delete a system property
69
     * @param $propertyName
70
     * @return array with HTTP status 200 (OK)
71
     * @link https://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html#delete-a-system-property
72
     */
73
    public static function deleteSystemProperty($propertyName)
74
    {
75
        $endpoint = self::$endpoint . '/properties/' . $propertyName;
76
        return self::sendRequest(Method::DELETE, $endpoint);
77
    }
78
79
    /**
80
     * Update a system property
81
     * @param $propertyName
82
     * @return array with HTTP status 200 (OK)
83
     * @link https://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html#update-a-system-property
84
     */
85
    public static function updateSystemProperty($propertyName)
86
    {
87
        $endpoint = self::$endpoint . '/properties/' . $propertyName;
88
        return self::sendRequest(Method::PUT, $endpoint);
89
    }
90
91
    /**
92
     * Get count of concurrent sessions
93
     * @return array with Sessions count
94
     * @link http://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html#retrieve-concurrent-sessions
95
     */
96
    public static function retrieveConcurrentSessions()
97
    {
98
        $endpoint = self::$endpoint . '/statistics' . SessionEndpoint::$endpoint;
99
        return self::sendRequest(Method::GET, $endpoint);
100
    }
101
}