# Companies

#### Create company

## Create company

<mark style="color:green;">`POST`</mark> `{base url}/v1/companies`

Create company

#### Headers

| Name                                            | Type         | Description                                  |
| ----------------------------------------------- | ------------ | -------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | Bearer token | The bearer token is the API users Secret Key |

#### Request Body

| Name                                      | Type   | Description                 |
| ----------------------------------------- | ------ | --------------------------- |
| registrationNumber                        | string | company registration number |
| name                                      | string | company name                |
| logo                                      | string | company logo                |
| address<mark style="color:red;">\*</mark> | string | company address             |
| city                                      | string | company city                |
| state<mark style="color:red;">\*</mark>   | string | company state               |
| country<mark style="color:red;">\*</mark> | string | company country             |
| email<mark style="color:red;">\*</mark>   | string | company email               |
| phoneNumber                               | string | company phone number        |
| customData                                | object | company custom data         |

{% tabs %}
{% tab title="403: Forbidden Unauthorised " %}

```
{
    "message": "unauthorized",
    "code": 92
}
```

{% endtab %}

{% tab title="200: OK company created successfully " %}

{% code fullWidth="false" %}

```json
    {
     "responseCode": "00",
    "message": "Companies created successful"
    }
    
```

{% endcode %}
{% endtab %}

{% tab title="409: Conflict Conflict" %}

```json
{
    "message": "Company already exists",
    "code": 90
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="sample request" %}

```postman_json
 {
            "organizationId": "ab3b150e-6a5d-429f-b499-f2d6ea99f668",
            "registrationNumber": "q3OnXwij90",
            "name": "test company",
            "logo": "https://res.cloudinary.com/dtui4qk9s/image/upload/v1695744841/uploads/mqfewgnixecehepqqdz6.jpg",
            "address": "Adnra crescent housing",
            "city": "Jimeta",
            "state": "Adamawa",
            "country": "Nigeria",
            "email": "test.emaillj89e@6xh.com",
            "phoneNumber": "09018031556",
            "customData": {
                "c": "17288735",
                "fr": "17288735",
                "frr": "17288735",
            }
}
```

{% endtab %}

{% tab title="sample response" %}

```
{
    "message": "company created successfully",
    "data": {
        "organizationId": "ab3b150e-6a5d-429f-b499-f2d6ea99f668",
        "registrationNumber": "q3OnXwij90",
        "name": "test company",
        "logo": "https://res.cloudinary.com/dtui4qk9s/image/upload/v1702468916/uploads/po7yyuafedamdownk59w.jpg",
        "address": "Adnra crescent housing",
        "city": "Jimeta",
        "state": "Adamawa",
        "country": "Nigeria",
        "email": "test.emaillj89e@6xh.com",
        "phoneNumber": "09018031556",
        "customData": {
            "c": "17288735",
            "fr": "17288735",
            "frr": "17288735",
        },
        "id": "13e475f7-f45f-4199-8f60-cd6025b95736",
        "status": "active",
        "created_at": "2023-12-13T12:01:57.144Z",
        "updated_at": "2023-12-13T12:01:57.144Z"
    }
}
```

{% endtab %}
{% endtabs %}

#### Get companies

## Get companies

<mark style="color:blue;">`GET`</mark> `{base url}/v1/companies?page={page}&perPage={perPage}`

Returns paginated data of all companies

#### Query Parameters

| Name    | Type   | Description              |
| ------- | ------ | ------------------------ |
| page    | number | page to return           |
| perPage | number | number of items per page |

#### Headers

| Name                                            | Type         | Description                                  |
| ----------------------------------------------- | ------------ | -------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | Bearer token | The bearer token is the API users Secret Key |

{% tabs %}
{% tab title="403: Forbidden Unauthorised " %}

```
{
    "message": "unauthorized",
    "code": 92
}
```

{% endtab %}

{% tab title="200: OK Companies fetched succesfuly" %}

```
{
    "responseCode": "00",
    "message": "Companies fetch successful",
    "data": [
        {
            "id": "ae80b11b-2e06-4bcd-84ac-f8398202b2d6",
            "organizationId": "a5f38f16-6c44-408f-b7ff-6775f02b83ac",
            "registrationNumber": "wewewewew",
            "name": "member",
            "logo": null,
            "address": "lagos",
            "city": "Mubi",
            "state": "Adamawa",
            "country": "Nigeria",
            "email": "toheeb.rauf@oobla.io",
            "phoneNumber": "09013128631",
            "status": "inactive",
            "customData": {
                "CAC": "test",
                "new feature test": "wewewewewew"
            },
            "created_at": "2023-09-29T10:19:31.001Z",
            "updated_at": "2023-11-03T12:32:12.725Z"
        },
        {
            "id": "05768940-15ed-450c-8d8e-70f36ffffff8",
            "organizationId": "a5f38f16-6c44-408f-b7ff-6775f02b83ac",
            "registrationNumber": "",
            "name": "chowDeck",
            "logo": null,
            "address": "30, jakande estate",
            "city": "",
            "state": "Abia",
            "country": "Nigeria",
            "email": "chukwunonso.nwosu+4000@oobla.io",
            "phoneNumber": "09071938110",
            "status": "blocked",
            "customData": {
                "new feature test": "sdsdsd"
            },
            "created_at": "2023-08-22T08:19:22.303Z",
            "updated_at": "2023-10-03T16:32:17.562Z"
        },
        
    ]
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="sample response" %}

