Completed
Push — master ( 665a4f...4b89eb )
by James
02:51
created

Client::AddDistributionGroupToImList()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 4
nc 1
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
     * @param \jamesiarmes\PhpEws\Request\AddDistributionGroupToImListType $request
245
     * @return \jamesiarmes\PhpEws\Response\AddDistributionGroupToImListResponseMessageType
246
     *
247
     * @since Exchange 2013
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
     * @param \jamesiarmes\PhpEws\Request\AddImContactToGroup $request
261
     * @return \jamesiarmes\PhpEws\Response\AddImContactToGroupResponseMessageType
262
     *
263
     * @since Exchange 2013
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
     * @param \jamesiarmes\PhpEws\Request\AddImGroupType $request
277
     * @return \jamesiarmes\PhpEws\Response\AddImGroupResponseMessageType
278
     *
279
     * @since Exchange 2013
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
     * Function Description
291
     *
292
     * @param \jamesiarmes\PhpEws\Request\ConvertIdType $request
293
     * @return \jamesiarmes\PhpEws\Response\ConvertIdResponseType
294
     */
295
    public function ConvertId($request)
296
    {
297
        $this->initializeSoapClient();
298
        $response = $this->soap->{__FUNCTION__}($request);
299
300
        return $this->processResponse($response);
301
    }
302
303
    /**
304
     * Function Description
305
     *
306
     * @param \jamesiarmes\PhpEws\Request\CopyFolderType $request
307
     * @return \jamesiarmes\PhpEws\Response\CopyFolderResponseType
308
     */
309
    public function CopyFolder($request)
310
    {
311
        $this->initializeSoapClient();
312
        $response = $this->soap->{__FUNCTION__}($request);
313
314
        return $this->processResponse($response);
315
    }
316
317
    /**
318
     * Function Description
319
     *
320
     * @param \jamesiarmes\PhpEws\Request\CopyItemType $request
321
     * @return \jamesiarmes\PhpEws\Response\CopyItemResponseType
322
     */
323
    public function CopyItem($request)
324
    {
325
        $this->initializeSoapClient();
326
        $response = $this->soap->{__FUNCTION__}($request);
327
328
        return $this->processResponse($response);
329
    }
330
331
    /**
332
     * Function Description
333
     *
334
     * @param \jamesiarmes\PhpEws\Request\CreateAttachmentType $request
335
     * @return \jamesiarmes\PhpEws\Response\CreateAttachmentResponseType
336
     */
337
    public function CreateAttachment($request)
338
    {
339
        $this->initializeSoapClient();
340
        $response = $this->soap->{__FUNCTION__}($request);
341
342
        return $this->processResponse($response);
343
    }
344
345
    /**
346
     * Function Description
347
     *
348
     * @param \jamesiarmes\PhpEws\Request\CreateFolderType $request
349
     * @return \jamesiarmes\PhpEws\Response\CreateFolderResponseType
350
     */
351
    public function CreateFolder($request)
352
    {
353
        $this->initializeSoapClient();
354
        $response = $this->soap->{__FUNCTION__}($request);
355
356
        return $this->processResponse($response);
357
    }
358
359
    /**
360
     * Function Description
361
     *
362
     * @param \jamesiarmes\PhpEws\Request\CreateItemType $request
363
     * @return \jamesiarmes\PhpEws\Response\CreateItemResponseType
364
     */
365
    public function CreateItem($request)
366
    {
367
        $this->initializeSoapClient();
368
        $response = $this->soap->{__FUNCTION__}($request);
369
370
        return $this->processResponse($response);
371
    }
372
373
    /**
374
     * Function Description
375
     *
376
     * @param \jamesiarmes\PhpEws\Request\CreateManagedFolderRequestType $request
377
     * @return \jamesiarmes\PhpEws\Response\CreateManagedFolderResponseType
378
     */
379
    public function CreateManagedFolder($request)
380
    {
381
        $this->initializeSoapClient();
382
        $response = $this->soap->{__FUNCTION__}($request);
383
384
        return $this->processResponse($response);
385
    }
386
387
    /**
388
     * Function Description
389
     *
390
     * @param \jamesiarmes\PhpEws\Request\DeleteAttachmentType $request
391
     * @return \jamesiarmes\PhpEws\Response\DeleteAttachmentResponseType
392
     */
393
    public function DeleteAttachment($request)
394
    {
395
        $this->initializeSoapClient();
396
        $response = $this->soap->{__FUNCTION__}($request);
397
398
        return $this->processResponse($response);
399
    }
