Skip to content

Commit

Permalink
Made a simple way to send mail. Fixed add() function. Fixed EmailAddr…
Browse files Browse the repository at this point in the history
…ess class.
  • Loading branch information
Garethp committed Aug 24, 2015
1 parent c1f3283 commit 74b019d
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 43 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.5.1 - 2015-08-24
* Added an example for sending mail

## 0.5.0 - 2015-08-24
* Massive Breaking Change
* Some basic mail fetching functions
Expand Down
24 changes: 12 additions & 12 deletions Resources/wsdl/types.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
</xs:anyAttribute>
</xs:complexType>
<xs:element name="OpenAsAdminOrSystemService" type="t:OpenAsAdminOrSystemServiceType" />

<!-- External sharing security header for person-to-person sharing relationships -->
<xs:element name="SharingSecurity" type="t:EncryptedDataContainerType"/>

Expand Down Expand Up @@ -470,7 +470,7 @@
<xs:enumeration value="contacts:WeddingAnniversary" />
<xs:enumeration value="contacts:UserSMIMECertificate" />
<xs:enumeration value="contacts:HasPicture" />

<xs:enumeration value="distributionlist:Members" />

<!-- Post item -->
Expand Down Expand Up @@ -1240,25 +1240,25 @@
<xs:element name="DistinguishedFolderId" type="t:DistinguishedFolderIdType"/>
</xs:choice>
</xs:complexType>

<!-- UploadItems types -->
<xs:complexType name="NonEmptyArrayOfUploadItemsType">
<xs:sequence>
<xs:element name="Item" type="t:UploadItemType" maxOccurs="unbounded" minOccurs="1"/>
</xs:sequence>
</xs:complexType>

<!-- UploadItemType-->
<xs:complexType name="UploadItemType">
<xs:sequence>
<xs:element name="ParentFolderId" type="t:FolderIdType" maxOccurs ="1" minOccurs ="1"/>
<xs:element name="ItemId" type="t:ItemIdType" maxOccurs ="1" minOccurs="0"/>
<xs:element name="Data" type="xs:base64Binary" maxOccurs ="1" minOccurs ="1"/>
<xs:element name="Data" type="xs:base64Binary" maxOccurs ="1" minOccurs ="1"/>
</xs:sequence>
<xs:attribute name="CreateAction" type="t:CreateActionType" use="required"/>
<xs:attribute name="IsAssociated" type="xs:boolean" use="optional"/>
</xs:complexType>

<!-- CreateActionType -->
<xs:simpleType name="CreateActionType">
<xs:restriction base="xs:string">
Expand Down Expand Up @@ -1446,7 +1446,7 @@
<xs:complexType name="NonEmptyArrayOfItemIdsType">
<xs:sequence>
<xs:element name="ItemId" type="t:ItemIdType" maxOccurs ="unbounded" minOccurs ="1"/>
</xs:sequence>
</xs:sequence>
</xs:complexType>

<!-- Item classes -->
Expand Down Expand Up @@ -1699,7 +1699,7 @@
<xs:enumeration value="SetReadState" />
</xs:restriction>
</xs:simpleType>

<xs:complexType name="ConversationActionType">
<xs:sequence>
<xs:element name="Action" type="t:ConversationActionTypeType" minOccurs="1" maxOccurs="1" />
Expand Down Expand Up @@ -3603,7 +3603,7 @@
<xs:element name="MovedEvent" type="t:MovedCopiedEventType"/>
<xs:element name="NewMailEvent" type="t:BaseObjectChangedEventType"/>
<xs:element name="StatusEvent" type="t:BaseNotificationEventType"/>
<xs:element name="FreeBusyChangedEvent" type="t:BaseObjectChangedEventType"/>
<xs:element name="FreeBusyChangedEvent" type="t:BaseObjectChangedEventType"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
Expand Down Expand Up @@ -3682,14 +3682,14 @@
<xs:enumeration value="Unsubscribe" />
</xs:restriction>
</xs:simpleType>

<xs:complexType name="NonEmptyArrayOfSubscriptionIdsType">
<xs:sequence>
<xs:element name="SubscriptionId" type="t:SubscriptionIdType" minOccurs="1"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>

<xs:complexType name="NonEmptyArrayOfNotificationsType">
<xs:sequence>
<xs:element name="Notification" type="t:NotificationType" minOccurs="0"
Expand Down Expand Up @@ -4854,7 +4854,7 @@
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="ArrayOfTrackingPropertiesType" type="t:ArrayOfTrackingPropertiesType" />
</xs:choice>
</xs:complexType>
</xs:complexType>

<xs:complexType name="ArrayOfRecipientTrackingEventType">
<xs:choice minOccurs="0" maxOccurs="unbounded">
Expand Down
16 changes: 16 additions & 0 deletions examples/mail/sendMail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

require_once "vendor/autoload.php";

use jamesiarmes\PEWS\API\Type;

$api = new \jamesiarmes\PEWS\Mail\MailAPI();
$api->buildClient('server', 'username', 'password');