```
{
    "responseCode": "00",
    "message": "Companies fetch successful",
    "data": [
        {
            "id": "ae80b11b-2e06-4bcd-84ac-f8398202b2d6",
            "organizationId": "a5f38f16-6c44-408f-b7ff-6775f02b83ac",
            "registrationNumber": "2367890654",
            "name": "member",
            "logo": null,
            "address": "lagos",
            "city": "Mubi",
            "state": "Adamawa",
            "country": "Nigeria",
            "email": "toheeb.rauf@oobla.io",
            "phoneNumber": "09013128631",
            "status": "inactive",
            "customData": {
                "CAC": "test",
                "new feature test": "testing"
            },
            "created_at": "2023-09-29T10:19:31.001Z",
            "updated_at": "2023-11-03T12:32:12.725Z"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

#### Get companies by id

## Get companies by Id

<mark style="color:blue;">`GET`</mark> `{base url}/v1/companies? companyId={companyId}`

Return single company by Id

#### Query Parameters

| Name                                        | Type   | Description  |
| ------------------------------------------- | ------ | ------------ |
| companyId<mark style="color:red;">\*</mark> | string | Company’s Id |

#### Headers

| Name                                            | Type         | Description                                  |
| ----------------------------------------------- | ------------ | -------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | Bearer token | The bearer token is the API users Secret Key |

{% tabs %}
{% tab title="403: Forbidden Unauthorised " %}

```
{
    "message": "unauthorized",
    "code": 92
}
```

{% endtab %}

{% tab title="200: OK company fetched successfully " %}

```json
{
    "responseCode": "00",
    "data": {
        "id": "ae80b11b-2e06-4bcd-84ac-f8398202b2d6",
        "organizationId": "a5f38f16-6c44-408f-b7ff-6775f02b83ac",
        "registrationNumber": "09878654",
        "name": "member",
        "logo": null,
        "address": "lagos",
        "city": "Mubi",
        "state": "Adamawa",
        "country": "Nigeria",
        "email": "toheeb.rauf@oobla.io",
        "phoneNumber": "09013128631",
        "status": "inactive",
        "customData": {
            "CAC": "test",
            "new feature test": "wewewewewew"
        },
        "created_at": "2023-09-29T10:19:31.001Z",
        "updated_at": "2023-11-03T12:32:12.725Z",
        "documentCount": 0,
        "depositCount": 0,
        "loanCount": 0
    }
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="sample response" %}

```
{
    "responseCode": "00",
    "data": {
        "id": "ae80b11b-2e06-4bcd-84ac-f8398202b2d6",
        "organizationId": "a5f38f16-6c44-408f-b7ff-6775f02b83ac",
        "registrationNumber": "000876542345678",
        "name": "member",
        "logo": null,
        "address": "lagos",
        "city": "Mubi",
        "state": "Adamawa",
        "country": "Nigeria",
        "email": "toheeb.rauf@oobla.io",
        "phoneNumber": "09013128631",
        "status": "inactive",
        "customData": {
            "CAC": "test",
            "new feature test": "testing"
        },
        "created_at": "2023-09-29T10:19:31.001Z",
        "updated_at": "2023-11-03T12:32:12.725Z",
        "documentCount": 0,
        "depositCount": 0,
        "loanCount": 0
    }
}
```

