Skip to content

Commit

Permalink
Installed dependency for Symfony Http Client
Browse files Browse the repository at this point in the history
Added phpdocs for methods
  • Loading branch information
oleksandr-mykhailenko committed Jul 21, 2024
1 parent 9b606c7 commit ddd733b
Show file tree
Hide file tree
Showing 14 changed files with 241 additions and 111 deletions.
38 changes: 29 additions & 9 deletions src/Contracts/ContactMetadataContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,33 @@

interface ContactMetadataContract
{
public function getAll();

public function get(string $id);

public function create(ContactMetadata $metadata);

public function update(string $id, ContactMetadata $metadata);

public function delete(string $id);
/**
* @return array
*/
public function getAll(): array;

/**
* @param string $id
* @return array
*/
public function get(string $id): array;

/**
* @param ContactMetadata $metadata
* @return array
*/
public function create(ContactMetadata $metadata): array;

/**
* @param string $id
* @param ContactMetadata $metadata
* @return array
*/
public function update(string $id, ContactMetadata $metadata): array;

/**
* @param string $id
* @return array
*/
public function delete(string $id): array;
}
46 changes: 42 additions & 4 deletions src/Contracts/ContactsListContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,55 @@

interface ContactsListContract
{
public function create(string $id, Contact $contact, $action = Contact::ACTION_ADDFORCE): array;

public function update(string $id, Contact $contact, $action = Contact::ACTION_ADDNOFORCE): array;

/**
* @param string $id
* @param Contact $contact
* @param string $action
* @return array
*/
public function create(string $id, Contact $contact, string $action = Contact::ACTION_ADDFORCE): array;

/**
* @param string $id
* @param Contact $contact
* @param string $action
* @return array
*/
public function update(string $id, Contact $contact, string $action = Contact::ACTION_ADDNOFORCE): array;

/**
* @param string $id
* @param Contact $contact
* @param bool $force
* @return array
*/
public function subscribe(string $id, Contact $contact, bool $force = true): array;

/**
* @param string $id
* @param Contact $contact
* @return array
*/
public function unsubscribe(string $id, Contact $contact): array;

/**
* @param string $id
* @param Contact $contact
* @return array
*/
public function delete(string $id, Contact $contact): array;

/**
* @param string $id
* @param Contact $contact
* @param string $oldEmail
* @return array
*/
public function updateEmail(string $id, Contact $contact, string $oldEmail): array;

/**
* @param ContactsList $list
* @return array
*/
public function uploadManyContactsList(ContactsList $list): array;
}
8 changes: 6 additions & 2 deletions src/Contracts/ContactsV4Contract.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@

interface ContactsV4Contract
{
public function delete($id);
}
/**
* @param int $id
* @return bool
*/
public function delete(int $id): bool;
}
20 changes: 20 additions & 0 deletions src/Contracts/EventCallbackUrlContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,33 @@

interface EventCallbackUrlContract
{
/**
* @return array
*/
public function getAll(): array;

/**
* @param string $id
* @return array
*/
public function get(string $id): array;

/**
* @param EventCallbackUrl $url
* @return array
*/
public function create(EventCallbackUrl $url): array;

/**
* @param string $id
* @param EventCallbackUrl $url
* @return array
*/
public function update(string $id, EventCallbackUrl $url): array;

/**
* @param string $id
* @return array
*/
public function delete(string $id): array;
}
27 changes: 27 additions & 0 deletions src/Contracts/MailjetServiceContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,40 @@

interface MailjetServiceContract
{
/**
* @param array $resource
* @param array $args
* @param array $options
* @return Response
*/
public function post(array $resource, array $args = [], array $options = []): Response;

/**
* @param array $resource
* @param array $args
* @param array $options
* @return Response
*/
public function get(array $resource, array $args = [], array $options = []): Response;

/**
* @param array $resource
* @param array $args
* @param array $options
* @return Response
*/
public function put(array $resource, array $args = [], array $options = []): Response;

/**
* @param array $resource
* @param array $args
* @param array $options
* @return Response
*/
public function delete(array $resource, array $args = [], array $options = []): Response;

/**
* @return Client
*/
public function getClient(): Client;
}
34 changes: 34 additions & 0 deletions src/Contracts/TemplateServiceContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,53 @@

