# Enable-Request

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

## Create Enable-Request

<mark style="color:green;">`POST`</mark> `https://switchapi3.azurewebsites.net/admin/enable_requests/:user_id`

Creates a request to enable a disabled user.\
This endpoint can only be used by ***customer\_success*** admins

#### Headers

| Name          | Type   | Description                                    |
| ------------- | ------ | ---------------------------------------------- |
| SWI-CS        | string | Payload checksum                               |
| SWI-CID       | string | Client ID                                      |
| Authorization | string | Format for Authorization is ***Bearer token*** |

#### Request Body

| Name     | Type   | Description                             |
| -------- | ------ | --------------------------------------- |
| user\_id | string | The id of the user to be disabled.      |
| reason   | string | Reason for requesting user's enablement |

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

```
{
  "message": "Enable-request created successfully",
  "data": {
    "status": "pending",
    "id": "21",
    "reason": "User no longer suspicious",
    "super_admin_comment": null,
    "user": {
      "first_name": "Testing",
      "last_name": "Andrew",
      "email": "testingandrew@gmail.com",
      "is_verified": false,
      "switch_id": 100125,
      "image_selfie_url": null
    },
    "created_by": {
      "id": "11",
      "email": "cs@switch.ng"
    }
  }
}
```

{% endtab %}

{% tab title="400 " %}

```
{
    "message": "user is not disabled"
}
```

{% endtab %}
{% endtabs %}

## Get Enable-Request list

<mark style="color:blue;">`GET`</mark> `https://switchapi3.azurewebsites.net/admin/enable_requests`

Retrieves the list of enable-requests.

#### Query Parameters

| Name   | Type   | Description                                                                    |
| ------ | ------ | ------------------------------------------------------------------------------ |
| status | string | Status filter. Could be either ***pending***, ***approved*** or ***declined*** |

#### Headers

| Name          | Type   | Description                  |
| ------------- | ------ | ---------------------------- |
| SWI-CID       | string | Client ID                    |
| Authorization | string | Format is ***Bearer token*** |

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

