6750 lines
257 KiB
Go
6750 lines
257 KiB
Go
// Code generated by ogen, DO NOT EDIT.
|
||
|
||
package api
|
||
|
||
import (
|
||
"context"
|
||
"net/url"
|
||
"strings"
|
||
"time"
|
||
|
||
"github.com/go-faster/errors"
|
||
"go.opentelemetry.io/otel/attribute"
|
||
"go.opentelemetry.io/otel/codes"
|
||
"go.opentelemetry.io/otel/metric"
|
||
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
|
||
"go.opentelemetry.io/otel/trace"
|
||
|
||
"github.com/ogen-go/ogen/conv"
|
||
ht "github.com/ogen-go/ogen/http"
|
||
"github.com/ogen-go/ogen/ogenerrors"
|
||
"github.com/ogen-go/ogen/uri"
|
||
)
|
||
|
||
func trimTrailingSlashes(u *url.URL) {
|
||
u.Path = strings.TrimRight(u.Path, "/")
|
||
u.RawPath = strings.TrimRight(u.RawPath, "/")
|
||
}
|
||
|
||
// Invoker invokes operations described by OpenAPI v3 specification.
|
||
type Invoker interface {
|
||
// APIV2BufferGoodsTaskGet invokes GET /api/v2/buffer/goods/task operation.
|
||
//
|
||
// Метод предоставляет информацию о товарах и ошибках в
|
||
// товарах из загрузки в обработке.
|
||
// <div class="description_important">
|
||
// Необработанная загрузка — это загрузка скидок для <a
|
||
// href="/openapi/promotion#tag/Kalendar-akcij">календаря акций</a>. Такие
|
||
// скидки применятся к товарам только в момент начала
|
||
// акции.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 10 запросов за 6 <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">секунд</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Цены и скидки</a>
|
||
// на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// GET /api/v2/buffer/goods/task
|
||
APIV2BufferGoodsTaskGet(ctx context.Context, params APIV2BufferGoodsTaskGetParams) (APIV2BufferGoodsTaskGetRes, error)
|
||
// APIV2BufferTasksGet invokes GET /api/v2/buffer/tasks operation.
|
||
//
|
||
// Метод предоставляет информацию про загрузку скидок в
|
||
// обработке.
|
||
// <div class="description_important">
|
||
// Необработанная загрузка — это загрузка скидок для <a
|
||
// href="/openapi/promotion#tag/Kalendar-akcij">календаря акций</a>. Такие
|
||
// скидки применятся к товарам только в момент начала
|
||
// акции.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 10 запросов за 6 <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">секунд</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Цены и скидки</a>
|
||
// на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// GET /api/v2/buffer/tasks
|
||
APIV2BufferTasksGet(ctx context.Context, params APIV2BufferTasksGetParams) (APIV2BufferTasksGetRes, error)
|
||
// APIV2HistoryGoodsTaskGet invokes GET /api/v2/history/goods/task operation.
|
||
//
|
||
// Метод предоставляет информацию о товарах и об
|
||
// ошибках в товарах в обработанной загрузке.
|
||
// <div class="description_important">
|
||
// Обработанная загрузка — это загрузка цен и скидок
|
||
// для <a
|
||
// href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task/post">товаров</a> и <a href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task~1size/post">размеров товаров</a>, а также скидок <a href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task~1club-discount/post">WB Клуба</a>.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 10 запросов за 6 <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">секунд</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Цены и скидки</a>
|
||
// на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// GET /api/v2/history/goods/task
|
||
APIV2HistoryGoodsTaskGet(ctx context.Context, params APIV2HistoryGoodsTaskGetParams) (APIV2HistoryGoodsTaskGetRes, error)
|
||
// APIV2HistoryTasksGet invokes GET /api/v2/history/tasks operation.
|
||
//
|
||
// Метод предоставляет информацию об обработанной
|
||
// загрузке цен и скидок.
|
||
// <div class="description_important">
|
||
// Обработанная загрузка — это загрузка цен и скидок
|
||
// для <a
|
||
// href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task/post">товаров</a> и <a href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task~1size/post">размеров товаров</a>, а также скидок <a href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task~1club-discount/post">WB Клуба</a>.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 10 запросов за 6 <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">секунд</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Цены и скидки</a>
|
||
// на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// GET /api/v2/history/tasks
|
||
APIV2HistoryTasksGet(ctx context.Context, params APIV2HistoryTasksGetParams) (APIV2HistoryTasksGetRes, error)
|
||
// APIV2ListGoodsFilterGet invokes GET /api/v2/list/goods/filter operation.
|
||
//
|
||
// Метод предоставляет информацию о товарах по их
|
||
// артикулам: цены, валюту, общие скидки и скидки для [WB
|
||
// Клуба](/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task~1club-discount/post).
|
||
// <br><br>
|
||
// Чтобы получить информацию обо всех товарах продавца,
|
||
// оставьте артикул пустым, установите `limit=1000`, в
|
||
// параметре `offset` установите смещение по количеству
|
||
// записей. Количество нужно рассчитать по формуле: `offset`
|
||
// плюс `limit` из предыдущего запроса. Повторяйте запрос,
|
||
// пока вы не получите ответ с пустым массивом.<br> Чтобы
|
||
// получить информацию о размерах товара, используйте
|
||
// [отдельный
|
||
// метод](/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1list~1goods~1size~1nm/get).
|
||
// <div class="description_limit">
|
||
// Максимум 10 запросов за 6 <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">секунд</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Цены и скидки</a>
|
||
// на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// GET /api/v2/list/goods/filter
|
||
APIV2ListGoodsFilterGet(ctx context.Context, params APIV2ListGoodsFilterGetParams) (APIV2ListGoodsFilterGetRes, error)
|
||
// APIV2ListGoodsSizeNmGet invokes GET /api/v2/list/goods/size/nm operation.
|
||
//
|
||
// Метод предоставляет информацию обо всех размерах
|
||
// одного товарам: цены, валюту, общие скидки и скидки
|
||
// для [WB
|
||
// Клуба](/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task~1club-discount/post).
|
||
// <br><br>
|
||
// Работает только для товаров из категорий, где можно
|
||
// устанавливать цены отдельно для разных размеров. Для
|
||
// таких товаров `editableSizePrice: true`.
|
||
// <br><br>
|
||
// Чтобы получить информацию о самом товаре,
|
||
// используйте [отдельный
|
||
// метод](/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1list~1goods~1filter/get).
|
||
// <div class="description_limit">
|
||
// Максимум 10 запросов за 6 <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">секунд</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Цены и скидки</a>
|
||
// на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// GET /api/v2/list/goods/size/nm
|
||
APIV2ListGoodsSizeNmGet(ctx context.Context, params APIV2ListGoodsSizeNmGetParams) (APIV2ListGoodsSizeNmGetRes, error)
|
||
// APIV2QuarantineGoodsGet invokes GET /api/v2/quarantine/goods operation.
|
||
//
|
||
// Метод предоставляет информацию о товарах в карантине.
|
||
// <br><br>
|
||
// Если новая цена товара со скидкой будет минимум в 3
|
||
// раза меньше старой, товар попадёт [в
|
||
// карантин](https://seller.wildberries.ru/discount-and-prices/quarantine) и будет
|
||
// продаваться по старой цене. Ошибка об этом будет в
|
||
// ответах методов [состояний
|
||
// загрузок](/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1history~1tasks/get).
|
||
// <br><br>
|
||
// Вы можете изменить цену или скидку с помощью API либо
|
||
// вывести товар из карантина [в личном
|
||
// кабинете](https://seller.wildberries.ru/discount-and-prices/quarantine).
|
||
// <br><br>
|
||
// Для товаров с [поразмерной установкой
|
||
// цен](/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task~1size/post)
|
||
// карантин не применяется.
|
||
// <div class="description_limit">
|
||
// Максимум 10 запросов за 6 <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">секунд</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Цены и скидки</a>
|
||
// на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// GET /api/v2/quarantine/goods
|
||
APIV2QuarantineGoodsGet(ctx context.Context, params APIV2QuarantineGoodsGetParams) (APIV2QuarantineGoodsGetRes, error)
|
||
// APIV2UploadTaskClubDiscountPost invokes POST /api/v2/upload/task/club-discount operation.
|
||
//
|
||
// Устанавливает скидки для товаров в рамках подписки [WB
|
||
// Клуб](https://seller.wildberries.ru/help-center/article/A-337).
|
||
// <div class="description_important">
|
||
// Получить информацию о процессе установки цен и
|
||
// скидок можно с помощью методов <a
|
||
// href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1history~1tasks/get">состояния</a> и <a href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1history~1goods~1task/get">детализации</a> обработанной загрузки.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 10 запросов за 6 <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">секунд</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Цены и скидки</a>
|
||
// на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// POST /api/v2/upload/task/club-discount
|
||
APIV2UploadTaskClubDiscountPost(ctx context.Context, request *APIV2UploadTaskClubDiscountPostReq) (APIV2UploadTaskClubDiscountPostRes, error)
|
||
// APIV2UploadTaskPost invokes POST /api/v2/upload/task operation.
|
||
//
|
||
// Метод устанавливает цены и скидки для товаров.
|
||
// <br><br>
|
||
// Чтобы установить цены и скидки для размеров товара,
|
||
// используйте [отдельный
|
||
// метод](/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task~1size/post).
|
||
// <div class="description_important">
|
||
// Получить информацию о процессе установки цен и
|
||
// скидок можно с помощью методов <a
|
||
// href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1history~1tasks/get">состояния</a> и <a href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1history~1goods~1task/get">детализации</a> обработанной загрузки.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 10 запросов за 6 <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">секунд</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Цены и скидки</a>
|
||
// на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// POST /api/v2/upload/task
|
||
APIV2UploadTaskPost(ctx context.Context, request *APIV2UploadTaskPostReq) (APIV2UploadTaskPostRes, error)
|
||
// APIV2UploadTaskSizePost invokes POST /api/v2/upload/task/size operation.
|
||
//
|
||
// Метод устанавливает цены отдельно для размеров
|
||
// товаров.
|
||
// Работает только для товаров из категорий, где можно
|
||
// устанавливать цены отдельно для разных размеров. Для
|
||
// [таких
|
||
// товаров](/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1list~1goods~1size~1nm/get) `editableSizePrice: true`.
|
||
// Чтобы установить цены и скидки для самих товаров,
|
||
// используйте [отдельный
|
||
// метод](/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task/post).
|
||
// <div class="description_important">
|
||
// Получить информацию о процессе установки цен и
|
||
// скидок можно с помощью методов <a
|
||
// href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1history~1tasks/get">состояния</a> и <a href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1history~1goods~1task/get">детализации</a> обработанной загрузки.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 10 запросов за 6 <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">секунд</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Цены и скидки</a>
|
||
// на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// POST /api/v2/upload/task/size
|
||
APIV2UploadTaskSizePost(ctx context.Context, request *APIV2UploadTaskSizePostReq) (APIV2UploadTaskSizePostRes, error)
|
||
// APIV3OfficesGet invokes GET /api/v3/offices operation.
|
||
//
|
||
// Метод предоставляет список всех складов WB для
|
||
// привязки к складам продавца. Предназначен для
|
||
// определения складов WB, чтобы сдавать готовые заказы
|
||
// по схеме [FBS](/openapi/orders-fbs#tag/Zakazy-FBS) (Fulfillment by Seller).
|
||
// <div class="description_limit">
|
||
// Максимум 300 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Маркетплейс</a> на
|
||
// один аккаунт продавца.
|
||
// <br><br>
|
||
// Один запрос с кодом ответа <code>409</code> учитывается как 5
|
||
// запросов
|
||
// </div>.
|
||
//
|
||
// GET /api/v3/offices
|
||
APIV3OfficesGet(ctx context.Context) (APIV3OfficesGetRes, error)
|
||
// APIV3StocksWarehouseIdDelete invokes DELETE /api/v3/stocks/{warehouseId} operation.
|
||
//
|
||
// Метод удаляет запись об остатках товаров продавца из
|
||
// [списка
|
||
// остатков](/openapi/work-with-products#tag/Ostatki-na-skladah-prodavca/paths/~1api~1v3~1stocks~1%7BwarehouseId%7D/post).
|
||
// <div class="description_important">
|
||
// <strong>Действие необратимо</strong>. Удаленный остаток
|
||
// будет необходимо загрузить повторно для
|
||
// возобновления продаж.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 300 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Маркетплейс</a> на
|
||
// один аккаунт продавца.
|
||
// <br><br>
|
||
// Один запрос с кодом ответа <code>409</code> учитывается как 5
|
||
// запросов
|
||
// </div>.
|
||
//
|
||
// DELETE /api/v3/stocks/{warehouseId}
|
||
APIV3StocksWarehouseIdDelete(ctx context.Context, request *APIV3StocksWarehouseIdDeleteReq, params APIV3StocksWarehouseIdDeleteParams) (APIV3StocksWarehouseIdDeleteRes, error)
|
||
// APIV3StocksWarehouseIdPost invokes POST /api/v3/stocks/{warehouseId} operation.
|
||
//
|
||
// Метод предоставляет данные об остатках товаров на
|
||
// [складах продавца](/openapi/work-with-products#tag/Sklady-prodavca).
|
||
// <div class="description_limit">
|
||
// Максимум 300 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Маркетплейс</a> на
|
||
// один аккаунт продавца.
|
||
// <br><br>
|
||
// Один запрос с кодом ответа <code>409</code> учитывается как 5
|
||
// запросов
|
||
// </div>.
|
||
//
|
||
// POST /api/v3/stocks/{warehouseId}
|
||
APIV3StocksWarehouseIdPost(ctx context.Context, request *APIV3StocksWarehouseIdPostReq, params APIV3StocksWarehouseIdPostParams) (APIV3StocksWarehouseIdPostRes, error)
|
||
// APIV3StocksWarehouseIdPut invokes PUT /api/v3/stocks/{warehouseId} operation.
|
||
//
|
||
// Метод обновляет количество остатков товаров
|
||
// продавца [в
|
||
// списке](/openapi/work-with-products#tag/Ostatki-na-skladah-prodavca/paths/~1api~1v3~1stocks~1%7BwarehouseId%7D/post).
|
||
// <div class="description_important">
|
||
// Названия параметров запроса не валидируются. При
|
||
// отправке некорректных названий вы получите успешный
|
||
// ответ (<code>204</code>), но остатки не обновятся.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 300 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Маркетплейс</a> на
|
||
// один аккаунт продавца.
|
||
// <br><br>
|
||
// Один запрос с кодом ответа <code>409</code> учитывается как 5
|
||
// запросов
|
||
// </div>.
|
||
//
|
||
// PUT /api/v3/stocks/{warehouseId}
|
||
APIV3StocksWarehouseIdPut(ctx context.Context, request OptAPIV3StocksWarehouseIdPutReq, params APIV3StocksWarehouseIdPutParams) (APIV3StocksWarehouseIdPutRes, error)
|
||
// APIV3WarehousesGet invokes GET /api/v3/warehouses operation.
|
||
//
|
||
// Метод предоставляет список всех складов продавца.
|
||
// Может использоваться для получения [остатков
|
||
// товаров](/openapi/work-with-products#tag/Ostatki-na-skladah-prodavca/paths/~1api~1v3~1stocks~1%7BwarehouseId%7D/post).
|
||
// <div class="description_limit">
|
||
// Максимум 300 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Маркетплейс</a> на
|
||
// один аккаунт продавца.
|
||
// <br><br>
|
||
// Один запрос с кодом ответа <code>409</code> учитывается как 5
|
||
// запросов
|
||
// </div>.
|
||
//
|
||
// GET /api/v3/warehouses
|
||
APIV3WarehousesGet(ctx context.Context) (APIV3WarehousesGetRes, error)
|
||
// APIV3WarehousesPost invokes POST /api/v3/warehouses operation.
|
||
//
|
||
// Метод создаёт склад продавца для работы с [остатками
|
||
// товаров](/openapi/work-with-products#tag/Ostatki-na-skladah-prodavca/paths/~1api~1v3~1stocks~1%7BwarehouseId%7D/post). Нужно привязать к складу продавца [склад WB](/openapi/work-with-products#tag/Sklady-prodavca/paths/~1api~1v3~1offices/get) для работы по схеме [FBS](/openapi/orders-fbs#tag/Zakazy-FBS) (Fulfillment by Seller).
|
||
// <div class="description_important">
|
||
// Нельзя привязывать склад WB, который уже используется
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 300 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Маркетплейс</a> на
|
||
// один аккаунт продавца.
|
||
// <br><br>
|
||
// Один запрос с кодом ответа <code>409</code> учитывается как 5
|
||
// запросов
|
||
// </div>.
|
||
//
|
||
// POST /api/v3/warehouses
|
||
APIV3WarehousesPost(ctx context.Context, request *APIV3WarehousesPostReq) (APIV3WarehousesPostRes, error)
|
||
// APIV3WarehousesWarehouseIdDelete invokes DELETE /api/v3/warehouses/{warehouseId} operation.
|
||
//
|
||
// Метод удаляет склад продавца из [списка
|
||
// складов](/openapi/work-with-products#tag/Sklady-prodavca/paths/~1api~1v3~1warehouses/get).
|
||
// <div class="description_limit">
|
||
// Максимум 300 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Маркетплейс</a> на
|
||
// один аккаунт продавца.
|
||
// <br><br>
|
||
// Один запрос с кодом ответа <code>409</code> учитывается как 5
|
||
// запросов
|
||
// </div>.
|
||
//
|
||
// DELETE /api/v3/warehouses/{warehouseId}
|
||
APIV3WarehousesWarehouseIdDelete(ctx context.Context, params APIV3WarehousesWarehouseIdDeleteParams) (APIV3WarehousesWarehouseIdDeleteRes, error)
|
||
// APIV3WarehousesWarehouseIdPut invokes PUT /api/v3/warehouses/{warehouseId} operation.
|
||
//
|
||
// Метод обновляет данные склада продавца в [списке
|
||
// складов](/openapi/work-with-products#tag/Sklady-prodavca/paths/~1api~1v3~1warehouses/get).
|
||
// Данные о привязанном [складе
|
||
// WB](/openapi/work-with-products#tag/Sklady-prodavca/paths/~1api~1v3~1offices/get) можно
|
||
// изменить один раз в сутки.
|
||
// <div class="description_important">
|
||
// Нельзя привязывать склад WB, который уже используется
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 300 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Маркетплейс</a> на
|
||
// один аккаунт продавца.
|
||
// <br><br>
|
||
// Один запрос с кодом ответа <code>409</code> учитывается как 5
|
||
// запросов
|
||
// </div>.
|
||
//
|
||
// PUT /api/v3/warehouses/{warehouseId}
|
||
APIV3WarehousesWarehouseIdPut(ctx context.Context, request *APIV3WarehousesWarehouseIdPutReq, params APIV3WarehousesWarehouseIdPutParams) (APIV3WarehousesWarehouseIdPutRes, error)
|
||
// ContentV2BarcodesPost invokes POST /content/v2/barcodes operation.
|
||
//
|
||
// Метод генерирует массив уникальных баркодов для
|
||
// создания размера в [карточке
|
||
// товара](/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post). Можно использовать, если у вас нет собственных баркодов.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// POST /content/v2/barcodes
|
||
ContentV2BarcodesPost(ctx context.Context, request *ContentV2BarcodesPostReq) (ContentV2BarcodesPostRes, error)
|
||
// ContentV2CardsDeleteTrashPost invokes POST /content/v2/cards/delete/trash operation.
|
||
//
|
||
// Метод переносит [карточки товаров в
|
||
// корзину](/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1get~1cards~1trash/post). При этом карточки товаров не удаляются, их можно [восстановить](/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1recover/post).
|
||
// <div class="description_important">
|
||
// После переноса в корзину карточке товара
|
||
// присваивается новый <code>imtID</code>.
|
||
// </div>
|
||
// Карточки товаров удаляются автоматически, если лежат
|
||
// в корзине больше 30 дней. Очистка корзины происходит
|
||
// каждую ночь по московскому времени.<br>
|
||
// Карточки товаров можно удалить в любое время в
|
||
// [личном кабинете](https://seller.wildberries.ru/new-goods/basket-cards).
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// POST /content/v2/cards/delete/trash
|
||
ContentV2CardsDeleteTrashPost(ctx context.Context, request *ContentV2CardsDeleteTrashPostReq) (ContentV2CardsDeleteTrashPostRes, error)
|
||
// ContentV2CardsErrorListGet invokes GET /content/v2/cards/error/list operation.
|
||
//
|
||
// Метод предоставляет список карточек товаров, при
|
||
// создании или редактировании которых произошли
|
||
// ошибки, с описанием этих ошибок.
|
||
// <div class="description_important">
|
||
// Чтобы убрать карточку товара из списка, нужно
|
||
// повторно сделать запрос на <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создание</a> или редактирование карточки товара с исправленными ошибками.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/cards/error/list
|
||
ContentV2CardsErrorListGet(ctx context.Context, params ContentV2CardsErrorListGetParams) (ContentV2CardsErrorListGetRes, error)
|
||
// ContentV2CardsLimitsGet invokes GET /content/v2/cards/limits operation.
|
||
//
|
||
// Возвращает бесплатные и платные лимиты продавца на
|
||
// [создание карточек
|
||
// товаров](/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post).<br><br>
|
||
// Формула для получения количества карточек, которые
|
||
// можно создать:
|
||
// > (`freeLimits` + `paidLimits`) - количество созданных карточек
|
||
// Созданными считаются карточки, которые можно
|
||
// получить через методы [список карточек
|
||
// товаров](/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1get~1cards~1list/post) и [список карточек товаров в корзине](/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1get~1cards~1trash/post).
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/cards/limits
|
||
ContentV2CardsLimitsGet(ctx context.Context) (ContentV2CardsLimitsGetRes, error)
|
||
// ContentV2CardsRecoverPost invokes POST /content/v2/cards/recover operation.
|
||
//
|
||
// Метод восстанавливает [карточки товаров из
|
||
// корзины](/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1get~1cards~1trash/post).
|
||
// <div class="description_important">
|
||
// Карточка товара сохраняет тот же <code>imtID</code>, что был
|
||
// присвоен ей при <a
|
||
// href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1delete~1trash/post">перемещении в корзину</a>.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// POST /content/v2/cards/recover
|
||
ContentV2CardsRecoverPost(ctx context.Context, request *ContentV2CardsRecoverPostReq) (ContentV2CardsRecoverPostRes, error)
|
||
// ContentV2CardsUpdatePost invokes POST /content/v2/cards/update operation.
|
||
//
|
||
// Метод обновляет карточки товаров. Данные для
|
||
// обновления можно получить через [список карточек
|
||
// товаров](/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1get~1cards~1list/post) и [список карточек товаров в корзине](/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1get~1cards~1trash/post).
|
||
// <div class="description_important">
|
||
// Карточка товара перезаписывается при обновлении.
|
||
// Поэтому в запросе нужно передать <strong>все</strong>
|
||
// параметры карточки, в том числе те, которые вы не
|
||
// собираетесь обновлять.
|
||
// </div>
|
||
// Нельзя редактировать или удалять баркоды, но можно
|
||
// добавить дополнительный баркод к карточке товара.
|
||
// Параметры `photos`, `video` и `tags` редактировать или удалять
|
||
// через данный метод нельзя.<br>
|
||
// Габариты товаров можно указать только в `сантиметрах`,
|
||
// вес товара с упаковкой — в `килограммах`.
|
||
// <br><br>
|
||
// В одном запросе можно отредактировать максимум 3000
|
||
// карточек товаров (`nmID`). Максимальный размер запроса 10
|
||
// Мб.<br>
|
||
// Если ответ `Успешно` (`200`), но какие-то карточки не
|
||
// обновились, получите [список несозданных карточек
|
||
// товаров](/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1error~1list/get).
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня для метода будет отдельный
|
||
// лимит — 10 запросов в минуту на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// POST /content/v2/cards/update
|
||
ContentV2CardsUpdatePost(ctx context.Context, request []ContentV2CardsUpdatePostReqItem) (ContentV2CardsUpdatePostRes, error)
|
||
// ContentV2CardsUploadAddPost invokes POST /content/v2/cards/upload/add operation.
|
||
//
|
||
// Метод создаёт новые карточки товаров, присоединяя их
|
||
// к существующим карточкам.
|
||
// Габариты товаров можно указать только в `сантиметрах`,
|
||
// вес товара с упаковкой — в `килограммах`.
|
||
// <br><br>
|
||
// Создание карточки товара происходит асинхронно.
|
||
// После отправки запрос становится в очередь на
|
||
// обработку.<br>Максимальный размер запроса 10 Мб.<br>
|
||
// Если ответ `Успешно` (`200`), но какие-то карточки не
|
||
// обновились, получите [список несозданных карточек
|
||
// товаров](/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1error~1list/get).
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня для метода будет отдельный
|
||
// лимит — 10 запросов в минуту на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// POST /content/v2/cards/upload/add
|
||
ContentV2CardsUploadAddPost(ctx context.Context, request OptContentV2CardsUploadAddPostReq) (ContentV2CardsUploadAddPostRes, error)
|
||
// ContentV2CardsUploadPost invokes POST /content/v2/cards/upload operation.
|
||
//
|
||
// Метод создаёт карточки товаров c указанием описаний и
|
||
// характеристик товаров.<br>
|
||
// <div class="description_important">
|
||
// Есть две формы запроса: для создания отдельных и
|
||
// объединённых карточек товаров.
|
||
// </div>
|
||
// Габариты товаров можно указать только в `сантиметрах`,
|
||
// вес товара с упаковкой — в `килограммах`.
|
||
// <br><br>
|
||
// Создание карточки товара происходит асинхронно.
|
||
// После отправки запрос становится в очередь на
|
||
// обработку.<br>
|
||
// В одном запросе можно создать максимум 100
|
||
// объединённых карточек товаров (`imtID`), по 30 карточек
|
||
// товаров в каждой. Максимальный размер запроса 10 Мб.<br>
|
||
// Если ответ `Успешно` (`200`), но какие-то карточки не
|
||
// обновились, получите [список несозданных карточек
|
||
// товаров](/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1error~1list/get).
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня для метода будет отдельный
|
||
// лимит — 10 запросов в минуту на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// POST /content/v2/cards/upload
|
||
ContentV2CardsUploadPost(ctx context.Context, request []ContentV2CardsUploadPostReqItem) (ContentV2CardsUploadPostRes, error)
|
||
// ContentV2DirectoryColorsGet invokes GET /content/v2/directory/colors operation.
|
||
//
|
||
// Метод предоставляет возможные значения
|
||
// [характеристики](/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1object~1charcs~1%7BsubjectId%7D/get) предмета `Цвет`.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/directory/colors
|
||
ContentV2DirectoryColorsGet(ctx context.Context, params ContentV2DirectoryColorsGetParams) (ContentV2DirectoryColorsGetRes, error)
|
||
// ContentV2DirectoryCountriesGet invokes GET /content/v2/directory/countries operation.
|
||
//
|
||
// Метод предоставляет возможные значения
|
||
// [характеристики](/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1object~1charcs~1%7BsubjectId%7D/get) предмета `Страна производства`.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/directory/countries
|
||
ContentV2DirectoryCountriesGet(ctx context.Context, params ContentV2DirectoryCountriesGetParams) (ContentV2DirectoryCountriesGetRes, error)
|
||
// ContentV2DirectoryKindsGet invokes GET /content/v2/directory/kinds operation.
|
||
//
|
||
// Метод предоставляет возможные значения
|
||
// [характеристики](/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1object~1charcs~1%7BsubjectId%7D/get) предмета `Пол`.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/directory/kinds
|
||
ContentV2DirectoryKindsGet(ctx context.Context, params ContentV2DirectoryKindsGetParams) (ContentV2DirectoryKindsGetRes, error)
|
||
// ContentV2DirectorySeasonsGet invokes GET /content/v2/directory/seasons operation.
|
||
//
|
||
// Метод предоставляет возможные значения
|
||
// [характеристики](/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1object~1charcs~1%7BsubjectId%7D/get) предмета `Сезон`.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/directory/seasons
|
||
ContentV2DirectorySeasonsGet(ctx context.Context, params ContentV2DirectorySeasonsGetParams) (ContentV2DirectorySeasonsGetRes, error)
|
||
// ContentV2DirectoryTnvedGet invokes GET /content/v2/directory/tnved operation.
|
||
//
|
||
// Метод предоставляет список ТНВЭД-кодов по ID
|
||
// [предмета](/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1object~1all/get) и фрагменту ТНВЭД-кода.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/directory/tnved
|
||
ContentV2DirectoryTnvedGet(ctx context.Context, params ContentV2DirectoryTnvedGetParams) (ContentV2DirectoryTnvedGetRes, error)
|
||
// ContentV2DirectoryVatGet invokes GET /content/v2/directory/vat operation.
|
||
//
|
||
// Метод предоставляет возможные значения
|
||
// [характеристики](/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1object~1charcs~1%7BsubjectId%7D/get) предмета `Ставка НДС`.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/directory/vat
|
||
ContentV2DirectoryVatGet(ctx context.Context, params ContentV2DirectoryVatGetParams) (ContentV2DirectoryVatGetRes, error)
|
||
// ContentV2GetCardsListPost invokes POST /content/v2/get/cards/list operation.
|
||
//
|
||
// <div class="description_auth">
|
||
// Метод доступен по <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">токену</a> с
|
||
// категорией <strong>Контент</strong> или <strong>Продвижение</strong>
|
||
// </div>
|
||
// Метод предоставляет список созданных карточек
|
||
// товаров.
|
||
// <div class="description_important">
|
||
// В ответе метода не будет карточек, находящихся в
|
||
// корзине. Получить такие карточки можно через <a
|
||
// href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1get~1cards~1trash/post">отдельный метод</a>.
|
||
// </div>
|
||
// Чтобы получить **больше 100** карточек товаров,
|
||
// воспользуйтесь пагинацией:
|
||
// <ol>
|
||
// <li>Сделайте первый запрос: <br>
|
||
// <pre style="background-color: rgb(38 50 56 / 5%); color: #e53935">
|
||
// {
|
||
// "settings": {
|
||
// "cursor": {
|
||
// "limit": 100
|
||
// },
|
||
// "filter": {
|
||
// "withPhoto": -1
|
||
// }
|
||
// }
|
||
// }</pre>
|
||
// </li>
|
||
// <li>Пройдите в конец полученного списка карточек
|
||
// товаров.</li>
|
||
// <li>Скопируйте из <code>cursor</code> две строки:
|
||
// <ul>
|
||
// <li><code>"updatedAt": "***"</code></li>
|
||
// <li><code>"nmID": ***</code></li>
|
||
// </ul></li>
|
||
// <li>Вставьте скопированные строки в параметр запроса
|
||
// <code>cursor</code>.</li>
|
||
// <li>Повторите запрос. </li>
|
||
// <li>Повторяйте пункты со <b>2</b> по <b>5</b>, пока поле
|
||
// <code>total</code> в ответе не станет меньше чем параметр
|
||
// <code>limit</code> в запросе. Это будет означать, что вы
|
||
// получили все карточки.
|
||
// </ol>
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// POST /content/v2/get/cards/list
|
||
ContentV2GetCardsListPost(ctx context.Context, request *ContentV2GetCardsListPostReq, params ContentV2GetCardsListPostParams) (ContentV2GetCardsListPostRes, error)
|
||
// ContentV2GetCardsTrashPost invokes POST /content/v2/get/cards/trash operation.
|
||
//
|
||
// <div class="description_auth">
|
||
// Метод доступен по <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">токену</a> с
|
||
// категорией <strong>Контент</strong> или <strong>Продвижение</strong>
|
||
// </div>
|
||
// Метод предоставляет список карточек товаров в
|
||
// корзине.<br><br>
|
||
// Чтобы получить **больше 100** карточек товаров,
|
||
// воспользуйтесь пагинацией:
|
||
// <ol>
|
||
// <li>Сделайте первый запрос: <br>
|
||
// <pre style="background-color: rgb(38 50 56 / 5%); color: #e53935">
|
||
// {
|
||
// "settings": {
|
||
// "cursor": {
|
||
// "limit": 100
|
||
// },
|
||
// "filter": {
|
||
// "withPhoto": -1
|
||
// }
|
||
// }
|
||
// }</pre>
|
||
// </li>
|
||
// <li>Пройдите в конец полученного списка карточек
|
||
// товаров.</li>
|
||
// <li>Скопируйте из <code>cursor</code> две строки:
|
||
// <ul>
|
||
// <li><code>"trashedAt": "***"</code></li>
|
||
// <li><code>"nmID": ***</code></li>
|
||
// </ul></li>
|
||
// <li>Вставьте скопированные строки в параметр запроса
|
||
// <code>cursor</code>.</li>
|
||
// <li>Повторите запрос. </li>
|
||
// <li>Повторяйте пункты со <b>2</b> по <b>5</b>, пока поле
|
||
// <code>total</code> в ответе не станет меньше чем параметр
|
||
// <code>limit</code> в запросе. Это будет означать, что вы
|
||
// получили все карточки.
|
||
// </ol>
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// POST /content/v2/get/cards/trash
|
||
ContentV2GetCardsTrashPost(ctx context.Context, request *ContentV2GetCardsTrashPostReq, params ContentV2GetCardsTrashPostParams) (ContentV2GetCardsTrashPostRes, error)
|
||
// ContentV2ObjectAllGet invokes GET /content/v2/object/all operation.
|
||
//
|
||
// Метод предоставляет список названий [родительских
|
||
// категорий
|
||
// предметов](/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1object~1parent~1all/get) и их предметов с ID. Например, у категории `Игрушки` будут предметы `Калейдоскопы`, `Куклы`, `Мячики`.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/object/all
|
||
ContentV2ObjectAllGet(ctx context.Context, params ContentV2ObjectAllGetParams) (ContentV2ObjectAllGetRes, error)
|
||
// ContentV2ObjectCharcsSubjectIdGet invokes GET /content/v2/object/charcs/{subjectId} operation.
|
||
//
|
||
// Метод предоставляет параметры характеристик
|
||
// предмета: названия, типы данных, единицы измерения и
|
||
// так далее. В запросе необходимо указать ID
|
||
// [предмета](/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1object~1all/get).
|
||
// <div class="description_important">
|
||
// Для получения характеристик <a
|
||
// href="/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1directory~1colors/get">Цвет</a>, <a href="/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1directory~1kinds/get">Пол</a>, <a href="/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1directory~1countries/get">Страна производства</a>, <a href="/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1directory~1seasons/get">Сезон</a>, <a href="/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1directory~1vat/get">Ставка НДС</a> и <a href="/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1directory~1tnved/get">ТНВЭД-код</a> используйте отдельные методы
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/object/charcs/{subjectId}
|
||
ContentV2ObjectCharcsSubjectIdGet(ctx context.Context, params ContentV2ObjectCharcsSubjectIdGetParams) (ContentV2ObjectCharcsSubjectIdGetRes, error)
|
||
// ContentV2ObjectParentAllGet invokes GET /content/v2/object/parent/all operation.
|
||
//
|
||
// Метод предоставляет названия и ID всех родительских
|
||
// категорий для [создания карточек
|
||
// товаров](/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov): например,
|
||
// `Электроника`, `Бытовая химия`, `Рукоделие`.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/object/parent/all
|
||
ContentV2ObjectParentAllGet(ctx context.Context, params ContentV2ObjectParentAllGetParams) (ContentV2ObjectParentAllGetRes, error)
|
||
// ContentV2TagNomenclatureLinkPost invokes POST /content/v2/tag/nomenclature/link operation.
|
||
//
|
||
// Метод добавляет или снимает ярлык с карточки товара.
|
||
// К карточке можно добавить максимум 15 ярлыков.<br>
|
||
// При удалении ярлыка из карточки товара он не
|
||
// удаляется из [списка
|
||
// ярлыков](/openapi/work-with-products#tag/Yarlyki/paths/~1content~1v2~1tags/get)
|
||
// продавца.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// POST /content/v2/tag/nomenclature/link
|
||
ContentV2TagNomenclatureLinkPost(ctx context.Context, request *ContentV2TagNomenclatureLinkPostReq) (ContentV2TagNomenclatureLinkPostRes, error)
|
||
// ContentV2TagsGet invokes GET /content/v2/tags operation.
|
||
//
|
||
// Метод предоставляет список и характеристики всех
|
||
// ярлыков продавца для группировки и фильтрации
|
||
// товаров.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/tags
|
||
ContentV2TagsGet(ctx context.Context) (ContentV2TagsGetRes, error)
|
||
// ContentV3MediaFilePost invokes POST /content/v3/media/file operation.
|
||
//
|
||
// Метод загружает и добавляет один медиафайл к
|
||
// карточке товара.
|
||
// Требования к изображениям:
|
||
// * максимум изображений для одной карточки товара — 30
|
||
// * минимальное разрешение — 700x900 px
|
||
// * максимальный размер — 32 Мб
|
||
// * минимальное качество — 65%
|
||
// * форматы — JPG, PNG, BMP, GIF (статичные), WebP
|
||
// Требования к видео:
|
||
// * максимум одно видео для одной карточки товара
|
||
// * максимальный размер — 50 Мб
|
||
// * форматы — MOV, MP4
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// POST /content/v3/media/file
|
||
ContentV3MediaFilePost(ctx context.Context, request *ContentV3MediaFilePostReq, params ContentV3MediaFilePostParams) (ContentV3MediaFilePostRes, error)
|
||
// ContentV3MediaSavePost invokes POST /content/v3/media/save operation.
|
||
//
|
||
// Метод загружает набор медиафайлов в карточку товара
|
||
// через указание ссылок в запросе.
|
||
// <div class="description_important">
|
||
// Новые медиафайлы полностью заменяют старые. Чтобы
|
||
// добавить новые медиафайлы, укажите в запросе ссылки
|
||
// одновременно на новые и старые медиафайлы.
|
||
// </div>
|
||
// Требования к изображениям:
|
||
// * максимум изображений для одной карточки товара — 30
|
||
// * минимальное разрешение — 700×900 px
|
||
// * максимальный размер — 32 Мб
|
||
// * минимальное качество — 65%
|
||
// * форматы — JPG, PNG, BMP, GIF (статичные), WebP
|
||
// Требования к видео:
|
||
// * максимум одно видео для одной карточки товара
|
||
// * максимальный размер — 50 Мб
|
||
// * форматы — MOV, MP4
|
||
// Если видео или хотя бы одно изображение в запросе не
|
||
// соответствует требованиям, то даже при успешном
|
||
// ответе ни одно изображение/видео не загрузится.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// POST /content/v3/media/save
|
||
ContentV3MediaSavePost(ctx context.Context, request *ContentV3MediaSavePostReq) (ContentV3MediaSavePostRes, error)
|
||
}
|
||
|
||
// Client implements OAS client.
|
||
type Client struct {
|
||
serverURL *url.URL
|
||
sec SecuritySource
|
||
baseClient
|
||
}
|
||
|
||
var _ Handler = struct {
|
||
*Client
|
||
}{}
|
||
|
||
// NewClient initializes new Client defined by OAS.
|
||
func NewClient(serverURL string, sec SecuritySource, opts ...ClientOption) (*Client, error) {
|
||
u, err := url.Parse(serverURL)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
trimTrailingSlashes(u)
|
||
|
||
c, err := newClientConfig(opts...).baseClient()
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
return &Client{
|
||
serverURL: u,
|
||
sec: sec,
|
||
baseClient: c,
|
||
}, nil
|
||
}
|
||
|
||
type serverURLKey struct{}
|
||
|
||
// WithServerURL sets context key to override server URL.
|
||
func WithServerURL(ctx context.Context, u *url.URL) context.Context {
|
||
return context.WithValue(ctx, serverURLKey{}, u)
|
||
}
|
||
|
||
func (c *Client) requestURL(ctx context.Context) *url.URL {
|
||
u, ok := ctx.Value(serverURLKey{}).(*url.URL)
|
||
if !ok {
|
||
return c.serverURL
|
||
}
|
||
return u
|
||
}
|
||
|
||
// APIV2BufferGoodsTaskGet invokes GET /api/v2/buffer/goods/task operation.
|
||
//
|
||
// Метод предоставляет информацию о товарах и ошибках в
|
||
// товарах из загрузки в обработке.
|
||
// <div class="description_important">
|
||
// Необработанная загрузка — это загрузка скидок для <a
|
||
// href="/openapi/promotion#tag/Kalendar-akcij">календаря акций</a>. Такие
|
||
// скидки применятся к товарам только в момент начала
|
||
// акции.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 10 запросов за 6 <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">секунд</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Цены и скидки</a>
|
||
// на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// GET /api/v2/buffer/goods/task
|
||
func (c *Client) APIV2BufferGoodsTaskGet(ctx context.Context, params APIV2BufferGoodsTaskGetParams) (APIV2BufferGoodsTaskGetRes, error) {
|
||
res, err := c.sendAPIV2BufferGoodsTaskGet(ctx, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendAPIV2BufferGoodsTaskGet(ctx context.Context, params APIV2BufferGoodsTaskGetParams) (res APIV2BufferGoodsTaskGetRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("GET"),
|
||
semconv.HTTPRouteKey.String("/api/v2/buffer/goods/task"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, APIV2BufferGoodsTaskGetOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/api/v2/buffer/goods/task"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeQueryParams"
|
||
q := uri.NewQueryEncoder()
|
||
{
|
||
// Encode "limit" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "limit",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
return e.EncodeValue(conv.UintToString(params.Limit))
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
{
|
||
// Encode "offset" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "offset",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.Offset.Get(); ok {
|
||
return e.EncodeValue(conv.UintToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
{
|
||
// Encode "uploadID" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "uploadID",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
return e.EncodeValue(conv.IntToString(params.UploadID))
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
u.RawQuery = q.Values().Encode()
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "GET", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, APIV2BufferGoodsTaskGetOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeAPIV2BufferGoodsTaskGetResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// APIV2BufferTasksGet invokes GET /api/v2/buffer/tasks operation.
|
||
//
|
||
// Метод предоставляет информацию про загрузку скидок в
|
||
// обработке.
|
||
// <div class="description_important">
|
||
// Необработанная загрузка — это загрузка скидок для <a
|
||
// href="/openapi/promotion#tag/Kalendar-akcij">календаря акций</a>. Такие
|
||
// скидки применятся к товарам только в момент начала
|
||
// акции.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 10 запросов за 6 <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">секунд</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Цены и скидки</a>
|
||
// на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// GET /api/v2/buffer/tasks
|
||
func (c *Client) APIV2BufferTasksGet(ctx context.Context, params APIV2BufferTasksGetParams) (APIV2BufferTasksGetRes, error) {
|
||
res, err := c.sendAPIV2BufferTasksGet(ctx, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendAPIV2BufferTasksGet(ctx context.Context, params APIV2BufferTasksGetParams) (res APIV2BufferTasksGetRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("GET"),
|
||
semconv.HTTPRouteKey.String("/api/v2/buffer/tasks"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, APIV2BufferTasksGetOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/api/v2/buffer/tasks"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeQueryParams"
|
||
q := uri.NewQueryEncoder()
|
||
{
|
||
// Encode "uploadID" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "uploadID",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
return e.EncodeValue(conv.IntToString(params.UploadID))
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
u.RawQuery = q.Values().Encode()
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "GET", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, APIV2BufferTasksGetOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeAPIV2BufferTasksGetResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// APIV2HistoryGoodsTaskGet invokes GET /api/v2/history/goods/task operation.
|
||
//
|
||
// Метод предоставляет информацию о товарах и об
|
||
// ошибках в товарах в обработанной загрузке.
|
||
// <div class="description_important">
|
||
// Обработанная загрузка — это загрузка цен и скидок
|
||
// для <a
|
||
// href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task/post">товаров</a> и <a href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task~1size/post">размеров товаров</a>, а также скидок <a href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task~1club-discount/post">WB Клуба</a>.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 10 запросов за 6 <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">секунд</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Цены и скидки</a>
|
||
// на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// GET /api/v2/history/goods/task
|
||
func (c *Client) APIV2HistoryGoodsTaskGet(ctx context.Context, params APIV2HistoryGoodsTaskGetParams) (APIV2HistoryGoodsTaskGetRes, error) {
|
||
res, err := c.sendAPIV2HistoryGoodsTaskGet(ctx, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendAPIV2HistoryGoodsTaskGet(ctx context.Context, params APIV2HistoryGoodsTaskGetParams) (res APIV2HistoryGoodsTaskGetRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("GET"),
|
||
semconv.HTTPRouteKey.String("/api/v2/history/goods/task"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, APIV2HistoryGoodsTaskGetOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/api/v2/history/goods/task"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeQueryParams"
|
||
q := uri.NewQueryEncoder()
|
||
{
|
||
// Encode "limit" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "limit",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
return e.EncodeValue(conv.UintToString(params.Limit))
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
{
|
||
// Encode "offset" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "offset",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.Offset.Get(); ok {
|
||
return e.EncodeValue(conv.UintToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
{
|
||
// Encode "uploadID" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "uploadID",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
return e.EncodeValue(conv.IntToString(params.UploadID))
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
u.RawQuery = q.Values().Encode()
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "GET", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, APIV2HistoryGoodsTaskGetOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeAPIV2HistoryGoodsTaskGetResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// APIV2HistoryTasksGet invokes GET /api/v2/history/tasks operation.
|
||
//
|
||
// Метод предоставляет информацию об обработанной
|
||
// загрузке цен и скидок.
|
||
// <div class="description_important">
|
||
// Обработанная загрузка — это загрузка цен и скидок
|
||
// для <a
|
||
// href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task/post">товаров</a> и <a href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task~1size/post">размеров товаров</a>, а также скидок <a href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task~1club-discount/post">WB Клуба</a>.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 10 запросов за 6 <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">секунд</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Цены и скидки</a>
|
||
// на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// GET /api/v2/history/tasks
|
||
func (c *Client) APIV2HistoryTasksGet(ctx context.Context, params APIV2HistoryTasksGetParams) (APIV2HistoryTasksGetRes, error) {
|
||
res, err := c.sendAPIV2HistoryTasksGet(ctx, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendAPIV2HistoryTasksGet(ctx context.Context, params APIV2HistoryTasksGetParams) (res APIV2HistoryTasksGetRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("GET"),
|
||
semconv.HTTPRouteKey.String("/api/v2/history/tasks"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, APIV2HistoryTasksGetOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/api/v2/history/tasks"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeQueryParams"
|
||
q := uri.NewQueryEncoder()
|
||
{
|
||
// Encode "uploadID" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "uploadID",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
return e.EncodeValue(conv.IntToString(params.UploadID))
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
u.RawQuery = q.Values().Encode()
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "GET", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, APIV2HistoryTasksGetOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeAPIV2HistoryTasksGetResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// APIV2ListGoodsFilterGet invokes GET /api/v2/list/goods/filter operation.
|
||
//
|
||
// Метод предоставляет информацию о товарах по их
|
||
// артикулам: цены, валюту, общие скидки и скидки для [WB
|
||
// Клуба](/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task~1club-discount/post).
|
||
// <br><br>
|
||
// Чтобы получить информацию обо всех товарах продавца,
|
||
// оставьте артикул пустым, установите `limit=1000`, в
|
||
// параметре `offset` установите смещение по количеству
|
||
// записей. Количество нужно рассчитать по формуле: `offset`
|
||
// плюс `limit` из предыдущего запроса. Повторяйте запрос,
|
||
// пока вы не получите ответ с пустым массивом.<br> Чтобы
|
||
// получить информацию о размерах товара, используйте
|
||
// [отдельный
|
||
// метод](/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1list~1goods~1size~1nm/get).
|
||
// <div class="description_limit">
|
||
// Максимум 10 запросов за 6 <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">секунд</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Цены и скидки</a>
|
||
// на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// GET /api/v2/list/goods/filter
|
||
func (c *Client) APIV2ListGoodsFilterGet(ctx context.Context, params APIV2ListGoodsFilterGetParams) (APIV2ListGoodsFilterGetRes, error) {
|
||
res, err := c.sendAPIV2ListGoodsFilterGet(ctx, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendAPIV2ListGoodsFilterGet(ctx context.Context, params APIV2ListGoodsFilterGetParams) (res APIV2ListGoodsFilterGetRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("GET"),
|
||
semconv.HTTPRouteKey.String("/api/v2/list/goods/filter"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, APIV2ListGoodsFilterGetOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/api/v2/list/goods/filter"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeQueryParams"
|
||
q := uri.NewQueryEncoder()
|
||
{
|
||
// Encode "limit" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "limit",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
return e.EncodeValue(conv.UintToString(params.Limit))
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
{
|
||
// Encode "offset" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "offset",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.Offset.Get(); ok {
|
||
return e.EncodeValue(conv.UintToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
{
|
||
// Encode "filterNmID" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "filterNmID",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.FilterNmID.Get(); ok {
|
||
return e.EncodeValue(conv.IntToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
u.RawQuery = q.Values().Encode()
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "GET", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, APIV2ListGoodsFilterGetOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeAPIV2ListGoodsFilterGetResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// APIV2ListGoodsSizeNmGet invokes GET /api/v2/list/goods/size/nm operation.
|
||
//
|
||
// Метод предоставляет информацию обо всех размерах
|
||
// одного товарам: цены, валюту, общие скидки и скидки
|
||
// для [WB
|
||
// Клуба](/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task~1club-discount/post).
|
||
// <br><br>
|
||
// Работает только для товаров из категорий, где можно
|
||
// устанавливать цены отдельно для разных размеров. Для
|
||
// таких товаров `editableSizePrice: true`.
|
||
// <br><br>
|
||
// Чтобы получить информацию о самом товаре,
|
||
// используйте [отдельный
|
||
// метод](/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1list~1goods~1filter/get).
|
||
// <div class="description_limit">
|
||
// Максимум 10 запросов за 6 <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">секунд</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Цены и скидки</a>
|
||
// на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// GET /api/v2/list/goods/size/nm
|
||
func (c *Client) APIV2ListGoodsSizeNmGet(ctx context.Context, params APIV2ListGoodsSizeNmGetParams) (APIV2ListGoodsSizeNmGetRes, error) {
|
||
res, err := c.sendAPIV2ListGoodsSizeNmGet(ctx, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendAPIV2ListGoodsSizeNmGet(ctx context.Context, params APIV2ListGoodsSizeNmGetParams) (res APIV2ListGoodsSizeNmGetRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("GET"),
|
||
semconv.HTTPRouteKey.String("/api/v2/list/goods/size/nm"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, APIV2ListGoodsSizeNmGetOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/api/v2/list/goods/size/nm"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeQueryParams"
|
||
q := uri.NewQueryEncoder()
|
||
{
|
||
// Encode "limit" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "limit",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
return e.EncodeValue(conv.UintToString(params.Limit))
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
{
|
||
// Encode "offset" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "offset",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.Offset.Get(); ok {
|
||
return e.EncodeValue(conv.UintToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
{
|
||
// Encode "nmID" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "nmID",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
return e.EncodeValue(conv.IntToString(params.NmID))
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
u.RawQuery = q.Values().Encode()
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "GET", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, APIV2ListGoodsSizeNmGetOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeAPIV2ListGoodsSizeNmGetResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// APIV2QuarantineGoodsGet invokes GET /api/v2/quarantine/goods operation.
|
||
//
|
||
// Метод предоставляет информацию о товарах в карантине.
|
||
// <br><br>
|
||
// Если новая цена товара со скидкой будет минимум в 3
|
||
// раза меньше старой, товар попадёт [в
|
||
// карантин](https://seller.wildberries.ru/discount-and-prices/quarantine) и будет
|
||
// продаваться по старой цене. Ошибка об этом будет в
|
||
// ответах методов [состояний
|
||
// загрузок](/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1history~1tasks/get).
|
||
// <br><br>
|
||
// Вы можете изменить цену или скидку с помощью API либо
|
||
// вывести товар из карантина [в личном
|
||
// кабинете](https://seller.wildberries.ru/discount-and-prices/quarantine).
|
||
// <br><br>
|
||
// Для товаров с [поразмерной установкой
|
||
// цен](/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task~1size/post)
|
||
// карантин не применяется.
|
||
// <div class="description_limit">
|
||
// Максимум 10 запросов за 6 <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">секунд</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Цены и скидки</a>
|
||
// на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// GET /api/v2/quarantine/goods
|
||
func (c *Client) APIV2QuarantineGoodsGet(ctx context.Context, params APIV2QuarantineGoodsGetParams) (APIV2QuarantineGoodsGetRes, error) {
|
||
res, err := c.sendAPIV2QuarantineGoodsGet(ctx, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendAPIV2QuarantineGoodsGet(ctx context.Context, params APIV2QuarantineGoodsGetParams) (res APIV2QuarantineGoodsGetRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("GET"),
|
||
semconv.HTTPRouteKey.String("/api/v2/quarantine/goods"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, APIV2QuarantineGoodsGetOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/api/v2/quarantine/goods"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeQueryParams"
|
||
q := uri.NewQueryEncoder()
|
||
{
|
||
// Encode "limit" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "limit",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
return e.EncodeValue(conv.UintToString(params.Limit))
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
{
|
||
// Encode "offset" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "offset",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.Offset.Get(); ok {
|
||
return e.EncodeValue(conv.UintToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
u.RawQuery = q.Values().Encode()
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "GET", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, APIV2QuarantineGoodsGetOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeAPIV2QuarantineGoodsGetResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// APIV2UploadTaskClubDiscountPost invokes POST /api/v2/upload/task/club-discount operation.
|
||
//
|
||
// Устанавливает скидки для товаров в рамках подписки [WB
|
||
// Клуб](https://seller.wildberries.ru/help-center/article/A-337).
|
||
// <div class="description_important">
|
||
// Получить информацию о процессе установки цен и
|
||
// скидок можно с помощью методов <a
|
||
// href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1history~1tasks/get">состояния</a> и <a href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1history~1goods~1task/get">детализации</a> обработанной загрузки.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 10 запросов за 6 <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">секунд</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Цены и скидки</a>
|
||
// на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// POST /api/v2/upload/task/club-discount
|
||
func (c *Client) APIV2UploadTaskClubDiscountPost(ctx context.Context, request *APIV2UploadTaskClubDiscountPostReq) (APIV2UploadTaskClubDiscountPostRes, error) {
|
||
res, err := c.sendAPIV2UploadTaskClubDiscountPost(ctx, request)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendAPIV2UploadTaskClubDiscountPost(ctx context.Context, request *APIV2UploadTaskClubDiscountPostReq) (res APIV2UploadTaskClubDiscountPostRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("POST"),
|
||
semconv.HTTPRouteKey.String("/api/v2/upload/task/club-discount"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, APIV2UploadTaskClubDiscountPostOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/api/v2/upload/task/club-discount"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "POST", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
if err := encodeAPIV2UploadTaskClubDiscountPostRequest(request, r); err != nil {
|
||
return res, errors.Wrap(err, "encode request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, APIV2UploadTaskClubDiscountPostOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeAPIV2UploadTaskClubDiscountPostResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// APIV2UploadTaskPost invokes POST /api/v2/upload/task operation.
|
||
//
|
||
// Метод устанавливает цены и скидки для товаров.
|
||
// <br><br>
|
||
// Чтобы установить цены и скидки для размеров товара,
|
||
// используйте [отдельный
|
||
// метод](/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task~1size/post).
|
||
// <div class="description_important">
|
||
// Получить информацию о процессе установки цен и
|
||
// скидок можно с помощью методов <a
|
||
// href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1history~1tasks/get">состояния</a> и <a href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1history~1goods~1task/get">детализации</a> обработанной загрузки.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 10 запросов за 6 <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">секунд</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Цены и скидки</a>
|
||
// на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// POST /api/v2/upload/task
|
||
func (c *Client) APIV2UploadTaskPost(ctx context.Context, request *APIV2UploadTaskPostReq) (APIV2UploadTaskPostRes, error) {
|
||
res, err := c.sendAPIV2UploadTaskPost(ctx, request)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendAPIV2UploadTaskPost(ctx context.Context, request *APIV2UploadTaskPostReq) (res APIV2UploadTaskPostRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("POST"),
|
||
semconv.HTTPRouteKey.String("/api/v2/upload/task"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, APIV2UploadTaskPostOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/api/v2/upload/task"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "POST", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
if err := encodeAPIV2UploadTaskPostRequest(request, r); err != nil {
|
||
return res, errors.Wrap(err, "encode request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, APIV2UploadTaskPostOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeAPIV2UploadTaskPostResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// APIV2UploadTaskSizePost invokes POST /api/v2/upload/task/size operation.
|
||
//
|
||
// Метод устанавливает цены отдельно для размеров
|
||
// товаров.
|
||
// Работает только для товаров из категорий, где можно
|
||
// устанавливать цены отдельно для разных размеров. Для
|
||
// [таких
|
||
// товаров](/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1list~1goods~1size~1nm/get) `editableSizePrice: true`.
|
||
// Чтобы установить цены и скидки для самих товаров,
|
||
// используйте [отдельный
|
||
// метод](/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1upload~1task/post).
|
||
// <div class="description_important">
|
||
// Получить информацию о процессе установки цен и
|
||
// скидок можно с помощью методов <a
|
||
// href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1history~1tasks/get">состояния</a> и <a href="/openapi/work-with-products#tag/Ceny-i-skidki/paths/~1api~1v2~1history~1goods~1task/get">детализации</a> обработанной загрузки.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 10 запросов за 6 <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">секунд</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Цены и скидки</a>
|
||
// на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// POST /api/v2/upload/task/size
|
||
func (c *Client) APIV2UploadTaskSizePost(ctx context.Context, request *APIV2UploadTaskSizePostReq) (APIV2UploadTaskSizePostRes, error) {
|
||
res, err := c.sendAPIV2UploadTaskSizePost(ctx, request)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendAPIV2UploadTaskSizePost(ctx context.Context, request *APIV2UploadTaskSizePostReq) (res APIV2UploadTaskSizePostRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("POST"),
|
||
semconv.HTTPRouteKey.String("/api/v2/upload/task/size"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, APIV2UploadTaskSizePostOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/api/v2/upload/task/size"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "POST", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
if err := encodeAPIV2UploadTaskSizePostRequest(request, r); err != nil {
|
||
return res, errors.Wrap(err, "encode request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, APIV2UploadTaskSizePostOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeAPIV2UploadTaskSizePostResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// APIV3OfficesGet invokes GET /api/v3/offices operation.
|
||
//
|
||
// Метод предоставляет список всех складов WB для
|
||
// привязки к складам продавца. Предназначен для
|
||
// определения складов WB, чтобы сдавать готовые заказы
|
||
// по схеме [FBS](/openapi/orders-fbs#tag/Zakazy-FBS) (Fulfillment by Seller).
|
||
// <div class="description_limit">
|
||
// Максимум 300 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Маркетплейс</a> на
|
||
// один аккаунт продавца.
|
||
// <br><br>
|
||
// Один запрос с кодом ответа <code>409</code> учитывается как 5
|
||
// запросов
|
||
// </div>.
|
||
//
|
||
// GET /api/v3/offices
|
||
func (c *Client) APIV3OfficesGet(ctx context.Context) (APIV3OfficesGetRes, error) {
|
||
res, err := c.sendAPIV3OfficesGet(ctx)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendAPIV3OfficesGet(ctx context.Context) (res APIV3OfficesGetRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("GET"),
|
||
semconv.HTTPRouteKey.String("/api/v3/offices"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, APIV3OfficesGetOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/api/v3/offices"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "GET", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, APIV3OfficesGetOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeAPIV3OfficesGetResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// APIV3StocksWarehouseIdDelete invokes DELETE /api/v3/stocks/{warehouseId} operation.
|
||
//
|
||
// Метод удаляет запись об остатках товаров продавца из
|
||
// [списка
|
||
// остатков](/openapi/work-with-products#tag/Ostatki-na-skladah-prodavca/paths/~1api~1v3~1stocks~1%7BwarehouseId%7D/post).
|
||
// <div class="description_important">
|
||
// <strong>Действие необратимо</strong>. Удаленный остаток
|
||
// будет необходимо загрузить повторно для
|
||
// возобновления продаж.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 300 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Маркетплейс</a> на
|
||
// один аккаунт продавца.
|
||
// <br><br>
|
||
// Один запрос с кодом ответа <code>409</code> учитывается как 5
|
||
// запросов
|
||
// </div>.
|
||
//
|
||
// DELETE /api/v3/stocks/{warehouseId}
|
||
func (c *Client) APIV3StocksWarehouseIdDelete(ctx context.Context, request *APIV3StocksWarehouseIdDeleteReq, params APIV3StocksWarehouseIdDeleteParams) (APIV3StocksWarehouseIdDeleteRes, error) {
|
||
res, err := c.sendAPIV3StocksWarehouseIdDelete(ctx, request, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendAPIV3StocksWarehouseIdDelete(ctx context.Context, request *APIV3StocksWarehouseIdDeleteReq, params APIV3StocksWarehouseIdDeleteParams) (res APIV3StocksWarehouseIdDeleteRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("DELETE"),
|
||
semconv.HTTPRouteKey.String("/api/v3/stocks/{warehouseId}"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, APIV3StocksWarehouseIdDeleteOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [2]string
|
||
pathParts[0] = "/api/v3/stocks/"
|
||
{
|
||
// Encode "warehouseId" parameter.
|
||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
||
Param: "warehouseId",
|
||
Style: uri.PathStyleSimple,
|
||
Explode: false,
|
||
})
|
||
if err := func() error {
|
||
return e.EncodeValue(conv.Int64ToString(params.WarehouseId))
|
||
}(); err != nil {
|
||
return res, errors.Wrap(err, "encode path")
|
||
}
|
||
encoded, err := e.Result()
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "encode path")
|
||
}
|
||
pathParts[1] = encoded
|
||
}
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "DELETE", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
if err := encodeAPIV3StocksWarehouseIdDeleteRequest(request, r); err != nil {
|
||
return res, errors.Wrap(err, "encode request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, APIV3StocksWarehouseIdDeleteOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeAPIV3StocksWarehouseIdDeleteResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// APIV3StocksWarehouseIdPost invokes POST /api/v3/stocks/{warehouseId} operation.
|
||
//
|
||
// Метод предоставляет данные об остатках товаров на
|
||
// [складах продавца](/openapi/work-with-products#tag/Sklady-prodavca).
|
||
// <div class="description_limit">
|
||
// Максимум 300 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Маркетплейс</a> на
|
||
// один аккаунт продавца.
|
||
// <br><br>
|
||
// Один запрос с кодом ответа <code>409</code> учитывается как 5
|
||
// запросов
|
||
// </div>.
|
||
//
|
||
// POST /api/v3/stocks/{warehouseId}
|
||
func (c *Client) APIV3StocksWarehouseIdPost(ctx context.Context, request *APIV3StocksWarehouseIdPostReq, params APIV3StocksWarehouseIdPostParams) (APIV3StocksWarehouseIdPostRes, error) {
|
||
res, err := c.sendAPIV3StocksWarehouseIdPost(ctx, request, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendAPIV3StocksWarehouseIdPost(ctx context.Context, request *APIV3StocksWarehouseIdPostReq, params APIV3StocksWarehouseIdPostParams) (res APIV3StocksWarehouseIdPostRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("POST"),
|
||
semconv.HTTPRouteKey.String("/api/v3/stocks/{warehouseId}"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, APIV3StocksWarehouseIdPostOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [2]string
|
||
pathParts[0] = "/api/v3/stocks/"
|
||
{
|
||
// Encode "warehouseId" parameter.
|
||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
||
Param: "warehouseId",
|
||
Style: uri.PathStyleSimple,
|
||
Explode: false,
|
||
})
|
||
if err := func() error {
|
||
return e.EncodeValue(conv.Int64ToString(params.WarehouseId))
|
||
}(); err != nil {
|
||
return res, errors.Wrap(err, "encode path")
|
||
}
|
||
encoded, err := e.Result()
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "encode path")
|
||
}
|
||
pathParts[1] = encoded
|
||
}
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "POST", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
if err := encodeAPIV3StocksWarehouseIdPostRequest(request, r); err != nil {
|
||
return res, errors.Wrap(err, "encode request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, APIV3StocksWarehouseIdPostOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeAPIV3StocksWarehouseIdPostResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// APIV3StocksWarehouseIdPut invokes PUT /api/v3/stocks/{warehouseId} operation.
|
||
//
|
||
// Метод обновляет количество остатков товаров
|
||
// продавца [в
|
||
// списке](/openapi/work-with-products#tag/Ostatki-na-skladah-prodavca/paths/~1api~1v3~1stocks~1%7BwarehouseId%7D/post).
|
||
// <div class="description_important">
|
||
// Названия параметров запроса не валидируются. При
|
||
// отправке некорректных названий вы получите успешный
|
||
// ответ (<code>204</code>), но остатки не обновятся.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 300 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Маркетплейс</a> на
|
||
// один аккаунт продавца.
|
||
// <br><br>
|
||
// Один запрос с кодом ответа <code>409</code> учитывается как 5
|
||
// запросов
|
||
// </div>.
|
||
//
|
||
// PUT /api/v3/stocks/{warehouseId}
|
||
func (c *Client) APIV3StocksWarehouseIdPut(ctx context.Context, request OptAPIV3StocksWarehouseIdPutReq, params APIV3StocksWarehouseIdPutParams) (APIV3StocksWarehouseIdPutRes, error) {
|
||
res, err := c.sendAPIV3StocksWarehouseIdPut(ctx, request, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendAPIV3StocksWarehouseIdPut(ctx context.Context, request OptAPIV3StocksWarehouseIdPutReq, params APIV3StocksWarehouseIdPutParams) (res APIV3StocksWarehouseIdPutRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("PUT"),
|
||
semconv.HTTPRouteKey.String("/api/v3/stocks/{warehouseId}"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, APIV3StocksWarehouseIdPutOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [2]string
|
||
pathParts[0] = "/api/v3/stocks/"
|
||
{
|
||
// Encode "warehouseId" parameter.
|
||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
||
Param: "warehouseId",
|
||
Style: uri.PathStyleSimple,
|
||
Explode: false,
|
||
})
|
||
if err := func() error {
|
||
return e.EncodeValue(conv.Int64ToString(params.WarehouseId))
|
||
}(); err != nil {
|
||
return res, errors.Wrap(err, "encode path")
|
||
}
|
||
encoded, err := e.Result()
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "encode path")
|
||
}
|
||
pathParts[1] = encoded
|
||
}
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "PUT", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
if err := encodeAPIV3StocksWarehouseIdPutRequest(request, r); err != nil {
|
||
return res, errors.Wrap(err, "encode request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, APIV3StocksWarehouseIdPutOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeAPIV3StocksWarehouseIdPutResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// APIV3WarehousesGet invokes GET /api/v3/warehouses operation.
|
||
//
|
||
// Метод предоставляет список всех складов продавца.
|
||
// Может использоваться для получения [остатков
|
||
// товаров](/openapi/work-with-products#tag/Ostatki-na-skladah-prodavca/paths/~1api~1v3~1stocks~1%7BwarehouseId%7D/post).
|
||
// <div class="description_limit">
|
||
// Максимум 300 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Маркетплейс</a> на
|
||
// один аккаунт продавца.
|
||
// <br><br>
|
||
// Один запрос с кодом ответа <code>409</code> учитывается как 5
|
||
// запросов
|
||
// </div>.
|
||
//
|
||
// GET /api/v3/warehouses
|
||
func (c *Client) APIV3WarehousesGet(ctx context.Context) (APIV3WarehousesGetRes, error) {
|
||
res, err := c.sendAPIV3WarehousesGet(ctx)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendAPIV3WarehousesGet(ctx context.Context) (res APIV3WarehousesGetRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("GET"),
|
||
semconv.HTTPRouteKey.String("/api/v3/warehouses"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, APIV3WarehousesGetOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/api/v3/warehouses"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "GET", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, APIV3WarehousesGetOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeAPIV3WarehousesGetResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// APIV3WarehousesPost invokes POST /api/v3/warehouses operation.
|
||
//
|
||
// Метод создаёт склад продавца для работы с [остатками
|
||
// товаров](/openapi/work-with-products#tag/Ostatki-na-skladah-prodavca/paths/~1api~1v3~1stocks~1%7BwarehouseId%7D/post). Нужно привязать к складу продавца [склад WB](/openapi/work-with-products#tag/Sklady-prodavca/paths/~1api~1v3~1offices/get) для работы по схеме [FBS](/openapi/orders-fbs#tag/Zakazy-FBS) (Fulfillment by Seller).
|
||
// <div class="description_important">
|
||
// Нельзя привязывать склад WB, который уже используется
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 300 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Маркетплейс</a> на
|
||
// один аккаунт продавца.
|
||
// <br><br>
|
||
// Один запрос с кодом ответа <code>409</code> учитывается как 5
|
||
// запросов
|
||
// </div>.
|
||
//
|
||
// POST /api/v3/warehouses
|
||
func (c *Client) APIV3WarehousesPost(ctx context.Context, request *APIV3WarehousesPostReq) (APIV3WarehousesPostRes, error) {
|
||
res, err := c.sendAPIV3WarehousesPost(ctx, request)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendAPIV3WarehousesPost(ctx context.Context, request *APIV3WarehousesPostReq) (res APIV3WarehousesPostRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("POST"),
|
||
semconv.HTTPRouteKey.String("/api/v3/warehouses"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, APIV3WarehousesPostOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/api/v3/warehouses"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "POST", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
if err := encodeAPIV3WarehousesPostRequest(request, r); err != nil {
|
||
return res, errors.Wrap(err, "encode request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, APIV3WarehousesPostOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeAPIV3WarehousesPostResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// APIV3WarehousesWarehouseIdDelete invokes DELETE /api/v3/warehouses/{warehouseId} operation.
|
||
//
|
||
// Метод удаляет склад продавца из [списка
|
||
// складов](/openapi/work-with-products#tag/Sklady-prodavca/paths/~1api~1v3~1warehouses/get).
|
||
// <div class="description_limit">
|
||
// Максимум 300 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Маркетплейс</a> на
|
||
// один аккаунт продавца.
|
||
// <br><br>
|
||
// Один запрос с кодом ответа <code>409</code> учитывается как 5
|
||
// запросов
|
||
// </div>.
|
||
//
|
||
// DELETE /api/v3/warehouses/{warehouseId}
|
||
func (c *Client) APIV3WarehousesWarehouseIdDelete(ctx context.Context, params APIV3WarehousesWarehouseIdDeleteParams) (APIV3WarehousesWarehouseIdDeleteRes, error) {
|
||
res, err := c.sendAPIV3WarehousesWarehouseIdDelete(ctx, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendAPIV3WarehousesWarehouseIdDelete(ctx context.Context, params APIV3WarehousesWarehouseIdDeleteParams) (res APIV3WarehousesWarehouseIdDeleteRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("DELETE"),
|
||
semconv.HTTPRouteKey.String("/api/v3/warehouses/{warehouseId}"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, APIV3WarehousesWarehouseIdDeleteOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [2]string
|
||
pathParts[0] = "/api/v3/warehouses/"
|
||
{
|
||
// Encode "warehouseId" parameter.
|
||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
||
Param: "warehouseId",
|
||
Style: uri.PathStyleSimple,
|
||
Explode: false,
|
||
})
|
||
if err := func() error {
|
||
return e.EncodeValue(conv.Int64ToString(params.WarehouseId))
|
||
}(); err != nil {
|
||
return res, errors.Wrap(err, "encode path")
|
||
}
|
||
encoded, err := e.Result()
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "encode path")
|
||
}
|
||
pathParts[1] = encoded
|
||
}
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "DELETE", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, APIV3WarehousesWarehouseIdDeleteOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeAPIV3WarehousesWarehouseIdDeleteResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// APIV3WarehousesWarehouseIdPut invokes PUT /api/v3/warehouses/{warehouseId} operation.
|
||
//
|
||
// Метод обновляет данные склада продавца в [списке
|
||
// складов](/openapi/work-with-products#tag/Sklady-prodavca/paths/~1api~1v3~1warehouses/get).
|
||
// Данные о привязанном [складе
|
||
// WB](/openapi/work-with-products#tag/Sklady-prodavca/paths/~1api~1v3~1offices/get) можно
|
||
// изменить один раз в сутки.
|
||
// <div class="description_important">
|
||
// Нельзя привязывать склад WB, который уже используется
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 300 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Маркетплейс</a> на
|
||
// один аккаунт продавца.
|
||
// <br><br>
|
||
// Один запрос с кодом ответа <code>409</code> учитывается как 5
|
||
// запросов
|
||
// </div>.
|
||
//
|
||
// PUT /api/v3/warehouses/{warehouseId}
|
||
func (c *Client) APIV3WarehousesWarehouseIdPut(ctx context.Context, request *APIV3WarehousesWarehouseIdPutReq, params APIV3WarehousesWarehouseIdPutParams) (APIV3WarehousesWarehouseIdPutRes, error) {
|
||
res, err := c.sendAPIV3WarehousesWarehouseIdPut(ctx, request, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendAPIV3WarehousesWarehouseIdPut(ctx context.Context, request *APIV3WarehousesWarehouseIdPutReq, params APIV3WarehousesWarehouseIdPutParams) (res APIV3WarehousesWarehouseIdPutRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("PUT"),
|
||
semconv.HTTPRouteKey.String("/api/v3/warehouses/{warehouseId}"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, APIV3WarehousesWarehouseIdPutOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [2]string
|
||
pathParts[0] = "/api/v3/warehouses/"
|
||
{
|
||
// Encode "warehouseId" parameter.
|
||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
||
Param: "warehouseId",
|
||
Style: uri.PathStyleSimple,
|
||
Explode: false,
|
||
})
|
||
if err := func() error {
|
||
return e.EncodeValue(conv.Int64ToString(params.WarehouseId))
|
||
}(); err != nil {
|
||
return res, errors.Wrap(err, "encode path")
|
||
}
|
||
encoded, err := e.Result()
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "encode path")
|
||
}
|
||
pathParts[1] = encoded
|
||
}
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "PUT", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
if err := encodeAPIV3WarehousesWarehouseIdPutRequest(request, r); err != nil {
|
||
return res, errors.Wrap(err, "encode request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, APIV3WarehousesWarehouseIdPutOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeAPIV3WarehousesWarehouseIdPutResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV2BarcodesPost invokes POST /content/v2/barcodes operation.
|
||
//
|
||
// Метод генерирует массив уникальных баркодов для
|
||
// создания размера в [карточке
|
||
// товара](/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post). Можно использовать, если у вас нет собственных баркодов.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// POST /content/v2/barcodes
|
||
func (c *Client) ContentV2BarcodesPost(ctx context.Context, request *ContentV2BarcodesPostReq) (ContentV2BarcodesPostRes, error) {
|
||
res, err := c.sendContentV2BarcodesPost(ctx, request)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV2BarcodesPost(ctx context.Context, request *ContentV2BarcodesPostReq) (res ContentV2BarcodesPostRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("POST"),
|
||
semconv.HTTPRouteKey.String("/content/v2/barcodes"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV2BarcodesPostOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v2/barcodes"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "POST", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
if err := encodeContentV2BarcodesPostRequest(request, r); err != nil {
|
||
return res, errors.Wrap(err, "encode request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV2BarcodesPostOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV2BarcodesPostResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV2CardsDeleteTrashPost invokes POST /content/v2/cards/delete/trash operation.
|
||
//
|
||
// Метод переносит [карточки товаров в
|
||
// корзину](/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1get~1cards~1trash/post). При этом карточки товаров не удаляются, их можно [восстановить](/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1recover/post).
|
||
// <div class="description_important">
|
||
// После переноса в корзину карточке товара
|
||
// присваивается новый <code>imtID</code>.
|
||
// </div>
|
||
// Карточки товаров удаляются автоматически, если лежат
|
||
// в корзине больше 30 дней. Очистка корзины происходит
|
||
// каждую ночь по московскому времени.<br>
|
||
// Карточки товаров можно удалить в любое время в
|
||
// [личном кабинете](https://seller.wildberries.ru/new-goods/basket-cards).
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// POST /content/v2/cards/delete/trash
|
||
func (c *Client) ContentV2CardsDeleteTrashPost(ctx context.Context, request *ContentV2CardsDeleteTrashPostReq) (ContentV2CardsDeleteTrashPostRes, error) {
|
||
res, err := c.sendContentV2CardsDeleteTrashPost(ctx, request)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV2CardsDeleteTrashPost(ctx context.Context, request *ContentV2CardsDeleteTrashPostReq) (res ContentV2CardsDeleteTrashPostRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("POST"),
|
||
semconv.HTTPRouteKey.String("/content/v2/cards/delete/trash"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV2CardsDeleteTrashPostOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v2/cards/delete/trash"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "POST", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
if err := encodeContentV2CardsDeleteTrashPostRequest(request, r); err != nil {
|
||
return res, errors.Wrap(err, "encode request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV2CardsDeleteTrashPostOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV2CardsDeleteTrashPostResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV2CardsErrorListGet invokes GET /content/v2/cards/error/list operation.
|
||
//
|
||
// Метод предоставляет список карточек товаров, при
|
||
// создании или редактировании которых произошли
|
||
// ошибки, с описанием этих ошибок.
|
||
// <div class="description_important">
|
||
// Чтобы убрать карточку товара из списка, нужно
|
||
// повторно сделать запрос на <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создание</a> или редактирование карточки товара с исправленными ошибками.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/cards/error/list
|
||
func (c *Client) ContentV2CardsErrorListGet(ctx context.Context, params ContentV2CardsErrorListGetParams) (ContentV2CardsErrorListGetRes, error) {
|
||
res, err := c.sendContentV2CardsErrorListGet(ctx, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV2CardsErrorListGet(ctx context.Context, params ContentV2CardsErrorListGetParams) (res ContentV2CardsErrorListGetRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("GET"),
|
||
semconv.HTTPRouteKey.String("/content/v2/cards/error/list"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV2CardsErrorListGetOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v2/cards/error/list"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeQueryParams"
|
||
q := uri.NewQueryEncoder()
|
||
{
|
||
// Encode "locale" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "locale",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.Locale.Get(); ok {
|
||
return e.EncodeValue(conv.StringToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
u.RawQuery = q.Values().Encode()
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "GET", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV2CardsErrorListGetOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV2CardsErrorListGetResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV2CardsLimitsGet invokes GET /content/v2/cards/limits operation.
|
||
//
|
||
// Возвращает бесплатные и платные лимиты продавца на
|
||
// [создание карточек
|
||
// товаров](/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post).<br><br>
|
||
// Формула для получения количества карточек, которые
|
||
// можно создать:
|
||
// > (`freeLimits` + `paidLimits`) - количество созданных карточек
|
||
// Созданными считаются карточки, которые можно
|
||
// получить через методы [список карточек
|
||
// товаров](/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1get~1cards~1list/post) и [список карточек товаров в корзине](/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1get~1cards~1trash/post).
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/cards/limits
|
||
func (c *Client) ContentV2CardsLimitsGet(ctx context.Context) (ContentV2CardsLimitsGetRes, error) {
|
||
res, err := c.sendContentV2CardsLimitsGet(ctx)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV2CardsLimitsGet(ctx context.Context) (res ContentV2CardsLimitsGetRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("GET"),
|
||
semconv.HTTPRouteKey.String("/content/v2/cards/limits"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV2CardsLimitsGetOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v2/cards/limits"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "GET", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV2CardsLimitsGetOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV2CardsLimitsGetResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV2CardsRecoverPost invokes POST /content/v2/cards/recover operation.
|
||
//
|
||
// Метод восстанавливает [карточки товаров из
|
||
// корзины](/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1get~1cards~1trash/post).
|
||
// <div class="description_important">
|
||
// Карточка товара сохраняет тот же <code>imtID</code>, что был
|
||
// присвоен ей при <a
|
||
// href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1delete~1trash/post">перемещении в корзину</a>.
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// POST /content/v2/cards/recover
|
||
func (c *Client) ContentV2CardsRecoverPost(ctx context.Context, request *ContentV2CardsRecoverPostReq) (ContentV2CardsRecoverPostRes, error) {
|
||
res, err := c.sendContentV2CardsRecoverPost(ctx, request)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV2CardsRecoverPost(ctx context.Context, request *ContentV2CardsRecoverPostReq) (res ContentV2CardsRecoverPostRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("POST"),
|
||
semconv.HTTPRouteKey.String("/content/v2/cards/recover"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV2CardsRecoverPostOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v2/cards/recover"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "POST", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
if err := encodeContentV2CardsRecoverPostRequest(request, r); err != nil {
|
||
return res, errors.Wrap(err, "encode request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV2CardsRecoverPostOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV2CardsRecoverPostResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV2CardsUpdatePost invokes POST /content/v2/cards/update operation.
|
||
//
|
||
// Метод обновляет карточки товаров. Данные для
|
||
// обновления можно получить через [список карточек
|
||
// товаров](/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1get~1cards~1list/post) и [список карточек товаров в корзине](/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1get~1cards~1trash/post).
|
||
// <div class="description_important">
|
||
// Карточка товара перезаписывается при обновлении.
|
||
// Поэтому в запросе нужно передать <strong>все</strong>
|
||
// параметры карточки, в том числе те, которые вы не
|
||
// собираетесь обновлять.
|
||
// </div>
|
||
// Нельзя редактировать или удалять баркоды, но можно
|
||
// добавить дополнительный баркод к карточке товара.
|
||
// Параметры `photos`, `video` и `tags` редактировать или удалять
|
||
// через данный метод нельзя.<br>
|
||
// Габариты товаров можно указать только в `сантиметрах`,
|
||
//
|
||
// вес товара с упаковкой — в `килограммах`.
|
||
//
|
||
// <br><br>
|
||
// В одном запросе можно отредактировать максимум 3000
|
||
// карточек товаров (`nmID`). Максимальный размер запроса 10
|
||
// Мб.<br>
|
||
// Если ответ `Успешно` (`200`), но какие-то карточки не
|
||
// обновились, получите [список несозданных карточек
|
||
// товаров](/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1error~1list/get).
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня для метода будет отдельный
|
||
// лимит — 10 запросов в минуту на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// POST /content/v2/cards/update
|
||
func (c *Client) ContentV2CardsUpdatePost(ctx context.Context, request []ContentV2CardsUpdatePostReqItem) (ContentV2CardsUpdatePostRes, error) {
|
||
res, err := c.sendContentV2CardsUpdatePost(ctx, request)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV2CardsUpdatePost(ctx context.Context, request []ContentV2CardsUpdatePostReqItem) (res ContentV2CardsUpdatePostRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("POST"),
|
||
semconv.HTTPRouteKey.String("/content/v2/cards/update"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV2CardsUpdatePostOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v2/cards/update"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "POST", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
if err := encodeContentV2CardsUpdatePostRequest(request, r); err != nil {
|
||
return res, errors.Wrap(err, "encode request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV2CardsUpdatePostOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV2CardsUpdatePostResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV2CardsUploadAddPost invokes POST /content/v2/cards/upload/add operation.
|
||
//
|
||
// Метод создаёт новые карточки товаров, присоединяя их
|
||
// к существующим карточкам.
|
||
// Габариты товаров можно указать только в `сантиметрах`,
|
||
//
|
||
// вес товара с упаковкой — в `килограммах`.
|
||
//
|
||
// <br><br>
|
||
// Создание карточки товара происходит асинхронно.
|
||
// После отправки запрос становится в очередь на
|
||
// обработку.<br>Максимальный размер запроса 10 Мб.<br>
|
||
// Если ответ `Успешно` (`200`), но какие-то карточки не
|
||
// обновились, получите [список несозданных карточек
|
||
// товаров](/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1error~1list/get).
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня для метода будет отдельный
|
||
// лимит — 10 запросов в минуту на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// POST /content/v2/cards/upload/add
|
||
func (c *Client) ContentV2CardsUploadAddPost(ctx context.Context, request OptContentV2CardsUploadAddPostReq) (ContentV2CardsUploadAddPostRes, error) {
|
||
res, err := c.sendContentV2CardsUploadAddPost(ctx, request)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV2CardsUploadAddPost(ctx context.Context, request OptContentV2CardsUploadAddPostReq) (res ContentV2CardsUploadAddPostRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("POST"),
|
||
semconv.HTTPRouteKey.String("/content/v2/cards/upload/add"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV2CardsUploadAddPostOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v2/cards/upload/add"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "POST", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
if err := encodeContentV2CardsUploadAddPostRequest(request, r); err != nil {
|
||
return res, errors.Wrap(err, "encode request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV2CardsUploadAddPostOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV2CardsUploadAddPostResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV2CardsUploadPost invokes POST /content/v2/cards/upload operation.
|
||
//
|
||
// Метод создаёт карточки товаров c указанием описаний и
|
||
// характеристик товаров.<br>
|
||
// <div class="description_important">
|
||
// Есть две формы запроса: для создания отдельных и
|
||
// объединённых карточек товаров.
|
||
// </div>
|
||
// Габариты товаров можно указать только в `сантиметрах`,
|
||
//
|
||
// вес товара с упаковкой — в `килограммах`.
|
||
//
|
||
// <br><br>
|
||
// Создание карточки товара происходит асинхронно.
|
||
// После отправки запрос становится в очередь на
|
||
// обработку.<br>
|
||
// В одном запросе можно создать максимум 100
|
||
// объединённых карточек товаров (`imtID`), по 30 карточек
|
||
// товаров в каждой. Максимальный размер запроса 10 Мб.<br>
|
||
// Если ответ `Успешно` (`200`), но какие-то карточки не
|
||
// обновились, получите [список несозданных карточек
|
||
// товаров](/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1error~1list/get).
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня для метода будет отдельный
|
||
// лимит — 10 запросов в минуту на один аккаунт продавца
|
||
// </div>.
|
||
//
|
||
// POST /content/v2/cards/upload
|
||
func (c *Client) ContentV2CardsUploadPost(ctx context.Context, request []ContentV2CardsUploadPostReqItem) (ContentV2CardsUploadPostRes, error) {
|
||
res, err := c.sendContentV2CardsUploadPost(ctx, request)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV2CardsUploadPost(ctx context.Context, request []ContentV2CardsUploadPostReqItem) (res ContentV2CardsUploadPostRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("POST"),
|
||
semconv.HTTPRouteKey.String("/content/v2/cards/upload"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV2CardsUploadPostOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v2/cards/upload"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "POST", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
if err := encodeContentV2CardsUploadPostRequest(request, r); err != nil {
|
||
return res, errors.Wrap(err, "encode request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV2CardsUploadPostOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV2CardsUploadPostResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV2DirectoryColorsGet invokes GET /content/v2/directory/colors operation.
|
||
//
|
||
// Метод предоставляет возможные значения
|
||
// [характеристики](/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1object~1charcs~1%7BsubjectId%7D/get) предмета `Цвет`.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/directory/colors
|
||
func (c *Client) ContentV2DirectoryColorsGet(ctx context.Context, params ContentV2DirectoryColorsGetParams) (ContentV2DirectoryColorsGetRes, error) {
|
||
res, err := c.sendContentV2DirectoryColorsGet(ctx, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV2DirectoryColorsGet(ctx context.Context, params ContentV2DirectoryColorsGetParams) (res ContentV2DirectoryColorsGetRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("GET"),
|
||
semconv.HTTPRouteKey.String("/content/v2/directory/colors"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV2DirectoryColorsGetOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v2/directory/colors"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeQueryParams"
|
||
q := uri.NewQueryEncoder()
|
||
{
|
||
// Encode "locale" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "locale",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.Locale.Get(); ok {
|
||
return e.EncodeValue(conv.StringToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
u.RawQuery = q.Values().Encode()
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "GET", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV2DirectoryColorsGetOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV2DirectoryColorsGetResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV2DirectoryCountriesGet invokes GET /content/v2/directory/countries operation.
|
||
//
|
||
// Метод предоставляет возможные значения
|
||
// [характеристики](/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1object~1charcs~1%7BsubjectId%7D/get) предмета `Страна производства`.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/directory/countries
|
||
func (c *Client) ContentV2DirectoryCountriesGet(ctx context.Context, params ContentV2DirectoryCountriesGetParams) (ContentV2DirectoryCountriesGetRes, error) {
|
||
res, err := c.sendContentV2DirectoryCountriesGet(ctx, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV2DirectoryCountriesGet(ctx context.Context, params ContentV2DirectoryCountriesGetParams) (res ContentV2DirectoryCountriesGetRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("GET"),
|
||
semconv.HTTPRouteKey.String("/content/v2/directory/countries"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV2DirectoryCountriesGetOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v2/directory/countries"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeQueryParams"
|
||
q := uri.NewQueryEncoder()
|
||
{
|
||
// Encode "locale" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "locale",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.Locale.Get(); ok {
|
||
return e.EncodeValue(conv.StringToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
u.RawQuery = q.Values().Encode()
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "GET", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV2DirectoryCountriesGetOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV2DirectoryCountriesGetResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV2DirectoryKindsGet invokes GET /content/v2/directory/kinds operation.
|
||
//
|
||
// Метод предоставляет возможные значения
|
||
// [характеристики](/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1object~1charcs~1%7BsubjectId%7D/get) предмета `Пол`.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/directory/kinds
|
||
func (c *Client) ContentV2DirectoryKindsGet(ctx context.Context, params ContentV2DirectoryKindsGetParams) (ContentV2DirectoryKindsGetRes, error) {
|
||
res, err := c.sendContentV2DirectoryKindsGet(ctx, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV2DirectoryKindsGet(ctx context.Context, params ContentV2DirectoryKindsGetParams) (res ContentV2DirectoryKindsGetRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("GET"),
|
||
semconv.HTTPRouteKey.String("/content/v2/directory/kinds"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV2DirectoryKindsGetOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v2/directory/kinds"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeQueryParams"
|
||
q := uri.NewQueryEncoder()
|
||
{
|
||
// Encode "locale" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "locale",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.Locale.Get(); ok {
|
||
return e.EncodeValue(conv.StringToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
u.RawQuery = q.Values().Encode()
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "GET", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV2DirectoryKindsGetOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV2DirectoryKindsGetResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV2DirectorySeasonsGet invokes GET /content/v2/directory/seasons operation.
|
||
//
|
||
// Метод предоставляет возможные значения
|
||
// [характеристики](/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1object~1charcs~1%7BsubjectId%7D/get) предмета `Сезон`.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/directory/seasons
|
||
func (c *Client) ContentV2DirectorySeasonsGet(ctx context.Context, params ContentV2DirectorySeasonsGetParams) (ContentV2DirectorySeasonsGetRes, error) {
|
||
res, err := c.sendContentV2DirectorySeasonsGet(ctx, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV2DirectorySeasonsGet(ctx context.Context, params ContentV2DirectorySeasonsGetParams) (res ContentV2DirectorySeasonsGetRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("GET"),
|
||
semconv.HTTPRouteKey.String("/content/v2/directory/seasons"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV2DirectorySeasonsGetOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v2/directory/seasons"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeQueryParams"
|
||
q := uri.NewQueryEncoder()
|
||
{
|
||
// Encode "locale" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "locale",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.Locale.Get(); ok {
|
||
return e.EncodeValue(conv.StringToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
u.RawQuery = q.Values().Encode()
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "GET", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV2DirectorySeasonsGetOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV2DirectorySeasonsGetResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV2DirectoryTnvedGet invokes GET /content/v2/directory/tnved operation.
|
||
//
|
||
// Метод предоставляет список ТНВЭД-кодов по ID
|
||
// [предмета](/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1object~1all/get) и фрагменту ТНВЭД-кода.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/directory/tnved
|
||
func (c *Client) ContentV2DirectoryTnvedGet(ctx context.Context, params ContentV2DirectoryTnvedGetParams) (ContentV2DirectoryTnvedGetRes, error) {
|
||
res, err := c.sendContentV2DirectoryTnvedGet(ctx, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV2DirectoryTnvedGet(ctx context.Context, params ContentV2DirectoryTnvedGetParams) (res ContentV2DirectoryTnvedGetRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("GET"),
|
||
semconv.HTTPRouteKey.String("/content/v2/directory/tnved"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV2DirectoryTnvedGetOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v2/directory/tnved"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeQueryParams"
|
||
q := uri.NewQueryEncoder()
|
||
{
|
||
// Encode "subjectID" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "subjectID",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
return e.EncodeValue(conv.IntToString(params.SubjectID))
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
{
|
||
// Encode "search" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "search",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.Search.Get(); ok {
|
||
return e.EncodeValue(conv.IntToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
{
|
||
// Encode "locale" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "locale",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.Locale.Get(); ok {
|
||
return e.EncodeValue(conv.StringToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
u.RawQuery = q.Values().Encode()
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "GET", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV2DirectoryTnvedGetOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV2DirectoryTnvedGetResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV2DirectoryVatGet invokes GET /content/v2/directory/vat operation.
|
||
//
|
||
// Метод предоставляет возможные значения
|
||
// [характеристики](/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1object~1charcs~1%7BsubjectId%7D/get) предмета `Ставка НДС`.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/directory/vat
|
||
func (c *Client) ContentV2DirectoryVatGet(ctx context.Context, params ContentV2DirectoryVatGetParams) (ContentV2DirectoryVatGetRes, error) {
|
||
res, err := c.sendContentV2DirectoryVatGet(ctx, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV2DirectoryVatGet(ctx context.Context, params ContentV2DirectoryVatGetParams) (res ContentV2DirectoryVatGetRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("GET"),
|
||
semconv.HTTPRouteKey.String("/content/v2/directory/vat"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV2DirectoryVatGetOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v2/directory/vat"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeQueryParams"
|
||
q := uri.NewQueryEncoder()
|
||
{
|
||
// Encode "locale" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "locale",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.Locale.Get(); ok {
|
||
return e.EncodeValue(conv.StringToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
u.RawQuery = q.Values().Encode()
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "GET", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV2DirectoryVatGetOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV2DirectoryVatGetResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV2GetCardsListPost invokes POST /content/v2/get/cards/list operation.
|
||
//
|
||
// <div class="description_auth">
|
||
// Метод доступен по <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">токену</a> с
|
||
// категорией <strong>Контент</strong> или <strong>Продвижение</strong>
|
||
// </div>
|
||
// Метод предоставляет список созданных карточек
|
||
// товаров.
|
||
// <div class="description_important">
|
||
// В ответе метода не будет карточек, находящихся в
|
||
// корзине. Получить такие карточки можно через <a
|
||
// href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1get~1cards~1trash/post">отдельный метод</a>.
|
||
// </div>
|
||
// Чтобы получить **больше 100** карточек товаров,
|
||
// воспользуйтесь пагинацией:
|
||
// <ol>
|
||
// <li>Сделайте первый запрос: <br>
|
||
// <pre style="background-color: rgb(38 50 56 / 5%); color: #e53935">
|
||
// {
|
||
// "settings": {
|
||
// "cursor": {
|
||
// "limit": 100
|
||
// },
|
||
// "filter": {
|
||
// "withPhoto": -1
|
||
// }
|
||
// }
|
||
// }</pre>
|
||
// </li>
|
||
// <li>Пройдите в конец полученного списка карточек
|
||
// товаров.</li>
|
||
// <li>Скопируйте из <code>cursor</code> две строки:
|
||
// <ul>
|
||
// <li><code>"updatedAt": "***"</code></li>
|
||
// <li><code>"nmID": ***</code></li>
|
||
// </ul></li>
|
||
// <li>Вставьте скопированные строки в параметр запроса
|
||
// <code>cursor</code>.</li>
|
||
// <li>Повторите запрос. </li>
|
||
// <li>Повторяйте пункты со <b>2</b> по <b>5</b>, пока поле
|
||
// <code>total</code> в ответе не станет меньше чем параметр
|
||
// <code>limit</code> в запросе. Это будет означать, что вы
|
||
// получили все карточки.
|
||
// </ol>
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// POST /content/v2/get/cards/list
|
||
func (c *Client) ContentV2GetCardsListPost(ctx context.Context, request *ContentV2GetCardsListPostReq, params ContentV2GetCardsListPostParams) (ContentV2GetCardsListPostRes, error) {
|
||
res, err := c.sendContentV2GetCardsListPost(ctx, request, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV2GetCardsListPost(ctx context.Context, request *ContentV2GetCardsListPostReq, params ContentV2GetCardsListPostParams) (res ContentV2GetCardsListPostRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("POST"),
|
||
semconv.HTTPRouteKey.String("/content/v2/get/cards/list"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV2GetCardsListPostOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v2/get/cards/list"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeQueryParams"
|
||
q := uri.NewQueryEncoder()
|
||
{
|
||
// Encode "locale" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "locale",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.Locale.Get(); ok {
|
||
return e.EncodeValue(conv.StringToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
u.RawQuery = q.Values().Encode()
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "POST", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
if err := encodeContentV2GetCardsListPostRequest(request, r); err != nil {
|
||
return res, errors.Wrap(err, "encode request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV2GetCardsListPostOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV2GetCardsListPostResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV2GetCardsTrashPost invokes POST /content/v2/get/cards/trash operation.
|
||
//
|
||
// <div class="description_auth">
|
||
// Метод доступен по <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">токену</a> с
|
||
// категорией <strong>Контент</strong> или <strong>Продвижение</strong>
|
||
// </div>
|
||
// Метод предоставляет список карточек товаров в
|
||
// корзине.<br><br>
|
||
// Чтобы получить **больше 100** карточек товаров,
|
||
// воспользуйтесь пагинацией:
|
||
// <ol>
|
||
// <li>Сделайте первый запрос: <br>
|
||
// <pre style="background-color: rgb(38 50 56 / 5%); color: #e53935">
|
||
// {
|
||
// "settings": {
|
||
// "cursor": {
|
||
// "limit": 100
|
||
// },
|
||
// "filter": {
|
||
// "withPhoto": -1
|
||
// }
|
||
// }
|
||
// }</pre>
|
||
// </li>
|
||
// <li>Пройдите в конец полученного списка карточек
|
||
// товаров.</li>
|
||
// <li>Скопируйте из <code>cursor</code> две строки:
|
||
// <ul>
|
||
// <li><code>"trashedAt": "***"</code></li>
|
||
// <li><code>"nmID": ***</code></li>
|
||
// </ul></li>
|
||
// <li>Вставьте скопированные строки в параметр запроса
|
||
// <code>cursor</code>.</li>
|
||
// <li>Повторите запрос. </li>
|
||
// <li>Повторяйте пункты со <b>2</b> по <b>5</b>, пока поле
|
||
// <code>total</code> в ответе не станет меньше чем параметр
|
||
// <code>limit</code> в запросе. Это будет означать, что вы
|
||
// получили все карточки.
|
||
// </ol>
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// POST /content/v2/get/cards/trash
|
||
func (c *Client) ContentV2GetCardsTrashPost(ctx context.Context, request *ContentV2GetCardsTrashPostReq, params ContentV2GetCardsTrashPostParams) (ContentV2GetCardsTrashPostRes, error) {
|
||
res, err := c.sendContentV2GetCardsTrashPost(ctx, request, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV2GetCardsTrashPost(ctx context.Context, request *ContentV2GetCardsTrashPostReq, params ContentV2GetCardsTrashPostParams) (res ContentV2GetCardsTrashPostRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("POST"),
|
||
semconv.HTTPRouteKey.String("/content/v2/get/cards/trash"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV2GetCardsTrashPostOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v2/get/cards/trash"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeQueryParams"
|
||
q := uri.NewQueryEncoder()
|
||
{
|
||
// Encode "locale" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "locale",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.Locale.Get(); ok {
|
||
return e.EncodeValue(conv.StringToString(string(val)))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
u.RawQuery = q.Values().Encode()
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "POST", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
if err := encodeContentV2GetCardsTrashPostRequest(request, r); err != nil {
|
||
return res, errors.Wrap(err, "encode request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV2GetCardsTrashPostOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV2GetCardsTrashPostResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV2ObjectAllGet invokes GET /content/v2/object/all operation.
|
||
//
|
||
// Метод предоставляет список названий [родительских
|
||
// категорий
|
||
// предметов](/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1object~1parent~1all/get) и их предметов с ID. Например, у категории `Игрушки` будут предметы `Калейдоскопы`, `Куклы`, `Мячики`.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/object/all
|
||
func (c *Client) ContentV2ObjectAllGet(ctx context.Context, params ContentV2ObjectAllGetParams) (ContentV2ObjectAllGetRes, error) {
|
||
res, err := c.sendContentV2ObjectAllGet(ctx, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV2ObjectAllGet(ctx context.Context, params ContentV2ObjectAllGetParams) (res ContentV2ObjectAllGetRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("GET"),
|
||
semconv.HTTPRouteKey.String("/content/v2/object/all"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV2ObjectAllGetOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v2/object/all"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeQueryParams"
|
||
q := uri.NewQueryEncoder()
|
||
{
|
||
// Encode "locale" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "locale",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.Locale.Get(); ok {
|
||
return e.EncodeValue(conv.StringToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
{
|
||
// Encode "name" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "name",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.Name.Get(); ok {
|
||
return e.EncodeValue(conv.StringToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
{
|
||
// Encode "limit" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "limit",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.Limit.Get(); ok {
|
||
return e.EncodeValue(conv.IntToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
{
|
||
// Encode "offset" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "offset",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.Offset.Get(); ok {
|
||
return e.EncodeValue(conv.IntToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
{
|
||
// Encode "parentID" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "parentID",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.ParentID.Get(); ok {
|
||
return e.EncodeValue(conv.IntToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
u.RawQuery = q.Values().Encode()
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "GET", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV2ObjectAllGetOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV2ObjectAllGetResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV2ObjectCharcsSubjectIdGet invokes GET /content/v2/object/charcs/{subjectId} operation.
|
||
//
|
||
// Метод предоставляет параметры характеристик
|
||
// предмета: названия, типы данных, единицы измерения и
|
||
// так далее. В запросе необходимо указать ID
|
||
// [предмета](/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1object~1all/get).
|
||
// <div class="description_important">
|
||
// Для получения характеристик <a
|
||
// href="/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1directory~1colors/get">Цвет</a>, <a href="/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1directory~1kinds/get">Пол</a>, <a href="/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1directory~1countries/get">Страна производства</a>, <a href="/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1directory~1seasons/get">Сезон</a>, <a href="/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1directory~1vat/get">Ставка НДС</a> и <a href="/openapi/work-with-products#tag/Kategorii-predmety-i-harakteristiki/paths/~1content~1v2~1directory~1tnved/get">ТНВЭД-код</a> используйте отдельные методы
|
||
// </div>
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/object/charcs/{subjectId}
|
||
func (c *Client) ContentV2ObjectCharcsSubjectIdGet(ctx context.Context, params ContentV2ObjectCharcsSubjectIdGetParams) (ContentV2ObjectCharcsSubjectIdGetRes, error) {
|
||
res, err := c.sendContentV2ObjectCharcsSubjectIdGet(ctx, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV2ObjectCharcsSubjectIdGet(ctx context.Context, params ContentV2ObjectCharcsSubjectIdGetParams) (res ContentV2ObjectCharcsSubjectIdGetRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("GET"),
|
||
semconv.HTTPRouteKey.String("/content/v2/object/charcs/{subjectId}"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV2ObjectCharcsSubjectIdGetOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [2]string
|
||
pathParts[0] = "/content/v2/object/charcs/"
|
||
{
|
||
// Encode "subjectId" parameter.
|
||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
||
Param: "subjectId",
|
||
Style: uri.PathStyleSimple,
|
||
Explode: false,
|
||
})
|
||
if err := func() error {
|
||
return e.EncodeValue(conv.IntToString(params.SubjectId))
|
||
}(); err != nil {
|
||
return res, errors.Wrap(err, "encode path")
|
||
}
|
||
encoded, err := e.Result()
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "encode path")
|
||
}
|
||
pathParts[1] = encoded
|
||
}
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeQueryParams"
|
||
q := uri.NewQueryEncoder()
|
||
{
|
||
// Encode "locale" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "locale",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.Locale.Get(); ok {
|
||
return e.EncodeValue(conv.StringToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
u.RawQuery = q.Values().Encode()
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "GET", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV2ObjectCharcsSubjectIdGetOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV2ObjectCharcsSubjectIdGetResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV2ObjectParentAllGet invokes GET /content/v2/object/parent/all operation.
|
||
//
|
||
// Метод предоставляет названия и ID всех родительских
|
||
// категорий для [создания карточек
|
||
// товаров](/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov): например,
|
||
// `Электроника`, `Бытовая химия`, `Рукоделие`.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/object/parent/all
|
||
func (c *Client) ContentV2ObjectParentAllGet(ctx context.Context, params ContentV2ObjectParentAllGetParams) (ContentV2ObjectParentAllGetRes, error) {
|
||
res, err := c.sendContentV2ObjectParentAllGet(ctx, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV2ObjectParentAllGet(ctx context.Context, params ContentV2ObjectParentAllGetParams) (res ContentV2ObjectParentAllGetRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("GET"),
|
||
semconv.HTTPRouteKey.String("/content/v2/object/parent/all"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV2ObjectParentAllGetOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v2/object/parent/all"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeQueryParams"
|
||
q := uri.NewQueryEncoder()
|
||
{
|
||
// Encode "locale" parameter.
|
||
cfg := uri.QueryParameterEncodingConfig{
|
||
Name: "locale",
|
||
Style: uri.QueryStyleForm,
|
||
Explode: true,
|
||
}
|
||
|
||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
if val, ok := params.Locale.Get(); ok {
|
||
return e.EncodeValue(conv.StringToString(val))
|
||
}
|
||
return nil
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode query")
|
||
}
|
||
}
|
||
u.RawQuery = q.Values().Encode()
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "GET", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV2ObjectParentAllGetOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV2ObjectParentAllGetResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV2TagNomenclatureLinkPost invokes POST /content/v2/tag/nomenclature/link operation.
|
||
//
|
||
// Метод добавляет или снимает ярлык с карточки товара.
|
||
// К карточке можно добавить максимум 15 ярлыков.<br>
|
||
// При удалении ярлыка из карточки товара он не
|
||
// удаляется из [списка
|
||
// ярлыков](/openapi/work-with-products#tag/Yarlyki/paths/~1content~1v2~1tags/get)
|
||
// продавца.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// POST /content/v2/tag/nomenclature/link
|
||
func (c *Client) ContentV2TagNomenclatureLinkPost(ctx context.Context, request *ContentV2TagNomenclatureLinkPostReq) (ContentV2TagNomenclatureLinkPostRes, error) {
|
||
res, err := c.sendContentV2TagNomenclatureLinkPost(ctx, request)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV2TagNomenclatureLinkPost(ctx context.Context, request *ContentV2TagNomenclatureLinkPostReq) (res ContentV2TagNomenclatureLinkPostRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("POST"),
|
||
semconv.HTTPRouteKey.String("/content/v2/tag/nomenclature/link"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV2TagNomenclatureLinkPostOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v2/tag/nomenclature/link"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "POST", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
if err := encodeContentV2TagNomenclatureLinkPostRequest(request, r); err != nil {
|
||
return res, errors.Wrap(err, "encode request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV2TagNomenclatureLinkPostOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV2TagNomenclatureLinkPostResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV2TagsGet invokes GET /content/v2/tags operation.
|
||
//
|
||
// Метод предоставляет список и характеристики всех
|
||
// ярлыков продавца для группировки и фильтрации
|
||
// товаров.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// GET /content/v2/tags
|
||
func (c *Client) ContentV2TagsGet(ctx context.Context) (ContentV2TagsGetRes, error) {
|
||
res, err := c.sendContentV2TagsGet(ctx)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV2TagsGet(ctx context.Context) (res ContentV2TagsGetRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("GET"),
|
||
semconv.HTTPRouteKey.String("/content/v2/tags"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV2TagsGetOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v2/tags"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "GET", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV2TagsGetOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV2TagsGetResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV3MediaFilePost invokes POST /content/v3/media/file operation.
|
||
//
|
||
// Метод загружает и добавляет один медиафайл к
|
||
// карточке товара.
|
||
// Требования к изображениям:
|
||
// * максимум изображений для одной карточки товара — 30
|
||
// * минимальное разрешение — 700x900 px
|
||
// * максимальный размер — 32 Мб
|
||
// * минимальное качество — 65%
|
||
// * форматы — JPG, PNG, BMP, GIF (статичные), WebP
|
||
// Требования к видео:
|
||
// * максимум одно видео для одной карточки товара
|
||
// * максимальный размер — 50 Мб
|
||
// * форматы — MOV, MP4
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// POST /content/v3/media/file
|
||
func (c *Client) ContentV3MediaFilePost(ctx context.Context, request *ContentV3MediaFilePostReq, params ContentV3MediaFilePostParams) (ContentV3MediaFilePostRes, error) {
|
||
res, err := c.sendContentV3MediaFilePost(ctx, request, params)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV3MediaFilePost(ctx context.Context, request *ContentV3MediaFilePostReq, params ContentV3MediaFilePostParams) (res ContentV3MediaFilePostRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("POST"),
|
||
semconv.HTTPRouteKey.String("/content/v3/media/file"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV3MediaFilePostOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v3/media/file"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "POST", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
if err := encodeContentV3MediaFilePostRequest(request, r); err != nil {
|
||
return res, errors.Wrap(err, "encode request")
|
||
}
|
||
|
||
stage = "EncodeHeaderParams"
|
||
h := uri.NewHeaderEncoder(r.Header)
|
||
{
|
||
cfg := uri.HeaderParameterEncodingConfig{
|
||
Name: "X-Nm-Id",
|
||
Explode: false,
|
||
}
|
||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
return e.EncodeValue(conv.StringToString(params.XNmID))
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode header")
|
||
}
|
||
}
|
||
{
|
||
cfg := uri.HeaderParameterEncodingConfig{
|
||
Name: "X-Photo-Number",
|
||
Explode: false,
|
||
}
|
||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||
return e.EncodeValue(conv.IntToString(params.XPhotoNumber))
|
||
}); err != nil {
|
||
return res, errors.Wrap(err, "encode header")
|
||
}
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV3MediaFilePostOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV3MediaFilePostResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|
||
|
||
// ContentV3MediaSavePost invokes POST /content/v3/media/save operation.
|
||
//
|
||
// Метод загружает набор медиафайлов в карточку товара
|
||
// через указание ссылок в запросе.
|
||
// <div class="description_important">
|
||
// Новые медиафайлы полностью заменяют старые. Чтобы
|
||
// добавить новые медиафайлы, укажите в запросе ссылки
|
||
// одновременно на новые и старые медиафайлы.
|
||
// </div>
|
||
// Требования к изображениям:
|
||
// * максимум изображений для одной карточки товара — 30
|
||
// * минимальное разрешение — 700×900 px
|
||
// * максимальный размер — 32 Мб
|
||
// * минимальное качество — 65%
|
||
// * форматы — JPG, PNG, BMP, GIF (статичные), WebP
|
||
// Требования к видео:
|
||
// * максимум одно видео для одной карточки товара
|
||
// * максимальный размер — 50 Мб
|
||
// * форматы — MOV, MP4
|
||
// Если видео или хотя бы одно изображение в запросе не
|
||
// соответствует требованиям, то даже при успешном
|
||
// ответе ни одно изображение/видео не загрузится.
|
||
// <div class="description_limit">
|
||
// Максимум 100 запросов в <a
|
||
// href="/openapi/api-information#tag/Vvedenie/Limity-zaprosov">минуту</a> для всех
|
||
// методов категории <a
|
||
// href="/openapi/api-information#tag/Avtorizaciya/Kak-sozdat-token">Контент</a> на один
|
||
// аккаунт продавца. С 5 июня — за исключением методов <a
|
||
// href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload/post">создания</a>, <a href="/openapi/work-with-products#tag/Sozdanie-kartochek-tovarov/paths/~1content~1v2~1cards~1upload~1add/post">создания с присоединением</a> и <a href="/openapi/work-with-products#tag/Kartochki-tovarov/paths/~1content~1v2~1cards~1update/post">редактирования</a> карточек товаров
|
||
// </div>.
|
||
//
|
||
// POST /content/v3/media/save
|
||
func (c *Client) ContentV3MediaSavePost(ctx context.Context, request *ContentV3MediaSavePostReq) (ContentV3MediaSavePostRes, error) {
|
||
res, err := c.sendContentV3MediaSavePost(ctx, request)
|
||
return res, err
|
||
}
|
||
|
||
func (c *Client) sendContentV3MediaSavePost(ctx context.Context, request *ContentV3MediaSavePostReq) (res ContentV3MediaSavePostRes, err error) {
|
||
otelAttrs := []attribute.KeyValue{
|
||
semconv.HTTPRequestMethodKey.String("POST"),
|
||
semconv.HTTPRouteKey.String("/content/v3/media/save"),
|
||
}
|
||
|
||
// Run stopwatch.
|
||
startTime := time.Now()
|
||
defer func() {
|
||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||
elapsedDuration := time.Since(startTime)
|
||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||
}()
|
||
|
||
// Increment request counter.
|
||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
|
||
// Start a span for this request.
|
||
ctx, span := c.cfg.Tracer.Start(ctx, ContentV3MediaSavePostOperation,
|
||
trace.WithAttributes(otelAttrs...),
|
||
clientSpanKind,
|
||
)
|
||
// Track stage for error reporting.
|
||
var stage string
|
||
defer func() {
|
||
if err != nil {
|
||
span.RecordError(err)
|
||
span.SetStatus(codes.Error, stage)
|
||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||
}
|
||
span.End()
|
||
}()
|
||
|
||
stage = "BuildURL"
|
||
u := uri.Clone(c.requestURL(ctx))
|
||
var pathParts [1]string
|
||
pathParts[0] = "/content/v3/media/save"
|
||
uri.AddPathParts(u, pathParts[:]...)
|
||
|
||
stage = "EncodeRequest"
|
||
r, err := ht.NewRequest(ctx, "POST", u)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "create request")
|
||
}
|
||
if err := encodeContentV3MediaSavePostRequest(request, r); err != nil {
|
||
return res, errors.Wrap(err, "encode request")
|
||
}
|
||
|
||
{
|
||
type bitset = [1]uint8
|
||
var satisfied bitset
|
||
{
|
||
stage = "Security:HeaderApiKey"
|
||
switch err := c.securityHeaderApiKey(ctx, ContentV3MediaSavePostOperation, r); {
|
||
case err == nil: // if NO error
|
||
satisfied[0] |= 1 << 0
|
||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||
// Skip this security.
|
||
default:
|
||
return res, errors.Wrap(err, "security \"HeaderApiKey\"")
|
||
}
|
||
}
|
||
|
||
if ok := func() bool {
|
||
nextRequirement:
|
||
for _, requirement := range []bitset{
|
||
{0b00000001},
|
||
} {
|
||
for i, mask := range requirement {
|
||
if satisfied[i]&mask != mask {
|
||
continue nextRequirement
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
return false
|
||
}(); !ok {
|
||
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||
}
|
||
}
|
||
|
||
stage = "SendRequest"
|
||
resp, err := c.cfg.Client.Do(r)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "do request")
|
||
}
|
||
defer resp.Body.Close()
|
||
|
||
stage = "DecodeResponse"
|
||
result, err := decodeContentV3MediaSavePostResponse(resp)
|
||
if err != nil {
|
||
return res, errors.Wrap(err, "decode response")
|
||
}
|
||
|
||
return result, nil
|
||
}
|