wb_api_client/communications/apis/configuration.rs
1/*
2 * Общение с покупателями
3 *
4 * Узнать больше об общении с покупателями можно в [справочном центре](https://seller.wildberries.ru/instructions/category/f7f6c465-dd12-422d-80a0-a6d9562115d5?goBackOption=prevRoute&categoryId=30817062-14cc-4a82-bc78-3600c2b0685b) С помощью методов общения с покупателями вы можете работать с: 1. [Вопросами](https://dev.wildberries.ru/openapi/customer-communication#tag/questions) и [отзывами](https://dev.wildberries.ru/openapi/customer-communication#tag/feedbacks) покупателей 2. [Закреплёнными отзывами](https://dev.wildberries.ru/openapi/customer-communication#tag/pinnedFeedbacks) 3. [Чатами с покупателями](https://dev.wildberries.ru/openapi/customer-communication#tag/buyersChat) 4. [Заявками покупателей на возврат](https://dev.wildberries.ru/openapi/customer-communication#tag/buyersReturns) Протестировать методы общения с покупателями вы можете в [песочнице](https://dev.wildberries.ru/sandbox). Также в песочнице доступны [специальные методы](https://dev.wildberries.ru/docs/openapi-other/sandbox-environment#tag/questionsAndFeedbacks) для управления тестовыми вопросами и отзывами Узнать, как использовать методы в бизнес-кейсах, можно в [инструкции](https://dev.wildberries.ru/knowledge-base/articles/019d49a4-0b26-7620-8d0b-e3050b7cd01d/obshchenie-s-pokupateliami) по работе с разделом **Общение с покупателями**
5 *
6 * The version of the OpenAPI document: communication
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}