400
401
    /**
402
     * Function Description
403
     *
404
     * @param \jamesiarmes\PhpEws\Request\DeleteFolderType $request
405
     * @return \jamesiarmes\PhpEws\Response\DeleteFolderResponseType
406
     */
407
    public function DeleteFolder($request)
408
    {
409
        $this->initializeSoapClient();
410
        $response = $this->soap->{__FUNCTION__}($request);
411
412
        return $this->processResponse($response);
413
    }
414
415
    /**
416
     * Function Description
417
     *
418
     * @param \jamesiarmes\PhpEws\Request\DeleteItemType $request
419
     * @return \jamesiarmes\PhpEws\Response\DeleteItemResponseType
420
     */
421
    public function DeleteItem($request)
422
    {
423
        $this->initializeSoapClient();
424
        $response = $this->soap->{__FUNCTION__}($request);
425
426
        return $this->processResponse($response);
427
    }
428
429
    /**
430
     * Function Description
431
     *
432
     * @param \jamesiarmes\PhpEws\Request\ExpandDLType $request
433
     * @return \jamesiarmes\PhpEws\Response\ExpandDLResponseType
434
     */
435
    public function ExpandDL($request)
436
    {
437
        $this->initializeSoapClient();
438
        $response = $this->soap->{__FUNCTION__}($request);
439
440
        return $this->processResponse($response);
441
    }
442
443
    /**
444
     * Function Description
445
     *
446
     * @param \jamesiarmes\PhpEws\Request\FindFolderType $request
447
     * @return \jamesiarmes\PhpEws\Response\FindFolderResponseType
448
     */
449
    public function FindFolder($request)
450
    {
451
        $this->initializeSoapClient();
452
        $response = $this->soap->{__FUNCTION__}($request);
453
454
        return $this->processResponse($response);
455
    }
456
457
    /**
458
     * Function Description
459
     *
460
     * @param \jamesiarmes\PhpEws\Request\FindItemType $request
461
     * @return \jamesiarmes\PhpEws\Response\FindItemResponseType
462
     */
463
    public function FindItem($request)
464
    {
465
        $this->initializeSoapClient();
466
        $response = $this->soap->{__FUNCTION__}($request);
467
468
        return $this->processResponse($response);
469
    }
470
471
    /**
472
     * Function Description
473
     *
474
     * @param \jamesiarmes\PhpEws\Request\GetAttachmentType $request
475
     * @return \jamesiarmes\PhpEws\Response\GetAttachmentResponseType
476
     */
477
    public function GetAttachment($request)
478
    {
479
        $this->initializeSoapClient();
480
        $response = $this->soap->{__FUNCTION__}($request);
481
482
        return $this->processResponse($response);
483
    }
484
485
    /**
486
     * Function Description
487
     *
488
     * @param \jamesiarmes\PhpEws\Request\GetDelegateType $request
489
     * @return \jamesiarmes\PhpEws\Response\GetDelegateResponseMessageType
490
     */
491
    public function GetDelegate($request)
492
    {
493
        $this->initializeSoapClient();
494
        $response = $this->soap->{__FUNCTION__}($request);
495
496
        return $this->processResponse($response);
497
    }
498
499
    /**
500
     * Function Description
501
     *
502
     * @param \jamesiarmes\PhpEws\Request\GetEventsType $request
503
     * @return \jamesiarmes\PhpEws\Response\GetEventsResponseType
504
     */
505
    public function GetEvents($request)
506
    {
507
        $this->initializeSoapClient();
508
        $response = $this->soap->{__FUNCTION__}($request);
509
510
        return $this->processResponse($response);
511
    }
512
513
    /**
514
     * Function Description
515
     *
516
     * @param \jamesiarmes\PhpEws\Request\GetFolderType $request
517
     * @return \jamesiarmes\PhpEws\Response\GetFolderResponseType
518
     */
519
    public function GetFolder($request)
520
    {
521
        $this->initializeSoapClient();
522
        $response = $this->soap->{__FUNCTION__}($request);
523
524
        return $this->processResponse($response);
525
    }
526
527
    /**
528
     * Function Description
529
     *
530
     * @param \jamesiarmes\PhpEws\Request\GetItemType $request
531
     * @return \jamesiarmes\PhpEws\Response\GetItemResponseType
532
     */
533
    public function GetItem($request)
