-
Notifications
You must be signed in to change notification settings - Fork 12
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 #41 from signnow/user-initial-signature
Added user/initial and user/signature endpoints
- Loading branch information
Showing
11 changed files
with
692 additions
and
3 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
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,61 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SignNow\Api\Action\User; | ||
|
||
use ReflectionException; | ||
use SignNow\Api\Entity\User\Initial as UserInitialEntity; | ||
use SignNow\Api\Entity\User\ImageResponse; | ||
use SignNow\Rest\EntityManager; | ||
use SignNow\Rest\EntityManager\Exception\EntityManagerException; | ||
use SignNow\Rest\Http\Request; | ||
|
||
/** | ||
* Class Initial | ||
* | ||
* @package SignNow\Api\Action\User | ||
*/ | ||
class Initial | ||
{ | ||
/** | ||
* @var EntityManager | ||
*/ | ||
private $entityManager; | ||
|
||
/** | ||
* Initial constructor. | ||
* | ||
* @param EntityManager $entityManager | ||
*/ | ||
public function __construct(EntityManager $entityManager) | ||
{ | ||
$this->entityManager = $entityManager; | ||
} | ||
|
||
/** | ||
* @param string $base64ImageData | ||
* | ||
* @return object|ImageResponse | ||
* @throws EntityManagerException|ReflectionException | ||
*/ | ||
public function upload(string $base64ImageData): ImageResponse | ||
{ | ||
$this->entityManager->setUpdateHttpMethod(Request::METHOD_PUT); | ||
|
||
return $this->entityManager->update( | ||
new UserInitialEntity($base64ImageData) | ||
); | ||
} | ||
|
||
/** | ||
* @return object|ImageResponse | ||
* @throws EntityManagerException|ReflectionException | ||
*/ | ||
public function get(): ImageResponse | ||
{ | ||
return $this->entityManager->get( | ||
new UserInitialEntity() | ||
); | ||
} | ||
} |
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,61 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SignNow\Api\Action\User; | ||
|
||
use ReflectionException; | ||
use SignNow\Api\Entity\User\Signature as UserSignatureEntity; | ||
use SignNow\Api\Entity\User\ImageResponse; | ||
use SignNow\Rest\EntityManager; | ||
use SignNow\Rest\EntityManager\Exception\EntityManagerException; | ||
use SignNow\Rest\Http\Request; | ||
|
||
/** | ||
* Class Signature | ||
* | ||
* @package SignNow\Api\Action\User | ||
*/ | ||
class Signature | ||
{ | ||
/** | ||
* @var EntityManager | ||
*/ | ||
private $entityManager; | ||
|
||
/** | ||
* Signature constructor. | ||
* | ||
* @param EntityManager $entityManager | ||
*/ | ||
public function __construct(EntityManager $entityManager) | ||
{ | ||
$this->entityManager = $entityManager; | ||
} | ||
|
||
/** | ||
* @param string $base64ImageData | ||
* | ||
* @return object|ImageResponse | ||
* @throws EntityManagerException|ReflectionException | ||
*/ | ||
public function upload(string $base64ImageData): ImageResponse | ||
{ | ||
$this->entityManager->setUpdateHttpMethod(Request::METHOD_PUT); | ||
|
||
return $this->entityManager->update( | ||
new UserSignatureEntity($base64ImageData) | ||
); | ||
} | ||
|
||
/** | ||
* @return object|ImageResponse | ||
* @throws EntityManagerException|ReflectionException | ||
*/ | ||
public function get(): ImageResponse | ||
{ | ||
return $this->entityManager->get( | ||
new UserSignatureEntity() | ||
); | ||
} | ||
} |
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,102 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SignNow\Api\Entity\User; | ||
|
||
use JMS\Serializer\Annotation as Serializer; | ||
|
||
/** | ||
* Class ImageResponse | ||
* | ||
* @package SignNow\Api\Entity\User | ||
*/ | ||
class ImageResponse | ||
{ | ||
/** | ||
* @var string | ||
* | ||
* @Serializer\Type("string") | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* @var int | ||
* | ||
* @Serializer\Type("integer") | ||
*/ | ||
private $width; | ||
|
||
/** | ||
* @var int | ||
* | ||
* @Serializer\Type("integer") | ||
*/ | ||
private $height; | ||
|
||
/** | ||
* @var int | ||
* | ||
* @Serializer\Type("integer") | ||
*/ | ||
private $created; | ||
|
||
/** | ||
* This field is in use fot GET /user/initial | ||
* base64 encoded image data | ||
* | ||
* @var null|string | ||
* | ||
* @Serializer\Type("string") | ||
*/ | ||
private $data; | ||
|
||
/** | ||
* This field is in use fot GET /user/initial | ||
* | ||
* @var null|string | ||
* | ||
* @Serializer\Type("string") | ||
*/ | ||
private $uniqueId; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getId(): string | ||
{ | ||
return $this->uniqueId ?? $this->id; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getWidth(): int | ||
{ | ||
return $this->width; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getHeight(): int | ||
{ | ||
return $this->height; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getCreated(): int | ||
{ | ||
return $this->created; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getData(): string | ||
{ | ||
return $this->data; | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SignNow\Api\Entity\User; | ||
|
||
use SignNow\Rest\Entity\Entity; | ||
use SignNow\Rest\EntityManager\Annotation\HttpEntity; | ||
use SignNow\Rest\EntityManager\Annotation\ResponseType; | ||
|
||
/** | ||
* Class Initial | ||
* | ||
* @HttpEntity("user/initial", idProperty="") | ||
* @ResponseType("SignNow\Api\Entity\User\ImageResponse") | ||
* | ||
* @package SignNow\Api\Entity\User | ||
*/ | ||
class Initial extends Entity | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $data; | ||
|
||
/** | ||
* Initial constructor. | ||
* | ||
* @param string $data user initials image as base64 encoded string | ||
*/ | ||
public function __construct(string $data = '') | ||
{ | ||
$this->data = $data; | ||
} | ||
} |
Oops, something went wrong.