Get Cart OptIn | Climes API
This endpoint is used to fetch the latest opted in status for any cart_id. Since we maintain per cart level opt-ins on our end you can use this to fetch whether the checkbox should indicate that the user has already opted in or not.
This endpoint creates a optin.
Request Parameters
Endpoint
/v3/integrations/vote/opt-in?cartId={cart_id}
Method
GET
Headers
{
'x-api-key' : 'API_KEY',
'Content-Type' : 'application/json'
}
Response Parameters
Status Code
200
Response Data
{
optedIn : false
}
Sample Request
- cURL
- NodeJs
- Axios
- Python
- Php
curl --location --request GET 'BASE_URL/v3/integrations/vote/opt-in?cartId=9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'
--header 'x-api-key: API_KEY'
const fetch = require('node-fetch');
const apiKey = 'API_KEY';
const url = 'BASE_URL/v3/integrations/vote/opt-in?cartId=9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d';
fetch(url, {
method: 'GET',
headers: {
'x-api-key': apiKey,
},
})
.then(response => response.json())
.then(data => {
// Handle the response data
console.log(data);
})
.catch(error => {
// Handle the error
console.error(error);
});
var axios = require('axios');
var config = {
method: 'get',
url: 'BASE_URL/v3/integrations/vote/opt-in?cartId=9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d',
headers: {
'x-api-key': 'API_KEY'
}
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
url = "BASE_URL/v3/integrations/vote/opt-in?cartId=9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"
payload={}
headers = {
'x-api-key': 'API_KEY'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('BASE_URL/v3/integrations/vote/opt-in?cartId=9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'x-api-key' => 'API_KEY'
));
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
Sample Response
Below are sample responses for the above request.
Responses
- Success - 200
- Failure - 400
{
"optedIn": false
}
{
"message": "Bad Request! Please send all the variables properly."
}