# Products

## List all purchase products

<mark style="color:blue;">`GET`</mark> `https://app.gem-books.com/api/purchases_products`

This endpoint allows you to get the list of your purchase products.&#x20;

#### Headers

| Name                                             | Type   | Description                  |
| ------------------------------------------------ | ------ | ---------------------------- |
| Authentication<mark style="color:red;">\*</mark> | string | Bearer Token                 |
| Accept                                           | string | Should be `application/json` |

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

```json
{
  "data": [
    {
      "id": 1,
      "purchase_id": 2,
      "product_id": "5",
      "produit_compte": "67",
      "product_name": "Breaks",
      "product_description": "",
      "produit_projet": null,
      "product_quantity": "8.00",
      "produit_quantite_receive": "0.00",
      "produit_quantite_onhold": "8.00",
      "produit_poids": "0.000",
      "produit_poids_receive": "0.000",
      "produit_poids_onhold": "0.000",
      "product_price": "30.0000",
      "product_discount": "0.00",
      "product_serialnumber": "",
      "produit_total": "240.00",
      "taxes_rules_id": 2,
      "gestion_taxes": "[]",
      "province_id": 0,
      "system_id": 99217
    }
  ],
  "meta": {
    "current_page": 1,
    "last_page": 1,
    "per_page": 500,
    "total": 1
  },
  "success": true
}
```

{% endtab %}
{% endtabs %}

## Retrieve a specific sale product

<mark style="color:blue;">`GET`</mark> `https://app.gem-books.com/api/sales_products/:id`

This endpoint allows you to get one specific sale product.&#x20;

#### Path Parameters

| Name | Type    | Description                              |
| ---- | ------- | ---------------------------------------- |
| id   | integer | The ID of the sales product to retrieve. |

#### Headers

| Name                                             | Type   | Description                  |
| ------------------------------------------------ | ------ | ---------------------------- |
| Authentication<mark style="color:red;">\*</mark> | string | Bearer Token                 |
| Accept                                           | string | Should be `application/json` |

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

```json
{
  "data": [
    {
      "id": 1,
      "purchase_id": 2,
      "product_id": "5",
      "produit_compte": "67",
      "product_name": "Breaks",
      "product_description": "",
      "produit_projet": null,
      "product_quantity": "8.00",
      "produit_quantite_receive": "0.00",
      "produit_quantite_onhold": "8.00",
      "produit_poids": "0.000",
      "produit_poids_receive": "0.000",
      "produit_poids_onhold": "0.000",
      "product_price": "30.0000",
      "product_discount": "0.00",
      "product_serialnumber": "",
      "produit_total": "240.00",
      "taxes_rules_id": 2,
      "gestion_taxes": "[]",
      "province_id": 0,
      "system_id": 99217
    }
  ],
  "success": true
}
```

{% endtab %}
{% endtabs %}

## Create a purchase product

<mark style="color:green;">`POST`</mark> `https://app.gem-books.com/api/purchases_products`

#### Headers

| Name           | Type   | Description                  |
| -------------- | ------ | ---------------------------- |
| Authentication | string | Bearer Token                 |
| Content-type   | string | Should be application/json   |
| Accept         | string | Should be `application/json` |

#### Request Body

| Name         | Type   | Description |
| ------------ | ------ | ----------- |
| purchase\_id | string | Invoice ID  |
| product\_id  | string | Product ID  |

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

```json
{
  "data": [
    {
      "id": 2,
      "purchase_id": 5,
      "product_id": "3",
      "product_name": "timing belt",
      "product_description": "",
      "product_quantity": "0.00",
      "product_price": "0.0000",
      "product_discount": "0.00",
      "product_serialnumber": "",
      "produit_cost": "0.00",
      "taxes_rules_id": 2,
      "province_id": 0,
      "system_id": 99217
    }
  ],
  "success": true
}
```

{% endtab %}
{% endtabs %}

#### Body Example

```
{
    "purchase_id": 5,
    "product_id": 3,
    "product_name": "timing belt"
}
```

## Update a purchase product

<mark style="color:orange;">`PUT`</mark> `https://app.gem-books.com/api/purchases_products/:id`

This endpoint allows you to update a specific purchase product. \
Returns the updated purchase product.

#### Path Parameters

| Name | Type    | Description                    |
| ---- | ------- | ------------------------------ |
| id   | integer | Purchase product ID to update. |

#### Headers

| Name           | Type   | Description                  |
| -------------- | ------ | ---------------------------- |
| Authentication | string | Bearer Token                 |
| Content-Type   | string | Should be `application/json` |
| Accept         | string | Should be `application/json` |

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

```json
{
  "data": [
    {
      "id": 2,
      "purchase_id": 5,
      "product_id": "3",
      "product_name": "timing belt",
      "product_description": "",
      "product_quantity": "0.00",
      "product_price": "0.0000",
      "product_discount": "0.00",
      "product_serialnumber": "",
      "produit_cost": "0.00",
      "taxes_rules_id": 2,
      "province_id": 0,
      "system_id": 99217
    }
  ],
  "success": true
}
```

{% endtab %}
{% endtabs %}

#### Body Example

```json
{
    "product_name": "Timing Belt",
    "product_quantity": 10,
    "product_price": 30
}
```
