diff --git a/examples/emailmessages-view.php b/examples/emailmessages-view.php new file mode 100644 index 00000000..0e77af40 --- /dev/null +++ b/examples/emailmessages-view.php @@ -0,0 +1,17 @@ +emailmessages->read('ca0a8220453bc36ddeb3115a37400870'); // Set a message id here + var_dump($emailMessageResult); +} catch (\MessageBird\Exceptions\AuthenticateException $e) { + // That means that your accessKey is unknown + echo 'wrong login'; +} catch (\Exception $e) { + var_dump($e->getMessage()); +} diff --git a/examples/verify-create-email.php b/examples/verify-create-email.php new file mode 100644 index 00000000..800e43a1 --- /dev/null +++ b/examples/verify-create-email.php @@ -0,0 +1,33 @@ +recipient = 'Client Name '; + +$extraOptions = [ + 'type' => 'email', + // This email domain needs to be set up as an email channel in your account at https://dashboard.messagebird.com/en/channels/ + 'originator' => 'Email Verification ', + 'timeout' => 60, +]; + +try { + $verifyResult = $messageBird->verify->create($verify, $extraOptions); + var_dump($verifyResult); +} catch (AuthenticateException $e) { + // That means that your accessKey is unknown + echo 'wrong login'; +} catch (BalanceException $e) { + // That means that you are out of credits, so do something about it. + echo 'no balance'; +} catch (\Exception $e) { + echo $e->getMessage(); +} diff --git a/src/MessageBird/Client.php b/src/MessageBird/Client.php index aea45d9f..22f69b86 100644 --- a/src/MessageBird/Client.php +++ b/src/MessageBird/Client.php @@ -41,6 +41,11 @@ class Client */ public $groups; + /** + * @var Resources\EmailMessage + */ + public $emailmessages; + /** * @var Resources\VoiceMessage */ @@ -241,6 +246,7 @@ public function __construct($accessKey = null, Common\HttpClient $httpClient = n $this->hlr = new Resources\Hlr($this->httpClient); $this->verify = new Resources\Verify($this->httpClient); $this->balance = new Resources\Balance($this->httpClient); + $this->emailmessages = new Resources\EmailMessage($this->httpClient); $this->voicemessages = new Resources\VoiceMessage($this->httpClient); $this->lookup = new Resources\Lookup($this->httpClient); $this->lookupHlr = new Resources\LookupHlr($this->httpClient); diff --git a/src/MessageBird/Objects/EmailMessage.php b/src/MessageBird/Objects/EmailMessage.php new file mode 100644 index 00000000..cebec096 --- /dev/null +++ b/src/MessageBird/Objects/EmailMessage.php @@ -0,0 +1,46 @@ +id; + } + + /** + * Get the status + * + * @return string + */ + public function getStatus() + { + return $this->status; + } +} diff --git a/src/MessageBird/Objects/Verify.php b/src/MessageBird/Objects/Verify.php index 6467f4ca..c50645f7 100644 --- a/src/MessageBird/Objects/Verify.php +++ b/src/MessageBird/Objects/Verify.php @@ -31,9 +31,9 @@ class Verify extends Base protected $href; /** - * The msisdn of the recipient + * The msisdn or email of the recipient * - * @var int + * @var int|string */ public $recipient; diff --git a/src/MessageBird/Resources/EmailMessage.php b/src/MessageBird/Resources/EmailMessage.php new file mode 100644 index 00000000..53fdebce --- /dev/null +++ b/src/MessageBird/Resources/EmailMessage.php @@ -0,0 +1,25 @@ +setObject(new Objects\EmailMessage); + $this->setResourceName('verify/messages/email'); + + parent::__construct($httpClient); + } +}