> For the complete documentation index, see [llms.txt](https://docs.ventiapp.mx/ventiapp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ventiapp.mx/ventiapp/desarrolladores/api/categorias.md).

# Categorías

## Create Category

<mark style="color:green;">`POST`</mark> `https://ventiapi.azurewebsites.net/api/Category/CreateCategory`

Este endpoint será utilizado para crear nuevas categorias en Ventiapp, se podrá hacer un mapeo automático en caso de especificar la información de origen (source)

#### Headers

| Name          | Type   | Description      |
| ------------- | ------ | ---------------- |
| Authorization | string | Bearer + Token   |
| Content-Type  | string | application/json |

{% tabs %}
{% tab title="200 Categoría creada con éxito" %}

```javascript
{
    "title": "Kitchen",
    "categoryId": 59869
}
```

{% endtab %}

{% tab title="400 La categoría ya existe" %}

```javascript
{
    "message": "Error: There is already a category with the same origin and category id. "
}
```

{% endtab %}
{% endtabs %}

Body:

```javascript
{
    "Title": "Kitchen",
    "CategorySource": "magento",
    "CategorySourceId": 19,
    "CategorySourceParent": null,
    "CategorySourceParentId": null
}
```

Parámetros del body:

**Title**: Título que llevará la categoría creada en Ventiapp\
**CategorySource**: Canal de origen donde estamos obteniendo la categoría, ej: "magento"\
**CategorySourceId**: Id de origen donde la estamos obteniendo la categoría, ej: 19\
**CategorySourceParent**: Nombre del canal Padre, en donde obtiene la integración destino, en caso de no existir una categoría destino\
**CategorySourceParentId**: Id de Ventiapp de la categoría Padre, en caso de querer insertar a la categoría como nodo hijo

## Update Category

<mark style="color:green;">`POST`</mark> `https://ventiapi.azurewebsites.net/api/Category/UpdateCategory`

Este endpoint será utilizado para actualizar una categoría existente en Ventiapp

#### Headers

| Name          | Type   | Description      |
| ------------- | ------ | ---------------- |
| Authorization | string | Bearer + token   |
| Content-Type  | string | application/json |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "title": "Bathroom",
    "categoryId": 59869
}
```

{% endtab %}

{% tab title="400 La categoría no existe" %}

```javascript
{
    "message": "Error: Category not found. "
}
```

{% endtab %}

{% tab title="500: Internal Server Error " %}

```javascript
{
    "message": "Error: No response was obtained from the server."
}
```

{% endtab %}
{% endtabs %}

Body:

```javascript
{
    "Title": "Bathroom",
    "CategorySource": "tiendanube",
    "CategorySourceId": 3
}
```

Parámetros del body:

**Title**: Título que llevará la categoría actualizada en Ventiapp\
**CategorySource**: Canal de origen donde estamos obteniendo la categoría, ej: "tiendanube"\
**CategorySourceId**: Id de origen donde la estamos obteniendo la categoría, ej: 3<br>

## Search Category

<mark style="color:blue;">`GET`</mark> `https://ventiapi.azurewebsites.net/api/Category/SearchCategory`

Este método será utilizado para buscar una categoría específica en un canal

#### Query Parameters

| Name    | Type   | Description                         |
| ------- | ------ | ----------------------------------- |
| Keyword | string | Palabras para busquéda de categoría |
| Channel | string | Canal donde se desa buscar ej: meli |

#### Headers

| Name          | Type   | Description      |
| ------------- | ------ | ---------------- |
| Authorization | string | Bearer + Token   |
| Content-Type  | string | application/json |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "title": "Postes de Asiento",
    "categoryId": "MLM189777"
}
```

{% endtab %}
{% endtabs %}

Ejemplo de Query:  <https://ventiapi.azurewebsites.net/api/Category/SearchCategory?Keyword=zapatos\\&channel=meli>

## Map Category

<mark style="color:green;">`POST`</mark> `https://ventiapi.azurewebsites.net/api/Category/MapCategory`