534
    {
535
        $this->initializeSoapClient();
536
        $response = $this->soap->{__FUNCTION__}($request);
537
538
        return $this->processResponse($response);
539
    }
540
541
    /**
542
     * Retrieve the timezones supported by the server.
543
     *
544
     * @since Exchange 2010
545
     *
546
     * @param \jamesiarmes\PhpEws\Request\GetServerTimeZonesType $request
547
     * @return \jamesiarmes\PhpEws\Response\GetServerTimeZonesResponseType
548
     */
549
    public function GetServerTimeZones($request)
550
    {
551
        $this->initializeSoapClient();
552
        $response = $this->soap->{__FUNCTION__}($request);
553
554
        return $this->processResponse($response);
555
    }
556
557
    /**
558
     * Function Description
559
     *
560
     * @param \jamesiarmes\PhpEws\Request\GetUserAvailabilityRequestType $request
561
     * @return \jamesiarmes\PhpEws\Response\GetUserAvailabilityResponseType
562
     */
563
    public function GetUserAvailability($request)
564
    {
565
        $this->initializeSoapClient();
566
        $response = $this->soap->{__FUNCTION__}($request);
567
568
        return $this->processResponse($response);
569
    }
570
571
    /**
572
     * Function Description
573
     *
574
     * @param \jamesiarmes\PhpEws\Request\GetUserOofSettingsRequest $request
575
     * @return \jamesiarmes\PhpEws\Response\GetUserOofSettingsResponse
576
     */
577
    public function GetUserOofSettings($request)
578
    {
579
        $this->initializeSoapClient();
580
        $response = $this->soap->{__FUNCTION__}($request);
581
582
        return $this->processResponse($response);
583
    }
584
585
    /**
586
     * Function Description
587
     *
588
     * @param \jamesiarmes\PhpEws\Request\MoveFolderType $request
589
     * @return \jamesiarmes\PhpEws\Response\MoveFolderResponseType
590
     */
591
    public function MoveFolder($request)
592
    {
593
        $this->initializeSoapClient();
594
        $response = $this->soap->{__FUNCTION__}($request);
595
596
        return $this->processResponse($response);
597
    }
598
599
    /**
600
     * Function Description
601
     *
602
     * @param \jamesiarmes\PhpEws\Request\MoveItemType $request
603
     * @return \jamesiarmes\PhpEws\Response\MoveItemResponseType
604
     */
605
    public function MoveItem($request)
606
    {
607
        $this->initializeSoapClient();
608
        $response = $this->soap->{__FUNCTION__}($request);
609
610
        return $this->processResponse($response);
611
    }
612
613
    /**
614
     * Function Description
615
     *
616
     * @param \jamesiarmes\PhpEws\Request\RemoveDelegateType $request
617
     * @return \jamesiarmes\PhpEws\Response\RemoveDelegateResponseMessageType
618
     */
619
    public function RemoveDelegate($request)
620
    {
621
        $this->initializeSoapClient();
622
        $response = $this->soap->{__FUNCTION__}($request);
623
624
        return $this->processResponse($response);
625
    }
626
627
    /**
628
     * Function Description
629
     *
630
     * @param \jamesiarmes\PhpEws\Request\ResolveNamesType $request
631
     * @return \jamesiarmes\PhpEws\Response\ResolveNamesResponseType
632
     */
633
    public function ResolveNames($request)
634
    {
635
        $this->initializeSoapClient();
636
        $response = $this->soap->{__FUNCTION__}($request);
637
638
        return $this->processResponse($response);
639
    }
640
641
    /**
642
     * Function Description
643
     *
644
     * @param \jamesiarmes\PhpEws\Request\SendItemType $request
645
     * @return \jamesiarmes\PhpEws\Response\SendItemResponseType
646
     */
647
    public function SendItem($request)
648
    {
649
        $this->initializeSoapClient();
650
        $response = $this->soap->{__FUNCTION__}($request);
651
652
        return $this->processResponse($response);
653
    }
654
655
    /**
656
     * Function Description
657
     *
658
     * @param \jamesiarmes\PhpEws\Request\SetUserOofSettingsRequest $request
659
     * @return \jamesiarmes\PhpEws\Response\SetUserOofSettingsResponse
660
     */
661
    public function SetUserOofSettings($request)
662
    {
663
        $this->initializeSoapClient();
664
        $response = $this->soap->{__FUNCTION__}($request);
665
666
        return $this->processResponse($response);
667
    }
