开始使用Job
使用专用API代币,首先验证测试数据的读取操作.
- 保存代币服务器侧,然后将其发送到Authorization标题中.
- 检查所需参数,并扩大请求或响应方案.
- 在应用错误中处理HTTP状态和稳定的error字段.
通过可编辑的独立合同来支持本页面. 在生产使用之前,验证使用测试数据的写作操作.
/api/job
准备使用的工作流程
使用专用API代币,首先验证测试数据的读取操作.
数据模型
模型在此列出一次,并且可以直接从使用它们的终端点扩展.
idinteger · int32Id.
namestring姓名.
categoryClassstring类别类.
clientIdinteger · int64客户身份证.
deletedboolean删除了.
positionIdinteger · int64位置身份.
versionIdinteger · int64版本ID.
createdUserstring创建用户.
createdDatestring · date-time创造日期.
pricenumber · double价格.
tariffsJobTariff[]关税.
idinteger · int64Id.
jobIdinteger · int32工作身份证.
pricenumber · double价格.
brandIdinteger · int32品牌身份证.
categoryClassstring类别类.
categoryIdinteger · int32类别的ID.
priorityinteger · int32优先考虑.
productIdinteger · int64产品身份证
错误合同
编程的代码在每个地方都相同,而用户面向的消息由服务器翻译. 建立在error周围的应用逻辑,仅用于显示.
鱼类稳定机器可读的代码用于集成逻辑.
鱼类在API代币用户语言中显示准备的消息.
鱼类服务器在本地化消息模板中插入的值.
localMessage使用了 API代币的用户的lang字段.文档语言和 Accept-Language标题不会改变它;当用户没有语言配置时,使用俄语.
{
"error": "error_brand_already_exists",
"localMessage": "Бренд Base уже существует",
"params": {
"name": "Base"
}
}{
"error": "error_brand_already_exists",
"localMessage": "品牌 Base 已经存在",
"params": {
"name": "Base"
}
}终点
/api/job/{jobId}通过PUT/api/job/{jobId}. 输入工作
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
jobId |
integer · int64 | 是 | 工作身份证. |
application/jsonJob| 字段 | 类型 | 必填 | 描述 | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id |
integer · int32 | 否 | Id. | ||||||||||||||||||||||||||||||||||||
name |
string | 否 | 姓名. | ||||||||||||||||||||||||||||||||||||
categoryClass |
stringSHOES, LIGHT, DRUGS, CAMERA, TYRES, MILK, WATER, TOBACCO, FURS, BEER, BICYCLES, PERFUMES, ELECTRONIC, OTHER, NONE, FOOD, WHEELCHAIRS, OTP, NCP, BIO, ANTISEPTIC, NABEER, SOFTDRINKS, PETFOOD, SEAFOOD, MEAT, TOYS, TITAN, RADIO, OPTIC_FIBER, VEGETABLE_OIL, CONSERVE, VETPHARMA, CHEMISTRY, AUTOFLUIDS, GROCERY, BOOKS, CONSTRUCTION, FIRE, HEATER, CABLERAW, POLYMER, SWEETS, CARPARTS, NATURAL_FUR, NICOTINDEV, GADGETS, FROZEN, FERTILIZERS, HOMEWARE, VETBIO, INDUSTRIAL, PYROTECHNICS | 否 | 类别类. | ||||||||||||||||||||||||||||||||||||
clientId |
integer · int64 | 否 | 客户身份证. | ||||||||||||||||||||||||||||||||||||
deleted |
boolean | 否 | 删除了. | ||||||||||||||||||||||||||||||||||||
positionId |
integer · int64 | 否 | 位置身份. | ||||||||||||||||||||||||||||||||||||
versionId |
integer · int64 | 否 | 版本ID. | ||||||||||||||||||||||||||||||||||||
createdUser |
string | 否 | 创建用户. | ||||||||||||||||||||||||||||||||||||
createdDate |
string · date-time | 否 | 创造日期. | ||||||||||||||||||||||||||||||||||||
price |
number · double | 否 | 价格. | ||||||||||||||||||||||||||||||||||||
tariffs |
JobTariff[] | 否 | 关税. | ||||||||||||||||||||||||||||||||||||
阵列项结构
|
|||||||||||||||||||||||||||||||||||||||
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
id |
integer · int64 | 否 | Id. |
jobId |
integer · int32 | 否 | 工作身份证. |
price |
number · double | 否 | 价格. |
brandId |
integer · int32 | 否 | 品牌身份证. |
categoryClass |
stringSHOES, LIGHT, DRUGS, CAMERA, TYRES, MILK, WATER, TOBACCO, FURS, BEER, BICYCLES, PERFUMES, ELECTRONIC, OTHER, NONE, FOOD, WHEELCHAIRS, OTP, NCP, BIO, ANTISEPTIC, NABEER, SOFTDRINKS, PETFOOD, SEAFOOD, MEAT, TOYS, TITAN, RADIO, OPTIC_FIBER, VEGETABLE_OIL, CONSERVE, VETPHARMA, CHEMISTRY, AUTOFLUIDS, GROCERY, BOOKS, CONSTRUCTION, FIRE, HEATER, CABLERAW, POLYMER, SWEETS, CARPARTS, NATURAL_FUR, NICOTINDEV, GADGETS, FROZEN, FERTILIZERS, HOMEWARE, VETBIO, INDUSTRIAL, PYROTECHNICS | 否 | 类别类. |
categoryId |
integer · int32 | 否 | 类别的ID. |
priority |
integer · int32 | 否 | 优先考虑. |
productId |
integer · int64 | 否 | 产品身份证 |
curl --request PUT 'https://api.selsup.ru/api/job/1001' \
--header 'Authorization: YOUR_API_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"id": 1001,
"name": "Example",
"categoryClass": "SHOES",
"clientId": 1001,
"deleted": false,
"positionId": 1001
}'
const response = await fetch('https://api.selsup.ru/api/job/1001', {
method: 'PUT',
headers: {
Authorization: process.env.SELSUP_API_TOKEN,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"id": 1001,
"name": "Example",
"categoryClass": "SHOES",
"clientId": 1001,
"deleted": false,
"positionId": 1001
}),
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.error || 'selsup_request_failed');
}
const result = await response.json();
const response: Response = await fetch('https://api.selsup.ru/api/job/1001', {
method: 'PUT',
headers: {
Authorization: process.env.SELSUP_API_TOKEN!,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"id": 1001,
"name": "Example",
"categoryClass": "SHOES",
"clientId": 1001,
"deleted": false,
"positionId": 1001
}),
});
if (!response.ok) {
const error = await response.json() as { error?: string };
throw new Error(error.error ?? 'selsup_request_failed');
}
const result: unknown = await response.json();
import os
import requests
response = requests.put(
'https://api.selsup.ru/api/job/1001',
headers={'Authorization': os.environ['SELSUP_API_TOKEN']},
json={
'id': 1001,
'name': 'Example',
'categoryClass': 'SHOES',
'clientId': 1001,
'deleted': False,
'positionId': 1001
},
)
response.raise_for_status()
result = response.json()
<?php
$payload = <<<'JSON'
{
"id": 1001,
"name": "Example",
"categoryClass": "SHOES",
"clientId": 1001,
"deleted": false,
"positionId": 1001
}
JSON;
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.selsup.ru/api/job/1001',
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: ' . getenv('SELSUP_API_TOKEN'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => $payload,
]);
$response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($response === false || $status >= 400) {
throw new RuntimeException($response ?: 'selsup_request_failed');
}
echo $response;
package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
req, err := http.NewRequest("PUT", "https://api.selsup.ru/api/job/1001", strings.NewReader(`{
"id": 1001,
"name": "Example",
"categoryClass": "SHOES",
"clientId": 1001,
"deleted": false,
"positionId": 1001
}`))
if err != nil { panic(err) }
req.Header.Set("Authorization", os.Getenv("SELSUP_API_TOKEN"))
req.Header.Set("Content-Type", "application/json")
response, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer response.Body.Close()
result, _ := io.ReadAll(response.Body)
fmt.Printf("%d\n%s\n", response.StatusCode, result)
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class SelSupExample {
public static void main(String[] args) throws Exception {
HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.selsup.ru/api/job/1001"))
.header("Authorization", System.getenv("SELSUP_API_TOKEN"))
.header("Content-Type", "application/json")
.method("PUT", HttpRequest.BodyPublishers.ofString("""
{
"id": 1001,
"name": "Example",
"categoryClass": "SHOES",
"clientId": 1001,
"deleted": false,
"positionId": 1001
}
"""))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
}
}
Job
| 字段 | 类型 | 必填 | 描述 | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id |
integer · int32 | 否 | Id. | ||||||||||||||||||||||||||||||||||||
name |
string | 否 | 姓名. | ||||||||||||||||||||||||||||||||||||
categoryClass |
stringSHOES, LIGHT, DRUGS, CAMERA, TYRES, MILK, WATER, TOBACCO, FURS, BEER, BICYCLES, PERFUMES, ELECTRONIC, OTHER, NONE, FOOD, WHEELCHAIRS, OTP, NCP, BIO, ANTISEPTIC, NABEER, SOFTDRINKS, PETFOOD, SEAFOOD, MEAT, TOYS, TITAN, RADIO, OPTIC_FIBER, VEGETABLE_OIL, CONSERVE, VETPHARMA, CHEMISTRY, AUTOFLUIDS, GROCERY, BOOKS, CONSTRUCTION, FIRE, HEATER, CABLERAW, POLYMER, SWEETS, CARPARTS, NATURAL_FUR, NICOTINDEV, GADGETS, FROZEN, FERTILIZERS, HOMEWARE, VETBIO, INDUSTRIAL, PYROTECHNICS | 否 | 类别类. | ||||||||||||||||||||||||||||||||||||
clientId |
integer · int64 | 否 | 客户身份证. | ||||||||||||||||||||||||||||||||||||
deleted |
boolean | 否 | 删除了. | ||||||||||||||||||||||||||||||||||||
positionId |
integer · int64 | 否 | 位置身份. | ||||||||||||||||||||||||||||||||||||
versionId |
integer · int64 | 否 | 版本ID. | ||||||||||||||||||||||||||||||||||||
createdUser |
string | 否 | 创建用户. | ||||||||||||||||||||||||||||||||||||
createdDate |
string · date-time | 否 | 创造日期. | ||||||||||||||||||||||||||||||||||||
price |
number · double | 否 | 价格. | ||||||||||||||||||||||||||||||||||||
tariffs |
JobTariff[] | 否 | 关税. | ||||||||||||||||||||||||||||||||||||
阵列项结构
|
|||||||||||||||||||||||||||||||||||||||
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
id |
integer · int64 | 否 | Id. |
jobId |
integer · int32 | 否 | 工作身份证. |
price |
number · double | 否 | 价格. |
brandId |
integer · int32 | 否 | 品牌身份证. |
categoryClass |
stringSHOES, LIGHT, DRUGS, CAMERA, TYRES, MILK, WATER, TOBACCO, FURS, BEER, BICYCLES, PERFUMES, ELECTRONIC, OTHER, NONE, FOOD, WHEELCHAIRS, OTP, NCP, BIO, ANTISEPTIC, NABEER, SOFTDRINKS, PETFOOD, SEAFOOD, MEAT, TOYS, TITAN, RADIO, OPTIC_FIBER, VEGETABLE_OIL, CONSERVE, VETPHARMA, CHEMISTRY, AUTOFLUIDS, GROCERY, BOOKS, CONSTRUCTION, FIRE, HEATER, CABLERAW, POLYMER, SWEETS, CARPARTS, NATURAL_FUR, NICOTINDEV, GADGETS, FROZEN, FERTILIZERS, HOMEWARE, VETBIO, INDUSTRIAL, PYROTECHNICS | 否 | 类别类. |
categoryId |
integer · int32 | 否 | 类别的ID. |
priority |
integer · int32 | 否 | 优先考虑. |
productId |
integer · int64 | 否 | 产品身份证 |
{
"id": 1001,
"name": "Example",
"categoryClass": "SHOES",
"clientId": 1001,
"deleted": false,
"positionId": 1001
}应用错误通常以 JSON, error,localMessage和 params为回归. 如何返回应用错误 ↑
auth_requiredAuthorization 缺失,空,或包含无效的代币.
error_access_denied代币存在,但它的作用不能执行这个操作.
error_unknown节省请求时间和联系支持;不要盲目重新尝试突变.
error_empty_category_class应用逻辑中使用稳定的error_empty_category_class代码;localMessage包含上述翻译.
error_empty_job_price应用逻辑中使用稳定的error_empty_job_price代码;localMessage包含上述翻译.
error_empty_position应用逻辑中使用稳定的error_empty_position代码;localMessage包含上述翻译.
error_empty_tariff_price应用逻辑中使用稳定的error_empty_tariff_price代码;localMessage包含上述翻译.
error_empty_tariff_priority应用逻辑中使用稳定的error_empty_tariff_priority代码;localMessage包含上述翻译.
error_empty_tariffs应用逻辑中使用稳定的error_empty_tariffs代码;localMessage包含上述翻译.
error_job_already_exists应用逻辑中使用稳定的error_job_already_exists代码;localMessage包含上述翻译.
error_job_modified应用逻辑中使用稳定的error_job_modified代码;localMessage包含上述翻译.
error_job_tariff_wrong_product_id应用逻辑中使用稳定的error_job_tariff_wrong_product_id代码;localMessage包含上述翻译.
error_no_client应用逻辑中使用稳定的error_no_client代码;localMessage包含上述翻译.
error_subscription_expired应用逻辑中使用稳定的error_subscription_expired代码;localMessage包含上述翻译.
/api/job/{jobId}使用 DELETE /api/job/{jobId}. 删除工作
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
jobId |
integer · int32 | 是 | 工作身份证. |
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
deleted |
boolean | 是 | 删除了. |
curl --request DELETE 'https://api.selsup.ru/api/job/1001?deleted=false' \
--header 'Authorization: YOUR_API_TOKEN'
const response = await fetch('https://api.selsup.ru/api/job/1001?deleted=false', {
method: 'DELETE',
headers: { Authorization: process.env.SELSUP_API_TOKEN },
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.error || 'selsup_request_failed');
}
const result = await response.json();
const response: Response = await fetch('https://api.selsup.ru/api/job/1001?deleted=false', {
method: 'DELETE',
headers: { Authorization: process.env.SELSUP_API_TOKEN! },
});
if (!response.ok) {
const error = await response.json() as { error?: string };
throw new Error(error.error ?? 'selsup_request_failed');
}
const result: unknown = await response.json();
import os
import requests
response = requests.delete(
'https://api.selsup.ru/api/job/1001?deleted=false',
headers={'Authorization': os.environ['SELSUP_API_TOKEN']},
)
response.raise_for_status()
result = response.json()
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.selsup.ru/api/job/1001?deleted=false',
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: ' . getenv('SELSUP_API_TOKEN')],
]);
$response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($response === false || $status >= 400) {
throw new RuntimeException($response ?: 'selsup_request_failed');
}
echo $response;
package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, err := http.NewRequest("DELETE", "https://api.selsup.ru/api/job/1001?deleted=false", nil)
if err != nil { panic(err) }
req.Header.Set("Authorization", os.Getenv("SELSUP_API_TOKEN"))
response, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer response.Body.Close()
result, _ := io.ReadAll(response.Body)
fmt.Printf("%d\n%s\n", response.StatusCode, result)
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class SelSupExample {
public static void main(String[] args) throws Exception {
HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.selsup.ru/api/job/1001?deleted=false"))
.header("Authorization", System.getenv("SELSUP_API_TOKEN"))
.method("DELETE", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
}
}
"string"应用错误通常以 JSON, error,localMessage和 params为回归. 如何返回应用错误 ↑
auth_requiredAuthorization 缺失,空,或包含无效的代币.
error_access_denied代币存在,但它的作用不能执行这个操作.
error_unknown节省请求时间和联系支持;不要盲目重新尝试突变.
error_job_modified应用逻辑中使用稳定的error_job_modified代码;localMessage包含上述翻译.
error_no_client应用逻辑中使用稳定的error_no_client代码;localMessage包含上述翻译.
error_subscription_expired应用逻辑中使用稳定的error_subscription_expired代码;localMessage包含上述翻译.
/api/job/使用 POST /api/job/. 发布工作
application/jsonJob| 字段 | 类型 | 必填 | 描述 | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id |
integer · int32 | 否 | Id. | ||||||||||||||||||||||||||||||||||||
name |
string | 否 | 姓名. | ||||||||||||||||||||||||||||||||||||
categoryClass |
stringSHOES, LIGHT, DRUGS, CAMERA, TYRES, MILK, WATER, TOBACCO, FURS, BEER, BICYCLES, PERFUMES, ELECTRONIC, OTHER, NONE, FOOD, WHEELCHAIRS, OTP, NCP, BIO, ANTISEPTIC, NABEER, SOFTDRINKS, PETFOOD, SEAFOOD, MEAT, TOYS, TITAN, RADIO, OPTIC_FIBER, VEGETABLE_OIL, CONSERVE, VETPHARMA, CHEMISTRY, AUTOFLUIDS, GROCERY, BOOKS, CONSTRUCTION, FIRE, HEATER, CABLERAW, POLYMER, SWEETS, CARPARTS, NATURAL_FUR, NICOTINDEV, GADGETS, FROZEN, FERTILIZERS, HOMEWARE, VETBIO, INDUSTRIAL, PYROTECHNICS | 否 | 类别类. | ||||||||||||||||||||||||||||||||||||
clientId |
integer · int64 | 否 | 客户身份证. | ||||||||||||||||||||||||||||||||||||
deleted |
boolean | 否 | 删除了. | ||||||||||||||||||||||||||||||||||||
positionId |
integer · int64 | 否 | 位置身份. | ||||||||||||||||||||||||||||||||||||
versionId |
integer · int64 | 否 | 版本ID. | ||||||||||||||||||||||||||||||||||||
createdUser |
string | 否 | 创建用户. | ||||||||||||||||||||||||||||||||||||
createdDate |
string · date-time | 否 | 创造日期. | ||||||||||||||||||||||||||||||||||||
price |
number · double | 否 | 价格. | ||||||||||||||||||||||||||||||||||||
tariffs |
JobTariff[] | 否 | 关税. | ||||||||||||||||||||||||||||||||||||
阵列项结构
|
|||||||||||||||||||||||||||||||||||||||
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
id |
integer · int64 | 否 | Id. |
jobId |
integer · int32 | 否 | 工作身份证. |
price |
number · double | 否 | 价格. |
brandId |
integer · int32 | 否 | 品牌身份证. |
categoryClass |
stringSHOES, LIGHT, DRUGS, CAMERA, TYRES, MILK, WATER, TOBACCO, FURS, BEER, BICYCLES, PERFUMES, ELECTRONIC, OTHER, NONE, FOOD, WHEELCHAIRS, OTP, NCP, BIO, ANTISEPTIC, NABEER, SOFTDRINKS, PETFOOD, SEAFOOD, MEAT, TOYS, TITAN, RADIO, OPTIC_FIBER, VEGETABLE_OIL, CONSERVE, VETPHARMA, CHEMISTRY, AUTOFLUIDS, GROCERY, BOOKS, CONSTRUCTION, FIRE, HEATER, CABLERAW, POLYMER, SWEETS, CARPARTS, NATURAL_FUR, NICOTINDEV, GADGETS, FROZEN, FERTILIZERS, HOMEWARE, VETBIO, INDUSTRIAL, PYROTECHNICS | 否 | 类别类. |
categoryId |
integer · int32 | 否 | 类别的ID. |
priority |
integer · int32 | 否 | 优先考虑. |
productId |
integer · int64 | 否 | 产品身份证 |
curl --request POST 'https://api.selsup.ru/api/job/' \
--header 'Authorization: YOUR_API_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"id": 1001,
"name": "Example",
"categoryClass": "SHOES",
"clientId": 1001,
"deleted": false,
"positionId": 1001
}'
const response = await fetch('https://api.selsup.ru/api/job/', {
method: 'POST',
headers: {
Authorization: process.env.SELSUP_API_TOKEN,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"id": 1001,
"name": "Example",
"categoryClass": "SHOES",
"clientId": 1001,
"deleted": false,
"positionId": 1001
}),
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.error || 'selsup_request_failed');
}
const result = await response.json();
const response: Response = await fetch('https://api.selsup.ru/api/job/', {
method: 'POST',
headers: {
Authorization: process.env.SELSUP_API_TOKEN!,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"id": 1001,
"name": "Example",
"categoryClass": "SHOES",
"clientId": 1001,
"deleted": false,
"positionId": 1001
}),
});
if (!response.ok) {
const error = await response.json() as { error?: string };
throw new Error(error.error ?? 'selsup_request_failed');
}
const result: unknown = await response.json();
import os
import requests
response = requests.post(
'https://api.selsup.ru/api/job/',
headers={'Authorization': os.environ['SELSUP_API_TOKEN']},
json={
'id': 1001,
'name': 'Example',
'categoryClass': 'SHOES',
'clientId': 1001,
'deleted': False,
'positionId': 1001
},
)
response.raise_for_status()
result = response.json()
<?php
$payload = <<<'JSON'
{
"id": 1001,
"name": "Example",
"categoryClass": "SHOES",
"clientId": 1001,
"deleted": false,
"positionId": 1001
}
JSON;
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.selsup.ru/api/job/',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: ' . getenv('SELSUP_API_TOKEN'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => $payload,
]);
$response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($response === false || $status >= 400) {
throw new RuntimeException($response ?: 'selsup_request_failed');
}
echo $response;
package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
req, err := http.NewRequest("POST", "https://api.selsup.ru/api/job/", strings.NewReader(`{
"id": 1001,
"name": "Example",
"categoryClass": "SHOES",
"clientId": 1001,
"deleted": false,
"positionId": 1001
}`))
if err != nil { panic(err) }
req.Header.Set("Authorization", os.Getenv("SELSUP_API_TOKEN"))
req.Header.Set("Content-Type", "application/json")
response, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer response.Body.Close()
result, _ := io.ReadAll(response.Body)
fmt.Printf("%d\n%s\n", response.StatusCode, result)
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class SelSupExample {
public static void main(String[] args) throws Exception {
HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.selsup.ru/api/job/"))
.header("Authorization", System.getenv("SELSUP_API_TOKEN"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("""
{
"id": 1001,
"name": "Example",
"categoryClass": "SHOES",
"clientId": 1001,
"deleted": false,
"positionId": 1001
}
"""))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
}
}
Job
| 字段 | 类型 | 必填 | 描述 | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id |
integer · int32 | 否 | Id. | ||||||||||||||||||||||||||||||||||||
name |
string | 否 | 姓名. | ||||||||||||||||||||||||||||||||||||
categoryClass |
stringSHOES, LIGHT, DRUGS, CAMERA, TYRES, MILK, WATER, TOBACCO, FURS, BEER, BICYCLES, PERFUMES, ELECTRONIC, OTHER, NONE, FOOD, WHEELCHAIRS, OTP, NCP, BIO, ANTISEPTIC, NABEER, SOFTDRINKS, PETFOOD, SEAFOOD, MEAT, TOYS, TITAN, RADIO, OPTIC_FIBER, VEGETABLE_OIL, CONSERVE, VETPHARMA, CHEMISTRY, AUTOFLUIDS, GROCERY, BOOKS, CONSTRUCTION, FIRE, HEATER, CABLERAW, POLYMER, SWEETS, CARPARTS, NATURAL_FUR, NICOTINDEV, GADGETS, FROZEN, FERTILIZERS, HOMEWARE, VETBIO, INDUSTRIAL, PYROTECHNICS | 否 | 类别类. | ||||||||||||||||||||||||||||||||||||
clientId |
integer · int64 | 否 | 客户身份证. | ||||||||||||||||||||||||||||||||||||
deleted |
boolean | 否 | 删除了. | ||||||||||||||||||||||||||||||||||||
positionId |
integer · int64 | 否 | 位置身份. | ||||||||||||||||||||||||||||||||||||
versionId |
integer · int64 | 否 | 版本ID. | ||||||||||||||||||||||||||||||||||||
createdUser |
string | 否 | 创建用户. | ||||||||||||||||||||||||||||||||||||
createdDate |
string · date-time | 否 | 创造日期. | ||||||||||||||||||||||||||||||||||||
price |
number · double | 否 | 价格. | ||||||||||||||||||||||||||||||||||||
tariffs |
JobTariff[] | 否 | 关税. | ||||||||||||||||||||||||||||||||||||
阵列项结构
|
|||||||||||||||||||||||||||||||||||||||
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
id |
integer · int64 | 否 | Id. |
jobId |
integer · int32 | 否 | 工作身份证. |
price |
number · double | 否 | 价格. |
brandId |
integer · int32 | 否 | 品牌身份证. |
categoryClass |
stringSHOES, LIGHT, DRUGS, CAMERA, TYRES, MILK, WATER, TOBACCO, FURS, BEER, BICYCLES, PERFUMES, ELECTRONIC, OTHER, NONE, FOOD, WHEELCHAIRS, OTP, NCP, BIO, ANTISEPTIC, NABEER, SOFTDRINKS, PETFOOD, SEAFOOD, MEAT, TOYS, TITAN, RADIO, OPTIC_FIBER, VEGETABLE_OIL, CONSERVE, VETPHARMA, CHEMISTRY, AUTOFLUIDS, GROCERY, BOOKS, CONSTRUCTION, FIRE, HEATER, CABLERAW, POLYMER, SWEETS, CARPARTS, NATURAL_FUR, NICOTINDEV, GADGETS, FROZEN, FERTILIZERS, HOMEWARE, VETBIO, INDUSTRIAL, PYROTECHNICS | 否 | 类别类. |
categoryId |
integer · int32 | 否 | 类别的ID. |
priority |
integer · int32 | 否 | 优先考虑. |
productId |
integer · int64 | 否 | 产品身份证 |
{
"id": 1001,
"name": "Example",
"categoryClass": "SHOES",
"clientId": 1001,
"deleted": false,
"positionId": 1001
}应用错误通常以 JSON, error,localMessage和 params为回归. 如何返回应用错误 ↑
auth_requiredAuthorization 缺失,空,或包含无效的代币.
error_access_denied代币存在,但它的作用不能执行这个操作.
error_unknown节省请求时间和联系支持;不要盲目重新尝试突变.
error_empty_category_class应用逻辑中使用稳定的error_empty_category_class代码;localMessage包含上述翻译.
error_empty_job_price应用逻辑中使用稳定的error_empty_job_price代码;localMessage包含上述翻译.
error_empty_position应用逻辑中使用稳定的error_empty_position代码;localMessage包含上述翻译.
error_empty_tariff_price应用逻辑中使用稳定的error_empty_tariff_price代码;localMessage包含上述翻译.
error_empty_tariff_priority应用逻辑中使用稳定的error_empty_tariff_priority代码;localMessage包含上述翻译.
error_empty_tariffs应用逻辑中使用稳定的error_empty_tariffs代码;localMessage包含上述翻译.
error_job_already_exists应用逻辑中使用稳定的error_job_already_exists代码;localMessage包含上述翻译.
error_job_tariff_wrong_product_id应用逻辑中使用稳定的error_job_tariff_wrong_product_id代码;localMessage包含上述翻译.
error_no_client应用逻辑中使用稳定的error_no_client代码;localMessage包含上述翻译.