версия от 2023-02-13
Группа методов позволяет управлять email-адресами для получения уведомлений от Плюсофон.
Адрес: https://restapi.plusofon.ru
GET
api/v1/notifications/emails
Метод позволяет получить список всех добавленных email-адресов для уведомлений.
Query
page
integer
номер выводимой страницы (для пагинации)
limit
integer
количество элементов на странице
curl -X GET \
-G "https://restapi.plusofon.ru/api/v1/notifications/emails?page=1" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}"
const url = new URL(
"https://restapi.plusofon.ru/api/v1/notifications/emails"
);
let params = {
"page": "1",
};
Object.keys(params)
.forEach(key => url.searchParams.append(key, params[key]));
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
fetch(url, {
method: "GET",
headers: headers,
})
.then(response => response.json())
.then(json => console.log(json));
$client = new \GuzzleHttp\Client();
$response = $client->get(
'https://restapi.plusofon.ru/api/v1/notifications/emails',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
'query' => [
'page'=> '1',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/notifications/emails'
params = {
'page': '1',
}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('GET', url, headers=headers, params=params)
response.json()
В ответе возвращается массив data
:
id
ИД email-адреса
email
email-адрес
{
{
"current_page": 1,
"data": [
{
"id": 1,
"email": "user@gmail.com"
},
{
"id": 2,
"email": "user@mail.ru"
}
],
"first_page_url": "http:\/\/localhost\/api\/v1\/notifications\/emails?page=1",
"from": 1,
"last_page": 1,
"last_page_url": "http:\/\/localhost\/api\/v1\/notifications\/emails?page=1",
"next_page_url": null,
"path": "http:\/\/localhost\/api\/v1\/notifications\/emails",
"per_page": 15,
"prev_page_url": null,
"to": 2,
"total": 2,
"success": true
}
}
GET
api/v1/notifications/emails/{email_id}
Метод позволяет получить конкретный email-адрес.
Path
email_id
stringi
curl -X GET \
-G "https://restapi.plusofon.ru/api/v1/notifications/emails/12" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}"
const url = new URL(
"https://restapi.plusofon.ru/api/v1/notifications/emails/12"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
fetch(url, {
method: "GET",
headers: headers,
})
.then(response => response.json())
.then(json => console.log(json));
$client = new \GuzzleHttp\Client();
$response = $client->get(
'https://restapi.plusofon.ru/api/v1/notifications/emails/12',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/notifications/emails/12'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('GET', url, headers=headers)
response.json()
В ответе возвращается:
id
ИД email-адреса
email
email-адрес
success
признак успешно выполненного запроса
Получен определённый email-адрес:
{
"id": 12,
"email": "user@mail.ru",
"success": true
}
POST
api/v1/notifications/emails
Метод позволяет добавить новый email-адрес для уведомлений.
Body
email
stringcurl -X POST \
"https://restapi.plusofon.ru/api/v1/notifications/emails" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}" \
-d '{"email":"user@mail.ru"}'
const url = new URL(
"https://restapi.plusofon.ru/api/v1/notifications/emails"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
let body = {
"email": "user@mail.ru"
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
$client = new \GuzzleHttp\Client();
$response = $client->post(
'https://restapi.plusofon.ru/api/v1/notifications/emails',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
'json' => [
'email' => 'user@mail.ru',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/notifications/emails'
payload = {
"email": "user@mail.ru"
}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('POST', url, headers=headers, json=payload)
response.json()
В ответе может возвращаться:
success
признак успешно выполненного запроса
message
сообщение об ошибке
Email-адрес успешно добавлен:
{
"success": true
}
PUT
api/v1/notifications/emails/{email_id}
Метод позволяет изменить конкретный email-адрес для уведомлений.
curl -X PUT \
"https://restapi.plusofon.ru/api/v1/notifications/emails/14" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}" \
-d '{"email":"user2@mail.ru"}'
const url = new URL(
"https://restapi.plusofon.ru/api/v1/notifications/emails/14"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
let body = {
"email": "user2@mail.ru"
}
fetch(url, {
method: "PUT",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
$client = new \GuzzleHttp\Client();
$response = $client->put(
'https://restapi.plusofon.ru/api/v1/notifications/emails/14',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
'json' => [
'email' => 'user2@mail.ru',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/notifications/emails/14'
payload = {
"email": "user2@mail.ru"
}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('PUT', url, headers=headers, json=payload)
response.json()
В ответе может возвращаться:
success
признак успешно выполненного запроса
message
сообщение об ошибке
Email-адрес успешно изменён:
{
"success": true
}
DELETE
api/v1/notifications/emails/{email_id}
Метод позволяет удалить конкретный email-адрес.
Path
email_id
stringi
curl -X DELETE \
"https://restapi.plusofon.ru/api/v1/notifications/emails/22" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}"
const url = new URL(
"https://restapi.plusofon.ru/api/v1/notifications/emails/22"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
fetch(url, {
method: "DELETE",
headers: headers,
})
.then(response => response.json())
.then(json => console.log(json));
$client = new \GuzzleHttp\Client();
$response = $client->delete(
'https://restapi.plusofon.ru/api/v1/notifications/emails/22',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/notifications/emails/22'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('DELETE', url, headers=headers)
response.json()
В ответе может возвращаться:
success
признак успешно выполненного запроса
message
сообщение об ошибке
Email-адрес успешно удалён:
{
"success": true
}