1
|
|
|
<?php namespace OutlookRestClient\Facade\Requests; |
2
|
|
|
/** |
3
|
|
|
* Copyright 2017 OpenStack Foundation |
4
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
5
|
|
|
* you may not use this file except in compliance with the License. |
6
|
|
|
* You may obtain a copy of the License at |
7
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
8
|
|
|
* Unless required by applicable law or agreed to in writing, software |
9
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
10
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
11
|
|
|
* See the License for the specific language governing permissions and |
12
|
|
|
* limitations under the License. |
13
|
|
|
**/ |
14
|
|
|
use DateTime; |
15
|
|
|
use DateTimeZone; |
16
|
|
|
use phpDocumentor\Reflection\Location; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Class EventVO |
20
|
|
|
* @package OutlookRestClient\Facade |
21
|
|
|
*/ |
22
|
|
|
final class EventVO implements IValueObject |
23
|
|
|
{ |
24
|
|
|
const DateTimeFormat = "Y-m-d\TH:i:s"; |
25
|
|
|
/** |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
private $subject; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
private $body; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
private $body_preview; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var DateTime |
42
|
|
|
*/ |
43
|
|
|
private $start; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var DateTime |
47
|
|
|
*/ |
48
|
|
|
private $end; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var DateTimeZone |
52
|
|
|
*/ |
53
|
|
|
private $time_zone; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var LocationVO |
57
|
|
|
*/ |
58
|
|
|
private $location; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* EventVO constructor. |
62
|
|
|
* @param string $subject |
63
|
|
|
* @param string $body |
64
|
|
|
* @param DateTime $start |
65
|
|
|
* @param DateTime $end |
66
|
|
|
* @param DateTimeZone $time_zone |
67
|
|
|
* @param LocationVO $location |
68
|
|
|
*/ |
69
|
|
|
public function __construct |
70
|
|
|
( |
71
|
|
|
$subject, |
72
|
|
|
$body, |
73
|
|
|
DateTime $start, |
74
|
|
|
DateTime $end, |
75
|
|
|
DateTimeZone $time_zone = null, |
76
|
|
|
LocationVO $location = null |
77
|
|
|
) |
78
|
|
|
{ |
79
|
|
|
$this->subject = $subject; |
80
|
|
|
$this->body = $body; |
81
|
|
|
$this->start = $start; |
82
|
|
|
$this->end = $end; |
83
|
|
|
$this->time_zone = $time_zone; |
84
|
|
|
$this->location = $location; |
85
|
|
|
|
86
|
|
|
if(is_null($this->time_zone)){ |
87
|
|
|
$this->time_zone = new DateTimeZone('UTC'); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return array |
93
|
|
|
*/ |
94
|
|
|
public function toArray(){ |
95
|
|
|
return [ |
96
|
|
|
'Subject' => $this->subject, |
97
|
|
|
"Body" => [ |
98
|
|
|
"ContentType" => "HTML", |
99
|
|
|
"Content" => $this->body |
100
|
|
|
], |
101
|
|
|
"BodyPreview" => $this->body_preview, |
102
|
|
|
// https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/datetimetimezone |
103
|
|
|
"Start" => [ |
104
|
|
|
"DateTime" => $this->start->format(self::DateTimeFormat), |
105
|
|
|
"TimeZone" => $this->time_zone->getName() |
106
|
|
|
], |
107
|
|
|
"End" => [ |
108
|
|
|
"DateTime" => $this->end->format(self::DateTimeFormat), |
109
|
|
|
"TimeZone" => $this->time_zone->getName() |
110
|
|
|
], |
111
|
|
|
"Location" => $this->location->toArray() |
112
|
|
|
]; |
113
|
|
|
} |
114
|
|
|
} |