# Consumer Endpoints

The Consumer Search Suite provides a set of endpoints to:

- Authenticate
- Search Criteria
- Customer Data Requirements
- Consumer Search


## Flow Diagram

```mermaid
graph TD
    A(Authentication) --> B(Consumer Search Criteria)
    B --> C(Return Custom Report Parameters)
    C --> D(Consumer Report)
```

> *Diagram summary (accessibility): Authenticate first, then get consumer search criteria, retrieve custom report parameters where required, and finally run the consumer report request.*


## 1. Authenticate

Before using any of the endpoints, you must authenticate. This ensures you have the necessary permissions to access the data.

### Example Request

```http
POST /authenticate
```

## 2. Consumer Search Criteria

This endpoint returns all the parameters you (The logged in user) will need to use in the consumer endpoint to narrow the search to one unique result.

This endpoint uses the `countries` to search for the parameters available.

### Example Request

```http
GET /consumers/searchcriteria?countries=de
```

### Response Object

The response object will provide a list of query parameters that will need to be submitted in the Consumer request. It will also define if a specific proeprty is required.

### Example Response

```json
{
"correlationId":"0a24e698-2304-4cad-909a-b089db51e940",
"countries":[
    "DE"
    ],
"criteriaSets":[
    {
    "firstName":{
        "required":true
        },
    "lastName":{
        "required":true
        },
    "dateOfBirth":{
        "required":false
        },
    "address":{
        "street":{
            "required":true,
            "minLength":2
            },
        "city":{
            "required":true,
            "minLength":2
            },
        "postCode":{
            "required":true,
            "minLength":5,
            "maxLength":5
            },
        "houseNo":{
            "required":true
            }
        },
    "customData":{
        "required":true
        }
    }
],
"customData":[
    {
        "key":"de_reason_code",
        "optional":false,
        "allowedValues":[
            "BD"
            ],
        "allowMultiple":false
        }
    ]
}
```

## 3. Custom Report Parameters

The `customData` parameter in the consumer report endpoint is required for certain countries. If the `Consumer Search Criteria` endpoint indicates that `customData` is required, use this endpoint to retrieve the necessary values.

### Example Request

```http
GET /reportcustomdata/de
```

## 4. Consumer Report

The consumer report requires a single unique result to generate the report. Ensure that all required parameters are provided to narrow the search to one result.

### Example Request

```http
get /consumers
```