Creating README.md and updating composer.json

This commit is contained in:
2020-04-09 12:55:07 +02:00
parent d46e750911
commit 571a9784e9
6 changed files with 77 additions and 0 deletions

42
src/BMailApi.php Normal file
View File

@@ -0,0 +1,42 @@
<?php
namespace BMail;
use GuzzleHttp\Client;
class BMailApi
{
/**
* The API key
*
* @var string
*/
private $api_key;
public function __construct(string $api_key)
{
$this->api_key = $api_key;
}
public function send($template)
{
$url = "http://127.0.0.1:9000/api/project/template/send";
// TODO
// $url = "http://127.0.0.1:9000/api/project/template/send";
$client = new Client();
try {
return $client->request('post', $url, [
'form_params' => $template,
'headers' => ['Authorization' => 'Bearer ' . $this->api_key]
])->getBody();
} catch(\Exception $e) {
throw new BMailException($e->getMessage());
}
}
}