{% endtab %}
{% endtabs %}

#### Get company loans

## Get company loans

<mark style="color:blue;">`GET`</mark> `{base url}/v1/companies/{companyId}/loans?page={page}&perPage={perPage}`

Get company loans

#### Query Parameters

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| companyId<mark style="color:red;">\*</mark> | string | Company’s Id             |
| page                                        | number | page to return           |
| perPage                                     | number | number of items per page |

#### Headers

| Name                                            | Type         | Description                                  |
| ----------------------------------------------- | ------------ | -------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | Bearer token | The bearer token is the API users Secret Key |

{% tabs %}
{% tab title="403: Forbidden Unauthorised " %}

```
{
    "message": "unauthorized",
    "code": 92
}
```

{% endtab %}

{% tab title="200: OK Company fetched successfully" %}

```json
{
    "responseCode": "00",
    "message": "Loan fetch successful",
    "data": [
    {
        "id": "ae80b11b-2e06-4bcd-84ac-f8398202b2d6",
        "organizationId": "a5f38f16-6c44-408f-b7ff-6775f02b83ac",
        "registrationNumber": "000876542345678",
        "name": "member",
        "logo": null,
        "address": "lagos",
        "city": "Mubi",
        "state": "Adamawa",
        "country": "Nigeria",
        "email": "toheeb.rauf@oobla.io",
        "phoneNumber": "09013128631",
        "status": "inactive",
        "customData": {
            "CAC": "test",
            "new feature test": "wewewewewew"
        },
        "created_at": "2023-09-29T10:19:31.001Z",
        "updated_at": "2023-11-03T12:32:12.725Z",
        "documentCount": 0,
        "depositCount": 0,
        "loanCount": 0
    }
    ]
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="sample response" %}

```
{
    "responseCode": "00",
    "message": "Loan fetch successful",
    "data": [{
        "id": "ae80b11b-2e06-4bcd-84ac-f8398202b2d6",
        "organizationId": "a5f38f16-6c44-408f-b7ff-6775f02b83ac",
        "registrationNumber": "000876542345678",
        "name": "member",
        "logo": null,
        "address": "lagos",
        "city": "Mubi",
        "state": "Adamawa",
        "country": "Nigeria",
        "email": "toheeb.rauf@oobla.io",
        "phoneNumber": "09013128631",
        "status": "inactive",
        "customData": {
            "CAC": "test",
            "new feature test": "testing"
        },
        "created_at": "2023-09-29T10:19:31.001Z",
        "updated_at": "2023-11-03T12:32:12.725Z",
        "documentCount": 0,
        "depositCount": 0,
        "loanCount": 0
    }]
}
```

{% endtab %}
{% endtabs %}

#### Get company deposits

## Get company deposits

<mark style="color:blue;">`GET`</mark> `{base url}/v1/companies/{companyId}/deposits?page={page}&perPage={perPage}`

Returns paginated list of company deposits

#### Query Parameters

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| companyId<mark style="color:red;">\*</mark> | string | company Id               |
| page                                        | number | page to return           |
| perPage                                     | number | number of items per page |

#### Headers

| Name                                            | Type         | Description                                  |
| ----------------------------------------------- | ------------ | -------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | Bearer token | The bearer token is the API users Secret Key |

#### Request Body

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| companyId<mark style="color:red;">\*</mark> | string | companys Id |

{% tabs %}
{% tab title="403: Forbidden Unauthorised " %}

```
{
    "message": "unauthorized",
    "code": 92
}
```

{% endtab %}

{% tab title="200: OK company deposits fetched successfully " %}

```json
{
    "responseCode": "00",
    "message": "deposits fetch successful",
    "data": []
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="sample response" %}

```
{
    "responseCode": "00",
    "message": "deposits fetch successful",
    "data": []
}
```

{% endtab %}
{% endtabs %}

#### Update company

## Update company

<mark style="color:purple;">`PATCH`</mark> `{base url}/v1/companies?companyId={companyId}`

Update company

#### Query Parameters

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| companyId<mark style="color:red;">\*</mark> | string | company Id  |

#### Headers

| Name                                            | Type         | Description                                  |
| ----------------------------------------------- | ------------ | -------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | Bearer token | The bearer token is the API users Secret Key |

#### Request Body

