## End a product exclusion list

### cURL

```bash
curl --request POST \
  --url https://api.fabric.inc/v3/product-exclusion-lists/{id}/actions/end \
  --header 'Authorization: Bearer <token>' \
  --header 'x-fabric-tenant-id: <x-fabric-tenant-id>'
```

### Python

```python
import requests

url = "https://api.fabric.inc/v3/product-exclusion-lists/{id}/actions/end"

headers = {
    "x-fabric-tenant-id": "<x-fabric-tenant-id>",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, headers=headers)

print(response.text)
```

### JavaScript (Fetch)

```javascript
const options = {
  method: 'POST',
  headers: {'x-fabric-tenant-id': '<x-fabric-tenant-id>', Authorization: 'Bearer <token>'}
};

fetch('https://api.fabric.inc/v3/product-exclusion-lists/{id}/actions/end', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### PHP

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.fabric.inc/v3/product-exclusion-lists/{id}/actions/end",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "", 
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "x-fabric-tenant-id: <x-fabric-tenant-id>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
?>
```

### Go

```go
package main

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

func main() {

url := "https://api.fabric.inc/v3/product-exclusion-lists/{id}/actions/end"

req, _ := http.NewRequest("POST", url, nil)

req.Header.Add("x-fabric-tenant-id", "<x-fabric-tenant-id>")
	req.Header.Add("Authorization", "Bearer <token>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
}
```

### Java (Unirest)

```java
HttpResponse<String> response = Unirest.post("https://api.fabric.inc/v3/product-exclusion-lists/{id}/actions/end")
  .header("x-fabric-tenant-id", "<x-fabric-tenant-id>")
  .header("Authorization", "Bearer <token>")
  .asString();
```

### Ruby

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.fabric.inc/v3/product-exclusion-lists/{id}/actions/end")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-fabric-tenant-id"] = '<x-fabric-tenant-id>'
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

### Response Codes

- 200
- 400
- 401
- 404
- 500

### Example Responses

Successful Response:
```json
{
  "id": "614b58924e92f6861ac9d43b",
  "name": "Gucci handbags",
  "startAt": "2022-05-04T09:23:51.459Z",
  "endAt": "2022-05-04T09:23:51.459Z",
  "scopes": [
    "PRODUCT_PRICE"
  ],
  "listType": "GLOBAL_EXCLUSION",
  "createdAt": "2019-08-20T14:15:22.000Z",
  "updatedAt": "2019-08-20T14:15:22.000Z",
  "isDeleted": false
}
```

Error Response:
```json
{
  "type": "SKU_LIST_CAN_NOT_BE_ENDED",
  "message": "Product exclusion list can't be ended because it isn't ACTIVE."
}
```

```json
{
  "type": "UNAUTHORIZED",
  "message": "Invalid credentials"
}
```

```json
{
  "type": "SKU_LIST_NOT_FOUND",
  "message": "Product exclusion List not found."
}
```

```json
{
  "type": "INTERNAL_SERVER_ERROR",
  "message": "Internal server error"
}
```

### Authorizations
- **Authorization**: Required header with Bearer token.

### Headers
- **x-fabric-tenant-id**: Required tenant identifier.

### Path Parameters
- **id**: Required product exclusion list ID.