interface TemplateServiceContract
{
/**
* @param array|null $filters
* @return array
*/
public function getAll(array $filters = null): array;

/**
* @param string $id
* @return array
*/
public function get(string $id): array;

/**
* @param Template $template
* @return array
*/
public function create(Template $template): array;

/**
* @param string $id
* @param Template $template
* @return array
*/
public function update(string $id, Template $template): array;

/**
* @param string $id
* @return array
*/
public function delete(string $id): array;

/**
* @param string $id
* @return array
*/
public function getDetailContent(string $id): array;

/**
* @param string $id
* @param array $content
* @return array
*/
public function createDetailContent(string $id, array $content): array;

/**
* @param string $id
* @return array
*/
public function deleteDetailContent(string $id): array;
}
11 changes: 6 additions & 5 deletions src/Exception/MailjetException.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ class MailjetException extends \Exception

/**
* https://dev.mailjet.com/guides/#about-the-mailjet-restful-api
*
* @param Response $response
* @param \Throwable $previous
* @param int $statusCode
* @param null $message
* @param Response|null $response
* @param Throwable|null $previous
*/
public function __construct($statusCode = 0, $message = null, Response $response = null, Throwable $previous = null)
public function __construct(int $statusCode = 0, $message = null, Response $response = null, Throwable $previous = null)
{
if ($response) {
$statusCode = $response->getStatus();
$statusCode = $response->getStatus() ?? 0;
$message = "{$message}: {$response->getReasonPhrase()}";

$this->setErrorFromResponse($response);
Expand Down
3 changes: 3 additions & 0 deletions src/Facades/Mailjet.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

class Mailjet extends Facade
{
/**
* @return string
*/
protected static function getFacadeAccessor(): string
{
return 'Mailjet';
Expand Down
24 changes: 9 additions & 15 deletions src/Services/ContactMetadataService.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ public function __construct(MailjetService $mailjet)

/**
* Retrieve all ContactMetadata.
*
* @return array
* @throws \Mailjet\LaravelMailjet\Exception\MailjetException
* @throws MailjetException
*/
public function getAll(): array
{
Expand All @@ -43,11 +42,9 @@ public function getAll(): array

/**
* Retrieve one ContactMetadata.
*
* @param string $id
*
* @return array
* @throws \Mailjet\LaravelMailjet\Exception\MailjetException
* @throws MailjetException
*/
public function get(string $id): array
{
Expand All @@ -62,10 +59,9 @@ public function get(string $id): array

/**
* create a new fresh ContactMetadata
*
* @param ContactMetadata $metadata
*
* @throws \Mailjet\LaravelMailjet\Exception\MailjetException
* @return array
* @throws MailjetException
*/
public function create(ContactMetadata $metadata): array
{
Expand All @@ -80,11 +76,10 @@ public function create(ContactMetadata $metadata): array

/**
* Update one ContactMetadata
*
* @param string $id
* @param string $id
* @param ContactMetadata $metadata
*
* @throws \Mailjet\LaravelMailjet\Exception\MailjetException
* @return array
* @throws MailjetException
*/
public function update(string $id, ContactMetadata $metadata): array
{
Expand All @@ -99,10 +94,9 @@ public function update(string $id, ContactMetadata $metadata): array

/**
* Delete one ContactMetadata
*
* @param string $id
*
* @throws \Mailjet\LaravelMailjet\Exception\MailjetException
* @return array
* @throws MailjetException
*/
public function delete(string $id): array
{
Expand Down
Loading

0 comments on commit ddd733b

Please sign in to comment.