```
{
  "message": "Enable-requests retrieved successfully",
  "data": [
    {
      "id": "20",
      "reason": "User no longer suspicious",
      "status": "declined",
      "super_admin_comment": null,
      "user": {
        "first_name": "Okiki",
        "last_name": "Oyeleke",
        "email": "okiki@test.com",
        "is_verified": false,
        "switch_id": 100116,
        "image_selfie_url": null
      },
      "created_by": {
        "id": "11",
        "email": "cs@switch.ng"
      }
    },
    {
      "id": "19",
      "reason": "User no longer suspicious",
      "status": "declined",
      "super_admin_comment": "Not okay",
      "user": {
        "first_name": "Okiki",
        "last_name": "Oyeleke",
        "email": "okiki@test.com",
        "is_verified": false,
        "switch_id": 100116,
        "image_selfie_url": null
      },
      "created_by": {
        "id": "11",
        "email": "cs@switch.ng"
      }
    },
    {
      "id": "18",
      "reason": "User no longer suspicious",
      "status": "approved",
      "super_admin_comment": "Okay",
      "user": {
        "first_name": "Tee",
        "last_name": "Tee",
        "email": "mcvenom2003@yahoo.co.uk",
        "is_verified": false,
        "switch_id": 100121,
        "image_selfie_url": null
      },
      "created_by": {
        "id": "11",
        "email": "cs@switch.ng"
      }
    },
    {
      "id": "17",
      "reason": "User no longer suspicious",
      "status": "approved",
      "super_admin_comment": null,
      "user": {
        "first_name": "Testing",
        "last_name": "Andrew",
        "email": "testingandrew@gmail.com",
        "is_verified": false,
        "switch_id": 100125,
        "image_selfie_url": null
      },
      "created_by": {
        "id": "11",
        "email": "cs@switch.ng"
      }
    },
    {
      "id": "14",
      "reason": "User no longer suspicious",
      "status": "approved",
      "super_admin_comment": null,
      "user": {
        "first_name": "Testing",
        "last_name": "Andrew",
        "email": "testingandrew@gmail.com",
        "is_verified": false,
        "switch_id": 100125,
        "image_selfie_url": null
      },
      "created_by": {
        "id": "11",
        "email": "cs@switch.ng"
      }
    },
    {
      "id": "13",
      "reason": "User no longer suspicious",
      "status": "approved",
      "super_admin_comment": "Okay",
      "user": {
        "first_name": "Tee",
        "last_name": "Tee",
        "email": "mcvenom2003@yahoo.co.uk",
        "is_verified": false,
        "switch_id": 100121,
        "image_selfie_url": null
      },
      "created_by": {
        "id": "11",
        "email": "cs@switch.ng"
      }
    },
    {
      "id": "12",
      "reason": "User no longer suspicious",
      "status": "approved",
      "super_admin_comment": "Okay",
      "user": {
        "first_name": "Okiki",
        "last_name": "Oyeleke",
        "email": "okiki@test.com",
        "is_verified": false,
        "switch_id": 100116,
        "image_selfie_url": null
      },
      "created_by": {
        "id": "11",
        "email": "cs@switch.ng"
      }
    },
    {
      "id": "8",
      "reason": "Testing",
      "status": "approved",
      "super_admin_comment": null,
      "user": {
        "first_name": "Demilade",
        "last_name": "Omitiran",
        "email": "omitirand@gmail.com",
        "is_verified": false,
        "switch_id": 100199,
        "image_selfie_url": "+2348184392899_image_selfie_url_Screenshot 2019-05-07 at 4.00.10 PM.png"
      },
      "created_by": {
        "id": "11",
        "email": "cs@switch.ng"
      }
    },
    {
      "id": "7",
      "reason": "This user already provides means of identification for the legibility of their company funds.",
      "status": "approved",
      "super_admin_comment": null,
      "user": {
        "first_name": "Babatunde",
        "last_name": "Badmus",
        "email": "babatundebadmus@gmail.com",
        "is_verified": false,
        "switch_id": 100369,
        "image_selfie_url": null
      },
      "created_by": {
        "id": "11",
        "email": "cs@switch.ng"
      }
    },
    {
      "id": "6",
      "reason": "Please allow this user.",
      "status": "approved",
      "super_admin_comment": null,
      "user": null,
      "created_by": {
        "id": "11",
        "email": "cs@switch.ng"
      }
    },
    {
      "id": "5",
      "reason": "Please help this user.",
      "status": "approved",
      "super_admin_comment": null,
      "user": {
        "first_name": "Motolani",
        "last_name": "Fayomi",
        "email": "fayomitolani@gmail.com",
        "is_verified": false,
        "switch_id": 100364,
        "image_selfie_url": "+112345678907_image_selfie_url_DownloadQrCode (1).png"
      },
      "created_by": {
        "id": "11",
        "email": "cs@switch.ng"
      }
    },
    {
      "id": "4",
      "reason": "Please help this user.",
      "status": "approved",
      "super_admin_comment": null,
      "user": {
        "first_name": "Esther",
        "last_name": "John-Paul",
        "email": "ecnwowo@gmail.com",
        "is_verified": false,
        "switch_id": 100356,
        "image_selfie_url": "+15678654213_image_selfie_url_Screenshot_20190327-124157.png"
      },
      "created_by": {
        "id": "11",
        "email": "cs@switch.ng"
      }
    },
    {
      "id": "3",
      "reason": "Please enable this user.",
      "status": "approved",
      "super_admin_comment": null,
      "user": {
        "first_name": "Francis",
        "last_name": "Ezinna",
        "email": "eegbuchu@yahoo.com",
        "is_verified": false,
        "switch_id": 100361,
        "image_selfie_url": "+2348034134689_image_selfie_url_ankara-14029402298k4gn.jpg"
      },
      "created_by": {
        "id": "11",
        "email": "cs@switch.ng"
      }
    },
    {
      "id": "2",
      "reason": "We need to remove the ban for this user, he paid his dues already.",
      "status": "approved",
      "super_admin_comment": null,
      "user": null,
      "created_by": {
        "id": "11",
        "email": "cs@switch.ng"
      }
    },
    {
      "id": "1",
      "reason": "I spoke to this customer and we are good to go.",
      "status": "declined",
      "super_admin_comment": null,
      "user": null,
      "created_by": {
        "id": "11",
        "email": "cs@switch.ng"
      }
    }
  ],
  "meta": {
    "total": 15,
    "per_page": 20,
    "page": 1,
    "page_count": 1
  }
}
```

