Группа методов позволяет управлять «умными номерами».
Метод позволяет получить список всех умных номеров.
GET
api/v1/smart-numbers
https://restapi.plusofon.ru
user_id
curl -X GET \
-G "https://restapi.plusofon.ru/api/v1/smart-numbers"\
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}" \
-d '{"user_id":12}'
const url = new URL(
"https://restapi.plusofon.ru/api/v1/smart-numbers"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
let body = {
"user_id": 12
}
fetch(url, {
method: "GET",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
$client = new \GuzzleHttp\Client();
$response = $client->get(
'https://restapi.plusofon.ru/api/v1/smart-numbers',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
'json' => [
'user_id' => 12,
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/smart-numbers'
payload = {
"user_id": 12
}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('GET', url, headers=headers, json=payload)
response.json()
В ответе возвращается массив data
:
id
ИД умного номера
user_id
ИД пользователя
phoneA
исходящий номер
phoneB
номер назначения
phoneX
умный номер
description
название умного номера
created_at
дата создания
{
"current_page": 1,
"data": [
{
"id": 2,
"user_id": 40,
"phoneA": "79991230046",
"phoneB": "37410324040",
"phoneX": "79770005419",
"description": "тестовый умный номер",
"created_at": "2022-07-01 07:59:59"
},
{
"id": 3,
"user_id": 40,
"phoneA": "79991230046",
"phoneB": "995322250484",
"phoneX": "79770005462",
"description": "тестовый умный номер2",
"created_at": "2022-07-03 04:50:34"
}
],
"first_page_url": "http:\/\/localhost\/api\/v1\/smart-numbers?page=1",
"from": 1,
"last_page": 1,
"last_page_url": "http:\/\/localhost\/api\/v1\/smart-numbers?page=1",
"next_page_url": null,
"path": "http:\/\/localhost\/api\/v1\/smart-numbers",
"per_page": 15,
"prev_page_url": null,
"to": 2,
"total": 2
}
Пользователь не найден:
{
"message": "User not found",
"code": 500
}
Метод позволяет добавить новый умный номер.
POST
api/v1/smart-numbers
https://restapi.plusofon.ru
curl -X POST \
"https://restapi.plusofon.ru/api/v1/smart-numbers" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Client: 10553" \
-H "Authorization: Bearer {token}" \
-d '{"phone_b":"79993332210","user_id":15,"description":"quas"}'
const url = new URL(
"https://restapi.plusofon.ru/api/v1/smart-numbers"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Client": "10553",
"Authorization": "Bearer {token}",
};
let body = {
"phone_b": "79993332210",
"user_id": 15,
"description": "quas"
}
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/smart-numbers',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Client' => '10553',
'Authorization' => 'Bearer {token}',
],
'json' => [
'phone_b' => '79993332210',
'user_id' => 15,
'description' => 'quas',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json
url = 'https://restapi.plusofon.ru/api/v1/smart-numbers'
payload = {
"phone_b": "79993332210",
"user_id": 15,
"description": "quas"
}
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
сообщение об ошибке
Умный номер успешно добавлен:
{
"success": true
}
Пользователь не найден:
{
"message": "User not found.",
"code": 500
}
Метод позволяет удалить конкретный умный номер.
DELETE
api/v1/smart-numbers/{smartNumberId}
https://restapi.plusofon.ru
smartNumberId
curl -X DELETE \
"https://restapi.plusofon.ru/api/v1/smart-numbers/5" \
-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/smart-numbers/5"
);
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/smart-numbers/5',
[
'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/smart-numbers/5'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Client': '10553',
'Authorization': 'Bearer {token}'
}
response = requests.request('DELETE', url, headers=headers)
response.json()
В ответе может возвращаться:
success
признак успешно выполненного запроса
message
сообщение об ошибке
Умный номер успешно удалён:
{
"success": true
}
Передан некорректный ИД умного номера:
{
"message": "The smart number id must be int",
"code": 400
}
Пользователь не найден:
{
"message": "User not found",
"code": 500
}