| версия от 2023-02-13 |
Группа методов позволяет управлять контактами для объединения в белые и чёрные списки.
Адрес: https://restapi.plusofon.ru
GET api/v1/contact-lists
Метод позволяет получить перечень всех созданных списков контактов.
Не имеет параметров.
curl -X GET \
-G "https://restapi.plusofon.ru/api/v1/contact-lists" \
-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/contact-lists"
);
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/contact-lists',
[
'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/contact-lists'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('GET', url, headers=headers)
response.json()
В ответе возвращается перечень списков:
"data" |
array | массив списков |
"id" |
integer | ИД списка |
"name" |
string | название списка |
"type" |
string | тип списка возможные варианты:
|
{
"current_page": 1,
"data": [
{
"id": 11,
"name": "Черный список 1",
"type": "black"
},
{
"id": 17,
"name": "Белый список 1",
"type": "white"
}
],
"first_page_url": "http:\/\/localhost\/api\/v1\/contact-lists?page=1",
"from": 1,
"last_page": 1,
"last_page_url": "http:\/\/localhost\/api\/v1\/contact-lists?page=1",
"next_page_url": null,
"path": "http:\/\/localhost\/api\/v1\/contact-lists",
"per_page": 15,
"prev_page_url": null,
"to": 2,
"total": 2,
"success": true
}
GET api/v1/contact-lists/{contact_list_id}
Метод позволяет получить данные контактов из конкретного списка.
Параметры Path
"contact_list_id" |
string | ИД списка контактов (см. "id" в ответе на запрос получения всех списков) |
curl -X GET \
-G "https://restapi.plusofon.ru/api/v1/contact-lists/15" \
-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/contact-lists/15"
);
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/contact-lists/15',
[
'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/contact-lists/15'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('GET', url, headers=headers)
response.json()
В ответе возвращается перечень контактов:
"id" |
integer | ИД списка |
"name" |
string | название списка |
"type" |
string | тип списка возможные варианты:
|
"contacts" |
array | массив контактов |
"name" |
string | имя контакта |
"contacts" |
array | массив телефонных номеров контакта |
{
"id": 19,
"name": "Черный Список 1",
"type": "black",
"contacts": [
{
"name": "Иван Петров",
"phones": [
"79993332210",
"74951332210"
]
},
{
"name": "Петр Иванов",
"phones": [
"79993332211",
"74951332211"
]
}
],
"success": true
}
POST api/v1/contact-lists
Метод позволяет создать новый список контактов.
URL для получения созданного списка контактов находится в заголовке "Location".
Параметры Body
"name" |
string | название списка |
"type" |
string | тип списка (см. "type" в ответе на запрос получения типов списков) возможные варианты:
|
"contacts" |
array | массив контактов |
"name" |
string | имя контакта |
"contacts" |
array | массив телефонных номеров контакта |
curl -X POST \
"https://restapi.plusofon.ru/api/v1/contact-lists" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}" \
-d '{"name":"ЧС","type":"black","contacts":[{"name":"Иван Петров","phones":["79993332210","74951332210"]},{"name":"Петр Иванов","phones":["79993332211","74951332211"]}]}'
const url = new URL(
"https://restapi.plusofon.ru/api/v1/contact-lists"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
let body = {
"name": "ЧС",
"type": "black",
"contacts": [
{
"name": "Иван Петров",
"phones": [
"79993332210",
"74951332210"
]
},
{
"name": "Петр Иванов",
"phones": [
"79993332211",
"74951332211"
]
}
]
}
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/contact-lists',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
'json' => [
'name' => 'ЧС',
'type' => 'black',
'contacts' => [
[
'name' => 'Иван Петров',
'phones' => [
'79993332210',
'74951332210',
],
],
[
'name' => 'Петр Иванов',
'phones' => [
'79993332211',
'74951332211',
],
],
],
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/contact-lists'
payload = {
"name": "ЧС",
"type": "black",
"contacts": [
{
"name": "Иван Петров",
"phones": [
"79993332210",
"74951332210"
]
},
{
"name": "Петр Иванов",
"phones": [
"79993332211",
"74951332211"
]
}
]
}
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" |
bool | признак успешно выполненного запроса |
"message" |
string | сообщение об ошибке |
Список успешно создан:
{
"success": true
}
PUT api/v1/contact-lists/{contact_list_id}
Метод позволяет обновить состав конкретного списка контактов.
Параметры Path
"contact_list_id" |
string | ИД списка контактов (см. "id" в ответе на запрос получения всех списков) |
Параметры Body
"name" |
string | название списка |
"type" |
string | тип списка (см. "type" в ответе на запрос получения типов списков) возможные варианты:
|
"contacts" |
array | массив контактов |
"name" |
string | имя контакта |
"contacts" |
array | массив телефонных номеров контакта |
curl -X PUT \
"https://restapi.plusofon.ru/api/v1/contact-lists/15" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}" \
-d '{"name":"ЧС","type":"black","contacts":[{"name":"Иван Петров","phones":["79993332210","74951332210"]},{"name":"Петр Иванов","phones":["79993332211","74951332211"]}]}'
const url = new URL(
"https://restapi.plusofon.ru/api/v1/contact-lists/15"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
let body = {
"name": "ЧС",
"type": "black",
"contacts": [
{
"name": "Иван Петров",
"phones": [
"79993332210",
"74951332210"
]
},
{
"name": "Петр Иванов",
"phones": [
"79993332211",
"74951332211"
]
}
]
}
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/contact-lists/15',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
'json' => [
'name' => 'ЧС',
'type' => 'black',
'contacts' => [
[
'name' => 'Иван Петров',
'phones' => [
'79993332210',
'74951332210',
],
],
[
'name' => 'Петр Иванов',
'phones' => [
'79993332211',
'74951332211',
],
],
],
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/contact-lists/15'
payload = {
"name": "ЧС",
"type": "black",
"contacts": [
{
"name": "Иван Петров",
"phones": [
"79993332210",
"74951332210"
]
},
{
"name": "Петр Иванов",
"phones": [
"79993332211",
"74951332211"
]
}
]
}
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" |
bool | признак успешно выполненного запроса |
"message" |
string | сообщение об ошибке |
Список успешно обновлён:
{
"success": true
}
DELETE api/v1/contact-lists/{contact_list_id}
Метод позволяет удалить конкретный список контактов.
Параметры Path
"contact_list_id" |
string | ИД списка контактов (см. "id" в ответе на запрос получения всех списков) |
curl -X DELETE \
"https://restapi.plusofon.ru/api/v1/contact-lists/15" \
-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/contact-lists/15"
);
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/contact-lists/15',
[
'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/contact-lists/15'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('DELETE', url, headers=headers)
response.json()
В ответе может возвращаться:
"success" |
bool | признак успешно выполненного запроса |
"message" |
string | сообщение об ошибке |
Список успешно удалён:
{
"success": true
}
GET api/v1/contact-lists/types
Метод позволяет получить перечень типов списков контактов, доступных для создания.
Не имеет параметров.
curl -X GET \
-G "https://restapi.plusofon.ru/api/v1/contact-lists/types" \
-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/contact-lists/types"
);
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/contact-lists/types',
[
'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/contact-lists/types'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('GET', url, headers=headers)
response.json()
В ответе возвращается перечень типов списков:
"types" |
array | массив типов |
"type" |
string | код типа |
"title" |
string | название типа |
{
"types": [
{
"type": "black",
"title": "Черный"
},
{
"type": "white",
"title": "Белый"
}
],
"success": true
}