668
669
    /**
670
     * Function Description
671
     *
672
     * @param \jamesiarmes\PhpEws\Request\SubscribeType $request
673
     * @return \jamesiarmes\PhpEws\Response\SubscribeResponseType
674
     */
675
    public function Subscribe($request)
676
    {
677
        $this->initializeSoapClient();
678
        $response = $this->soap->{__FUNCTION__}($request);
679
680
        return $this->processResponse($response);
681
    }
682
683
    /**
684
     * Function Description
685
     *
686
     * @param \jamesiarmes\PhpEws\Request\SyncFolderHierarchyType $request
687
     * @return \jamesiarmes\PhpEws\Response\SyncFolderHierarchyResponseType
688
     */
689
    public function SyncFolderHierarchy($request)
690
    {
691
        $this->initializeSoapClient();
692
        $response = $this->soap->{__FUNCTION__}($request);
693
694
        return $this->processResponse($response);
695
    }
696
697
    /**
698
     * Function Description
699
     *
700
     * @param \jamesiarmes\PhpEws\Request\SyncFolderItemsType $request
701
     * @return \jamesiarmes\PhpEws\Response\SyncFolderItemsResponseType
702
     */
703
    public function SyncFolderItems($request)
704
    {
705
        $this->initializeSoapClient();
706
        $response = $this->soap->{__FUNCTION__}($request);
707
708
        return $this->processResponse($response);
709
    }
710
711
    /**
712
     * Function Description
713
     *
714
     * @param \jamesiarmes\PhpEws\Request\UnsubscribeType $request
715
     * @return \jamesiarmes\PhpEws\Response\UnsubscribeResponseType
716
     */
717
    public function Unsubscribe($request)
718
    {
719
        $this->initializeSoapClient();
720
        $response = $this->soap->{__FUNCTION__}($request);
721
722
        return $this->processResponse($response);
723
    }
724
725
    /**
726
     * Function Description
727
     *
728
     * @param \jamesiarmes\PhpEws\Request\UpdateDelegateType $request
729
     * @return \jamesiarmes\PhpEws\Response\UpdateDelegateResponseMessageType
730
     */
731
    public function UpdateDelegate($request)
732
    {
733
        $this->initializeSoapClient();
734
        $response = $this->soap->{__FUNCTION__}($request);
735
736
        return $this->processResponse($response);
737
    }
738
739
    /**
740
     * Function Description
741
     *
742
     * @param \jamesiarmes\PhpEws\Request\UpdateFolderType $request
743
     * @return \jamesiarmes\PhpEws\Response\UpdateFolderResponseType
744
     */
745
    public function UpdateFolder($request)
746
    {
747
        $this->initializeSoapClient();
748
        $response = $this->soap->{__FUNCTION__}($request);
749
750
        return $this->processResponse($response);
751
    }
752
753
    /**
754
     * Function Description
755
     *
756
     * @param \jamesiarmes\PhpEws\Request\UpdateItemType $request
757
     * @return \jamesiarmes\PhpEws\Response\UpdateItemResponseType
758
     */
759
    public function UpdateItem($request)
760
    {
761
        $this->initializeSoapClient();
762
        $response = $this->soap->{__FUNCTION__}($request);
763
764
        return $this->processResponse($response);
765
    }
766
767
    /**
768
     * Initializes the SoapClient object to make a request
769
     *
770
     * @return \jamesiarmes\PhpEws\SoapClient
771
     *
772
     * TODO: Build a class map that we can pass to the client.
773
     */
774
    protected function initializeSoapClient()
775
    {
776
        $this->soap = new SoapClient(
777
            dirname(__FILE__) . '/assets/services.wsdl',
778
            array(
779
                'user' => $this->username,
780
                'password' => $this->password,
781
                'version' => $this->version,
782
                'location' => 'https://' . $this->server . '/EWS/Exchange.asmx',
783
                'impersonation' => $this->impersonation,
784
            )
785
        );
786
787
        return $this->soap;
788
    }
789
790
    /**
791
     * Process a response to verify that it succeeded and take the appropriate
792
     * action
793
     *
794
     * @throws \Exception
795
     *
796
     * @param \stdClass $response
797
     * @return \stdClass
798
     */
799
    protected function processResponse($response)
800
    {
801
        // If the soap call failed then we need to throw an exception.
802
        $code = $this->soap->getResponseCode();
803
        if ($code != 200) {
804
            throw new \Exception(
805
                "SOAP client returned status of $code.",
806
                $code
807
            );
808
        }
809
810
        return $response;
811
    }
812
}
813