| Name                                      | Type   | Description                 |
| ----------------------------------------- | ------ | --------------------------- |
| registrationNumber                        | string | company registration number |
| name<mark style="color:red;">\*</mark>    | string | company name                |
| address<mark style="color:red;">\*</mark> | string | company address             |
| city<mark style="color:red;">\*</mark>    | string | company city                |
| state<mark style="color:red;">\*</mark>   | string | company state               |
| country<mark style="color:red;">\*</mark> | string | company country             |
| email<mark style="color:red;">\*</mark>   | string | company email               |
| phoneNumber                               | string | company phone number        |
| status<mark style="color:red;">\*</mark>  | string | company status              |
| customData                                | object | company custom data         |

{% tabs %}
{% tab title="403: Forbidden Unuathorized" %}

```
{
    "message": "unauthorized",
    "code": 92
}
```

{% endtab %}

{% tab title="200: OK company updated successfully " %}

```json
{
    "message": "Company updated successfully",
    "code": 00
}
```

{% endtab %}

{% tab title="406: Not Acceptable Inactive" %}

```json
{
    "message": "Company account is not active",
    "code": 90
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="sample request" %}

```
{
          
            "registrationNumber": "q3OnXwij",
            "name": "Opay",
            "logo": "https://res.cloudinary.com/dtui4qk9s/image/upload/v1701792271/uploads/fe3kg0frlrft4ve1np7t.jpg",
            "address": "Adnra crescent housing",
            "city": "Jimeta",
            "state": "Adamawa",
            "country": "Nigeria",
            "email": "test.emaillje@6xh.com",
            "phoneNumber": "09018031556",
            "status": "active",
            "customData": {
                "c": "17288735",
                "fr": "17288735",
                "frr": "17288735"
            }
}
```

{% endtab %}

{% tab title="sample response" %}

```
{
    "message": "Company updated successfully",
    "code": 00
}
```

{% endtab %}
{% endtabs %}

#### Delete company

## Delete company

<mark style="color:red;">`DELETE`</mark> `{base url}/v1/companies?companyId={companyId}`

Delete a single company

#### Query Parameters

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| companyId<mark style="color:red;">\*</mark> | string | company Id  |

#### Headers

| Name                                            | Type         | Description                                  |
| ----------------------------------------------- | ------------ | -------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | Bearer token | The bearer token is the API users Secret Key |

{% tabs %}
{% tab title="403: Forbidden Unauthorised " %}

```
{
    "message": "unauthorized",
    "code": 92
}
```

{% endtab %}

{% tab title="200: OK company successfully deleted" %}

```
{
    "message": "Company deleted successfully",
    "code": 00
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="sample response" %}

```
{
    "message": "Company deleted successfully",
    "code": 00
}
```

{% endtab %}
{% endtabs %}

#### Search companies

## Search company

<mark style="color:blue;">`GET`</mark> `{base url}/v1/companies?search={search}`

Search company

#### Query Parameters

| Name                                     | Type   | Description |
| ---------------------------------------- | ------ | ----------- |
| search<mark style="color:red;">\*</mark> | string | search term |

#### Headers

| Name          | Type         | Description                                  |
| ------------- | ------------ | -------------------------------------------- |
| Authorization | Bearer token | The bearer token is the API users Secret Key |

{% tabs %}
{% tab title="403: Forbidden Unauthorised " %}

```
{
    "message": "unauthorized",
    "code": 92
}
```

{% endtab %}

{% tab title="200: OK Clients fetched successfully" %}

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="sample response" %}

```
{
    "responseCode": "00",
    "message": "Companies fetch successful",
    "data": [
        {
            "id": "ae80b11b-2e06-4bcd-84ac-f8398202b2d6",
            "organizationId": "a5f38f16-6c44-408f-b7ff-6775f02b83ac",
            "registrationNumber": "2367890654",
            "name": "member",
            "logo": null,
            "address": "lagos",
            "city": "Mubi",
            "state": "Adamawa",
            "country": "Nigeria",
            "email": "toheeb.rauf@oobla.io",
            "phoneNumber": "09013128631",
            "status": "inactive",
            "customData": {
                "CAC": "test",
                "new feature test": "testing"
            },
            "created_at": "2023-09-29T10:19:31.001Z",
            "updated_at": "2023-11-03T12:32:12.725Z"
        }
    ]
}
```

{% endtab %}
{% endtabs %}
