Skip to content

Commit ddd733b

Browse files
Installed dependency for Symfony Http Client
Added phpdocs for methods
1 parent 9b606c7 commit ddd733b

14 files changed

+241
-111
lines changed

src/Contracts/ContactMetadataContract.php

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,33 @@
88

99
interface ContactMetadataContract
1010
{
11-
public function getAll();
12-
13-
public function get(string $id);
14-
15-
public function create(ContactMetadata $metadata);
16-
17-
public function update(string $id, ContactMetadata $metadata);
18-
19-
public function delete(string $id);
11+
/**
12+
* @return array
13+
*/
14+
public function getAll(): array;
15+
16+
/**
17+
* @param string $id
18+
* @return array
19+
*/
20+
public function get(string $id): array;
21+
22+
/**
23+
* @param ContactMetadata $metadata
24+
* @return array
25+
*/
26+
public function create(ContactMetadata $metadata): array;
27+
28+
/**
29+
* @param string $id
30+
* @param ContactMetadata $metadata
31+
* @return array
32+
*/
33+
public function update(string $id, ContactMetadata $metadata): array;
34+
35+
/**
36+
* @param string $id
37+
* @return array
38+
*/
39+
public function delete(string $id): array;
2040
}

src/Contracts/ContactsListContract.php

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,55 @@
99

1010
interface ContactsListContract
1111
{
12-
public function create(string $id, Contact $contact, $action = Contact::ACTION_ADDFORCE): array;
13-
14-
public function update(string $id, Contact $contact, $action = Contact::ACTION_ADDNOFORCE): array;
15-
12+
/**
13+
* @param string $id
14+
* @param Contact $contact
15+
* @param string $action
16+
* @return array
17+
*/
18+
public function create(string $id, Contact $contact, string $action = Contact::ACTION_ADDFORCE): array;
19+
20+
/**
21+
* @param string $id
22+
* @param Contact $contact
23+
* @param string $action
24+
* @return array
25+
*/
26+
public function update(string $id, Contact $contact, string $action = Contact::ACTION_ADDNOFORCE): array;
27+
28+
/**
29+
* @param string $id
30+
* @param Contact $contact
31+
* @param bool $force
32+
* @return array
33+
*/
1634
public function subscribe(string $id, Contact $contact, bool $force = true): array;
1735

36+
/**
37+
* @param string $id
38+
* @param Contact $contact
39+
* @return array
40+
*/
1841
public function unsubscribe(string $id, Contact $contact): array;
1942

43+
/**
44+
* @param string $id
45+
* @param Contact $contact
46+
* @return array
47+
*/
2048
public function delete(string $id, Contact $contact): array;
2149

50+
/**
51+
* @param string $id
52+
* @param Contact $contact
53+
* @param string $oldEmail
54+
* @return array
55+
*/
2256
public function updateEmail(string $id, Contact $contact, string $oldEmail): array;
2357

58+
/**
59+
* @param ContactsList $list
60+
* @return array
61+
*/
2462
public function uploadManyContactsList(ContactsList $list): array;
2563
}

src/Contracts/ContactsV4Contract.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,9 @@
99

1010
interface ContactsV4Contract
1111
{
12-
public function delete($id);
13-
}
12+
/**
13+
* @param int $id
14+
* @return bool
15+
*/
16+
public function delete(int $id): bool;
17+
}

src/Contracts/EventCallbackUrlContract.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,33 @@
88

99
interface EventCallbackUrlContract
1010
{
11+
/**
12+
* @return array
13+
*/
1114
public function getAll(): array;
1215

16+
/**
17+
* @param string $id
18+
* @return array
19+
*/
1320
public function get(string $id): array;
1421

22+
/**
23+
* @param EventCallbackUrl $url
24+
* @return array
25+
*/
1526
public function create(EventCallbackUrl $url): array;
1627

28+
/**
29+
* @param string $id
30+
* @param EventCallbackUrl $url
31+
* @return array
32+
*/
1733
public function update(string $id, EventCallbackUrl $url): array;
1834

35+
/**
36+
* @param string $id
37+
* @return array
38+
*/
1939
public function delete(string $id): array;
2040
}

src/Contracts/MailjetServiceContract.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,40 @@
99

1010
interface MailjetServiceContract
1111
{
12+
/**
13+
* @param array $resource
14+
* @param array $args
15+
* @param array $options
16+
* @return Response
17+
*/
1218
public function post(array $resource, array $args = [], array $options = []): Response;
1319

20+
/**
21+
* @param array $resource
22+
* @param array $args
23+
* @param array $options
24+
* @return Response
25+
*/
1426
public function get(array $resource, array $args = [], array $options = []): Response;
1527

28+
/**
29+
* @param array $resource
30+
* @param array $args
31+
* @param array $options
32+
* @return Response
33+
*/
1634
public function put(array $resource, array $args = [], array $options = []): Response;
1735

36+
/**
37+
* @param array $resource
38+
* @param array $args
39+
* @param array $options
40+
* @return Response
41+
*/
1842
public function delete(array $resource, array $args = [], array $options = []): Response;
1943

44+
/**
45+
* @return Client
46+
*/
2047
public function getClient(): Client;
2148
}

