Skip to content

Commit

Permalink
Finished GET endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandr-mykhailenko committed Feb 27, 2024
1 parent 83adc1b commit 20c9895
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Api/Templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Exception;
use Mailgun\Assert;
use Mailgun\Model\Domain\CreateResponse;
use Mailgun\Model\Domain\IndexResponse;
use Mailgun\Model\Templates\GetResponse;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Message\ResponseInterface;
Expand All @@ -37,8 +36,9 @@ class Templates extends HttpApi
* @param string $page
* @param string $pivot
* @param array $requestHeaders
* @return mixed|ResponseInterface
* @return GetResponse|ResponseInterface
* @throws ClientExceptionInterface
* @throws Exception
*/
public function get(string $domain, int $limit, string $page, string $pivot, array $requestHeaders = [])
{
Expand Down
4 changes: 4 additions & 0 deletions src/Model/Templates/GetResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ private function __construct()
{
}

/**
* @param array $data
* @return static
*/
public static function create(array $data): self
{
$items = [];
Expand Down
106 changes: 102 additions & 4 deletions src/Model/Templates/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,118 @@

class Template
{
private $tag;
/** @var string $id */
private $id;
/** @var string $id */
private $name;
/** @var string $id */
private $description;
private $firstSeen;
private $lastSeen;
/** @var string $id */
private $createdAt;
/** @var string $id */
private $createdBy;

/**
*
*/
private function __construct()
{
}

/**
* @param array $data
* @return static

Check failure on line 36 in src/Model/Templates/Template.php

View workflow job for this annotation

GitHub Actions / Psalm

The declared return type 'Mailgun\Model\Templates\Template&static' for Mailgun\Model\Templates\Template::create is more specific than the inferred return type 'Mailgun\Model\Templates\Template' (see https://psalm.dev/070)
*/
public static function create(array $data): self
{
$model = new self();

print_r($data);
$model->setId($data['id']);
$model->setName($data['name']);
$model->setDescription($data['description'] ?? '');
$model->setCreatedAt($data['createdAt'] ?? '');
$model->setCreatedBy($data['createdBy'] ?? '');

return $model;

Check failure on line 48 in src/Model/Templates/Template.php

View workflow job for this annotation

GitHub Actions / PHPStan

Method Mailgun\Model\Templates\Template::create() should return static(Mailgun\Model\Templates\Template) but returns Mailgun\Model\Templates\Template.

Check failure on line 48 in src/Model/Templates/Template.php

View workflow job for this annotation

GitHub Actions / Psalm

The type 'Mailgun\Model\Templates\Template' is more general than the declared return type 'Mailgun\Model\Templates\Template&static' for Mailgun\Model\Templates\Template::create (see https://psalm.dev/129)
}

/**
* @return string
*/
public function getId(): string
{
return $this->id;
}

/**
* @param string $id
*/
public function setId(string $id): void
{
$this->id = $id;
}

/**
* @return string
*/
public function getName(): string
{
return $this->name;
}

/**
* @param string $name
*/
public function setName(string $name): void
{
$this->name = $name;
}

/**
* @return string
*/
public function getDescription(): string
{
return $this->description;
}

/**
* @param string $description
*/
public function setDescription(string $description): void
{
$this->description = $description;
}

/**
* @return string
*/
public function getCreatedAt(): string
{
return $this->createdAt;
}

/**
* @param string $createdAt
*/
public function setCreatedAt(string $createdAt): void
{
$this->createdAt = $createdAt;
}

/**
* @return string
*/
public function getCreatedBy(): string
{
return $this->createdBy;
}

/**
* @param string $createdBy
*/
public function setCreatedBy(string $createdBy): void
{
$this->createdBy = $createdBy;
}
}

0 comments on commit 20c9895

Please sign in to comment.