开始使用 发票
使用专用API代币,首先验证测试数据的读取操作.
- 保存代币服务器侧,然后将其发送到Authorization标题中.
- 检查所需参数,并扩大请求或响应方案.
- 在应用错误中处理HTTP状态和稳定的error字段.
通过可编辑的独立合同来支持本页面. 在生产使用之前,验证使用测试数据的写作操作.
/api/billing/find
准备使用的工作流程
使用专用API代币,首先验证测试数据的读取操作.
数据模型
模型在此列出一次,并且可以直接从使用它们的终端点扩展.
idinteger · int64Id.
namestring姓名.
productIdinteger · int64产品身份证
itemIdinteger · int64标签:
orderIdinteger · int64订单身份证.
pricenumber · double价格.
volumeinteger · int32音量.
weightinteger · int32体重.
quantityinteger · int32量量.
totalPricenumber · double总价格.
tariffIdinteger · int64关税证.
linkedClientIdinteger · int64链接的客户身份证.
clientIdinteger · int64客户身份证.
fromstring · date-time没有.
tostring · date-time为了.
datestring · date-time约会.
userIdinteger · int64用户身份证
rowsBilling[]排列.
错误合同
编程的代码在每个地方都相同,而用户面向的消息由服务器翻译. 建立在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/billing/find使用 GET /api/billing/find.获得账单操作
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
from |
string · date-time | 否 | 没有. |
to |
string · date-time | 否 | 为了. |
limit |
integer · int32 | 否 | 限制. |
page |
integer · int32 | 否 | 页面. |
count |
boolean | 否 | 伯爵. |
sortBy |
string | 否 | 排序了. |
ascending |
boolean | 否 | 升高. |
curl --request GET 'https://api.selsup.ru/api/billing/find?limit=50&page=1' \
--header 'Authorization: YOUR_API_TOKEN'
const response = await fetch('https://api.selsup.ru/api/billing/find?limit=50&page=1', {
method: 'GET',
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/billing/find?limit=50&page=1', {
method: 'GET',
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.get(
'https://api.selsup.ru/api/billing/find?limit=50&page=1',
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/billing/find?limit=50&page=1',
CURLOPT_CUSTOMREQUEST => 'GET',
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("GET", "https://api.selsup.ru/api/billing/find?limit=50&page=1", 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/billing/find?limit=50&page=1"))
.header("Authorization", System.getenv("SELSUP_API_TOKEN"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
}
}
FindResponseBilling
| 字段 | 类型 | 必填 | 描述 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
rows |
Billing[] | 否 | 排列. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
阵列项结构
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
id |
integer · int64 | 否 | Id. |
name |
string | 否 | 姓名. |
productId |
integer · int64 | 否 | 产品身份证 |
itemId |
integer · int64 | 否 | 标签: |
orderId |
integer · int64 | 否 | 订单身份证. |
price |
number · double | 否 | 价格. |
volume |
integer · int32 | 否 | 音量. |
weight |
integer · int32 | 否 | 体重. |
quantity |
integer · int32 | 否 | 量量. |
totalPrice |
number · double | 否 | 总价格. |
tariffId |
integer · int64 | 否 | 关税证. |
linkedClientId |
integer · int64 | 否 | 链接的客户身份证. |
clientId |
integer · int64 | 否 | 客户身份证. |
from |
string · date-time | 否 | 没有. |
to |
string · date-time | 否 | 为了. |
date |
string · date-time | 否 | 约会. |
userId |
integer · int64 | 否 | 用户身份证 |
{
"rows": "string"
}应用错误通常以 JSON, error,localMessage和 params为回归. 如何返回应用错误 ↑
auth_requiredAuthorization 缺失,空,或包含无效的代币.
error_access_denied代币存在,但它的作用不能执行这个操作.
error_unknown节省请求时间和联系支持;不要盲目重新尝试突变.
error_no_client应用逻辑中使用稳定的error_no_client代码;localMessage包含上述翻译.
error_subscription_expired应用逻辑中使用稳定的error_subscription_expired代码;localMessage包含上述翻译.