{% endtab %}

{% tab title="401 " %}

```
{
    "message": "Only an admin with a role of super_admin can perform this action"
}
```

{% endtab %}
{% endtabs %}

## Get Enable-Request info

<mark style="color:blue;">`GET`</mark> `https://switchapi3.azurewebsites.net/admin/enable_requests/:request_id`

Retrieves the info of an enable-request by id.

#### Path Parameters

| Name        | Type   | Description           |
| ----------- | ------ | --------------------- |
| request\_id | string | The id of the request |

#### Headers

| Name          | Type   | Description                  |
| ------------- | ------ | ---------------------------- |
| SWI-CID       | string | Client ID                    |
| Authorization | string | Format is ***Bearer token*** |

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

```
{
  "message": "Enable-request retrieved successfully",
  "data": {
    "id": "19",
    "reason": "User no longer suspicious",
    "status": "declined",
    "super_admin_comment": "Not okay",
    "user": {
      "first_name": "Okiki",
      "last_name": "Oyeleke",
      "email": "okiki@test.com",
      "is_verified": false,
      "switch_id": 100116,
      "image_selfie_url": null
    },
    "created_by": {
      "id": "11",
      "email": "cs@switch.ng"
    }
  }
}
```

{% endtab %}
{% endtabs %}

## Approve Request

<mark style="color:green;">`POST`</mark> `https://switchapi3.azurewebsites.net/admin/enable_requests/approve/:request_id`

This endpoint allows a super-admin to approve a request.

#### Path Parameters

| Name        | Type   | Description    |
| ----------- | ------ | -------------- |
| request\_id | string | The request id |

#### Headers

| Name          | Type   | Description                  |
| ------------- | ------ | ---------------------------- |
| SWI-CID       | string | Client ID                    |
| Authorization | string | Format is ***Bearer token*** |

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

```
{
  "message": "Enable-request approved successfully",
  "data": {
    "id": "21",
    "reason": "User no longer suspicious",
    "status": "approved",
    "super_admin_comment": "Okay",
    "user": {
      "first_name": "Testing",
      "last_name": "Andrew",
      "email": "testingandrew@gmail.com",
      "is_verified": false,
      "switch_id": 100125,
      "image_selfie_url": null
    },
    "created_by": {
      "id": "11",
      "email": "cs@switch.ng"
    }
  }
}
```

{% endtab %}

{% tab title="400 " %}

```
{
    "message": "enable-request already approved"
}
```

{% endtab %}

{% tab title="404 " %}

```
{
  "message": "enable-request with id 210 does not exist"
}
```

{% endtab %}
{% endtabs %}

## Decline Request

<mark style="color:green;">`POST`</mark> `https://switchapi3.azurewebsites.net/admin/enable_requests/decline/:request_id`

This endpoint allows a super-admin to decline a request.

#### Path Parameters

| Name        | Type   | Description    |
| ----------- | ------ | -------------- |
| request\_id | string | The request id |

#### Headers

| Name          | Type   | Description                  |
| ------------- | ------ | ---------------------------- |
| SWI-CID       | string | Client ID                    |
| Authorization | string | Format is ***Bearer token*** |

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

```
{
    "message": "Enable-Request declined successfully",
    "data": {
        "id": 8,
        "reason": "He's now responsible",
        "status": "declined",
        "super_admin_comment": "Some reason",
        "user": {
          "first_name": "Testing",
          "last_name": "Andrew",
          "email": "testingandrew@gmail.com",
          "is_verified": false,
          "switch_id": 100125,
          "image_selfie_url": null
        },
        "created_by": {
            "id": 11,
            "email": "cs@switch.ng"
        },
        "created_at": "2019-05-19T13:35:07.681Z"
    }
}
```

{% endtab %}

{% tab title="400 " %}

```
{
    "message": "enable-request already declined"
}
```

{% endtab %}
{% endtabs %}
