Add Clientes
parent
da15020193
commit
3bf9fa92d8
|
@ -0,0 +1,294 @@
|
|||
### Documentación - API ogCore
|
||||
|
||||
## Select Language / Seleccionar Idioma
|
||||
|
||||
- [English](#english)
|
||||
- [Español](#español)
|
||||
|
||||
---
|
||||
|
||||
## English
|
||||
|
||||
### Table of Contents
|
||||
|
||||
1. [Introduction](#introduction)
|
||||
2. [Configuration](#configuration)
|
||||
3. [Resource Definition](#resource-definition)
|
||||
4. [API Operations](#api-operations)
|
||||
5. [Entity Properties](#entity-properties)
|
||||
6. [Client Input DTO](#client-input-dto)
|
||||
|
||||
### Introduction
|
||||
|
||||
This documentation describes the configuration of API Platform in a Symfony project. It details the resources, operations, and entity properties exposed through the API.
|
||||
|
||||
### Configuration
|
||||
|
||||
API configuration is done in Symfony configuration files, usually in the `config/packages/api_platform.yaml` file.
|
||||
|
||||
```yaml
|
||||
resources:
|
||||
App\Entity\Client:
|
||||
processor: App\State\Processor\ClientProcessor
|
||||
input: App\Dto\Input\ClientInput
|
||||
output: App\Dto\Output\ClientOutput
|
||||
normalizationContext:
|
||||
groups: ['default', 'client:read']
|
||||
denormalizationContext:
|
||||
groups: ['client:write']
|
||||
operations:
|
||||
ApiPlatform\Metadata\GetCollection:
|
||||
provider: App\State\Provider\ClientProvider
|
||||
filters:
|
||||
- 'api_platform.filter.client.order'
|
||||
- 'api_platform.filter.client.search'
|
||||
- 'api_platform.filter.client.boolean'
|
||||
ApiPlatform\Metadata\Get:
|
||||
provider: App\State\Provider\ClientProvider
|
||||
ApiPlatform\Metadata\Put:
|
||||
provider: App\State\Provider\ClientProvider
|
||||
ApiPlatform\Metadata\Patch:
|
||||
provider: App\State\Provider\ClientProvider
|
||||
validationContext:
|
||||
groups: ['client:patch']
|
||||
ApiPlatform\Metadata\Post: ~
|
||||
ApiPlatform\Metadata\Delete: ~
|
||||
|
||||
change_organizational_units:
|
||||
provider: App\State\Provider\ClientProvider
|
||||
class: ApiPlatform\Metadata\Post
|
||||
method: POST
|
||||
input: App\Dto\Input\ChangeOrganizationalUnitInput
|
||||
uriTemplate: /clients/change-organizational-units
|
||||
controller: App\Controller\ChangeOrganizationalUnitAction
|
||||
|
||||
properties:
|
||||
App\Entity\Client:
|
||||
id:
|
||||
identifier: false
|
||||
uuid:
|
||||
identifier: true
|
||||
```
|
||||
|
||||
### Resource Definition
|
||||
|
||||
#### App\Entity\Client
|
||||
|
||||
- **Processor**: `App\State\Processor\ClientProcessor`
|
||||
- **Input**: `App\Dto\Input\ClientInput`
|
||||
- **Output**: `App\Dto\Output\ClientOutput`
|
||||
- **Normalization Context**: `['default', 'client:read']`
|
||||
- **Denormalization Context**: `['client:write']`
|
||||
|
||||
### API Operations
|
||||
|
||||
#### Client Operations
|
||||
|
||||
##### Get Client Collection (GetCollection)
|
||||
- **Provider**: `App\State\Provider\ClientProvider`
|
||||
- **Filters**:
|
||||
- Order clients: `api_platform.filter.client.order`
|
||||
- Search clients: `api_platform.filter.client.search`
|
||||
- Boolean filter: `api_platform.filter.client.boolean`
|
||||
|
||||
##### Get Client (Get)
|
||||
- **Provider**: `App\State\Provider\ClientProvider`
|
||||
|
||||
##### Update Client (Put)
|
||||
- **Provider**: `App\State\Provider\ClientProvider`
|
||||
|
||||
##### Partially Update Client (Patch)
|
||||
- **Provider**: `App\State\Provider\ClientProvider`
|
||||
- **Validation Context**: `['client:patch']`
|
||||
|
||||
##### Create Client (Post)
|
||||
- **Default Operation**: ~
|
||||
|
||||
##### Delete Client (Delete)
|
||||
- **Default Operation**: ~
|
||||
|
||||
##### Change Organizational Units (Post - Custom Operation)
|
||||
- **Provider**: `App\State\Provider\ClientProvider`
|
||||
- **Class**: `ApiPlatform\Metadata\Post`
|
||||
- **Method**: `POST`
|
||||
- **Input**: `App\Dto\Input\ChangeOrganizationalUnitInput`
|
||||
- **URI Template**: `/clients/change-organizational-units`
|
||||
- **Controller**: `App\Controller\ChangeOrganizationalUnitAction`
|
||||
|
||||
### Entity Properties
|
||||
|
||||
#### App\Entity\Client
|
||||
|
||||
- **id**:
|
||||
- **Identifier**: `false`
|
||||
|
||||
- **uuid**:
|
||||
- **Identifier**: `true`
|
||||
|
||||
### Client Input DTO
|
||||
|
||||
#### Fields Required in Client Endpoint Input
|
||||
|
||||
1. **name**
|
||||
- **Type**: string
|
||||
- **Validation**: Not blank
|
||||
- **Groups**: `client:write`
|
||||
|
||||
2. **email**
|
||||
- **Type**: string
|
||||
- **Validation**: Email
|
||||
- **Groups**: `client:write`
|
||||
|
||||
3. **phoneNumber**
|
||||
- **Type**: string
|
||||
- **Validation**: Not blank
|
||||
- **Groups**: `client:write`
|
||||
|
||||
4. **organization**
|
||||
- **Type**: string
|
||||
- **Validation**: Not blank
|
||||
- **Groups**: `client:write`
|
||||
|
||||
---
|
||||
|
||||
## Español
|
||||
|
||||
### Índice
|
||||
|
||||
1. [Introducción](#introducción)
|
||||
2. [Configuración](#configuración)
|
||||
3. [Definición de Recursos](#definición-de-recursos)
|
||||
4. [Operaciones de API](#operaciones-de-api)
|
||||
5. [Propiedades de la Entidad](#propiedades-de-la-entidad)
|
||||
6. [DTO de Entrada de Cliente](#dto-de-entrada-de-cliente)
|
||||
|
||||
### Introducción
|
||||
|
||||
Esta documentación describe la configuración de API Platform en un proyecto Symfony. Se detallan los recursos, operaciones y propiedades de las entidades expuestas a través de la API.
|
||||
|
||||
### Configuración
|
||||
|
||||
La configuración de la API se realiza en los archivos de configuración de Symfony, generalmente en `config/packages/api_platform.yaml`.
|
||||
|
||||
```yaml
|
||||
resources:
|
||||
App\Entity\Client:
|
||||
processor: App\State\Processor\ClientProcessor
|
||||
input: App\Dto\Input\ClientInput
|
||||
output: App\Dto\Output\ClientOutput
|
||||
normalizationContext:
|
||||
groups: ['default', 'client:read']
|
||||
denormalizationContext:
|
||||
groups: ['client:write']
|
||||
operations:
|
||||
ApiPlatform\Metadata\GetCollection:
|
||||
provider: App\State\Provider\ClientProvider
|
||||
filters:
|
||||
- 'api_platform.filter.client.order'
|
||||
- 'api_platform.filter.client.search'
|
||||
- 'api_platform.filter.client.boolean'
|
||||
ApiPlatform\Metadata\Get:
|
||||
provider: App\State\Provider\ClientProvider
|
||||
ApiPlatform\Metadata\Put:
|
||||
provider: App\State\Provider\ClientProvider
|
||||
ApiPlatform\Metadata\Patch:
|
||||
provider: App\State\Provider\ClientProvider
|
||||
validationContext:
|
||||
groups: ['client:patch']
|
||||
ApiPlatform\Metadata\Post: ~
|
||||
ApiPlatform\Metadata\Delete: ~
|
||||
|
||||
change_organizational_units:
|
||||
provider: App\State\Provider\ClientProvider
|
||||
class: ApiPlatform\Metadata\Post
|
||||
method: POST
|
||||
input: App\Dto\Input\ChangeOrganizationalUnitInput
|
||||
uriTemplate: /clients/change-organizational-units
|
||||
controller: App\Controller\ChangeOrganizationalUnitAction
|
||||
|
||||
properties:
|
||||
App\Entity\Client:
|
||||
id:
|
||||
identifier: false
|
||||
uuid:
|
||||
identifier: true
|
||||
```
|
||||
|
||||
### Definición de Recursos
|
||||
|
||||
#### App\Entity\Client
|
||||
|
||||
- **Processor**: `App\State\Processor\ClientProcessor`
|
||||
- **Input**: `App\Dto\Input\ClientInput`
|
||||
- **Output**: `App\Dto\Output\ClientOutput`
|
||||
- **Contexto de Normalización**: `['default', 'client:read']`
|
||||
- **Contexto de Desnormalización**: `['client:write']`
|
||||
|
||||
### Operaciones de API
|
||||
|
||||
#### Operaciones de Cliente
|
||||
|
||||
##### Obtener Colección de Clientes (GetCollection)
|
||||
- **Provider**: `App\State\Provider\ClientProvider`
|
||||
- **Filtros**:
|
||||
- Ordenar clientes: `api_platform.filter.client.order`
|
||||
- Buscar clientes: `api_platform.filter.client.search`
|
||||
- Filtro booleano: `api_platform.filter.client.boolean`
|
||||
|
||||
##### Obtener Cliente (Get)
|
||||
- **Provider**: `App\State\Provider\ClientProvider`
|
||||
|
||||
##### Actualizar Cliente (Put)
|
||||
- **Provider**: `App\State\Provider\ClientProvider`
|
||||
|
||||
##### Actualización Parcial de Cliente (Patch)
|
||||
- **Provider**: `App\State\Provider\ClientProvider`
|
||||
- **Contexto de Validación**: `['client:patch']`
|
||||
|
||||
##### Crear Cliente (Post)
|
||||
- **Operación Predeterminada**: ~
|
||||
|
||||
##### Eliminar Cliente (Delete)
|
||||
- **Operación Predeterminada**: ~
|
||||
|
||||
##### Cambiar Unidades Organizativas (Post - Operación Personalizada)
|
||||
- **Provider**: `App\State\Provider\ClientProvider`
|
||||
- **Clase**: `ApiPlatform\Metadata\Post`
|
||||
- **Método**: `POST`
|
||||
- **Entrada**: `App\Dto\Input\ChangeOrganizationalUnitInput`
|
||||
- **Plantilla URI**: `/clients/change-organizational-units`
|
||||
- **Controlador**: `App\Controller\ChangeOrganizationalUnitAction`
|
||||
|
||||
### Propiedades de la Entidad
|
||||
|
||||
#### App\Entity\Client
|
||||
|
||||
- **id**:
|
||||
- **Identificador**: `false`
|
||||
|
||||
- **uuid**:
|
||||
- **Identificador**: `true`
|
||||
|
||||
### DTO de Entrada de Cliente
|
||||
|
||||
#### Campos Requeridos en la Entrada del Endpoint de Cliente
|
||||
|
||||
1. **name**
|
||||
- **Tipo**: string
|
||||
- **Validación**: No nulo
|
||||
- **Groups**: `client:write`
|
||||
|
||||
2. **email**
|
||||
- **Tipo**: string
|
||||
- **Validación**: Email
|
||||
- **Groups**: `client:write`
|
||||
|
||||
3. **phoneNumber**
|
||||
- **Tipo**: string
|
||||
- **Validación**: No nulo
|
||||
- **Groups**: `client:write`
|
||||
|
||||
4. **organization**
|
||||
- **Tipo**: string
|
||||
- **Validación**: No nulo
|
||||
- **Groups**
|
Loading…
Reference in New Issue