twelve_data_client/apis/
regulatory_api.rs

1/*
2 * Twelve Data API
3 *
4 * ## Overview  Welcome to Twelve Data developer docs — your gateway to comprehensive financial market data through a powerful and easy-to-use API. Twelve Data provides access to financial markets across over 50 global countries, covering more than 1 million public instruments, including stocks, forex, ETFs, mutual funds, commodities, and cryptocurrencies.  ## Quickstart  To get started, you'll need to sign up for an API key. Once you have your API key, you can start making requests to the API.  ### Step 1: Create Twelve Data account  Sign up on the Twelve Data website to create your account [here](https://twelvedata.com/register). This gives you access to the API dashboard and your API key.  ### Step 2: Get your API key  After signing in, navigate to your [dashboard](https://twelvedata.com/account/api-keys) to find your unique API key. This key is required to authenticate all API and WebSocket requests.  ### Step 3: Make your first request  Try a simple API call with cURL to fetch the latest price for Apple (AAPL):  ``` curl \"https://api.twelvedata.com/price?symbol=AAPL&apikey=your_api_key\" ```  ### Step 4: Make a request from Python or Javascript  Use our client libraries or standard HTTP clients to make API calls programmatically. Here’s an example in [Python](https://github.com/twelvedata/twelvedata-python) and JavaScript:  #### Python (using official Twelve Data SDK):  ```python from twelvedata import TDClient  # Initialize client with your API key td = TDClient(apikey=\"your_api_key\")  # Get latest price for Apple price = td.price(symbol=\"AAPL\").as_json()  print(price) ```  #### JavaScript (Node.js):  ```javascript const fetch = require('node-fetch');  fetch('https://api.twelvedata.com/price?symbol=AAPL&apikey=your_api_key') &nbsp;&nbsp;.then(response => response.json()) &nbsp;&nbsp;.then(data => console.log(data)); ```  ### Step 5: Perform correlation analysis between Tesla and Microsoft prices  Fetch historical price data for Tesla (TSLA) and Microsoft (MSFT) and calculate the correlation of their closing prices:  ```python from twelvedata import TDClient import pandas as pd  # Initialize client with your API key td = TDClient(apikey=\"your_api_key\")  # Fetch historical price data for Tesla tsla_ts = td.time_series( &nbsp;&nbsp;&nbsp;&nbsp;symbol=\"TSLA\", &nbsp;&nbsp;&nbsp;&nbsp;interval=\"1day\", &nbsp;&nbsp;&nbsp;&nbsp;outputsize=100 ).as_pandas()  # Fetch historical price data for Microsoft msft_ts = td.time_series( &nbsp;&nbsp;&nbsp;&nbsp;symbol=\"MSFT\", &nbsp;&nbsp;&nbsp;&nbsp;interval=\"1day\", &nbsp;&nbsp;&nbsp;&nbsp;outputsize=100 ).as_pandas()  # Align data on datetime index combined = pd.concat( &nbsp;&nbsp;&nbsp;&nbsp;[tsla_ts['close'].astype(float), msft_ts['close'].astype(float)], &nbsp;&nbsp;&nbsp;&nbsp;axis=1, &nbsp;&nbsp;&nbsp;&nbsp;keys=[\"TSLA\", \"MSFT\"] ).dropna()  # Calculate correlation correlation = combined[\"TSLA\"].corr(combined[\"MSFT\"]) print(f\"Correlation of closing prices between TSLA and MSFT: {correlation:.2f}\") ```  ### Authentication  Authenticate your requests using one of these methods:  #### Query parameter method ``` GET https://api.twelvedata.com/endpoint?symbol=AAPL&apikey=your_api_key ```  #### HTTP header method (recommended) ``` Authorization: apikey your_api_key ```  ##### API key useful information <ul> <li> Demo API key (<code>apikey=demo</code>) available for demo requests</li> <li> Personal API key required for full access</li> <li> Premium endpoints and data require higher-tier plans (testable with <a href=\"https://twelvedata.com/exchanges\">trial symbols</a>)</li> </ul>  ### API endpoints   Service | Base URL | ---------|----------|  REST API | `https://api.twelvedata.com` |  WebSocket | `wss://ws.twelvedata.com` |  ### Parameter guidelines <ul> <li><b>Separator:</b> Use <code>&</code> to separate multiple parameters</li> <li><b>Case sensitivity:</b> Parameter names are case-insensitive</li>  <ul><li><code>symbol=AAPL</code> = <code>symbol=aapl</code></li></ul>  <li><b>Multiple values:</b> Separate with commas where supported</li> </ul>  ### Response handling  #### Default format All responses return JSON format by default unless otherwise specified.  #### Null values <b>Important:</b> Some response fields may contain `null` values when data is unavailable for specific metrics. This is expected behavior, not an error.  ##### Best Practices: <ul> <li>Always implement <code>null</code> value handling in your application</li> <li>Use defensive programming techniques for data processing</li> <li>Consider fallback values or error handling for critical metrics</li> </ul>  #### Error handling Structure your code to gracefully handle: <ul> <li>Network timeouts</li> <li>Rate limiting responses</li> <li>Invalid parameter errors</li> <li>Data unavailability periods</li> </ul>  ##### Best practices <ul> <li><b>Rate limits:</b> Adhere to your plan’s rate limits to avoid throttling. Check your dashboard for details.</li> <li><b>Error handling:</b> Implement retry logic for transient errors (e.g., <code>429 Too Many Requests</code>).</li> <li><b>Caching:</b> Cache responses for frequently accessed data to reduce API calls and improve performance.</li> <li><b>Secure storage:</b> Store your API key securely and never expose it in client-side code or public repositories.</li> </ul>  ## Errors  Twelve Data API employs a standardized error response format, delivering a JSON object with `code`, `message`, and `status` keys for clear and consistent error communication.  ### Codes  Below is a table of possible error codes, their HTTP status, meanings, and resolution steps:   Code | status | Meaning | Resolution |  --- | --- | --- | --- |  **400** | Bad Request | Invalid or incorrect parameter(s) provided. | Check the `message` in the response for details. Refer to the API Documenta­tion to correct the input. |  **401** | Unauthor­ized | Invalid or incorrect API key. | Verify your API key is correct. Sign up for a key <a href=\"https://twelvedata.com/account/api-keys\">here</a>. |  **403** | Forbidden | API key lacks permissions for the requested resource (upgrade required). | Upgrade your plan <a href=\"https://twelvedata.com/pricing\">here</a>. |  **404** | Not Found | Requested data could not be found. | Adjust parameters to be less strict as they may be too restrictive. |  **414** | Parameter Too Long | Input parameter array exceeds the allowed length. | Follow the `message` guidance to adjust the parameter length. |  **429** | Too Many Requests | API request limit reached for your key. | Wait briefly or upgrade your plan <a href=\"https://twelvedata.com/pricing\">here</a>. |  **500** | Internal Server Error | Server-side issue occurred; retry later. | Contact support <a href=\"https://twelvedata.com/contact\">here</a> for assistance. |  ### Example error response  Consider the following invalid request:  ``` https://api.twelvedata.com/time_series?symbol=AAPL&interval=0.99min&apikey=your_api_key ```  Due to the incorrect `interval` value, the API returns:  ```json { &nbsp;&nbsp;\"code\": 400, &nbsp;&nbsp;\"message\": \"Invalid **interval** provided: 0.99min. Supported intervals: 1min, 5min, 15min, 30min, 45min, 1h, 2h, 4h, 8h, 1day, 1week, 1month\", &nbsp;&nbsp;\"status\": \"error\" } ```  Refer to the API Documentation for valid parameter values to resolve such errors.  ## Libraries  Twelve Data provides a growing ecosystem of libraries and integrations to help you build faster and smarter in your preferred environment. Official libraries are actively maintained by the Twelve Data team, while selected community-built libraries offer additional flexibility.  A full list is available on our [GitHub profile](https://github.com/search?q=twelvedata).  ### Official SDKs <ul> <li><b>Python:</b> <a href=\"https://github.com/twelvedata/twelvedata-python\">twelvedata-python</a></li> <li><b>R:</b> <a href=\"https://github.com/twelvedata/twelvedata-r-sdk\">twelvedata-r-sdk</a></li> </ul>  ### AI integrations <ul> <li><b>Twelve Data MCP Server:</b> <a href=\"https://github.com/twelvedata/mcp\">Repository</a> — Model Context Protocol (MCP) server that provides seamless integration with AI assistants and language models, enabling direct access to Twelve Data's financial market data within conversational interfaces and AI workflows.</li> </ul>  ### Spreadsheet add-ons <ul> <li><b>Excel:</b> <a href=\"https://twelvedata.com/excel\">Excel Add-in</a></li> <li><b>Google Sheets:</b> <a href=\"https://twelvedata.com/google-sheets\">Google Sheets Add-on</a></li> </ul>  ### Community libraries  The community has developed libraries in several popular languages. You can explore more community libraries on [GitHub](https://github.com/search?q=twelvedata). <ul> <li><b>C#:</b> <a href=\"https://github.com/pseudomarkets/TwelveDataSharp\">TwelveDataSharp</a></li> <li><b>JavaScript:</b> <a href=\"https://github.com/evzaboun/twelvedata\">twelvedata</a></li> <li><b>PHP:</b> <a href=\"https://github.com/ingelby/twelvedata\">twelvedata</a></li> <li><b>Go:</b> <a href=\"https://github.com/soulgarden/twelvedata\">twelvedata</a></li> <li><b>TypeScript:</b> <a href=\"https://github.com/Clyde-Goodall/twelve-data-wrapper\">twelve-data-wrapper</a></li> </ul>  ### Other Twelve Data repositories <ul> <li><b>searchindex</b> <i>(Go)</i>: <a href=\"https://github.com/twelvedata/searchindex\">Repository</a> — In-memory search index by strings</li> <li><b>ws-tools</b> <i>(Python)</i>: <a href=\"https://github.com/twelvedata/ws-tools\">Repository</a> — Utility tools for WebSocket stream handling</li> </ul>  ### API specification <ul> <li><b>OpenAPI / Swagger:</b> Access the <a href=\"https://api.twelvedata.com/doc/swagger/openapi.json\">complete API specification</a> in OpenAPI format. You can use this file to automatically generate client libraries in your preferred programming language, explore the API interactively via Swagger tools, or integrate Twelve Data seamlessly into your AI and LLM workflows.</li> </ul>
5 *
6 * The version of the OpenAPI document: 0.0.1
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16/// struct for passing parameters to the method [`get_direct_holders`]
17#[derive(Clone, Debug, Default, Serialize, Deserialize)]
18pub struct GetDirectHoldersParams {
19    /// Symbol ticker of instrument. For preffered stocks use dot(.) delimiter. E.g. `BRK.A` or `BRK.B` will be correct
20    pub symbol: Option<String>,
21    /// Filter by financial instrument global identifier (FIGI)
22    pub figi: Option<String>,
23    /// Filter by international securities identification number (ISIN)
24    pub isin: Option<String>,
25    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
26    pub cusip: Option<String>,
27    /// Exchange where instrument is traded
28    pub exchange: Option<String>,
29    /// Market Identifier Code (MIC) under ISO 10383 standard
30    pub mic_code: Option<String>,
31    /// Country where instrument is traded, e.g., `United States` or `US`
32    pub country: Option<String>,
33}
34
35impl GetDirectHoldersParams {
36    /// Create a new builder for this parameter struct
37    pub fn builder() -> GetDirectHoldersParamsBuilder {
38        GetDirectHoldersParamsBuilder::default()
39    }
40}
41
42/// Builder for [`GetDirectHoldersParams`]
43#[derive(Clone, Debug, Default)]
44pub struct GetDirectHoldersParamsBuilder {
45    /// Symbol ticker of instrument. For preffered stocks use dot(.) delimiter. E.g. `BRK.A` or `BRK.B` will be correct
46    symbol: Option<String>,
47    /// Filter by financial instrument global identifier (FIGI)
48    figi: Option<String>,
49    /// Filter by international securities identification number (ISIN)
50    isin: Option<String>,
51    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
52    cusip: Option<String>,
53    /// Exchange where instrument is traded
54    exchange: Option<String>,
55    /// Market Identifier Code (MIC) under ISO 10383 standard
56    mic_code: Option<String>,
57    /// Country where instrument is traded, e.g., `United States` or `US`
58    country: Option<String>,
59}
60
61impl GetDirectHoldersParamsBuilder {
62    /// Symbol ticker of instrument. For preffered stocks use dot(.) delimiter. E.g. `BRK.A` or `BRK.B` will be correct
63    pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
64        self.symbol = Some(symbol.into());
65        self
66    }
67    /// Filter by financial instrument global identifier (FIGI)
68    pub fn figi(mut self, figi: impl Into<String>) -> Self {
69        self.figi = Some(figi.into());
70        self
71    }
72    /// Filter by international securities identification number (ISIN)
73    pub fn isin(mut self, isin: impl Into<String>) -> Self {
74        self.isin = Some(isin.into());
75        self
76    }
77    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
78    pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
79        self.cusip = Some(cusip.into());
80        self
81    }
82    /// Exchange where instrument is traded
83    pub fn exchange(mut self, exchange: impl Into<String>) -> Self {
84        self.exchange = Some(exchange.into());
85        self
86    }
87    /// Market Identifier Code (MIC) under ISO 10383 standard
88    pub fn mic_code(mut self, mic_code: impl Into<String>) -> Self {
89        self.mic_code = Some(mic_code.into());
90        self
91    }
92    /// Country where instrument is traded, e.g., `United States` or `US`
93    pub fn country(mut self, country: impl Into<String>) -> Self {
94        self.country = Some(country.into());
95        self
96    }
97
98    /// Build the parameter struct
99    pub fn build(self) -> GetDirectHoldersParams {
100        GetDirectHoldersParams {
101            symbol: self.symbol,
102            figi: self.figi,
103            isin: self.isin,
104            cusip: self.cusip,
105            exchange: self.exchange,
106            mic_code: self.mic_code,
107            country: self.country,
108        }
109    }
110}
111
112/// struct for passing parameters to the method [`get_fund_holders`]
113#[derive(Clone, Debug, Default, Serialize, Deserialize)]
114pub struct GetFundHoldersParams {
115    /// Symbol ticker of instrument. For preffered stocks use dot(.) delimiter. E.g. `BRK.A` or `BRK.B` will be correct
116    pub symbol: Option<String>,
117    /// Filter by financial instrument global identifier (FIGI)
118    pub figi: Option<String>,
119    /// Filter by international securities identification number (ISIN)
120    pub isin: Option<String>,
121    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
122    pub cusip: Option<String>,
123    /// Exchange where instrument is traded
124    pub exchange: Option<String>,
125    /// Market Identifier Code (MIC) under ISO 10383 standard
126    pub mic_code: Option<String>,
127    /// Country where instrument is traded, e.g., `United States` or `US`
128    pub country: Option<String>,
129}
130
131impl GetFundHoldersParams {
132    /// Create a new builder for this parameter struct
133    pub fn builder() -> GetFundHoldersParamsBuilder {
134        GetFundHoldersParamsBuilder::default()
135    }
136}
137
138/// Builder for [`GetFundHoldersParams`]
139#[derive(Clone, Debug, Default)]
140pub struct GetFundHoldersParamsBuilder {
141    /// Symbol ticker of instrument. For preffered stocks use dot(.) delimiter. E.g. `BRK.A` or `BRK.B` will be correct
142    symbol: Option<String>,
143    /// Filter by financial instrument global identifier (FIGI)
144    figi: Option<String>,
145    /// Filter by international securities identification number (ISIN)
146    isin: Option<String>,
147    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
148    cusip: Option<String>,
149    /// Exchange where instrument is traded
150    exchange: Option<String>,
151    /// Market Identifier Code (MIC) under ISO 10383 standard
152    mic_code: Option<String>,
153    /// Country where instrument is traded, e.g., `United States` or `US`
154    country: Option<String>,
155}
156
157impl GetFundHoldersParamsBuilder {
158    /// Symbol ticker of instrument. For preffered stocks use dot(.) delimiter. E.g. `BRK.A` or `BRK.B` will be correct
159    pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
160        self.symbol = Some(symbol.into());
161        self
162    }
163    /// Filter by financial instrument global identifier (FIGI)
164    pub fn figi(mut self, figi: impl Into<String>) -> Self {
165        self.figi = Some(figi.into());
166        self
167    }
168    /// Filter by international securities identification number (ISIN)
169    pub fn isin(mut self, isin: impl Into<String>) -> Self {
170        self.isin = Some(isin.into());
171        self
172    }
173    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
174    pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
175        self.cusip = Some(cusip.into());
176        self
177    }
178    /// Exchange where instrument is traded
179    pub fn exchange(mut self, exchange: impl Into<String>) -> Self {
180        self.exchange = Some(exchange.into());
181        self
182    }
183    /// Market Identifier Code (MIC) under ISO 10383 standard
184    pub fn mic_code(mut self, mic_code: impl Into<String>) -> Self {
185        self.mic_code = Some(mic_code.into());
186        self
187    }
188    /// Country where instrument is traded, e.g., `United States` or `US`
189    pub fn country(mut self, country: impl Into<String>) -> Self {
190        self.country = Some(country.into());
191        self
192    }
193
194    /// Build the parameter struct
195    pub fn build(self) -> GetFundHoldersParams {
196        GetFundHoldersParams {
197            symbol: self.symbol,
198            figi: self.figi,
199            isin: self.isin,
200            cusip: self.cusip,
201            exchange: self.exchange,
202            mic_code: self.mic_code,
203            country: self.country,
204        }
205    }
206}
207
208/// struct for passing parameters to the method [`get_insider_transactions`]
209#[derive(Clone, Debug, Default, Serialize, Deserialize)]
210pub struct GetInsiderTransactionsParams {
211    /// The ticker symbol of an instrument for which data is requested, e.g., `AAPL`, `TSLA`. For preffered stocks use dot(.) delimiter. E.g. `BRK.A` or `BRK.B` will be correct
212    pub symbol: Option<String>,
213    /// Filter by financial instrument global identifier (FIGI)
214    pub figi: Option<String>,
215    /// Filter by international securities identification number (ISIN)
216    pub isin: Option<String>,
217    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
218    pub cusip: Option<String>,
219    /// Exchange where instrument is traded, e.g., `Nasdaq`, `NSE`
220    pub exchange: Option<String>,
221    /// Market Identifier Code (MIC) under ISO 10383 standard
222    pub mic_code: Option<String>,
223    /// Country where instrument is traded, e.g., United States or US.
224    pub country: Option<String>,
225}
226
227impl GetInsiderTransactionsParams {
228    /// Create a new builder for this parameter struct
229    pub fn builder() -> GetInsiderTransactionsParamsBuilder {
230        GetInsiderTransactionsParamsBuilder::default()
231    }
232}
233
234/// Builder for [`GetInsiderTransactionsParams`]
235#[derive(Clone, Debug, Default)]
236pub struct GetInsiderTransactionsParamsBuilder {
237    /// The ticker symbol of an instrument for which data is requested, e.g., `AAPL`, `TSLA`. For preffered stocks use dot(.) delimiter. E.g. `BRK.A` or `BRK.B` will be correct
238    symbol: Option<String>,
239    /// Filter by financial instrument global identifier (FIGI)
240    figi: Option<String>,
241    /// Filter by international securities identification number (ISIN)
242    isin: Option<String>,
243    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
244    cusip: Option<String>,
245    /// Exchange where instrument is traded, e.g., `Nasdaq`, `NSE`
246    exchange: Option<String>,
247    /// Market Identifier Code (MIC) under ISO 10383 standard
248    mic_code: Option<String>,
249    /// Country where instrument is traded, e.g., United States or US.
250    country: Option<String>,
251}
252
253impl GetInsiderTransactionsParamsBuilder {
254    /// The ticker symbol of an instrument for which data is requested, e.g., `AAPL`, `TSLA`. For preffered stocks use dot(.) delimiter. E.g. `BRK.A` or `BRK.B` will be correct
255    pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
256        self.symbol = Some(symbol.into());
257        self
258    }
259    /// Filter by financial instrument global identifier (FIGI)
260    pub fn figi(mut self, figi: impl Into<String>) -> Self {
261        self.figi = Some(figi.into());
262        self
263    }
264    /// Filter by international securities identification number (ISIN)
265    pub fn isin(mut self, isin: impl Into<String>) -> Self {
266        self.isin = Some(isin.into());
267        self
268    }
269    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
270    pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
271        self.cusip = Some(cusip.into());
272        self
273    }
274    /// Exchange where instrument is traded, e.g., `Nasdaq`, `NSE`
275    pub fn exchange(mut self, exchange: impl Into<String>) -> Self {
276        self.exchange = Some(exchange.into());
277        self
278    }
279    /// Market Identifier Code (MIC) under ISO 10383 standard
280    pub fn mic_code(mut self, mic_code: impl Into<String>) -> Self {
281        self.mic_code = Some(mic_code.into());
282        self
283    }
284    /// Country where instrument is traded, e.g., United States or US.
285    pub fn country(mut self, country: impl Into<String>) -> Self {
286        self.country = Some(country.into());
287        self
288    }
289
290    /// Build the parameter struct
291    pub fn build(self) -> GetInsiderTransactionsParams {
292        GetInsiderTransactionsParams {
293            symbol: self.symbol,
294            figi: self.figi,
295            isin: self.isin,
296            cusip: self.cusip,
297            exchange: self.exchange,
298            mic_code: self.mic_code,
299            country: self.country,
300        }
301    }
302}
303
304/// struct for passing parameters to the method [`get_institutional_holders`]
305#[derive(Clone, Debug, Default, Serialize, Deserialize)]
306pub struct GetInstitutionalHoldersParams {
307    /// Symbol ticker of instrument. For preffered stocks use dot(.) delimiter. E.g. `BRK.A` or `BRK.B` will be correct
308    pub symbol: Option<String>,
309    /// Filter by financial instrument global identifier (FIGI)
310    pub figi: Option<String>,
311    /// Filter by international securities identification number (ISIN)
312    pub isin: Option<String>,
313    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
314    pub cusip: Option<String>,
315    /// Exchange where instrument is traded
316    pub exchange: Option<String>,
317    /// Market Identifier Code (MIC) under ISO 10383 standard
318    pub mic_code: Option<String>,
319    /// Country where instrument is traded, e.g., `United States` or `US`
320    pub country: Option<String>,
321}
322
323impl GetInstitutionalHoldersParams {
324    /// Create a new builder for this parameter struct
325    pub fn builder() -> GetInstitutionalHoldersParamsBuilder {
326        GetInstitutionalHoldersParamsBuilder::default()
327    }
328}
329
330/// Builder for [`GetInstitutionalHoldersParams`]
331#[derive(Clone, Debug, Default)]
332pub struct GetInstitutionalHoldersParamsBuilder {
333    /// Symbol ticker of instrument. For preffered stocks use dot(.) delimiter. E.g. `BRK.A` or `BRK.B` will be correct
334    symbol: Option<String>,
335    /// Filter by financial instrument global identifier (FIGI)
336    figi: Option<String>,
337    /// Filter by international securities identification number (ISIN)
338    isin: Option<String>,
339    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
340    cusip: Option<String>,
341    /// Exchange where instrument is traded
342    exchange: Option<String>,
343    /// Market Identifier Code (MIC) under ISO 10383 standard
344    mic_code: Option<String>,
345    /// Country where instrument is traded, e.g., `United States` or `US`
346    country: Option<String>,
347}
348
349impl GetInstitutionalHoldersParamsBuilder {
350    /// Symbol ticker of instrument. For preffered stocks use dot(.) delimiter. E.g. `BRK.A` or `BRK.B` will be correct
351    pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
352        self.symbol = Some(symbol.into());
353        self
354    }
355    /// Filter by financial instrument global identifier (FIGI)
356    pub fn figi(mut self, figi: impl Into<String>) -> Self {
357        self.figi = Some(figi.into());
358        self
359    }
360    /// Filter by international securities identification number (ISIN)
361    pub fn isin(mut self, isin: impl Into<String>) -> Self {
362        self.isin = Some(isin.into());
363        self
364    }
365    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
366    pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
367        self.cusip = Some(cusip.into());
368        self
369    }
370    /// Exchange where instrument is traded
371    pub fn exchange(mut self, exchange: impl Into<String>) -> Self {
372        self.exchange = Some(exchange.into());
373        self
374    }
375    /// Market Identifier Code (MIC) under ISO 10383 standard
376    pub fn mic_code(mut self, mic_code: impl Into<String>) -> Self {
377        self.mic_code = Some(mic_code.into());
378        self
379    }
380    /// Country where instrument is traded, e.g., `United States` or `US`
381    pub fn country(mut self, country: impl Into<String>) -> Self {
382        self.country = Some(country.into());
383        self
384    }
385
386    /// Build the parameter struct
387    pub fn build(self) -> GetInstitutionalHoldersParams {
388        GetInstitutionalHoldersParams {
389            symbol: self.symbol,
390            figi: self.figi,
391            isin: self.isin,
392            cusip: self.cusip,
393            exchange: self.exchange,
394            mic_code: self.mic_code,
395            country: self.country,
396        }
397    }
398}
399
400/// struct for passing parameters to the method [`get_source_sanctioned_entities`]
401#[derive(Clone, Debug, Default, Serialize, Deserialize)]
402pub struct GetSourceSanctionedEntitiesParams {
403    /// Sanctions source
404    pub source: String,
405}
406
407impl GetSourceSanctionedEntitiesParams {
408    /// Create a new builder for this parameter struct
409    pub fn builder() -> GetSourceSanctionedEntitiesParamsBuilder {
410        GetSourceSanctionedEntitiesParamsBuilder::default()
411    }
412}
413
414/// Builder for [`GetSourceSanctionedEntitiesParams`]
415#[derive(Clone, Debug, Default)]
416pub struct GetSourceSanctionedEntitiesParamsBuilder {
417    /// Sanctions source
418    source: String,
419}
420
421impl GetSourceSanctionedEntitiesParamsBuilder {
422    /// Sanctions source
423    pub fn source(mut self, source: impl Into<String>) -> Self {
424        self.source = source.into();
425        self
426    }
427
428    /// Build the parameter struct
429    pub fn build(self) -> GetSourceSanctionedEntitiesParams {
430        GetSourceSanctionedEntitiesParams {
431            source: self.source,
432        }
433    }
434}
435
436/// struct for passing parameters to the method [`get_tax_info`]
437#[derive(Clone, Debug, Default, Serialize, Deserialize)]
438pub struct GetTaxInfoParams {
439    /// The ticker symbol of an instrument for which data is requested, e.g., `SKYQ`, `AIRE`, `ALM:BME`, `HSI:HKEX`.
440    pub symbol: Option<String>,
441    /// The ISIN of an instrument for which data is requested
442    pub isin: Option<String>,
443    /// The FIGI of an instrument for which data is requested
444    pub figi: Option<String>,
445    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
446    pub cusip: Option<String>,
447    /// The exchange name where the instrument is traded, e.g., `Nasdaq`, `Euronext`
448    pub exchange: Option<String>,
449    /// The Market Identifier Code (MIC) of the exchange where the instrument is traded, e.g., `XNAS`, `XLON`
450    pub mic_code: Option<String>,
451}
452
453impl GetTaxInfoParams {
454    /// Create a new builder for this parameter struct
455    pub fn builder() -> GetTaxInfoParamsBuilder {
456        GetTaxInfoParamsBuilder::default()
457    }
458}
459
460/// Builder for [`GetTaxInfoParams`]
461#[derive(Clone, Debug, Default)]
462pub struct GetTaxInfoParamsBuilder {
463    /// The ticker symbol of an instrument for which data is requested, e.g., `SKYQ`, `AIRE`, `ALM:BME`, `HSI:HKEX`.
464    symbol: Option<String>,
465    /// The ISIN of an instrument for which data is requested
466    isin: Option<String>,
467    /// The FIGI of an instrument for which data is requested
468    figi: Option<String>,
469    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
470    cusip: Option<String>,
471    /// The exchange name where the instrument is traded, e.g., `Nasdaq`, `Euronext`
472    exchange: Option<String>,
473    /// The Market Identifier Code (MIC) of the exchange where the instrument is traded, e.g., `XNAS`, `XLON`
474    mic_code: Option<String>,
475}
476
477impl GetTaxInfoParamsBuilder {
478    /// The ticker symbol of an instrument for which data is requested, e.g., `SKYQ`, `AIRE`, `ALM:BME`, `HSI:HKEX`.
479    pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
480        self.symbol = Some(symbol.into());
481        self
482    }
483    /// The ISIN of an instrument for which data is requested
484    pub fn isin(mut self, isin: impl Into<String>) -> Self {
485        self.isin = Some(isin.into());
486        self
487    }
488    /// The FIGI of an instrument for which data is requested
489    pub fn figi(mut self, figi: impl Into<String>) -> Self {
490        self.figi = Some(figi.into());
491        self
492    }
493    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
494    pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
495        self.cusip = Some(cusip.into());
496        self
497    }
498    /// The exchange name where the instrument is traded, e.g., `Nasdaq`, `Euronext`
499    pub fn exchange(mut self, exchange: impl Into<String>) -> Self {
500        self.exchange = Some(exchange.into());
501        self
502    }
503    /// The Market Identifier Code (MIC) of the exchange where the instrument is traded, e.g., `XNAS`, `XLON`
504    pub fn mic_code(mut self, mic_code: impl Into<String>) -> Self {
505        self.mic_code = Some(mic_code.into());
506        self
507    }
508
509    /// Build the parameter struct
510    pub fn build(self) -> GetTaxInfoParams {
511        GetTaxInfoParams {
512            symbol: self.symbol,
513            isin: self.isin,
514            figi: self.figi,
515            cusip: self.cusip,
516            exchange: self.exchange,
517            mic_code: self.mic_code,
518        }
519    }
520}
521
522/// struct for typed errors of method [`get_direct_holders`]
523#[derive(Debug, Clone, Serialize, Deserialize)]
524#[serde(untagged)]
525pub enum GetDirectHoldersError {
526    UnknownValue(serde_json::Value),
527}
528
529/// struct for typed errors of method [`get_fund_holders`]
530#[derive(Debug, Clone, Serialize, Deserialize)]
531#[serde(untagged)]
532pub enum GetFundHoldersError {
533    UnknownValue(serde_json::Value),
534}
535
536/// struct for typed errors of method [`get_insider_transactions`]
537#[derive(Debug, Clone, Serialize, Deserialize)]
538#[serde(untagged)]
539pub enum GetInsiderTransactionsError {
540    UnknownValue(serde_json::Value),
541}
542
543/// struct for typed errors of method [`get_institutional_holders`]
544#[derive(Debug, Clone, Serialize, Deserialize)]
545#[serde(untagged)]
546pub enum GetInstitutionalHoldersError {
547    UnknownValue(serde_json::Value),
548}
549
550/// struct for typed errors of method [`get_source_sanctioned_entities`]
551#[derive(Debug, Clone, Serialize, Deserialize)]
552#[serde(untagged)]
553pub enum GetSourceSanctionedEntitiesError {
554    UnknownValue(serde_json::Value),
555}
556
557/// struct for typed errors of method [`get_tax_info`]
558#[derive(Debug, Clone, Serialize, Deserialize)]
559#[serde(untagged)]
560pub enum GetTaxInfoError {
561    UnknownValue(serde_json::Value),
562}
563
564/// The direct holders endpoint provides detailed information about the number of shares directly held by individuals or entities as recorded in a company's official share registry. This data is essential for understanding the distribution of stock ownership within a company, helping users identify major shareholders and assess shareholder concentration.
565pub async fn get_direct_holders(
566    configuration: &configuration::Configuration,
567    params: GetDirectHoldersParams,
568) -> Result<models::GetDirectHoldersResponse, Error<GetDirectHoldersError>> {
569    // Extract parameters from params struct
570    let p_query_symbol = params.symbol;
571    let p_query_figi = params.figi;
572    let p_query_isin = params.isin;
573    let p_query_cusip = params.cusip;
574    let p_query_exchange = params.exchange;
575    let p_query_mic_code = params.mic_code;
576    let p_query_country = params.country;
577
578    let uri_str = format!("{}/direct_holders", configuration.base_path);
579    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
580
581    if let Some(ref param_value) = p_query_symbol {
582        req_builder = req_builder.query(&[("symbol", &param_value.to_string())]);
583    }
584    if let Some(ref param_value) = p_query_figi {
585        req_builder = req_builder.query(&[("figi", &param_value.to_string())]);
586    }
587    if let Some(ref param_value) = p_query_isin {
588        req_builder = req_builder.query(&[("isin", &param_value.to_string())]);
589    }
590    if let Some(ref param_value) = p_query_cusip {
591        req_builder = req_builder.query(&[("cusip", &param_value.to_string())]);
592    }
593    if let Some(ref param_value) = p_query_exchange {
594        req_builder = req_builder.query(&[("exchange", &param_value.to_string())]);
595    }
596    if let Some(ref param_value) = p_query_mic_code {
597        req_builder = req_builder.query(&[("mic_code", &param_value.to_string())]);
598    }
599    if let Some(ref param_value) = p_query_country {
600        req_builder = req_builder.query(&[("country", &param_value.to_string())]);
601    }
602    if let Some(ref user_agent) = configuration.user_agent {
603        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
604    }
605    if let Some(ref apikey) = configuration.api_key {
606        let key = apikey.key.clone();
607        let value = match apikey.prefix {
608            Some(ref prefix) => format!("{} {}", prefix, key),
609            None => key,
610        };
611        req_builder = req_builder.header("Authorization", value);
612    };
613
614    let req = req_builder.build()?;
615    let resp = configuration.client.execute(req).await?;
616
617    let status = resp.status();
618    let content_type = resp
619        .headers()
620        .get("content-type")
621        .and_then(|v| v.to_str().ok())
622        .unwrap_or("application/octet-stream");
623    let content_type = super::ContentType::from(content_type);
624
625    if !status.is_client_error() && !status.is_server_error() {
626        let content = resp.text().await?;
627        match content_type {
628            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
629            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/*` content type response that cannot be converted to `models::GetDirectHoldersResponse`"))),
630            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetDirectHoldersResponse`")))),
631        }
632    } else {
633        let content = resp.text().await?;
634        let entity: Option<GetDirectHoldersError> = serde_json::from_str(&content).ok();
635        Err(Error::ResponseError(ResponseContent {
636            status,
637            content,
638            entity,
639        }))
640    }
641}
642
643/// The fund holders endpoint provides detailed information about the proportion of a company's stock that is owned by mutual fund holders. It returns data on the number of shares held, the percentage of total shares outstanding, and the names of the mutual funds involved. This endpoint is useful for users looking to understand mutual fund investment in a specific company.
644pub async fn get_fund_holders(
645    configuration: &configuration::Configuration,
646    params: GetFundHoldersParams,
647) -> Result<models::GetFundHoldersResponse, Error<GetFundHoldersError>> {
648    // Extract parameters from params struct
649    let p_query_symbol = params.symbol;
650    let p_query_figi = params.figi;
651    let p_query_isin = params.isin;
652    let p_query_cusip = params.cusip;
653    let p_query_exchange = params.exchange;
654    let p_query_mic_code = params.mic_code;
655    let p_query_country = params.country;
656
657    let uri_str = format!("{}/fund_holders", configuration.base_path);
658    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
659
660    if let Some(ref param_value) = p_query_symbol {
661        req_builder = req_builder.query(&[("symbol", &param_value.to_string())]);
662    }
663    if let Some(ref param_value) = p_query_figi {
664        req_builder = req_builder.query(&[("figi", &param_value.to_string())]);
665    }
666    if let Some(ref param_value) = p_query_isin {
667        req_builder = req_builder.query(&[("isin", &param_value.to_string())]);
668    }
669    if let Some(ref param_value) = p_query_cusip {
670        req_builder = req_builder.query(&[("cusip", &param_value.to_string())]);
671    }
672    if let Some(ref param_value) = p_query_exchange {
673        req_builder = req_builder.query(&[("exchange", &param_value.to_string())]);
674    }
675    if let Some(ref param_value) = p_query_mic_code {
676        req_builder = req_builder.query(&[("mic_code", &param_value.to_string())]);
677    }
678    if let Some(ref param_value) = p_query_country {
679        req_builder = req_builder.query(&[("country", &param_value.to_string())]);
680    }
681    if let Some(ref user_agent) = configuration.user_agent {
682        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
683    }
684    if let Some(ref apikey) = configuration.api_key {
685        let key = apikey.key.clone();
686        let value = match apikey.prefix {
687            Some(ref prefix) => format!("{} {}", prefix, key),
688            None => key,
689        };
690        req_builder = req_builder.header("Authorization", value);
691    };
692
693    let req = req_builder.build()?;
694    let resp = configuration.client.execute(req).await?;
695
696    let status = resp.status();
697    let content_type = resp
698        .headers()
699        .get("content-type")
700        .and_then(|v| v.to_str().ok())
701        .unwrap_or("application/octet-stream");
702    let content_type = super::ContentType::from(content_type);
703
704    if !status.is_client_error() && !status.is_server_error() {
705        let content = resp.text().await?;
706        match content_type {
707            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
708            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/*` content type response that cannot be converted to `models::GetFundHoldersResponse`"))),
709            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetFundHoldersResponse`")))),
710        }
711    } else {
712        let content = resp.text().await?;
713        let entity: Option<GetFundHoldersError> = serde_json::from_str(&content).ok();
714        Err(Error::ResponseError(ResponseContent {
715            status,
716            content,
717            entity,
718        }))
719    }
720}
721
722/// The insider transaction endpoint provides detailed data on trades executed by company insiders, such as executives and directors. It returns information including the insider's name, their role, the transaction type, the number of shares, the transaction date, and the price per share. This endpoint is useful for tracking insider activity and understanding potential insider sentiment towards a company's stock.
723pub async fn get_insider_transactions(
724    configuration: &configuration::Configuration,
725    params: GetInsiderTransactionsParams,
726) -> Result<models::GetInsiderTransactionsResponse, Error<GetInsiderTransactionsError>> {
727    // Extract parameters from params struct
728    let p_query_symbol = params.symbol;
729    let p_query_figi = params.figi;
730    let p_query_isin = params.isin;
731    let p_query_cusip = params.cusip;
732    let p_query_exchange = params.exchange;
733    let p_query_mic_code = params.mic_code;
734    let p_query_country = params.country;
735
736    let uri_str = format!("{}/insider_transactions", configuration.base_path);
737    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
738
739    if let Some(ref param_value) = p_query_symbol {
740        req_builder = req_builder.query(&[("symbol", &param_value.to_string())]);
741    }
742    if let Some(ref param_value) = p_query_figi {
743        req_builder = req_builder.query(&[("figi", &param_value.to_string())]);
744    }
745    if let Some(ref param_value) = p_query_isin {
746        req_builder = req_builder.query(&[("isin", &param_value.to_string())]);
747    }
748    if let Some(ref param_value) = p_query_cusip {
749        req_builder = req_builder.query(&[("cusip", &param_value.to_string())]);
750    }
751    if let Some(ref param_value) = p_query_exchange {
752        req_builder = req_builder.query(&[("exchange", &param_value.to_string())]);
753    }
754    if let Some(ref param_value) = p_query_mic_code {
755        req_builder = req_builder.query(&[("mic_code", &param_value.to_string())]);
756    }
757    if let Some(ref param_value) = p_query_country {
758        req_builder = req_builder.query(&[("country", &param_value.to_string())]);
759    }
760    if let Some(ref user_agent) = configuration.user_agent {
761        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
762    }
763    if let Some(ref apikey) = configuration.api_key {
764        let key = apikey.key.clone();
765        let value = match apikey.prefix {
766            Some(ref prefix) => format!("{} {}", prefix, key),
767            None => key,
768        };
769        req_builder = req_builder.header("Authorization", value);
770    };
771
772    let req = req_builder.build()?;
773    let resp = configuration.client.execute(req).await?;
774
775    let status = resp.status();
776    let content_type = resp
777        .headers()
778        .get("content-type")
779        .and_then(|v| v.to_str().ok())
780        .unwrap_or("application/octet-stream");
781    let content_type = super::ContentType::from(content_type);
782
783    if !status.is_client_error() && !status.is_server_error() {
784        let content = resp.text().await?;
785        match content_type {
786            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
787            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/*` content type response that cannot be converted to `models::GetInsiderTransactionsResponse`"))),
788            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetInsiderTransactionsResponse`")))),
789        }
790    } else {
791        let content = resp.text().await?;
792        let entity: Option<GetInsiderTransactionsError> = serde_json::from_str(&content).ok();
793        Err(Error::ResponseError(ResponseContent {
794            status,
795            content,
796            entity,
797        }))
798    }
799}
800
801/// The institutional holders endpoint provides detailed information on the percentage and amount of a company's stock owned by institutional investors, such as pension funds, insurance companies, and investment firms. This data is essential for understanding the influence and involvement of large entities in a company's ownership structure.
802pub async fn get_institutional_holders(
803    configuration: &configuration::Configuration,
804    params: GetInstitutionalHoldersParams,
805) -> Result<models::GetInstitutionalHoldersResponse, Error<GetInstitutionalHoldersError>> {
806    // Extract parameters from params struct
807    let p_query_symbol = params.symbol;
808    let p_query_figi = params.figi;
809    let p_query_isin = params.isin;
810    let p_query_cusip = params.cusip;
811    let p_query_exchange = params.exchange;
812    let p_query_mic_code = params.mic_code;
813    let p_query_country = params.country;
814
815    let uri_str = format!("{}/institutional_holders", configuration.base_path);
816    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
817
818    if let Some(ref param_value) = p_query_symbol {
819        req_builder = req_builder.query(&[("symbol", &param_value.to_string())]);
820    }
821    if let Some(ref param_value) = p_query_figi {
822        req_builder = req_builder.query(&[("figi", &param_value.to_string())]);
823    }
824    if let Some(ref param_value) = p_query_isin {
825        req_builder = req_builder.query(&[("isin", &param_value.to_string())]);
826    }
827    if let Some(ref param_value) = p_query_cusip {
828        req_builder = req_builder.query(&[("cusip", &param_value.to_string())]);
829    }
830    if let Some(ref param_value) = p_query_exchange {
831        req_builder = req_builder.query(&[("exchange", &param_value.to_string())]);
832    }
833    if let Some(ref param_value) = p_query_mic_code {
834        req_builder = req_builder.query(&[("mic_code", &param_value.to_string())]);
835    }
836    if let Some(ref param_value) = p_query_country {
837        req_builder = req_builder.query(&[("country", &param_value.to_string())]);
838    }
839    if let Some(ref user_agent) = configuration.user_agent {
840        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
841    }
842    if let Some(ref apikey) = configuration.api_key {
843        let key = apikey.key.clone();
844        let value = match apikey.prefix {
845            Some(ref prefix) => format!("{} {}", prefix, key),
846            None => key,
847        };
848        req_builder = req_builder.header("Authorization", value);
849    };
850
851    let req = req_builder.build()?;
852    let resp = configuration.client.execute(req).await?;
853
854    let status = resp.status();
855    let content_type = resp
856        .headers()
857        .get("content-type")
858        .and_then(|v| v.to_str().ok())
859        .unwrap_or("application/octet-stream");
860    let content_type = super::ContentType::from(content_type);
861
862    if !status.is_client_error() && !status.is_server_error() {
863        let content = resp.text().await?;
864        match content_type {
865            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
866            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/*` content type response that cannot be converted to `models::GetInstitutionalHoldersResponse`"))),
867            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetInstitutionalHoldersResponse`")))),
868        }
869    } else {
870        let content = resp.text().await?;
871        let entity: Option<GetInstitutionalHoldersError> = serde_json::from_str(&content).ok();
872        Err(Error::ResponseError(ResponseContent {
873            status,
874            content,
875            entity,
876        }))
877    }
878}
879
880/// The sanctions entities endpoint provides a comprehensive list of entities sanctioned by a specified authority, such as OFAC, UK, EU, or AU. Users can retrieve detailed information about individuals, organizations, and other entities subject to sanctions from the chosen source, facilitating compliance and risk management processes.
881pub async fn get_source_sanctioned_entities(
882    configuration: &configuration::Configuration,
883    params: GetSourceSanctionedEntitiesParams,
884) -> Result<models::GetSourceSanctionedEntitiesResponse, Error<GetSourceSanctionedEntitiesError>> {
885    // Extract parameters from params struct
886    let p_path_source = params.source;
887
888    let uri_str = format!(
889        "{}/sanctions/{source}",
890        configuration.base_path,
891        source = crate::apis::urlencode(p_path_source)
892    );
893    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
894
895    if let Some(ref user_agent) = configuration.user_agent {
896        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
897    }
898    if let Some(ref apikey) = configuration.api_key {
899        let key = apikey.key.clone();
900        let value = match apikey.prefix {
901            Some(ref prefix) => format!("{} {}", prefix, key),
902            None => key,
903        };
904        req_builder = req_builder.header("Authorization", value);
905    };
906
907    let req = req_builder.build()?;
908    let resp = configuration.client.execute(req).await?;
909
910    let status = resp.status();
911    let content_type = resp
912        .headers()
913        .get("content-type")
914        .and_then(|v| v.to_str().ok())
915        .unwrap_or("application/octet-stream");
916    let content_type = super::ContentType::from(content_type);
917
918    if !status.is_client_error() && !status.is_server_error() {
919        let content = resp.text().await?;
920        match content_type {
921            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
922            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/*` content type response that cannot be converted to `models::GetSourceSanctionedEntitiesResponse`"))),
923            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetSourceSanctionedEntitiesResponse`")))),
924        }
925    } else {
926        let content = resp.text().await?;
927        let entity: Option<GetSourceSanctionedEntitiesError> = serde_json::from_str(&content).ok();
928        Err(Error::ResponseError(ResponseContent {
929            status,
930            content,
931            entity,
932        }))
933    }
934}
935
936/// The tax information endpoint provides detailed tax-related data for a specified financial instrument, including applicable tax rates and relevant tax codes. This information is essential for users needing to understand the tax implications associated with trading or investing in specific instruments.
937pub async fn get_tax_info(
938    configuration: &configuration::Configuration,
939    params: GetTaxInfoParams,
940) -> Result<models::GetTaxInfoResponse, Error<GetTaxInfoError>> {
941    // Extract parameters from params struct
942    let p_query_symbol = params.symbol;
943    let p_query_isin = params.isin;
944    let p_query_figi = params.figi;
945    let p_query_cusip = params.cusip;
946    let p_query_exchange = params.exchange;
947    let p_query_mic_code = params.mic_code;
948
949    let uri_str = format!("{}/tax_info", configuration.base_path);
950    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
951
952    if let Some(ref param_value) = p_query_symbol {
953        req_builder = req_builder.query(&[("symbol", &param_value.to_string())]);
954    }
955    if let Some(ref param_value) = p_query_isin {
956        req_builder = req_builder.query(&[("isin", &param_value.to_string())]);
957    }
958    if let Some(ref param_value) = p_query_figi {
959        req_builder = req_builder.query(&[("figi", &param_value.to_string())]);
960    }
961    if let Some(ref param_value) = p_query_cusip {
962        req_builder = req_builder.query(&[("cusip", &param_value.to_string())]);
963    }
964    if let Some(ref param_value) = p_query_exchange {
965        req_builder = req_builder.query(&[("exchange", &param_value.to_string())]);
966    }
967    if let Some(ref param_value) = p_query_mic_code {
968        req_builder = req_builder.query(&[("mic_code", &param_value.to_string())]);
969    }
970    if let Some(ref user_agent) = configuration.user_agent {
971        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
972    }
973    if let Some(ref apikey) = configuration.api_key {
974        let key = apikey.key.clone();
975        let value = match apikey.prefix {
976            Some(ref prefix) => format!("{} {}", prefix, key),
977            None => key,
978        };
979        req_builder = req_builder.header("Authorization", value);
980    };
981
982    let req = req_builder.build()?;
983    let resp = configuration.client.execute(req).await?;
984
985    let status = resp.status();
986    let content_type = resp
987        .headers()
988        .get("content-type")
989        .and_then(|v| v.to_str().ok())
990        .unwrap_or("application/octet-stream");
991    let content_type = super::ContentType::from(content_type);
992
993    if !status.is_client_error() && !status.is_server_error() {
994        let content = resp.text().await?;
995        match content_type {
996            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
997            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/*` content type response that cannot be converted to `models::GetTaxInfoResponse`"))),
998            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetTaxInfoResponse`")))),
999        }
1000    } else {
1001        let content = resp.text().await?;
1002        let entity: Option<GetTaxInfoError> = serde_json::from_str(&content).ok();
1003        Err(Error::ResponseError(ResponseContent {
1004            status,
1005            content,
1006            entity,
1007        }))
1008    }
1009}