Skip to main content

wb_api_client/items/apis/
configuration.rs

1/*
2 * Работа с товарами
3 *
4 * С помощью методов этого раздела вы можете: - [создавать](https://dev.wildberries.ru/openapi/item-management#tag/listingItems) и [редактировать](https://dev.wildberries.ru/openapi/item-management#tag/listings) карточки товаров - получать [категории, предметы, характеристики и бренды товаров](https://dev.wildberries.ru/openapi/item-management#tag/categoriesSubcategoriesAndCharacteristics) - загружать [медиафайлы](https://dev.wildberries.ru/openapi/item-management#tag/mediaFiles) в карточки товаров - настраивать [ярлыки](https://dev.wildberries.ru/openapi/item-management#tag/labels) для поиска товаров - работать с [рекомендациями](https://dev.wildberries.ru/openapi/item-management#tag/recommendations) для товаров - устанавливать [цены и скидки](https://dev.wildberries.ru/openapi/item-management#tag/pricesAndDiscounts) - управлять [остатками товаров](https://dev.wildberries.ru/openapi/item-management#tag/sellerWarehousesInventory) и [складами](https://dev.wildberries.ru/openapi/item-management#tag/sellerWarehouses), если вы работаете по модели продаж со склада продавца Вы можете протестировать методы работы с товарами в [песочнице](https://dev.wildberries.ru/sandbox). Также в песочнице доступны [специальные методы](https://dev.wildberries.ru/docs/openapi-other/sandbox-environment#tag/itemManagement) для управления карточками товаров  Узнать, как использовать методы в бизнес-кейсах, можно в [инструкции](https://dev.wildberries.ru/knowledge-base/articles/019d49a4-1320-71bb-9dac-8ba07e7177ce/rabota-s-tovarami) по **работе с товарами**
5 *
6 * The version of the OpenAPI document: items
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11/// Wrapper around a bearer JWT that redacts under Debug and Display.
12/// Call [`SecretString::expose_secret`] to get the raw value — deliberately
13/// awkward so accidental leaks (logs, `println!("{:?}", config)`) become explicit.
14#[derive(Clone)]
15pub struct SecretString(String);
16
17impl SecretString {
18    pub fn new<S: Into<String>>(value: S) -> Self {
19        SecretString(value.into())
20    }
21
22    pub fn expose_secret(&self) -> &str {
23        &self.0
24    }
25}
26
27impl std::fmt::Debug for SecretString {
28    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29        f.write_str("<REDACTED>")
30    }
31}
32
33impl std::fmt::Display for SecretString {
34    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35        f.write_str("<REDACTED>")
36    }
37}
38
39#[derive(Debug, Clone)]
40pub struct Configuration {
41    pub base_path: String,
42    pub user_agent: Option<String>,
43    pub client: reqwest::Client,
44    pub basic_auth: Option<BasicAuth>,
45    pub oauth_access_token: Option<String>,
46    pub bearer_access_token: Option<SecretString>,
47    pub api_key: Option<ApiKey>,
48}
49
50pub type BasicAuth = (String, Option<String>);
51
52#[derive(Debug, Clone)]
53pub struct ApiKey {
54    pub prefix: Option<String>,
55    pub key: String,
56}
57
58impl Configuration {
59    pub fn new() -> Configuration {
60        Configuration::default()
61    }
62
63    /// Store the WB bearer JWT wrapped in a [`SecretString`] so it redacts
64    /// under Debug/Display; the raw value leaves only via `expose_secret()`.
65    pub fn set_access_token(&mut self, token: &str) {
66        self.bearer_access_token = Some(SecretString::new(token));
67    }
68}
69
70impl Default for Configuration {
71    fn default() -> Self {
72        Configuration {
73            base_path: "http://localhost".to_owned(),
74            user_agent: Some("ValeryVerkhoturov/wb-api-client/rust".to_owned()),
75            client: reqwest::Client::new(),
76            basic_auth: None,
77            oauth_access_token: None,
78            bearer_access_token: None,
79            api_key: None,
80        }
81    }
82}