$message = new Type\MessageType();
$message->setBody('Some Text');
$message->setSubject('Test Subject');
$message->setToRecipients('[email protected]');

$return = $api->sendMail($message);
3 changes: 2 additions & 1 deletion src/API/ClassMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class ClassMap
'Duration' => '\\jamesiarmes\\PEWS\\API\\Type\\DurationType',
'EffectiveRightsType' => '\\jamesiarmes\\PEWS\\API\\Type\\EffectiveRightsType',
'EmailAddressDictionaryEntryType' => '\\jamesiarmes\\PEWS\\API\\Type\\EmailAddressDictionaryEntryType',
'EmailAddress' => '\\jamesiarmes\\PEWS\\API\\Type\\Mailbox',
'EmailAddressType' => '\\jamesiarmes\\PEWS\\API\\Type\\EmailAddressType',
'EncryptedDataContainerType' => '\\jamesiarmes\\PEWS\\API\\Type\\SharingSecurity',
'EncryptedSharedFolderDataType' => '\\jamesiarmes\\PEWS\\API\\Type\\EncryptedSharedFolderDataType',
'EndDateRecurrenceRangeType' => '\\jamesiarmes\\PEWS\\API\\Type\\EndDateRecurrenceRangeType',
Expand Down Expand Up @@ -292,6 +292,7 @@ class ClassMap
'KeywordStatisticsSearchResultType' => '\\jamesiarmes\\PEWS\\API\\Type\\KeywordStatisticsSearchResultType',
'MailTipsServiceConfiguration' => '\\jamesiarmes\\PEWS\\API\\Type\\MailTipsServiceConfigurationType',
'MailTips' => '\\jamesiarmes\\PEWS\\API\\Type\\MailTipsType',
'EmailAddress' => '\\jamesiarmes\\PEWS\\API\\Type\\Mailbox',
'MailboxCultureType' => '\\jamesiarmes\\PEWS\\API\\Type\\MailboxCultureType',
'MailboxData' => '\\jamesiarmes\\PEWS\\API\\Type\\MailboxDataType',
'MailboxStatisticsSearchResultType' => '\\jamesiarmes\\PEWS\\API\\Type\\MailboxStatisticsSearchResultType',
Expand Down
6 changes: 3 additions & 3 deletions src/API/Message/GetUserOofSettingsRequestType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
*
* XSD Type: GetUserOofSettingsRequest
*
* @method \jamesiarmes\PEWS\API\Type\Mailbox getMailbox()
* @method GetUserOofSettingsRequestType setMailbox(\jamesiarmes\PEWS\API\Type\Mailbox $mailbox)
* @method \jamesiarmes\PEWS\API\Type\EmailAddressType getMailbox()
* @method GetUserOofSettingsRequestType setMailbox(\jamesiarmes\PEWS\API\Type\EmailAddressType $mailbox)
*/
class GetUserOofSettingsRequestType extends BaseRequestType
{

/**
* @var \jamesiarmes\PEWS\API\Type\Mailbox
* @var \jamesiarmes\PEWS\API\Type\EmailAddressType
*/
protected $mailbox = null;
}
6 changes: 3 additions & 3 deletions src/API/Message/SetUserOofSettingsRequestType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
*
* XSD Type: SetUserOofSettingsRequest
*
* @method \jamesiarmes\PEWS\API\Type\Mailbox getMailbox()
* @method SetUserOofSettingsRequestType setMailbox(\jamesiarmes\PEWS\API\Type\Mailbox $mailbox)
* @method \jamesiarmes\PEWS\API\Type\EmailAddressType getMailbox()
* @method SetUserOofSettingsRequestType setMailbox(\jamesiarmes\PEWS\API\Type\EmailAddressType $mailbox)
* @method \jamesiarmes\PEWS\API\Type\UserOofSettings getUserOofSettings()
* @method SetUserOofSettingsRequestType setUserOofSettings(\jamesiarmes\PEWS\API\Type\UserOofSettings $userOofSettings)
*/
class SetUserOofSettingsRequestType extends BaseRequestType
{

/**
* @var \jamesiarmes\PEWS\API\Type\Mailbox
* @var \jamesiarmes\PEWS\API\Type\EmailAddressType
*/
protected $mailbox = null;

Expand Down
2 changes: 1 addition & 1 deletion src/API/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __call($name, $arguments)
}

if ($callType == "add" && count($arguments) == 1) {
return $this->add($propertyName, $arguments);
return $this->add($propertyName, $arguments[0]);
}

if ($callType == "is" && count($arguments) == 0) {
Expand Down
6 changes: 6 additions & 0 deletions src/API/Type/BodyType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@ class BodyType extends Type
* @var string
*/
protected $bodyType = null;

public function __construct($text, $type = 'HTML')
{
$this->_ = $text;
$this->bodyType = $type;
}
}
28 changes: 20 additions & 8 deletions src/API/Type/EmailAddressType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@

namespace jamesiarmes\PEWS\API\Type;

use jamesiarmes\PEWS\API\Type;

