-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implementar OrdensDeProducao e atualizar entidades de Produtos
- Loading branch information
1 parent
fa74803
commit 3d94d4b
Showing
54 changed files
with
1,304 additions
and
39 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
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
{ | ||
"data": { | ||
"id": "436c56a5679921f5f13a3d6433561773", | ||
"nome": "Empresa Teste LTDA", | ||
"cnpj": "12.345.657/8910-11", | ||
"email": "empresa@email.com" | ||
"email": "empresa@email.com", | ||
"dataContrato": "2024-12-31" | ||
} | ||
} |
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,176 @@ | ||
<?php | ||
|
||
namespace AleBatistella\BlingErpApi\Entities\OrdensDeProducao; | ||
|
||
use AleBatistella\BlingErpApi\Entities\OrdensDeProducao\Schema\Get\GetParams; | ||
use AleBatistella\BlingErpApi\Entities\OrdensDeProducao\Schema\Create\CreateResponse; | ||
use AleBatistella\BlingErpApi\Entities\OrdensDeProducao\Schema\Delete\DeleteResponse; | ||
use AleBatistella\BlingErpApi\Entities\OrdensDeProducao\Schema\Find\FindResponse; | ||
use AleBatistella\BlingErpApi\Entities\OrdensDeProducao\Schema\GenerateOverDemand\GenerateOverDemandResponse; | ||
use AleBatistella\BlingErpApi\Entities\OrdensDeProducao\Schema\Get\GetResponse; | ||
use AleBatistella\BlingErpApi\Entities\OrdensDeProducao\Schema\Update\UpdateResponse; | ||
use AleBatistella\BlingErpApi\Entities\OrdensDeProducao\Schema\ChangeSituation\ChangeSituationResponse; | ||
use AleBatistella\BlingErpApi\Entities\Shared\BaseEntity; | ||
use AleBatistella\BlingErpApi\Entities\Shared\DTO\Request\RequestOptions; | ||
use AleBatistella\BlingErpApi\Exceptions\BlingApiException; | ||
use AleBatistella\BlingErpApi\Exceptions\BlingInternalException; | ||
|
||
/** | ||
* Entidade para interação com ordens de produção. | ||
* | ||
* @see https://developer.bling.com.br/referencia#/Ordens%20de%20Produ%C3%A7%C3%A3o | ||
*/ | ||
class OrdensDeProducao extends BaseEntity | ||
{ | ||
/** | ||
* Remove uma ordem de produção. | ||
* | ||
* @param int $idOrdemProducao ID da ordem de produção | ||
* | ||
* @return null | ||
* @throws BlingApiException|BlingInternalException | ||
* | ||
* @see https://developer.bling.com.br/referencia#/Ordens%20de%20Produ%C3%A7%C3%A3o/delete_ordens_producao__idOrdemProducao_ | ||
*/ | ||
public function delete(int $idOrdemProducao): null | ||
{ | ||
$response = $this->repository->destroy( | ||
new RequestOptions( | ||
endpoint: "ordens-producao/$idOrdemProducao" | ||
) | ||
); | ||
|
||
return DeleteResponse::fromResponse($response); | ||
} | ||
|
||
/** | ||
* Obtém ordens de produção. | ||
* | ||
* @param GetParams|array|null $params Parâmetros para a busca | ||
* | ||
* @return GetResponse | ||
* @throws BlingApiException|BlingInternalException | ||
* | ||
* @see https://developer.bling.com.br/referencia#/Ordens%20de%20Produ%C3%A7%C3%A3o/get_ordens_producao | ||
*/ | ||
public function get(GetParams|array|null $params = null): GetResponse | ||
{ | ||
$response = $this->repository->index( | ||
new RequestOptions( | ||
endpoint: "ordens-producao", | ||
queryParams: $params | ||
) | ||
); | ||
|
||
return GetResponse::fromResponse($response); | ||
} | ||
|
||
/** | ||
* Obtém uma ordem de produção. | ||
* | ||
* @param int $idOrdemProducao ID da ordem de produção | ||
* | ||
* @return FindResponse | ||
* @throws BlingApiException|BlingInternalException | ||
* | ||
* @see https://developer.bling.com.br/referencia#/Ordens%20de%20Produ%C3%A7%C3%A3o/get_ordens_producao__idOrdemProducao_ | ||
*/ | ||
public function find(int $idOrdemProducao): FindResponse | ||
{ | ||
$response = $this->repository->show( | ||
new RequestOptions( | ||
endpoint: "ordens-producao/$idOrdemProducao", | ||
) | ||
); | ||
|
||
return FindResponse::fromResponse($response); | ||
} | ||
|
||
/** | ||
* Cria uma ordem de produção. | ||
* | ||
* @param array $body Corpo da requisição | ||
* | ||
* @return CreateResponse | ||
* @throws BlingApiException|BlingInternalException | ||
* | ||
* @see https://developer.bling.com.br/referencia#/Ordens%20de%20Produ%C3%A7%C3%A3o/post_ordens_producao | ||
*/ | ||
public function create(array $body): CreateResponse | ||
{ | ||
$response = $this->repository->store( | ||
new RequestOptions( | ||
endpoint: "ordens-producao", | ||
body: $body | ||
) | ||
); | ||
|
||
return CreateResponse::fromResponse($response); | ||
} | ||
|
||
/** | ||
* Gera ordens de produção sob demanda. | ||
* | ||
* @return GenerateOverDemandResponse | ||
* @throws BlingApiException|BlingInternalException | ||
* | ||
* @see https://developer.bling.com.br/referencia#/Ordens%20de%20Produ%C3%A7%C3%A3o/post_ordens_producao_gerar_sob_demanda | ||
*/ | ||
public function generateOverDemand(): GenerateOverDemandResponse | ||
{ | ||
$response = $this->repository->store( | ||
new RequestOptions( | ||
endpoint: "ordens-producao/gerar-sob-demanda" | ||
) | ||
); | ||
|
||
return GenerateOverDemandResponse::fromResponse($response); | ||
} | ||
|
||
/** | ||
* Altera uma ordem de produção. | ||
* | ||
* @param int $idOrdemProducao ID da ordem de produção | ||
* @param array $body Corpo da requisição | ||
* | ||
* @return UpdateResponse | ||
* @throws BlingApiException|BlingInternalException | ||
* | ||
* @see https://developer.bling.com.br/referencia#/Ordens%20de%20Produ%C3%A7%C3%A3o/put_ordens_producao__idOrdemProducao_ | ||
*/ | ||
public function update(int $idOrdemProducao, array $body): null | ||
{ | ||
$response = $this->repository->replace( | ||
new RequestOptions( | ||
endpoint: "ordens-producao/$idOrdemProducao", | ||
body: $body | ||
) | ||
); | ||
|
||
return UpdateResponse::fromResponse($response); | ||
} | ||
|
||
|
||
/** | ||
* Altera a situação de uma ordem de produção. | ||
* | ||
* @param int $idOrdemProducao ID da ordem de produção | ||
* @param array $body Corpo da requisição | ||
* | ||
* @return ChangeSituationResponse | ||
* @throws BlingApiException|BlingInternalException | ||
* | ||
* @see https://developer.bling.com.br/referencia#/Ordens%20de%20Produ%C3%A7%C3%A3o/put_ordens_producao__idOrdemProducao__situacoes | ||
*/ | ||
public function changeSituation(int $idOrdemProducao, array $body): null | ||
{ | ||
$response = $this->repository->replace( | ||
new RequestOptions( | ||
endpoint: "ordens-producao/$idOrdemProducao/situacoes", | ||
body: $body | ||
) | ||
); | ||
|
||
return ChangeSituationResponse::fromResponse($response); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Entities/OrdensDeProducao/Schema/ChangeSituation/ChangeSituationResponse.php
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,24 @@ | ||
<?php | ||
|
||
namespace AleBatistella\BlingErpApi\Entities\OrdensDeProducao\Schema\ChangeSituation; | ||
|
||
use AleBatistella\BlingErpApi\Entities\Shared\BaseResponseRootObject; | ||
use AleBatistella\BlingErpApi\Entities\Shared\DTO\Request\ResponseOptions; | ||
|
||
/** | ||
* Resposta da alteração da situação de uma ordem de produção pelo ID. | ||
*/ | ||
readonly final class ChangeSituationResponse extends BaseResponseRootObject | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public static function fromResponse(ResponseOptions $response): null | ||
{ | ||
if (!is_null($response->body?->content)) { | ||
static::throwForInconsistentResponseOptions($response); | ||
} | ||
|
||
return null; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/Entities/OrdensDeProducao/Schema/Create/CreateResponse.php
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 AleBatistella\BlingErpApi\Entities\OrdensDeProducao\Schema\Create; | ||
|
||
use AleBatistella\BlingErpApi\Entities\Shared\BaseResponseRootObject; | ||
use AleBatistella\BlingErpApi\Entities\Shared\DTO\Request\ResponseOptions; | ||
use AleBatistella\BlingErpApi\Entities\Shared\DTO\Schema\Id; | ||
|
||
/** | ||
* Resposta da criação de uma ordem de produção. | ||
*/ | ||
readonly final class CreateResponse extends BaseResponseRootObject | ||
{ | ||
/** | ||
* Constrói o objeto. | ||
* | ||
* @param Id $data | ||
*/ | ||
public function __construct( | ||
public Id $data | ||
) {} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public static function fromResponse(ResponseOptions $response): static | ||
{ | ||
if (is_null($response->body?->content)) { | ||
static::throwForInconsistentResponseOptions($response); | ||
} | ||
|
||
return self::from($response->body->content); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Entities/OrdensDeProducao/Schema/Delete/DeleteResponse.php
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,24 @@ | ||
<?php | ||
|
||
namespace AleBatistella\BlingErpApi\Entities\OrdensDeProducao\Schema\Delete; | ||
|
||
use AleBatistella\BlingErpApi\Entities\Shared\BaseResponseRootObject; | ||
use AleBatistella\BlingErpApi\Entities\Shared\DTO\Request\ResponseOptions; | ||
|
||
/** | ||
* Resposta da remoção de uma ordem de produção pelo ID. | ||
*/ | ||
readonly final class DeleteResponse extends BaseResponseRootObject | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public static function fromResponse(ResponseOptions $response): null | ||
{ | ||
if (!is_null($response->body?->content)) { | ||
static::throwForInconsistentResponseOptions($response); | ||
} | ||
|
||
return null; | ||
} | ||
} |
Oops, something went wrong.