1: <?php
2:
3: namespace OpenCloud\CloudMonitoring\Resource;
4:
5: use OpenCloud\CloudMonitoring\Exception;
6:
7: /**
8: * NotificationHistory class.
9: *
10: * @extends ReadOnlyResource
11: * @implements ResourceInterface
12: */
13: class NotificationHistory extends ReadOnlyResource implements ResourceInterface
14: {
15: public $timestamp;
16: public $notification_plan_id;
17: public $transaction_id;
18: public $status;
19: public $state;
20: public $notification_results;
21: public $previous_state;
22:
23: protected static $json_name = false;
24: protected static $json_collection_name = 'values';
25: protected static $url_resource = 'notification_history';
26:
27: public function baseUrl()
28: {
29: return $this->Parent()->Url($this->Parent()->id) . '/notification_history';
30: }
31:
32: public function listChecks()
33: {
34: $response = $this->Service()->Request($this->Url());
35: return ($json = $response->httpBody()) ? json_decode($json) : false;
36: }
37:
38: public function listHistory($checkId)
39: {
40: return $this->Service()->Collection(get_class($this), $this->Url($checkId));
41: }
42:
43: public function getSingleHistoryItem($checkId, $historyId)
44: {
45: $response = $this->Service()->Request($this->Url($checkId . '/' . $historyId));
46: if ($json = $response->HttpBody()) {
47: $object = json_decode($json);
48: foreach ($object as $key => $val) {
49: $this->$key = $val;
50: }
51: }
52: return false;
53: }
54:
55: }