> For the complete documentation index, see [llms.txt](https://switchng.gitbook.io/switch/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://switchng.gitbook.io/switch/services-enrollment.md).

# Services Enrollment

```
STAGING_URL: https://switch-api-staging.herokuapp.com
LIVE_URL: https://switchapi.azurewebsites.net
```

## Get Vendor Products

<mark style="color:green;">`POST`</mark> `https://switch-api-staging.herokuapp.com/user/enrolments/vendors/:id/products`

This endpoint retrieves the list of vendor products.\
The list of possible response\_types returned include:\
\- text\
\- radio\
\- checkbox\
\- file\
\- date\
\- resource\
\- dependable

#### Headers

| Name        | Type   | Description                                                           |
| ----------- | ------ | --------------------------------------------------------------------- |
| auth\_token | string | The format for **auth\_token** is **Bearer&#x20;*****token\_string*** |

#### Request Body

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| sub\_category | string | product subcategory |

{% tabs %}
{% tab title="200 Vendor products retrieved successfully" %}

```javascript
{
    "message": "Vendor products retrieved successfully",
    "data":[
        {
            "id": 4,
            "name": "Target Savings",
            "category": "savings",
            "sub_category": "target_savings",
            "active": true,
            "created_at": "2019-02-26T09:55:11.257Z",
            "vendor_id": 2,
            "approval_status": "approved",
            "approval_comment": "okay",
            "vendor_name": "piggyvest",
            "vendor_logo_url": "https://storage.googleapis.com/switch/Vendor%20Logos/Piggyvest.png",
            "integration_service_name": "piggyvest",
            "product_requirements":[
                {
                    "id": 12,
                    "name": "frequency",
                    "depends_on": null,
                    "response_type": "radio_choice",
                    "response_fields":[
                        {
                            "key": "daily",
                            "value": "daily",
                            "text":"Daily"
                        },
                        {
                            "key": "weekly",
                            "value": "weekly",
                            "text": "Weekly"
                        },
                        {
                            "key": "monthly",
                            "value": "monthly",
                            "text": "Monthly"
                        }
                    ]
                },
                {
                    "id": 10,
                    "name": "name",
                    "depends_on": null,
                    "response_type": "text",
                    "response_fields": null
                },
                {
                    "id": 11,
                    "name": "target_amount",
                    "depends_on": null,
                    "response_type": "text",
                    "response_fields": null
                },
                {
                    "id": 14,
                    "name": "amount",
                    "depends_on": null,
                    "response_type": "text",
                    "response_fields":null
                },
                {
                    "id": 15,
                    "name": "withdrawal_date",
                    "depends_on": null,
                    "response_type": "date",
                    "response_fields": null
                },
                {
                    "id": 13,
                    "name": "duration_in_months",
                    "depends_on": null,
                    "response_type": "text",
                    "response_fields": null
                }
            ]
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Retrieve User Enrolments

<mark style="color:blue;">`GET`</mark> `https://switch-api-staging.herokuapp.com/user/enrolments`

#### Headers

| Name        | Type   | Description                                                           |
| ----------- | ------ | --------------------------------------------------------------------- |
| auth\_token | string | The format for **auth\_token** is **Bearer&#x20;*****token\_string*** |

{% tabs %}
{% tab title="200 Products enrolments retrieved successfully" %}

```
{
    "message":"Product enrolments retrieved successfully",
    "data":[
        {
            "id":14,
            "product": "Target Savings",
            "vendor": "piggyvest",
            "created_at": "2019-03-27T16:37:47.079Z",
            "vendor_logo_url":"https://storage.googleapis.com/switch/Vendor%20Logos/Piggyvest.png",
            "data":{
                "name": "Something",
                "target_amount": "20000",
                "amount": "5000",
                "withdrawal_date": "2019-04-27",
                "frequency": "weekly",
                "duration_in_months": "1",
                "description": "Something",
                "sub_description":"N5000 per week"
            },
            "transactions":[
                {
                    "amount_kobo": 500000,
                    "total_kobo": 500000,
                    "transaction_type": "debit",
                    "created_at": "2019-03-27T16:37:46.059Z",
                    "status": "success"
                },
                {
                    "amount_kobo": 500000,
                    "total_kobo": 500000,
                    "transaction_type": "debit",
                    "created_at": "2019-04-25T16:24:05.872Z",
                    "status": "success"
                }
            ]
        },
        {
            "id": 9,
            "product": "Target Savings",
            "vendor": "piggyvest",
            "created_at": "2019-03-25T14:08:42.363Z",
            "vendor_logo_url": "https://storage.googleapis.com/switch/Vendor%20Logos/Piggyvest.png",
            "data":{
                "name": "Investment",
                "target_amount": "1000",
                "frequency": "monthly",
                "amount": "500",
                "withdrawal_date": "2019-05-25",
                "duration_in_months": "2",
                "description": "Investment",
                "sub_description": "N500 per month"
            },
            "transactions":[
                null,
                {
                    "amount_kobo": 50000,
                    "total_kobo": 50000,
                    "transaction_type": "debit",
                    "created_at": "2019-03-25T14:08:41.895Z",
                    "status": "success"
                },
                {
                    "amount_kobo": 50000,
                    "total_kobo": 50000,
                    "transaction_type": "debit",
                    "created_at": "2019-04-25T16:24:09.222Z",
                    "status": "success"
                }
            ]
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Enroll for Service

<mark style="color:blue;">`GET`</mark> `https://switch-api-staging.herokuapp.com/user/enrolments`

#### Headers

| Name        | Type   | Description                                                           |
| ----------- | ------ | --------------------------------------------------------------------- |
| auth\_token | string | The format for **auth\_token** is **Bearer&#x20;*****token\_string*** |

#### Request Body

| Name                   | Type   | Description           |
| ---------------------- | ------ | --------------------- |
| answered\_requirements | string | answered requirements |
| product\_id            | string | product ID            |

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

```
```

{% endtab %}

{% tab title="404 Resource doesn't exist" %}

```
{
    "message": "The resource does not exist"
}
```

{% endtab %}
{% endtabs %}

## Get Vendor Categories

<mark style="color:blue;">`GET`</mark> `https://switch-api-staging.herokuapp.com/user/enrolments/categories`

Get categories for vendors

#### Path Parameters

| Name        | Type   | Description                                  |
| ----------- | ------ | -------------------------------------------- |
| auth\_token | string | The format for **auth\_token** is **Bearer** |

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

```
{
    "message": "Vendor categories retrieved successfully",
    "data": [
        "recommended",
        "investments",
        "insurance",
        "savings"
    ]
}
```

{% endtab %}
{% endtabs %}

## Get Vendors

<mark style="color:blue;">`GET`</mark> `https://switch-api-staging.herokuapp.com/user/enrolments/vendors`

Get all vendors

#### Headers

| Name        | Type   | Description                                                           |
| ----------- | ------ | --------------------------------------------------------------------- |
| auth\_token | string | The format for **auth\_token** is **Bearer&#x20;*****token\_string*** |

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

```
{
    "message": "Vendors retrieved successfully",
    "data": [
        {
            "id": "2",
            "description": "New Vendor",
            "name": "New Vendor",
            "category": "investments",
            "sponsor_name": null,
            "annual_returns_percentage": null
        },
        {
            "id": "3",
            "description": "piggyvest",
            "name": "piggyvest",
            "category": "savings",
            "sponsor_name": null,
            "annual_returns_percentage": null
        },
        {
            "id": "1",
            "description": "reliance hmo",
            "name": "reliance hmo",
            "category": "insurance",
            "sponsor_name": null,
            "annual_returns_percentage": null
        }
    ]
}
```

{% endtab %}
{% endtabs %}
