Работа с промокодами
Получение списка промокодов
GET
https://api.lpmotor.ru/v1/promo
This endpoint allows you to get free cakes.
Query Parameters
[
{
"id": 0,
"code": "string",
"pos": 0,
"is_enabled": true,
"bonus_type": 0,
"bonus_amount": 0,
"bonus_amount_is_in_percentages": true,
"time_limit_is_enabled": true,
"d_on": "2021-08-04T13:57:37.243Z",
"d_off": "2021-08-04T13:57:37.243Z",
"quantity_limit_is_enabled": true,
"quantity_limit": 0,
"promo_used_count": 0,
"is_valid": true
}
]
{
"title": "user cant view site",
"error": 30,
"code": 403
}Пример запроса
curl -X GET "Пример запроса
curl -X GET "
Пример запроса
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X GET "https://api.lpmotor.ru/v1/promo?site_id=11111"
<?php
$client = new GuzzleHttp\Client([
'base_uri' => 'https://api.lpmotor.ru',
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'X-Api-User-Id' => $userId,
'Authorization' => 'Bearer ' . $apiKey,
],
]);
$response = $client->get(
'/v1/promo',
[
'query' => [
'site_id' => $siteId,
]
]
);
$statusCode = $response->getStatusCode();
$promoCodes = json_decode((string) $response->getBody(), true);
http = Axios.create({
baseURL: "https://api.lpmotor.ru",
timeout: 60000,
headers: {
"Content-Type" : "application/json",
"Accept" : "application/json",
"Cache-Control": "no-cache, no-store, must-revalidate",
"X-Api-User-Id": userId,
"Authorization": "Bearer " + myApiKey,
}
});
http.get("/v1/promo", {
params: {
site_id: 11111,
},
});
Создание промокода
POST
https://api.lpmotor.ru/v1/promo
Request Body
{
"code": "string",
"is_enabled": true,
"bonus_type": 0,
"bonus_amount": 0,
"bonus_amount_is_in_percentages": true,
"time_limit_is_enabled": true,
"d_on": "2021-08-04T14:36:22.614Z",
"d_off": "2021-08-04T14:36:22.614Z",
"quantity_limit_is_enabled": true,
"quantity_limit": 0,
"personal_limit_is_enabled": true
}
{
"title": "user cant view site",
"error": 30,
"code": 403
}
Пример запроса
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X POST "https://api.lpmotor.ru/v1/promo" \
-d '{"user_id":123,"site_id":11111,"code":"mypromocode"}'
<?php
$client = new GuzzleHttp\Client([
'base_uri' => 'https://api.lpmotor.ru',
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'X-Api-User-Id' => $userId,
'Authorization' => 'Bearer ' . $apiKey,
],
]);
$response = $client->post(
'/v1/promo',
[
'json' => [
'user_id' => $userId,
'site_id' => $siteId,
'code' => 'mypromocode',
],
]
);
$statusCode = $response->getStatusCode();
$promoCode = json_decode((string) $response->getBody(), true);
http = Axios.create({
baseURL: "https://api.lpmotor.ru",
timeout: 60000,
headers: {
"Content-Type" : "application/json",
"Accept" : "application/json",
"Cache-Control": "no-cache, no-store, must-revalidate",
"X-Api-User-Id": userId,
"Authorization": "Bearer " + myApiKey,
}
});
http.post('/v1/promo', {
user_id: 123,
site_id: 11111,
code: 'mypromocode',
});
Получение промокода по ID
GET
https://api.lpmotor.ru/v1/promo/{promo_id}
Path Parameters
{
"code": "string",
"is_enabled": true,
"bonus_type": 0,
"bonus_amount": 0,
"bonus_amount_is_in_percentages": true,
"time_limit_is_enabled": true,
"d_on": "2021-08-04T14:39:18.248Z",
"d_off": "2021-08-04T14:39:18.248Z",
"quantity_limit_is_enabled": true,
"quantity_limit": 0,
"personal_limit_is_enabled": true
}
{
"title": "user cant view promo",
"error": 40,
"code": 403
}
Пример запроса
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X GET "https://api.lpmotor.ru/v1/promo/1"
<?php
$client = new GuzzleHttp\Client([
'base_uri' => 'https://api.lpmotor.ru',
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'X-Api-User-Id' => $userId,
'Authorization' => 'Bearer ' . $apiKey,
],
]);
$response = $client->get(
'/v1/promo/' . $promoId
);
$statusCode = $response->getStatusCode();
$promoCode = json_decode((string) $response->getBody(), true);
http = Axios.create({
baseURL: "https://api.lpmotor.ru",
timeout: 60000,
headers: {
"Content-Type" : "application/json",
"Accept" : "application/json",
"Cache-Control": "no-cache, no-store, must-revalidate",
"X-Api-User-Id": userId,
"Authorization": "Bearer " + myApiKey,
}
});
http.get("/v1/promo/" + promoId);
Изменение промокода
PUT
https://api.lpmotor.ru/v1/promo/{promo_id}
Path Parameters
Request Body
{
"code": "string",
"is_enabled": true,
"bonus_type": 0,
"bonus_amount": 0,
"bonus_amount_is_in_percentages": true,
"time_limit_is_enabled": true,
"d_on": "2021-08-04T14:43:46.897Z",
"d_off": "2021-08-04T14:43:46.897Z",
"quantity_limit_is_enabled": true,
"quantity_limit": 0,
"personal_limit_is_enabled": true
}
{
"title": "user cant view promo",
"error": 40,
"code": 403
}
Пример запроса
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X PUT "https://api.lpmotor.ru/v1/promo/1" \
-d '{"code":"newpromocode"}'
<?php
$client = new GuzzleHttp\Client([
'base_uri' => 'https://api.lpmotor.ru',
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'X-Api-User-Id' => $userId,
'Authorization' => 'Bearer ' . $apiKey,
],
]);
$response = $client->put(
'/v1/promo/1',
[
'json' => [
'code' => 'newpromocode',
],
]
);
$statusCode = $response->getStatusCode();
$promoCode = json_decode((string) $response->getBody(), true);
http = Axios.create({
baseURL: "https://api.lpmotor.ru",
timeout: 60000,
headers: {
"Content-Type" : "application/json",
"Accept" : "application/json",
"Cache-Control": "no-cache, no-store, must-revalidate",
"X-Api-User-Id": userId,
"Authorization": "Bearer " + myApiKey,
}
});
http.post('/v1/promo/1', {
code: 'newpromocode',
});
Удаление промокода
DELETE
https://api.lpmotor.ru/v1/promo/{promo_id}
Path Parameters
{
"title": "user cant view promo",
"error": 40,
"code": 403
}
Пример запроса
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X DELETE "https://api.lpmotor.ru/v1/promo/1"
<?php
$client = new GuzzleHttp\Client([
'base_uri' => 'https://api.lpmotor.ru',
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'X-Api-User-Id' => $userId,
'Authorization' => 'Bearer ' . $apiKey,
],
]);
$response = $client->delete(
'/v1/promo/1'
);
$statusCode = $response->getStatusCode();
http = Axios.create({
baseURL: "https://api.lpmotor.ru",
timeout: 60000,
headers: {
"Content-Type" : "application/json",
"Accept" : "application/json",
"Cache-Control": "no-cache, no-store, must-revalidate",
"X-Api-User-Id": userId,
"Authorization": "Bearer " + myApiKey,
}
});
http.delete("/v1/promo/1");
Получение статистики использования промокода
GET
https://api.lpmotor.ru/v1/promo/{promo_id}/statistics
Path Parameters
[
{
"id": 0,
"promo_id": 0,
"lead_id": 0,
"bonus_type_id": 0,
"bonus_amount": 0,
"bonus_amount_is_in_percentages": 0,
"order_price": 0,
"order_quantity": 0,
"discount_amount": 0,
"promo": {
"code": "string"
},
"d_lead_created": "2021-08-04T15:02:13.184Z",
"currency": "string"
}
]
{
"title": "user cant view site",
"error": 30,
"code": 403
}
Пример запроса
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X GET "https://api.lpmotor.ru/v1/promo/1/statistics"
<?php
$client = new GuzzleHttp\Client([
'base_uri' => 'https://api.lpmotor.ru',
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'X-Api-User-Id' => $userId,
'Authorization' => 'Bearer ' . $apiKey,
],
]);
$response = $client->get(
'/v1/promo/1/statistics'
);
$statusCode = $response->getStatusCode();
$statistics = json_decode((string) $response->getBody(), true);
http = Axios.create({
baseURL: "https://api.lpmotor.ru",
timeout: 60000,
headers: {
"Content-Type" : "application/json",
"Accept" : "application/json",
"Cache-Control": "no-cache, no-store, must-revalidate",
"X-Api-User-Id": userId,
"Authorization": "Bearer " + myApiKey,
}
});
http.get("/v1/promo/1/statistics");