Este método es utilizado para mapear una categoría de un canal hacia otro

#### Headers

| Name          | Type   | Description      |
| ------------- | ------ | ---------------- |
| Authorization | string | Bearer + token   |
| Content-Type  | string | application/json |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "title": "Postes de asiento",
    "categoryId": 63699
}
```

{% endtab %}
{% endtabs %}

Body

```json
{
   "channelSource" : "magento",
   "categorySourceId" : 50,
   "channelTarget" : "meli",
   "categoryTargetId" : "MLM189777"
}
```

## GetCategories

<mark style="color:blue;">`GET`</mark> `https://ventiapi.azurewebsites.net/api/Category/GetCategories`

Este método es utilizado para buscar alguna categoría de un canal dentro de Ventiapp.

Canales disponibles:

Mercado Libre - **"meli"**

Magento - **"magento"**

#### Query Parameters

| Name                                      | Type   | Description |
| ----------------------------------------- | ------ | ----------- |
| channel<mark style="color:red;">\*</mark> | String |             |

{% tabs %}
{% tab title="200: OK " %}

```json
// Ejemplo "magento"
{
    "items": [
        {
            "id": 2,
            "parent_id": 1,
            "name": "MensFashion",
            "is_active": true,
            "position": 1,
            "level": 1,
            "children": "4,5,6,7,8,9,10,19,44,112,125,147,297,318,335,338,353,372,376,377,382,391,412,433,447,450,454,470,471,479,503,527,528,529,533,584,612,627,697",
            "created_at": "2018-04-12 16:43:08",
            "updated_at": "2022-04-19 15:35:55",
            "path": "1/2",
            "available_sort_by": [],
            "include_in_menu": false,
            "custom_attributes": [
                {
                    "attribute_code": "description",
                    "value": "<div data-content-type=\"row\" data-appearance=\"contained\" data-element=\"main\"><div data-enable-parallax=\"0\" data-parallax-speed=\"0.5\" data-background-images=\"{}\" data-element=\"inner\" data-pb-style=\"60E2FED03F516\"><div class=\"pagebuilder-column-group\" data-content-type=\"column-group\" data-grid-size=\"12\" data-element=\"main\" data-pb-style=\"60E2FED03F52D\"><div class=\"pagebuilder-column\" data-content-type=\"column\" data-appearance=\"full-height\" data-background-images=\"{}\" data-element=\"main\" data-pb-style=\"60E2FED03F53E\"><figure data-content-type=\"image\" data-appearance=\"full-width\" data-element=\"main\" data-pb-style=\"60E2FED03F54E\"><img class=\"pagebuilder-mobile-hidden\" src=\"{{media url=wysiwyg/test-categoria2_1.jpg}}\" alt=\"\" title=\"\" data-element=\"desktop_image\" data-pb-style=\"60E2FED03F55D\"><img class=\"pagebuilder-mobile-only\" src=\"{{media url=wysiwyg/test-categoria2_1.jpg}}\" alt=\"\" title=\"\" data-element=\"mobile_image\" data-pb-style=\"60E2FED03F56C\"></figure></div><div class=\"pagebuilder-column\" data-content-type=\"column\" data-appearance=\"full-height\" data-background-images=\"{}\" data-element=\"main\" data-pb-style=\"60E2FED03F57B\"><figure data-content-type=\"image\" data-appearance=\"full-width\" data-element=\"main\" data-pb-style=\"60E2FED03F58A\"><img class=\"pagebuilder-mobile-hidden\" src=\"{{media url=wysiwyg/test-categoria1_2.jpg}}\" alt=\"\" title=\"\" data-element=\"desktop_image\" data-pb-style=\"60E2FED03F599\"><img class=\"pagebuilder-mobile-only\" src=\"{{media url=wysiwyg/test-categoria1_2.jpg}}\" alt=\"\" title=\"\" data-element=\"mobile_image\" data-pb-style=\"60E2FED03F5A8\"></figure></div></div></div></div><style>#html-body [data-pb-style=\"60E2FED03F516\"]{justify-content: flex-start; display: flex; flex-direction: column; background-position: left top; background-size: cover; background-repeat: no-repeat; background-attachment: scroll; border-style: none; border-width: 1px; border-radius: 0px; margin: 0px 0px 10px; padding: 10px;}#html-body [data-pb-style=\"60E2FED03F52D\"]{display: flex;}#html-body [data-pb-style=\"60E2FED03F53E\"]{justify-content: flex-start; display: flex; flex-direction: column; background-position: left top; background-size: cover; background-repeat: no-repeat; background-attachment: scroll; border-style: none; border-width: 1px; border-radius: 0px; width: 50%; margin: 0px; padding: 10px; align-self: stretch;}#html-body [data-pb-style=\"60E2FED03F54E\"]{margin: 0px; padding: 0px; border-style: none;}#html-body [data-pb-style=\"60E2FED03F55D\"]{border-style: none; border-width: 1px; border-radius: 0px; max-width: 100%; height: auto;}#html-body [data-pb-style=\"60E2FED03F56C\"]{border-style: none; border-width: 1px; border-radius: 0px; max-width: 100%; height: auto;}#html-body [data-pb-style=\"60E2FED03F57B\"]{justify-content: flex-start; display: flex; flex-direction: column; background-position: left top; background-size: cover; background-repeat: no-repeat; background-attachment: scroll; border-style: none; border-width: 1px; border-radius: 0px; width: 50%; margin: 0px; padding: 10px; align-self: stretch;}#html-body [data-pb-style=\"60E2FED03F58A\"]{margin: 0px; padding: 0px; border-style: none;}#html-body [data-pb-style=\"60E2FED03F599\"]{border-style: none; border-width: 1px; border-radius: 0px; max-width: 100%; height: auto;}#html-body [data-pb-style=\"60E2FED03F5A8\"]{border-style: none; border-width: 1px; border-radius: 0px; max-width: 100%; height: auto;}</style>"
                },
                {
                    "attribute_code": "image",
                    "value": "categoria.jpg"
                },
                {
                    "attribute_code": "meta_title",
                    "value": "Trajes para Caballero en Men's Fashion | Trajes para Hombres"
                },
                {
                    "attribute_code": "meta_keywords",
                    "value": "ropa, para, 2019, moda, sport, hombre, mejor, precios, mejores, calidad, vestir"
                },
                {
                    "attribute_code": "meta_description",
                    "value": "Trajes Formales para Hombre, Camisas de Vestir, Pantalones para Caballeros y Sacos en Men's Fashion. Trajes para Hombre de las Mejores Marcas - Trajes para Caballero"
                },
                {
                    "attribute_code": "display_mode",
                    "value": "PRODUCTS"
                },
                {
                    "attribute_code": "is_anchor",
                    "value": "1"
                },
                {
                    "attribute_code": "path",
                    "value": "1/2"
                },
                {
                    "attribute_code": "page_layout",
                    "value": "category-full-width"
                },
                {
                    "attribute_code": "children_count",
                    "value": "192"
                },
                {
                    "attribute_code": "custom_use_parent_settings",
                    "value": "0"
                },
                {
                    "attribute_code": "custom_apply_to_products",
                    "value": "0"
                },
                {
                    "attribute_code": "url_key",
                    "value": "mensfashion"
                },
                {
                    "attribute_code": "automatic_sorting",
                    "value": "0"
                },
                {
                    "attribute_code": "is_new",
                    "value": "0"
                },
                {
                    "attribute_code": "is_sale",
                    "value": "0"
                },
                {
                    "attribute_code": "use_name_in_product_search",
                    "value": "1"
                },
                {
                    "attribute_code": "virtual_rule",
                    "value": {
                        "condition": {
                            "condition_type": "Smile\\ElasticsuiteVirtualCategory\\Model\\Rule\\Condition\\Combine",
                            "aggregator_type": "all",
                            "operator": null,
                            "value": "1"
                        }
                    }
                },
                {
                    "attribute_code": "use_store_positions",
                    "value": "0"
                },
                {
                    "attribute_code": "sync_to_facebook_catalog",
                    "value": "1"
                },
                {
                    "attribute_code": "googleshopping_cat_exlude",
                    "value": "0"
                }
            ]
        },
        {
            "id": 3,
            "parent_id": 1,
            "name": "Roberts",
            "is_active": true,
            "position": 2,
            "level": 1,
            "children": "186,187,190,192,272,400,405,406,407,411,418,424,438,449,472,473,474,475,477,478,501,502,585,586,587,588,589,600,628,629,630,631,653,661,664,665,666,667,668,669,690",
            "created_at": "2018-05-03 15:15:18",
            "updated_at": "2021-11-23 21:36:30",
            "path": "1/3",
            "available_sort_by": [],
            "include_in_menu": true,
            "custom_attributes": [
                {
                    "attribute_code": "display_mode",
                    "value": "PRODUCTS"
                },
                {
                    "attribute_code": "is_anchor",
                    "value": "1"
                },
                {
                    "attribute_code": "path",
                    "value": "1/3"
                },
                {
                    "attribute_code": "children_count",
                    "value": "106"
                },
                {
                    "attribute_code": "custom_use_parent_settings",
                    "value": "0"
                },
                {
                    "attribute_code": "custom_apply_to_products",
                    "value": "0"
                },
                {
                    "attribute_code": "url_key",
                    "value": "roberts"
                },
                {
                    "attribute_code": "is_new",
                    "value": "1"
                },
                {
                    "attribute_code": "is_sale",
                    "value": "1"
                },
                {
                    "attribute_code": "use_name_in_product_search",
                    "value": "1"
                },
                {
                    "attribute_code": "virtual_rule",
                    "value": {
                        "condition": {
                            "condition_type": "Smile\\ElasticsuiteVirtualCategory\\Model\\Rule\\Condition\\Combine",
                            "aggregator_type": "all",
                            "operator": null,
                            "value": true
                        }
                    }
                }
            ]
        }
   ]
}
```

