# Announcement

## Announcement List

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/announcements/get/list/`

This API endpoint will return a list of announcements.&#x20;

#### Query Parameters

| Name         | Type   | Description                               |
| ------------ | ------ | ----------------------------------------- |
| offset       | string |                                           |
| limit        | string |                                           |
| read\_status | string | 0(unread) or 1(readed),default value is 1 |
| subject      | string | subject text                              |
| start\_date  | string | formate: mm/dd/yyyy                       |
| end\_date    | string | formate: mm/dd/yyyy                       |
| created      | string | formate: mm/dd/yyyy                       |

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

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

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "id": <announcement_id>,
                "subject": "<announcement_subject>",
                "message": "<announcement_meessage>",
                "types": "<announcement_types>",
                "image": "<image>",
                "slug": "<announcement_slug>",
                "start_date": "<start_date>",
                "end_date": <end_date>,
                "created": "<created_date>"
            },
            ...
        ],
        "count": <list_count>,
        "previous": <previous_page_url>,
        "next": <next_page_url>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/get/announcements-list/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {}
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/get/announcements-list/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_POSTFIELDS => array(),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

#### Error Responses

| Status Code | Error Type       | FIeld                                              | Description          |
| ----------- | ---------------- | -------------------------------------------------- | -------------------- |
| 400         | Validation Error | <p>start\_date,</p><p>end\_date,</p><p>created</p> | Invalid date format. |

## Close Announcement

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/announcements/close/`

This API endpoint will close an announcement.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

#### Request Body

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

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

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/close/announcement/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'slug': '<announcement_slug>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/close/announcement/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('slug' => '<announcement_slug>'),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

#### Error Responses

| Status Code | Error Type       | FIeld | Description                                                                                                                                                 |
| ----------- | ---------------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400         | Validation Error | slug  | <p>This field is required.</p><p>This field may not be blank.</p><p>Requested announcement not found.</p><p>You can't close the requested announcement.</p> |
