# Users

## Creating a new user&#x20;

## Create a user for a lender organization

<mark style="color:blue;">`GET`</mark> `https://configure-abierta-test.herokuapp.com/user`

#### Headers

| Name                                            | Type   | Description             |
| ----------------------------------------------- | ------ | ----------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer *YOUR\_API\_KEY* |

#### Request Body

| Name                                        | Type   | Description                                 |
| ------------------------------------------- | ------ | ------------------------------------------- |
| firstname<mark style="color:red;">\*</mark> | String | The user's first name                       |
| lastname<mark style="color:red;">\*</mark>  | String | The user's last name                        |
| email<mark style="color:red;">\*</mark>     | String | The user's email address                    |
| password<mark style="color:red;">\*</mark>  | String | The user's password                         |
| phone<mark style="color:red;">\*</mark>     | String | The user's phone numer with the format +234 |
| gender<mark style="color:red;">\*</mark>    | String | The user's gender                           |

{% tabs %}
{% tab title="200: OK User Created Successfully" %}

```javascript
{
    "status": "success",
    "message": "New Borrower Succesfully Created",
    "data": {
        "firstname": "Daniel",
        "lastname": "Osineye",
        "email": "isongjosiah+3@gmail.com",
        "phone": "+2348182791196",
        "gender": "Male",
        "reference": "LNNPVUjVigzfA",
        "is_active": true,
        "source": "api",
        "created_at": "2022-02-11T09:10:25.815412395+01:00",
        "updated_at": "2022-02-11T09:10:25.815412533+01:00"
    }
}
```

{% endtab %}

{% tab title="200: OK User Already Exists" %}

```javascript
{
    "status": "exists",
    "message": "There's an exisiting user with this email address",
    "data": {
        "firstname": "Daniel",
        "lastname": "Osineye",
        "email": "isongjosiah+3@gmail.com",
        "phone": "+2348182791196",
        "gender": "Male",
        "reference": "LNNPVUjVigzfA",
        "is_active": true,
        "source": "api",
        "created_at": "2022-02-11T08:10:25.815412Z",
        "updated_at": "2022-02-11T08:10:25.815413Z"
    }
}
```

{% endtab %}
{% endtabs %}

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

