Completed
Push — master ( db8482...7bd7dd )
by James
03:03
created

Client::processResponse()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 7
nc 2
nop 1
1
<?php
2
/**
3
 * Contains \jamesiarmes\PhpEws\Client.
4
 */
5
6
namespace jamesiarmes\PhpEws;
7
8
/**
9
 * Base class of the Exchange Web Services application.
10
 *
11
 * @package php-ews\Client
12
 */
13
class Client
14
{
15
    /**
16
     * Microsoft Exchange 2007
17
     *
18
     * @var string
19
     */
20
    const VERSION_2007 = 'Exchange2007';
21
22
    /**
23
     * Microsoft Exchange 2007 SP1
24
     *
25
     * @var string
26
     */
27
    const VERSION_2007_SP1 = 'Exchange2007_SP1';
28
29
    /**
30
     * Microsoft Exchange 2007 SP2
31
     *
32
     * @var string
33
     */
34
    const VERSION_2007_SP2 = 'Exchange2007_SP2';
35
36
    /**
37
     * Microsoft Exchange 2007 SP3
38
     *
39
     * @var string
40
     */
41
    const VERSION_2007_SP3 = 'Exchange2007_SP3';
42
43
    /**
44
     * Microsoft Exchange 2010
45
     *
46
     * @var string
47
     */
48
    const VERSION_2010 = 'Exchange2010';
49
50
    /**
51
     * Microsoft Exchange 2010 SP1
52
     *
53
     * @var string
54
     */
55
    const VERSION_2010_SP1 = 'Exchange2010_SP1';
56
57
    /**
58
     * Microsoft Exchange 2010 SP2
59
     *
60
     * @var string
61
     */
62
    const VERSION_2010_SP2 = 'Exchange2010_SP2';
63
64
    /**
65
     * Microsoft Exchange 2013.
66
     *
67
     * @var string
68
     */
69
    const VERSION_2013 = 'Exchange2013';
70
71
    /**
72
     * Microsoft Exchange 2013 SP1.
73
     *
74
     * @var string
75
     */
76
    const VERSION_2013_SP1 = 'Exchange2013_SP1';
77
78
    /**
79
     * Microsoft Exchange 2016.
80
     *
81
     * @var string
82
     */
83
    const VERSION_2016 = 'Exchange2016';
84
85
    /**
86
     * Password to use when connecting to the Exchange server.
87
     *
88
     * @var string
89
     */
90
    protected $password;
91
92
    /**
93
     * Location of the Exchange server.
94
     *
95
     * @var string
96
     */
97
    protected $server;
98
99
    /**
100
     * SOAP client used to make the request
101
     *
102
     * @var \jamesiarmes\PhpEws\SoapClient
103
     */
104
    protected $soap;
105
106
    /**
107
     * Username to use when connecting to the Exchange server.
108
     *
109
     * @var string
110
     */
111
    protected $username;
112
113
    /**
114
     * Exchange impersonation
115
     *
116
     * @var \jamesiarmes\PhpEws\Type\ExchangeImpersonationType
117
     */
118
    protected $impersonation;
119
120
    /**
121
     * Miscrosoft Exchange version that we are going to connect to
122
     *
123
     * @var string
124
     *
125
     * @see Client::VERSION_2007
126
     * @see Client::VERSION_2007_SP1
127
     * @see Client::VERSION_2007_SP2
128
     * @see Client::VERSION_2007_SP3
129
     * @see Client::VERSION_2010
130
     * @see Client::VERSION_2010_SP1
131
     * @see Client::VERSION_2010_SP2
132
     */
133
    protected $version;
134
135
    /**
136
     * Constructor for the ExchangeWebServices class
137
     *
138
     * @param string $server
139
     * @param string $username
140
     * @param string $password
141
     * @param string $version One of the Client::VERSION_* constants.
142
     */
143
    public function __construct(
144
        $server = null,
145
        $username = null,
146
        $password = null,
147
        $version = self::VERSION_2007
148
    ) {
149
        // Set the object properties.
150
        $this->setServer($server);
151
        $this->setUsername($username);
152
        $this->setPassword($password);
153
        $this->setVersion($version);
154
    }
155
156
    /**
157
     * Returns the SOAP Client that may be used to make calls against the server
158
     *
159
     * @return \jamesiarmes\PhpEws\SoapClient
160
     */
161
    public function getClient()
162
    {
163
        return $this->initializeSoapClient();
164
    }
165
166
    /**
167
     * Sets the impersonation property
168
     *
169
     * @param \jamesiarmes\PhpEws\Type\ExchangeImpersonationType $impersonation
170
     */
171
    public function setImpersonation($impersonation)
172
    {
173
        $this->impersonation = $impersonation;
174
175
        return true;
176
    }
177
178
    /**
179
     * Sets the password property
180
     *
181
     * @param string $password
182
     */
183
    public function setPassword($password)
184
    {
185
        $this->password = $password;
186
187
        return true;
188
    }
189
190
    /**
191
     * Sets the server property
192
     *
193
     * @param string $server
194
     */
195
    public function setServer($server)
196
    {
197
        $this->server = $server;
198
199
        return true;
200
    }
201
202
    /**
203
     * Sets the user name property
204
     *
205
     * @param string $username
206
     */
207
    public function setUsername($username)
208
    {
209
        $this->username = $username;
210
211
        return true;
212
    }
213
214
    /**
215
     * Sets the version property
216
     *
217
     * @param string $version
218
     */
219
    public function setVersion($version)
220
    {
221
        $this->version = $version;
222
223
        return true;
224
    }
225
226
    /**
227
     * Function Description
228
     *
229
     * @param \jamesiarmes\PhpEws\Request\AddDelegateType $request
230
     * @return \jamesiarmes\PhpEws\Response\AddDelegateResponseMessageType
231
     */
232
    public function AddDelegate($request)
233
    {
234
        $this->initializeSoapClient();
235
        $response = $this->soap->{__FUNCTION__}($request);
236
237
        return $this->processResponse($response);
238
    }
239
240
    /**
241
     * Adds a distribution group to the instant messaging (IM) list in the
242
     * Unified Contact Store.
243
     *
244
     * @since Exchange 2013
245
     *
246
     * @param \jamesiarmes\PhpEws\Request\AddDistributionGroupToImListType $request
247
     * @return \jamesiarmes\PhpEws\Response\AddDistributionGroupToImListResponseMessageType
248
     */
249
    public function AddDistributionGroupToImList($request)
250
    {
251
        $this->initializeSoapClient();
252
        $response = $this->soap->{__FUNCTION__}($request);
253
254
        return $this->processResponse($response);
255
    }
256
257
    /**
258
     * Adds an existing instant messaging (IM) contact to a group.
259
     *
260
     * @since Exchange 2013
261
     *
262
     * @param \jamesiarmes\PhpEws\Request\AddImContactToGroup $request
263
     * @return \jamesiarmes\PhpEws\Response\AddImContactToGroupResponseMessageType
264
     */
265
    public function AddImContactToGroup($request)
266
    {
267
        $this->initializeSoapClient();
268
        $response = $this->soap->{__FUNCTION__}($request);
269
270
        return $this->processResponse($response);
271
    }
272
273
    /**
274
     * Adds a new instant messaging (IM) group to a mailbox.
275
     *
276
     * @since Exchange 2013
277
     *
278
     * @param \jamesiarmes\PhpEws\Request\AddImGroupType $request
279
     * @return \jamesiarmes\PhpEws\Response\AddImGroupResponseMessageType
280
     */
281
    public function AddImGroup($request)
282
    {
283
        $this->initializeSoapClient();
284
        $response = $this->soap->{__FUNCTION__}($request);
285
286
        return $this->processResponse($response);
287
    }
288
289
    /**
290
     * Adds a new contact to an instant messaging (IM) group.
291
     *
292
     * @since Exchange 2013
293
     *
294
     * @param \jamesiarmes\PhpEws\Request\AddNewImContactToGroup $request
295
     * @return \jamesiarmes\PhpEws\Response\AddNewImContactToGroupResponseMessageType
296
     */
297
    public function AddNewImContactToGroup($request)
298
    {
299
        $this->initializeSoapClient();
300
        $response = $this->soap->{__FUNCTION__}($request);
301
302
        return $this->processResponse($response);
303
    }
304
305
    /**
306
     * Adds a new contact to a group based on a contact's phone number.
307
     *
308
     * @since Exchange 2013
309
     *
310
     * @param \jamesiarmes\PhpEws\Request\AddNewTelUriContactToGroupType $request
311
     * @return \jamesiarmes\PhpEws\Response\AddNewTelUriContactToGroupResponse
312
     */
313
    public function AddNewTelUriContactToGroup($request)
314
    {
315
        $this->initializeSoapClient();
316
        $response = $this->soap->{__FUNCTION__}($request);
317
318
        return $this->processResponse($response);
319
    }
320
321
    /**
322
     * Sets a one-time or follow up action on all the items in a conversation.
323
     *
324
     * This operation allows you to categorize, move, copy, delete, and set the
325
     * read state on all items in a conversation. Actions can also be set for
326
     * new messages in a conversation.
327
     *
328
     * @since Exchange 2010 SP1
329
     *
330
     * @param \jamesiarmes\PhpEws\Request\ApplyConversationActionType $request
331
     * @return \jamesiarmes\PhpEws\Response\ApplyConversationActionResponseType
332
     */
333
    public function ApplyConversationAction($request)
334
    {
335
        $this->initializeSoapClient();
336
        $response = $this->soap->{__FUNCTION__}($request);
337
338
        return $this->processResponse($response);
339
    }
340
341
    /**
342
     * Moves an item into the mailbox user's archive mailbox.
343
     *
344
     * @since Exchange 2013
345
     *
346
     * @param \jamesiarmes\PhpEws\Request\ArchiveItemType $request
347
     * @return \jamesiarmes\PhpEws\Response\ArchiveItemResponse
348
     */
349
    public function ArchiveItem($request)
350
    {
351
        $this->initializeSoapClient();
352
        $response = $this->soap->{__FUNCTION__}($request);
353
354
        return $this->processResponse($response);
355
    }
356
357
    /**
358
     * Function Description
359
     *
360
     * @param \jamesiarmes\PhpEws\Request\ConvertIdType $request
361
     * @return \jamesiarmes\PhpEws\Response\ConvertIdResponseType
362
     */
363
    public function ConvertId($request)
364
    {
365
        $this->initializeSoapClient();
366
        $response = $this->soap->{__FUNCTION__}($request);
367
368
        return $this->processResponse($response);
369
    }
370
371
    /**
372
     * Function Description
373
     *
374
     * @param \jamesiarmes\PhpEws\Request\CopyFolderType $request
375
     * @return \jamesiarmes\PhpEws\Response\CopyFolderResponseType
376
     */
377
    public function CopyFolder($request)
378
    {
379
        $this->initializeSoapClient();
380
        $response = $this->soap->{__FUNCTION__}($request);
381
382
        return $this->processResponse($response);
383
    }
384
385
    /**
386
     * Function Description
387
     *
388
     * @param \jamesiarmes\PhpEws\Request\CopyItemType $request
389
     * @return \jamesiarmes\PhpEws\Response\CopyItemResponseType
390
     */
391
    public function CopyItem($request)
392
    {
393
        $this->initializeSoapClient();
394
        $response = $this->soap->{__FUNCTION__}($request);
395
396
        return $this->processResponse($response);
397
    }
398
399
    /**
400
     * Function Description
401
     *
402
     * @param \jamesiarmes\PhpEws\Request\CreateAttachmentType $request
403
     * @return \jamesiarmes\PhpEws\Response\CreateAttachmentResponseType
404
     */
405
    public function CreateAttachment($request)
406
    {
407
        $this->initializeSoapClient();
408
        $response = $this->soap->{__FUNCTION__}($request);
409
410
        return $this->processResponse($response);
411
    }
412
413
    /**
414
     * Function Description
415
     *
416
     * @param \jamesiarmes\PhpEws\Request\CreateFolderType $request
417
     * @return \jamesiarmes\PhpEws\Response\CreateFolderResponseType
418
     */
419
    public function CreateFolder($request)
420
    {
421
        $this->initializeSoapClient();
422
        $response = $this->soap->{__FUNCTION__}($request);
423
424
        return $this->processResponse($response);
425
    }
426
427
    /**
428
     * Function Description
429
     *
430
     * @param \jamesiarmes\PhpEws\Request\CreateItemType $request
431
     * @return \jamesiarmes\PhpEws\Response\CreateItemResponseType
432
     */
433
    public function CreateItem($request)
434
    {
435
        $this->initializeSoapClient();
436
        $response = $this->soap->{__FUNCTION__}($request);
437
438
        return $this->processResponse($response);
439
    }
440
441
    /**
442
     * Function Description
443
     *
444
     * @param \jamesiarmes\PhpEws\Request\CreateManagedFolderRequestType $request
445
     * @return \jamesiarmes\PhpEws\Response\CreateManagedFolderResponseType
446
     */
447
    public function CreateManagedFolder($request)
448
    {
449
        $this->initializeSoapClient();
450
        $response = $this->soap->{__FUNCTION__}($request);
451
452
        return $this->processResponse($response);
453
    }
454
455
    /**
456
     * Function Description
457
     *
458
     * @param \jamesiarmes\PhpEws\Request\DeleteAttachmentType $request
459
     * @return \jamesiarmes\PhpEws\Response\DeleteAttachmentResponseType
460
     */
461
    public function DeleteAttachment($request)
462
    {
463
        $this->initializeSoapClient();
464
        $response = $this->soap->{__FUNCTION__}($request);
465
466
        return $this->processResponse($response);
467
    }
468
469
    /**
470
     * Function Description
471
     *
472
     * @param \jamesiarmes\PhpEws\Request\DeleteFolderType $request
473
     * @return \jamesiarmes\PhpEws\Response\DeleteFolderResponseType
474
     */
475
    public function DeleteFolder($request)
476
    {
477
        $this->initializeSoapClient();
478
        $response = $this->soap->{__FUNCTION__}($request);
479
480
        return $this->processResponse($response);
481
    }
482
483
    /**
484
     * Function Description
485
     *
486
     * @param \jamesiarmes\PhpEws\Request\DeleteItemType $request
487
     * @return \jamesiarmes\PhpEws\Response\DeleteItemResponseType
488
     */
489
    public function DeleteItem($request)
490
    {
491
        $this->initializeSoapClient();
492
        $response = $this->soap->{__FUNCTION__}($request);
493
494
        return $this->processResponse($response);
495
    }
496
497
    /**
498
     * Function Description
499
     *
500
     * @param \jamesiarmes\PhpEws\Request\ExpandDLType $request
501
     * @return \jamesiarmes\PhpEws\Response\ExpandDLResponseType
502
     */
503
    public function ExpandDL($request)
504
    {
505
        $this->initializeSoapClient();
506
        $response = $this->soap->{__FUNCTION__}($request);
507
508
        return $this->processResponse($response);
509
    }
510
511
    /**
512
     * Function Description
513
     *
514
     * @param \jamesiarmes\PhpEws\Request\FindFolderType $request
515
     * @return \jamesiarmes\PhpEws\Response\FindFolderResponseType
516
     */
517
    public function FindFolder($request)
518
    {
519
        $this->initializeSoapClient();
520
        $response = $this->soap->{__FUNCTION__}($request);
521
522
        return $this->processResponse($response);
523
    }
524
525
    /**
526
     * Function Description
527
     *
528
     * @param \jamesiarmes\PhpEws\Request\FindItemType $request
529
     * @return \jamesiarmes\PhpEws\Response\FindItemResponseType
530
     */
531
    public function FindItem($request)
532
    {
533
        $this->initializeSoapClient();
534
        $response = $this->soap->{__FUNCTION__}($request);
535
536
        return $this->processResponse($response);
537
    }
538
539
    /**
540
     * Function Description
541
     *
542
     * @param \jamesiarmes\PhpEws\Request\GetAttachmentType $request
543
     * @return \jamesiarmes\PhpEws\Response\GetAttachmentResponseType
544
     */
545
    public function GetAttachment($request)
546
    {
547
        $this->initializeSoapClient();
548
        $response = $this->soap->{__FUNCTION__}($request);
549
550
        return $this->processResponse($response);
551
    }
552
553
    /**
554
     * Function Description
555
     *
556
     * @param \jamesiarmes\PhpEws\Request\GetDelegateType $request
557
     * @return \jamesiarmes\PhpEws\Response\GetDelegateResponseMessageType
558
     */
559
    public function GetDelegate($request)
560
    {
561
        $this->initializeSoapClient();
562
        $response = $this->soap->{__FUNCTION__}($request);
563
564
        return $this->processResponse($response);
565
    }
566
567
    /**
568
     * Function Description
569
     *
570
     * @param \jamesiarmes\PhpEws\Request\GetEventsType $request
571
     * @return \jamesiarmes\PhpEws\Response\GetEventsResponseType
572
     */
573
    public function GetEvents($request)
574
    {
575
        $this->initializeSoapClient();
576
        $response = $this->soap->{__FUNCTION__}($request);
577
578
        return $this->processResponse($response);
579
    }
580
581
    /**
582
     * Function Description
583
     *
584
     * @param \jamesiarmes\PhpEws\Request\GetFolderType $request
585
     * @return \jamesiarmes\PhpEws\Response\GetFolderResponseType
586
     */
587
    public function GetFolder($request)
588
    {
589
        $this->initializeSoapClient();
590
        $response = $this->soap->{__FUNCTION__}($request);
591
592
        return $this->processResponse($response);
593
    }
594
595
    /**
596
     * Function Description
597
     *
598
     * @param \jamesiarmes\PhpEws\Request\GetItemType $request
599
     * @return \jamesiarmes\PhpEws\Response\GetItemResponseType
600
     */
601
    public function GetItem($request)
602
    {
603
        $this->initializeSoapClient();
604
        $response = $this->soap->{__FUNCTION__}($request);
605
606
        return $this->processResponse($response);
607
    }
608
609
    /**
610
     * Retrieve the timezones supported by the server.
611
     *
612
     * @since Exchange 2010
613
     *
614
     * @param \jamesiarmes\PhpEws\Request\GetServerTimeZonesType $request
615
     * @return \jamesiarmes\PhpEws\Response\GetServerTimeZonesResponseType
616
     */
617
    public function GetServerTimeZones($request)
618
    {
619
        $this->initializeSoapClient();
620
        $response = $this->soap->{__FUNCTION__}($request);
621
622
        return $this->processResponse($response);
623
    }
624
625
    /**
626
     * Function Description
627
     *
628
     * @param \jamesiarmes\PhpEws\Request\GetUserAvailabilityRequestType $request
629
     * @return \jamesiarmes\PhpEws\Response\GetUserAvailabilityResponseType
630
     */
631
    public function GetUserAvailability($request)
632
    {
633
        $this->initializeSoapClient();
634
        $response = $this->soap->{__FUNCTION__}($request);
635
636
        return $this->processResponse($response);
637
    }
638
639
    /**
640
     * Function Description
641
     *
642
     * @param \jamesiarmes\PhpEws\Request\GetUserOofSettingsRequest $request
643
     * @return \jamesiarmes\PhpEws\Response\GetUserOofSettingsResponse
644
     */
645
    public function GetUserOofSettings($request)
646
    {
647
        $this->initializeSoapClient();
648
        $response = $this->soap->{__FUNCTION__}($request);
649
650
        return $this->processResponse($response);
651
    }
652
653
    /**
654
     * Function Description
655
     *
656
     * @param \jamesiarmes\PhpEws\Request\MoveFolderType $request
657
     * @return \jamesiarmes\PhpEws\Response\MoveFolderResponseType
658
     */
659
    public function MoveFolder($request)
660
    {
661
        $this->initializeSoapClient();
662
        $response = $this->soap->{__FUNCTION__}($request);
663
664
        return $this->processResponse($response);
665
    }
666
667
    /**
668
     * Function Description
669
     *
670
     * @param \jamesiarmes\PhpEws\Request\MoveItemType $request
671
     * @return \jamesiarmes\PhpEws\Response\MoveItemResponseType
672
     */
673
    public function MoveItem($request)
674
    {
675
        $this->initializeSoapClient();
676
        $response = $this->soap->{__FUNCTION__}($request);
677
678
        return $this->processResponse($response);
679
    }
680
681
    /**
682
     * Function Description
683
     *
684
     * @param \jamesiarmes\PhpEws\Request\RemoveDelegateType $request
685
     * @return \jamesiarmes\PhpEws\Response\RemoveDelegateResponseMessageType
686
     */
687
    public function RemoveDelegate($request)
688
    {
689
        $this->initializeSoapClient();
690
        $response = $this->soap->{__FUNCTION__}($request);
691
692
        return $this->processResponse($response);
693
    }
694
695
    /**
696
     * Function Description
697
     *
698
     * @param \jamesiarmes\PhpEws\Request\ResolveNamesType $request
699
     * @return \jamesiarmes\PhpEws\Response\ResolveNamesResponseType
700
     */
701
    public function ResolveNames($request)
702
    {
703
        $this->initializeSoapClient();
704
        $response = $this->soap->{__FUNCTION__}($request);
705
706
        return $this->processResponse($response);
707
    }
708
709
    /**
710
     * Function Description
711
     *
712
     * @param \jamesiarmes\PhpEws\Request\SendItemType $request
713
     * @return \jamesiarmes\PhpEws\Response\SendItemResponseType
714
     */
715
    public function SendItem($request)
716
    {
717
        $this->initializeSoapClient();
718
        $response = $this->soap->{__FUNCTION__}($request);
719
720
        return $this->processResponse($response);
721
    }
722
723
    /**
724
     * Function Description
725
     *
726
     * @param \jamesiarmes\PhpEws\Request\SetUserOofSettingsRequest $request
727
     * @return \jamesiarmes\PhpEws\Response\SetUserOofSettingsResponse
728
     */
729
    public function SetUserOofSettings($request)
730
    {
731
        $this->initializeSoapClient();
732
        $response = $this->soap->{__FUNCTION__}($request);
733
734
        return $this->processResponse($response);
735
    }
736
737
    /**
738
     * Function Description
739
     *
740
     * @param \jamesiarmes\PhpEws\Request\SubscribeType $request
741
     * @return \jamesiarmes\PhpEws\Response\SubscribeResponseType
742
     */
743
    public function Subscribe($request)
744
    {
745
        $this->initializeSoapClient();
746
        $response = $this->soap->{__FUNCTION__}($request);
747
748
        return $this->processResponse($response);
749
    }
750
751
    /**
752
     * Function Description
753
     *
754
     * @param \jamesiarmes\PhpEws\Request\SyncFolderHierarchyType $request
755
     * @return \jamesiarmes\PhpEws\Response\SyncFolderHierarchyResponseType
756
     */
757
    public function SyncFolderHierarchy($request)
758
    {
759
        $this->initializeSoapClient();
760
        $response = $this->soap->{__FUNCTION__}($request);
761
762
        return $this->processResponse($response);
763
    }
764
765
    /**
766
     * Function Description
767
     *
768
     * @param \jamesiarmes\PhpEws\Request\SyncFolderItemsType $request
769
     * @return \jamesiarmes\PhpEws\Response\SyncFolderItemsResponseType
770
     */
771
    public function SyncFolderItems($request)
772
    {
773
        $this->initializeSoapClient();
774
        $response = $this->soap->{__FUNCTION__}($request);
775
776
        return $this->processResponse($response);
777
    }
778
779
    /**
780
     * Function Description
781
     *
782
     * @param \jamesiarmes\PhpEws\Request\UnsubscribeType $request
783
     * @return \jamesiarmes\PhpEws\Response\UnsubscribeResponseType
784
     */
785
    public function Unsubscribe($request)
786
    {
787
        $this->initializeSoapClient();
788
        $response = $this->soap->{__FUNCTION__}($request);
789
790
        return $this->processResponse($response);
791
    }
792
793
    /**
794
     * Function Description
795
     *
796
     * @param \jamesiarmes\PhpEws\Request\UpdateDelegateType $request
797
     * @return \jamesiarmes\PhpEws\Response\UpdateDelegateResponseMessageType
798
     */
799
    public function UpdateDelegate($request)
800
    {
801
        $this->initializeSoapClient();
802
        $response = $this->soap->{__FUNCTION__}($request);
803
804
        return $this->processResponse($response);
805
    }
806
807
    /**
808
     * Function Description
809
     *
810
     * @param \jamesiarmes\PhpEws\Request\UpdateFolderType $request
811
     * @return \jamesiarmes\PhpEws\Response\UpdateFolderResponseType
812
     */
813
    public function UpdateFolder($request)
814
    {
815
        $this->initializeSoapClient();
816
        $response = $this->soap->{__FUNCTION__}($request);
817
818
        return $this->processResponse($response);
819
    }
820
821
    /**
822
     * Function Description
823
     *
824
     * @param \jamesiarmes\PhpEws\Request\UpdateItemType $request
825
     * @return \jamesiarmes\PhpEws\Response\UpdateItemResponseType
826
     */
827
    public function UpdateItem($request)
828
    {
829
        $this->initializeSoapClient();
830
        $response = $this->soap->{__FUNCTION__}($request);
831
832
        return $this->processResponse($response);
833
    }
834
835
    /**
836
     * Initializes the SoapClient object to make a request
837
     *
838
     * @return \jamesiarmes\PhpEws\SoapClient
839
     *
840
     * TODO: Build a class map that we can pass to the client.
841
     */
842
    protected function initializeSoapClient()
843
    {
844
        $this->soap = new SoapClient(
845
            dirname(__FILE__) . '/assets/services.wsdl',
846
            array(
847
                'user' => $this->username,
848
                'password' => $this->password,
849
                'version' => $this->version,
850
                'location' => 'https://' . $this->server . '/EWS/Exchange.asmx',
851
                'impersonation' => $this->impersonation,
852
            )
853
        );
854
855
        return $this->soap;
856
    }
857
858
    /**
859
     * Process a response to verify that it succeeded and take the appropriate
860
     * action
861
     *
862
     * @throws \Exception
863
     *
864
     * @param \stdClass $response
865
     * @return \stdClass
866
     */
867
    protected function processResponse($response)
868
    {
869
        // If the soap call failed then we need to throw an exception.
870
        $code = $this->soap->getResponseCode();
871
        if ($code != 200) {
872
            throw new \Exception(
873
                "SOAP client returned status of $code.",
874
                $code
875
            );
876
        }
877
878
        return $response;
879
    }
880
}
881