{% endtab %}

{% tab title="400: Bad Request Canal sin implementar" %}

```json
{
    "message": "channel {channel} not found."
}
```

{% endtab %}

{% tab title="400: Bad Request Categoría no encontrada" %}

```json
{
    "message": "Error: Category not found."
}
```

{% endtab %}

{% tab title="500: Internal Server Error El servidor no responde" %}

```javascript
{
    "message": "Error: No response was obtained from the server."
}
```

{% endtab %}
{% endtabs %}

## Delete Category

<mark style="color:red;">`DELETE`</mark> `https://ventiapi.azurewebsites.net/api/Category/DeleteCategory`

Este método es utilizado para borrar alguna categoría dentro de Ventiapp.

#### Query Parameters

| Name                                         | Type | Description              |
| -------------------------------------------- | ---- | ------------------------ |
| internalId<mark style="color:red;">\*</mark> | int  | ID categoría de VentiApp |

{% tabs %}
{% tab title="200: OK Borrado exitosamente" %}

```json
"Category {internalId} has been deleted successfully."
```

{% endtab %}

{% tab title="400: Bad Request La categoría es de un canal diferente al de VentiApp" %}

```json
{
    "message": "Error: Category not found or channel is different from ventiapp."
}
```

{% endtab %}

{% tab title="400: Bad Request La categoría tiene subcategoría/s" %}

```javascript
{
    "message": "Error: The category has any subcategories."
}
```

{% endtab %}

{% tab title="500: Internal Server Error Error del servidor" %}

```javascript
{
    "message": "Error: There was an error, contact technical support."
}
```

{% endtab %}
{% endtabs %}
