Products

Fetch all products


Return all the products
GET /products
page Page number of products to return. Returns empty array if the page has no products. If page parameter isn't present, returns the first page Optional
size Number of products to return in a page. If size parameter isn't present, returns the page with 25 products Optional
Response Body
[
    {
        "_id": "521f26edcce8b4310e000079",
        "name": "Foo ABC Product",
        "price": 1000,
        "leads": [
            {
                "_id": "521f26eccce8b4310e000074",
                "name": "[Sample] Foo"
            }
        ]
    }
]

Show a product


Show details of an individual product
GET /products/:product_id
product_id Unique identifier of the product Required
Response Body
{
    "_id": "521f26edcce8b4310e000079",
    "name": "Foo ABC Product",
    "price": 1000,
    "leads": [
        {
            "_id": "521f26eccce8b4310e000074",
            "name": "[Sample] Foo"
        }
    ]
}

Create a product


Create a new product
POST /products
name Name of the product Required
price Price of the product (numbers only) Optional
Response Body
{
    "_id": "527cd58ecce8b4dc4000001f",
    "name": "New Product",
    "price": 2000
}

Update a product


Update the name and price of a product
PUT /products/:product_id
product_id Unique identifier of the product Required
name Name of the product Optional
price Price of the product (numbers only) Optional
Response Body
{
    "_id": "527cd58ecce8b4dc4000001f",
    "name": "Updated Product",
    "price": 2500
}

Delete a product


Delete a product
DELETE /products/:product_id
product_id Unique identifier of the product Required
Response Body
{}

Fetch all products for a lead


Return all the products for a specified lead
GET /leads/:lead_id/products
lead_id Unique identifier of the lead Required
page Page number of products to return. Returns empty array if the page has no products. If page parameter isn't present, returns the first page Optional
size Number of products to return in a page. If size parameter isn't present, returns the page with 25 products Optional
Response Body
[
    {
        "_id": "521f26edcce8b4310e00007c",
        "quantity": 3,
        "name": "Foo XYZ Product"
    }
]

Show a product for a lead


Show details of an individual product associated with a specified lead
GET /leads/:lead_id/products/:product_id
lead_id Unique identifier of the lead Required
product_id Unique identifier of the product Required
Response Body
{
    "_id": "521f26edcce8b4310e00007c",
    "quantity": 3,
    "name": "Foo XYZ Product"
}

Add a product to a lead


Add a product to a specified lead
PUT /leads/:lead_id/products/:product_id
lead_id Unique identifier of the lead Required
product_id Unique identifier of the product Required
quantity Quantity of the product (numbers only) Required
Response Body
{
    "_id": "521f26edcce8b4310e00007c",
    "quantity": 3,
    "name": "Foo XYZ Product"
}

Remove a product for a lead


Remove a product from the list of products associated with a specified lead
DELETE /leads/:lead_id/products/:product_id
lead_id Unique identifier of the lead Required
product_id Unique identifier of the product Required
Response Body
{}