src/Contracts/TemplateServiceContract.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,53 @@
88

99
interface TemplateServiceContract
1010
{
11+
/**
12+
* @param array|null $filters
13+
* @return array
14+
*/
1115
public function getAll(array $filters = null): array;
1216

17+
/**
18+
* @param string $id
19+
* @return array
20+
*/
1321
public function get(string $id): array;
1422

23+
/**
24+
* @param Template $template
25+
* @return array
26+
*/
1527
public function create(Template $template): array;
1628

29+
/**
30+
* @param string $id
31+
* @param Template $template
32+
* @return array
33+
*/
1734
public function update(string $id, Template $template): array;
1835

36+
/**
37+
* @param string $id
38+
* @return array
39+
*/
1940
public function delete(string $id): array;
2041

42+
/**
43+
* @param string $id
44+
* @return array
45+
*/
2146
public function getDetailContent(string $id): array;
2247

48+
/**
49+
* @param string $id
50+
* @param array $content
51+
* @return array
52+
*/
2353
public function createDetailContent(string $id, array $content): array;
2454

55+
/**
56+
* @param string $id
57+
* @return array
58+
*/
2559
public function deleteDetailContent(string $id): array;
2660
}

src/Exception/MailjetException.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ class MailjetException extends \Exception
2626

2727
/**
2828
* https://dev.mailjet.com/guides/#about-the-mailjet-restful-api
29-
*
30-
* @param Response $response
31-
* @param \Throwable $previous
29+
* @param int $statusCode
30+
* @param null $message
31+
* @param Response|null $response
32+
* @param Throwable|null $previous
3233
*/
33-
public function __construct($statusCode = 0, $message = null, Response $response = null, Throwable $previous = null)
34+
public function __construct(int $statusCode = 0, $message = null, Response $response = null, Throwable $previous = null)
3435
{
3536
if ($response) {
36-
$statusCode = $response->getStatus();
37+
$statusCode = $response->getStatus() ?? 0;
3738
$message = "{$message}: {$response->getReasonPhrase()}";
3839

3940
$this->setErrorFromResponse($response);

src/Facades/Mailjet.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
class Mailjet extends Facade
1010
{
11+
/**
12+
* @return string
13+
*/
1114
protected static function getFacadeAccessor(): string
1215
{
1316
return 'Mailjet';

src/Services/ContactMetadataService.php

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ public function __construct(MailjetService $mailjet)
2626

2727
/**
2828
* Retrieve all ContactMetadata.
29-
*
3029
* @return array
31-
* @throws \Mailjet\LaravelMailjet\Exception\MailjetException
30+
* @throws MailjetException
3231
*/
3332
public function getAll(): array
3433
{
@@ -43,11 +42,9 @@ public function getAll(): array
4342

4443
/**
4544
* Retrieve one ContactMetadata.
46-
*
4745
* @param string $id
48-
*
4946
* @return array
50-
* @throws \Mailjet\LaravelMailjet\Exception\MailjetException
47+
* @throws MailjetException
5148
*/
5249
public function get(string $id): array
5350
{
@@ -62,10 +59,9 @@ public function get(string $id): array
6259

6360
/**
6461
* create a new fresh ContactMetadata
65-
*
6662
* @param ContactMetadata $metadata
67-
*
68-
* @throws \Mailjet\LaravelMailjet\Exception\MailjetException
63+
* @return array
64+
* @throws MailjetException
6965
*/
7066
public function create(ContactMetadata $metadata): array
7167
{
@@ -80,11 +76,10 @@ public function create(ContactMetadata $metadata): array
8076

8177
/**
8278
* Update one ContactMetadata
83-
*
84-
* @param string $id
79+
* @param string $id
8580
* @param ContactMetadata $metadata
86-
*
87-
* @throws \Mailjet\LaravelMailjet\Exception\MailjetException
81+
* @return array
82+
* @throws MailjetException
8883
*/
8984
public function update(string $id, ContactMetadata $metadata): array
9085
{
@@ -99,10 +94,9 @@ public function update(string $id, ContactMetadata $metadata): array
9994

10095
/**
10196
* Delete one ContactMetadata
102-
*
10397
* @param string $id
104-
*
105-
* @throws \Mailjet\LaravelMailjet\Exception\MailjetException
98+
* @return array
99+
* @throws MailjetException
106100
*/
107101
public function delete(string $id): array
108102
{

0 commit comments

Comments
 (0)