-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from HiccupInsurance/add-member-api
Add member api
- Loading branch information
Showing
6 changed files
with
135 additions
and
6 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
vendor/ | ||
composer.lock | ||
config.yml |
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,18 @@ | ||
<?php | ||
|
||
require(__DIR__ . '/../vendor/autoload.php'); | ||
|
||
use Hiccup\MailChimpApi\MailChimp; | ||
use Noodlehaus\Config; | ||
|
||
$config = new Config(__DIR__ . '/../config.yml'); | ||
$mailChimp = new MailChimp($config->get('api_key')); | ||
|
||
$response = $mailChimp->getMember()->subscribe( | ||
$config->get('list_id'), | ||
[ | ||
'email_address' => 'budi.arsana@hiccup.co' | ||
] | ||
); | ||
|
||
var_dump($response); |
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,34 @@ | ||
<?php | ||
|
||
namespace Hiccup\MailChimpApi\Exception; | ||
|
||
use Throwable; | ||
|
||
final class InvalidParametersException extends \Exception | ||
{ | ||
|
||
/** | ||
* @param array $errors | ||
* @param int $code | ||
* @param Throwable|null $previous | ||
*/ | ||
public function __construct(array $errors, $code = 400, Throwable $previous = null) | ||
{ | ||
parent::__construct($this->buildMessage($errors), $code, $previous); | ||
} | ||
|
||
/** | ||
* @param array $errors | ||
* @return string | ||
*/ | ||
private function buildMessage(array $errors): string | ||
{ | ||
$listMessages = []; | ||
|
||
foreach ($errors as $parameter => $message) { | ||
$listMessages[] = sprintf('Parameter "%s" is "%s"', $parameter, $message); | ||
} | ||
|
||
return implode('. ', $listMessages); | ||
} | ||
} |
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