/**
* Class representing EmailAddressType
*
*
* XSD Type: EmailAddress
* Identifier for a fully resolved email address
* XSD Type: EmailAddressType
*
* @method string getName()
* @method EmailAddressType setName(string $name)
* @method string getAddress()
* @method EmailAddressType setAddress(string $address)
* @method string getEmailAddress()
* @method EmailAddressType setEmailAddress(string $emailAddress)
* @method string getRoutingType()
* @method EmailAddressType setRoutingType(string $routingType)
* @method string getMailboxType()
* @method EmailAddressType setMailboxType(string $mailboxType)
* @method ItemIdType getItemId()
* @method EmailAddressType setItemId(ItemIdType $itemId)
*/
class EmailAddressType extends Type
class EmailAddressType extends BaseEmailAddressType
{

/**
Expand All @@ -28,10 +30,20 @@ class EmailAddressType extends Type
/**
* @var string
*/
protected $address = null;
protected $emailAddress = null;

/**
* @var string
*/
protected $routingType = null;

/**
* @var string
*/
protected $mailboxType = null;

/**
* @var \jamesiarmes\PEWS\API\Type\ItemIdType
*/
protected $itemId = null;
}
13 changes: 7 additions & 6 deletions src/API/Type/ExchangeImpersonationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@
*/
class ExchangeImpersonationType extends Type
{

/**
* @var \jamesiarmes\PEWS\API\Type\ConnectingSIDType
*/
protected $connectingSID = null;

public static function fromEmailAddress($emailAddress)
{
$impersonation = new static();
$impersonation = new self();
$connectingSID = new ConnectingSIDType();
$connectingSID->setPrimarySmtpAddress($emailAddress);

$impersonation->setConnectingSID($connectingSID);
return $impersonation;
}

/**
* @var \jamesiarmes\PEWS\API\Type\ConnectingSIDType
*/
protected $connectingSID = null;
}
41 changes: 39 additions & 2 deletions src/API/Type/MessageType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
*
* @method SingleRecipientType getSender()
* @method MessageType setSender(SingleRecipientType $sender)
* @method MessageType addToRecipients(EmailAddressType $toRecipients)
* @method EmailAddressType[] getToRecipients()
* @method MessageType setToRecipients(array $toRecipients)
* @method MessageType addCcRecipients(EmailAddressType $ccRecipients)
* @method EmailAddressType[] getCcRecipients()
* @method MessageType setCcRecipients(array $ccRecipients)
Expand Down Expand Up @@ -139,4 +137,43 @@ public function isAReply()
{
return ($this->exists('inReplyTo') && $this->getInReplyTo() !== null);
}

/**
* @param BodyType|string $body
* @return MessageType
*/
public function setBody($body)
{
if (is_string($body)) {
$body = new BodyType($body);
}

return parent::setBody($body);
}

public function addToRecipients($recipient)
{
if (is_string($recipient)) {
$address = new Mailbox();
$address->setEmailAddress($recipient);
$recipient = $address;
}

return parent::addToRecipients($recipient);
}

public function setToRecipients($recipients)
{
$this->toRecipients = [ ];

if (!is_array($recipients)) {
$recipients = array($recipients);
}

foreach ($recipients as $recipient) {
$this->addToRecipients($recipient);
}

return $this;
}
}
8 changes: 8 additions & 0 deletions src/Generator/ConvertToPHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ function ($type) use ($schemas) {
}
);

$converter->addAliasMap(
'http://schemas.microsoft.com/exchange/services/2006/types',
'EmailAddress',
function ($type) use ($schemas) {
return "jamesiarmes\\PEWS\\API\\Type\\EmailAddressType";
}
);

$items = $converter->convert($schemas);
$progress->start($output, count($items));
$classMap = [];
Expand Down
14 changes: 7 additions & 7 deletions src/Generator/PhpConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,27 @@ public function __construct(NamingStrategy $namingStrategy)
parent::__construct($namingStrategy);

$this->addAliasMap("http://www.w3.org/2001/XMLSchema", "dateTime", function (Type $type) {

return "DateTime";
});
$this->addAliasMap("http://www.w3.org/2001/XMLSchema", "time", function (Type $type) {

return "DateTime";
});
$this->addAliasMap("http://www.w3.org/2001/XMLSchema", "date", function (Type $type) {

return "DateTime";
});
$this->addAliasMap("http://www.w3.org/2001/XMLSchema", "anySimpleType", function (Type $type) {

return "mixed";
});
$this->addAliasMap("http://www.w3.org/2001/XMLSchema", "anyType", function (Type $type) {

return "mixed";
});
$this->addAliasMap("http://www.w3.org/2001/XMLSchema", "base64Binary", function (Type $type) {

return "string";
});
}
Expand All @@ -82,7 +82,7 @@ public function convert(array $schemas)
private function getTypes()
{
uasort($this->classes, function ($a, $b) {

return strcmp($a["class"]->getFullName(), $b["class"]->getFullName());
});
$ret = array();
Expand Down
Loading

0 comments on commit 74b019d

Please sign in to comment.