# Modificar objeto

Para modificar un objeto en cliente, se debe enviar un PUT como el que se especifica a continuación.

<mark style="color:orange;">`PUT`</mark> `https://api.persat.com.ar/v1/clientobjvalue/uid_client/obj_id/field_1`

#### Path Parameters

| Name                                          | Type   | Description                                         |
| --------------------------------------------- | ------ | --------------------------------------------------- |
| uid\_client<mark style="color:red;">\*</mark> | String | Indentificador del cliente                          |
| obj\_id<mark style="color:red;">\*</mark>     | Number | Identificador del tipo de objeto. Heladeras por ej. |
| field\_1<mark style="color:red;">\*</mark>    | String | Identificador del elemento a modificar              |

#### Headers

| Name                                            | Type   | Description      |
| ----------------------------------------------- | ------ | ---------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer API\_KEY  |
| Content-Type<mark style="color:red;">\*</mark>  | String | application/json |

#### Request Body

| Name        | Type   | Description                                                               |
| ----------- | ------ | ------------------------------------------------------------------------- |
| uid\_client | String | Identificador del cliente al que quiero mover el objeto                   |
| fields      | Object | Los campos del objeto a insertar. Ver en el ejemplo en esta misma sección |

{% tabs %}
{% tab title="200: OK La consulta se ejecutó con éxito" %}

```json
{
    "success": true,
    "data": {
        "uid_client": "AABC9098",
        "obj_id": 2,
        "fields": {
            "1": "AABCSA090AA",
            "4": "cycle de frost",
            "3": "1500"
            "6": "",
            "7": "",
            "8": ""
        },
        "updated": "2022-05-19T19:38:44.000Z"
    }
}
```

{% endtab %}

{% tab title="404: Not Found El objeto a modificar no existe" %}

```json
{
    "success": false,
    "error": {
        "status": 404,
        "type": "NOT_FOUND",
        "userMessage": "El recurso no existe"
    }
}
```

{% endtab %}

{% tab title="400: Bad Request Error en alguno de los campos enviados. userMessage contiene informacipon adicional." %}

```javascript
{
    "success": false,
    "error": {
        "status": 400,
        "type": "BAD_REQUEST",
        "userMessage": "'obj_id' debe ser un number"
    }
}
```

{% endtab %}
{% endtabs %}

## Ejemplo Modificando un campo del Objeto

En este ejemplo queremos modificar la heladera identificada con&#x20;

* **field\_1**: <mark style="color:green;">AABCSA090AA</mark>      - Identificador de la heladera
* **obj\_id**: 2                              - Tipo de Objeto Heladera
* **uid\_client**: <mark style="color:blue;">AABC9098</mark>        - Identificador del cliente

Y modificar únicamente el tipo de heladera que es el field "4" para nuestra plantilla

La consulta PUT entonces queda así:

\*\*<https://api.persat.com.ar/v1/clientobjvalue**/><mark style="color:blue;">AABC9098</mark>/2/<mark style="color:green;">AABCSA090AA</mark>

#### body

```json
{
    "fields": {
        "4": "cycle de frost"
    }
}
```

{% hint style="info" %}
Los valores a insertar son siempre strings, mas alla de que en la definición de la plantilla sean de tipo Numero, email, etc.&#x20;

Por el momento, no se realizan validaciones durante la inserción o modificación de estos campos.&#x20;
{% endhint %}

### Analizando la Respuesta

En caso que no haya ningun error, obtenemos el objeto completo con la modificación realizada

```json
{
    "success": true,
    "data": {
        "uid_client": "AABC9098",
        "obj_id": 2,
        "fields": {
            "1": "AABCSA090AA",
            "4": "cycle de frost",
            "3": "1500"
            "6": "",
            "7": "",
            "8": ""
        },
        "updated": "2022-05-19T19:38:44.000Z"
    }
}
```

**updated:** Es la fecha de inserción o modificación en UTC

## Ejemplo Moviendo el objeto a otro cliente

En este ejemplo queremos mover la heladera a otro cliente. La heladera esta identificada por estos datos

* **field\_1**: <mark style="color:green;">AABCSA090AA</mark>      - Identificador de la heladera
* **obj\_id**: 2                              - Tipo de Objeto Heladera
* **uid\_client**: <mark style="color:blue;">AABC9098</mark>        - Identificador del cliente

Y la queremos mover al cliente con uid\_client: **BJJKJ777**. La consulta PUT entonces queda igual que en el ejemplo anterior solo que lo que cambia ahora es el body

#### body

```json
{
    "uid_client": "BJJKJ777"
}
```

### Analizando la Respuesta

En caso que no haya ningun error, obtenemos el objeto, ahora situado en el nuevo cliente

```json
{
    "success": true,
    "data": {
        "uid_client": "BJJKJ777",
        "obj_id": 2,
        "fields": {
            "1": "AABCSA090AA",
            "4": "cycle de frost",
            "3": "1500"
            "6": "",
            "7": "",
            "8": ""
        },
        "updated": "2022-05-19T19:38:44.000Z"
    }
}
```

{% hint style="success" %}
Se puede mover un objeto a otro cliente mientras se modifican los campos internos al mismo tiempo. Es cuestión de enviar en el body ambas modificaciones

**body**

```
{
    "uid_client": "BJJKJ777",
    "fields": {
        "4": "cycle de frost"
    }
}
```

{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.api.persat.com.ar/entidades-basicas/objetos-en-cliente/modificar-objeto.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
