1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* FlexiPeeHP - WebHooks. |
4
|
|
|
* |
5
|
|
|
* @link https://www.flexibee.eu/api/dokumentace/ref/web-hooks WebHooks Reference |
6
|
|
|
* @author Vítězslav Dvořák <[email protected]> |
7
|
|
|
* @copyright (C) 2015,2016 Spoje.Net |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace FlexiPeeHP; |
11
|
|
|
|
12
|
|
|
class Hooks extends FlexiBee |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* Evidence užitá objektem. |
16
|
|
|
* |
17
|
|
|
* @var string |
18
|
|
|
*/ |
19
|
|
|
public $evidence = 'hooks'; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Zaregistruje WebHook |
23
|
|
|
* |
24
|
|
|
* @param string $url URL skript přímající WebHook |
25
|
|
|
* @param string $format json|xml formát přenášených dat |
26
|
|
|
* @return string výsledek požadavku |
27
|
|
|
*/ |
28
|
|
|
public function register($url, $format = 'json') |
29
|
|
|
{ |
30
|
|
|
$this->setDataValue('url', $url); |
31
|
|
|
$this->setDataValue('format', $format); |
32
|
|
|
return $this->insertToFlexiBee(); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Odregistruje webhook |
37
|
|
|
* |
38
|
|
|
* @param int $id číslo záznamu |
39
|
|
|
*/ |
40
|
|
|
public function unregister($id) |
41
|
|
|
{ |
42
|
|
|
return $this->deleteFromFlexiBee($id); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Povolí oznamování změn |
47
|
|
|
* @return type |
48
|
|
|
*/ |
49
|
|
|
public function enableChanges() |
50
|
|
|
{ |
51
|
|
|
$this->performRequest('changes/enable.xml', 'POST', 'xml'); |
52
|
|
|
return $this->lastResponseCode == 200; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Zakáže oznamování změn |
57
|
|
|
* @return type |
58
|
|
|
*/ |
59
|
|
|
public function disableChanges() |
60
|
|
|
{ |
61
|
|
|
$this->performRequest('changes/disable.xml', 'POST', 'xml'); |
62
|
|
|
return $this->lastResponseCode == 200; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Vrátí stav zapnutí ChangesAPI |
67
|
|
|
* |
68
|
|
|
* @return boolan |
69
|
|
|
*/ |
70
|
|
|
public function getChangesStatus() |
71
|
|
|
{ |
72
|
|
|
$status = $this->performRequest('changes/status.xml', 'GET', 'xml'); |
73
|
|
|
return (($this->lastResponseCode == 200) && ($status['success'] == 'true')); |
74
|
|
|
} |
75
|
|
|
} |