```bash
curl --location --request POST 'http://localhost:6000/api/v1/user' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "firstname": "Daniel",
    "lastname": "Osineye",
    "email": "isongjosiah+3@gmail.com",
    "password": "password",
    "phone": "+2348182791196",
    "gender":"Male"
}'bas
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "http://evolvecredit.io/api/v1/user"
  method := "POST"

  payload := strings.NewReader(`{
    "firstname": "Daniel",
    "lastname": "Osineye",
    "email": "isongjosiah+3@gmail.com",
    "password": "password",
    "phone": "+2348182791196",
    "gender":"Male"
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'POST',
  'hostname': 'localhost',
  'port': 6000,
  'path': '/api/v1/user',
  'headers': {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData = JSON.stringify({"firstname":"Daniel","lastname":"Osineye","email":"isongjosiah+3@gmail.com","password":"password","phone":"+2348182791196","gender":"Male"});

req.write(postData);

req.end();
```

{% endtab %}
{% endtabs %}

## User actions

## Checks if a user exists in a lender organization

<mark style="color:blue;">`GET`</mark> `https://configure-abierta-test.herokuapp.com/user/actions`

#### Query Parameters

| Name                                     | Type   | Description                       |
| ---------------------------------------- | ------ | --------------------------------- |
| email<mark style="color:red;">\*</mark>  | String | The user's email address          |
| action<mark style="color:red;">\*</mark> | String | The specified action e.g `exists` |

#### Headers

| Name                                            | Type   | Description             |
| ----------------------------------------------- | ------ | ----------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer *YOUR\_API\_KEY* |

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

```javascript
{
    "status": "success",
    "message": "Email Exists",
    "data": true
}
```

{% endtab %}

{% tab title="200: OK User Does Not Exists" %}

```javascript
{
    "status": "success",
    "message": "Does not exist",
    "data": false
}
```

{% endtab %}
{% endtabs %}

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

```bash
curl --location --request GET 'http://localhost:6000/api/v1/user/actions?email=isongjosiah%2B2%40gmail.com&action=exists' \
--header 'Authorization: Bearer YOUR_API_KEY'
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "http://localhost:6000/api/v1/user/actions?email=isongjosiah%252B2%2540gmail.com&action=exists"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "Bearer YOUR_API_KEY")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'http://localhost:6000/api/v1/user/actions?email=isongjosiah%2B2%40gmail.com&action=exists',
  'headers': {
    'Authorization': 'Bearer YOUR_API_KEY'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

{% endtab %}
{% endtabs %}

## Get Users

## Fetch Lenders users with pagination

<mark style="color:blue;">`GET`</mark> `https://configure-abierta-test.herokuapp.comevolvecredit.io/api/v1/user`

#### Query Parameters

| Name  | Type   | Description                                     |
| ----- | ------ | ----------------------------------------------- |
| start | String | specify start creation date to fetch users from |
| end   | String | specify end creation date to fetch user from    |
| pages | Int    | Specify page - useful for pagination            |

#### Headers

| Name                                            | Type   | Description             |
| ----------------------------------------------- | ------ | ----------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer *YOUR\_API\_KEY* |

{% tabs %}
{% tab title="200: OK Get User's Information" %}

```javascript
{
    "status": "success",
    "message": "Users retrieved succesfully",
    "data": [
        {
            "id": 6,
            "org_id": 1,
            "firstname": "Collins",
            "lastname": "Ogbuzuru",
            "email": "collinsogbuzuru22@gmail.com",
            "phone": "08120697934",
            "gender": "male",
            "is_blacklisted": true,
            "created_at": "2021-09-21T19:27:07.432496Z",
            "updated_at": "0001-01-01T00:00:00Z"
        },
        {
            "id": 22,
            "org_id": 1,
            "firstname": "Soji",
            "lastname": "Joseph",
            "email": "j@evolvecredit.co",
            "phone": "080976547284",
            "gender": "female",
            "is_active": true,
            "created_at": "2021-10-18T09:59:21.381115Z",
            "updated_at": "0001-01-01T00:00:00Z"
        },
        {
            "id": 1,
            "org_id": 1,
            "firstname": "Daniel",
            "lastname": "Osineye",
            "email": "daniel.osineye@gmail.com",
            "phone": "08182791196",
            "gender": "male",
            "is_active": true,
            "created_at": "2021-09-21T09:29:28.011746Z",
            "updated_at": "0001-01-01T00:00:00Z"
        },
        {
            "id": 23,
            "org_id": 1,
            "firstname": "Akan",
            "lastname": "Nelson ",
            "email": "akannelson@gmail.com",
            "phone": "08092347589",
            "gender": "male",
            "is_active": true,
            "created_at": "2021-10-21T08:51:43.520709Z",
            "updated_at": "0001-01-01T00:00:00Z"
        },
        {
            "id": 24,
            "org_id": 1,
            "firstname": "Damilola",
            "lastname": "Ale",
            "email": "codenlyn@gmail.com",
            "phone": "0903 518 5172",
            "gender": "female",
            "is_active": true,
            "created_at": "2021-10-26T07:02:20.114638Z",
            "updated_at": "0001-01-01T00:00:00Z"
        },
        {
            "id": 29,
            "org_id": 1,
            "firstname": "Akan",
            "lastname": "Joseph",
            "email": "a@evolvecredit.app",
            "phone": "08092648595",
            "gender": "male",
            "is_active": true,
            "created_at": "2021-11-01T12:31:44.898313Z",
            "updated_at": "0001-01-01T00:00:00Z"
        },
        {
            "id": 34,
            "org_id": 1,
            "firstname": "Fredrick",
            "lastname": "Mattins",
            "email": "fred.mat@gmail.com",
            "phone": "+2348182745196",
            "gender": "Male",
            "is_active": true,
            "created_at": "2021-11-04T13:32:02.62933Z",
            "updated_at": "0001-01-01T00:00:00Z"
        },
        {
            "id": 39,
            "org_id": 1,
            "firstname": "Akan",
            "lastname": "nelson",
            "email": "a@evolvecredit.co",
            "phone": "+2346759485969",
            "gender": "male",
            "is_active": true,
            "created_at": "2021-11-08T12:48:38.931633Z",
            "updated_at": "0001-01-01T00:00:00Z"
        },
        {
            "id": 33,
            "org_id": 1,
            "firstname": "Harry",
            "lastname": "Potter",
            "email": "harry.potter@gmail.com",
            "phone": "+2348182791193",
            "gender": "Male",
            "is_blacklisted": true,
            "created_at": "2021-11-04T12:25:11.48563Z",
            "updated_at": "0001-01-01T00:00:00Z"
        },
        {
            "id": 41,
            "org_id": 1,
            "firstname": "Odunmolorun",
            "lastname": "Osineye",
            "email": "odunosineye@gmail.com",
            "phone": "+2348182791196",
            "gender": "male",
            "is_active": true,
            "created_at": "2021-11-11T14:19:54.314163Z",
            "updated_at": "0001-01-01T00:00:00Z"
        },
        {
            "id": 42,
            "org_id": 1,
            "firstname": "Iyanuoluwa",
            "lastname": "Osineye",
            "email": "dcodes.daniel@gmail.com",
            "phone": "2348182791196",
            "gender": "Male",
            "is_active": true,
            "created_at": "2021-11-17T07:27:34.031347Z",
            "updated_at": "0001-01-01T00:00:00Z"
        },
        {
            "id": 43,
            "org_id": 1,
            "firstname": "Stephen",
            "lastname": "curry",
            "email": "currystep@gmail.com",
            "phone": "+2348182791854",
            "gender": "Male",
            "is_active": true,
            "created_at": "2021-11-19T08:25:31.897201Z",
            "updated_at": "0001-01-01T00:00:00Z"
        },
        {
            "id": 44,
            "org_id": 1,
            "firstname": "Sydel",
            "lastname": "curry",
            "email": "curryseth@gmail.com",
            "phone": "+2348182792534",
            "gender": "Female",
            "is_active": true,
            "created_at": "2021-11-19T08:34:11.913207Z",
            "updated_at": "0001-01-01T00:00:00Z"
        },
        {
            "id": 45,
            "org_id": 1,
            "firstname": "Collins",
            "lastname": "Ogbuzuru",
            "email": "Collinsogbuzuru00@gmail.com",
            "phone": "+23481206979347",
            "gender": "male",
            "is_active": true,
            "created_at": "2021-11-19T10:25:53.349403Z",
            "updated_at": "0001-01-01T00:00:00Z"
        },
        {
            "id": 88,
            "org_id": 1,
            "firstname": "Forbes",
            "lastname": "Tuase",
            "email": "forbes.tuase@gmail.com",
            "phone": "+2348182792234",
            "gender": "Female",
            "is_active": true,
            "created_at": "2021-12-13T10:14:41.082949Z",
            "updated_at": "0001-01-01T00:00:00Z"
        },
        {
            "id": 89,
            "org_id": 1,
            "firstname": "Forbes",
            "lastname": "Tuase",
            "email": "forbes.tuase@devio.co",
            "phone": "+2348182792234",
            "gender": "Female",
            "is_active": true,
            "created_at": "2021-12-13T10:19:50.272167Z",
            "updated_at": "0001-01-01T00:00:00Z"
        },
        {
            "id": 100,
            "org_id": 1,
            "firstname": "Lola",
            "lastname": "Osineye",
            "email": "omololaosineye@gmail.com",
            "phone": "+234818223374",
            "gender": "male",
            "is_active": true,
            "created_at": "2021-12-20T13:33:00.909983Z",
            "updated_at": "0001-01-01T00:00:00Z"
        },
        {
            "id": 102,
            "org_id": 1,
            "firstname": "fola",
            "lastname": "Ade",
            "email": "fola.ade@icloud.com",
            "phone": "+2348182792234",
            "gender": "Male",
            "is_active": true,
            "created_at": "2021-12-20T14:23:58.862476Z",
            "updated_at": "0001-01-01T00:00:00Z"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

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

```bash
curl --location --request GET 'http://localhost:6000/api/v1/user?start=2021-07-01&end=2022-05-30&pages=2' \
--header 'Authorization: Bearer YOUR_API_KEY'
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "http://localhost:6000/api/v1/user?start=2021-07-01&end=2022-05-30&pages=2"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "Bearer YOUR_API_KEY")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'GET',
  'hostname': 'localhost',
  'port': 6000,
  'path': '/api/v1/user?start=2021-07-01&end=2022-05-30&pages=2',
  'headers': {
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

req.end();
```

{% endtab %}
{% endtabs %}
