-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to fetch email messages created by Verify email verificat…
…ion (#171) * Feature: Add ability to fetch an Email Message * Feature: Fix docblock to allow for email * Add example of how to send a verify email message * Add example of how to fetch an emailmessage
- Loading branch information
Bernhard Breytenbach
authored
May 28, 2021
1 parent
53692f9
commit f89d839
Showing
6 changed files
with
129 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
use MessageBird\Client; | ||
|
||
require_once(__DIR__ . '/../autoload.php'); | ||
|
||
$messageBird = new Client('YOUR_ACCESS_KEY'); // Set your own API access key here. | ||
|
||
try { | ||
$emailMessageResult = $messageBird->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()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
use MessageBird\Client; | ||
use MessageBird\Exceptions\AuthenticateException; | ||
use MessageBird\Exceptions\BalanceException; | ||
use MessageBird\Objects\Verify; | ||
|
||
require_once(__DIR__ . '/../autoload.php'); | ||
|
||
$messageBird = new Client('YOUR_ACCESS_KEY'); // Set your own API access key here. | ||
|
||
$verify = new Verify(); | ||
$verify->recipient = 'Client Name <[email protected]>'; | ||
|
||
$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 <[email protected]>', | ||
'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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace MessageBird\Objects; | ||
|
||
/** | ||
* Class EmailMessage | ||
* | ||
* @package MessageBird\Objects | ||
*/ | ||
class EmailMessage extends Base | ||
{ | ||
/** | ||
* An unique random ID which is created on the MessageBird | ||
* platform and is returned upon creation of the object. | ||
* | ||
* @var string | ||
*/ | ||
protected $id; | ||
|
||
/** | ||
* The status of the Email Message. | ||
* | ||
* @var string | ||
*/ | ||
protected $status; | ||
|
||
/** | ||
* Get the created id | ||
* | ||
* @return mixed | ||
*/ | ||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* Get the status | ||
* | ||
* @return string | ||
*/ | ||
public function getStatus() | ||
{ | ||
return $this->status; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace MessageBird\Resources; | ||
|
||
use MessageBird\Common; | ||
use MessageBird\Objects; | ||
|
||
/** | ||
* Class EmailMessage | ||
* | ||
* @package MessageBird\Resources | ||
*/ | ||
class EmailMessage extends Base | ||
{ | ||
/** | ||
* @param Common\HttpClient $httpClient | ||
*/ | ||
public function __construct(Common\HttpClient $httpClient) | ||
{ | ||
$this->setObject(new Objects\EmailMessage); | ||
$this->setResourceName('verify/messages/email'); | ||
|
||
parent::__construct($httpClient); | ||
} | ||
} |