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
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17/// struct for passing parameters to the method [`get_direct_holders`]
18#[derive(Clone, Debug, Default, Serialize, Deserialize)]
19pub struct GetDirectHoldersParams {
20    /// Symbol ticker of instrument. For preffered stocks use dot(.) delimiter. E.g. `BRK.A` or `BRK.B` will be correct
21    pub symbol: Option<String>,
22    /// Filter by financial instrument global identifier (FIGI)
23    pub figi: Option<String>,
24    /// Filter by international securities identification number (ISIN)
25    pub isin: Option<String>,
26    /// 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
27    pub cusip: Option<String>,
28    /// Exchange where instrument is traded
29    pub exchange: Option<String>,
30    /// Market Identifier Code (MIC) under ISO 10383 standard
31    pub mic_code: Option<String>,
32    /// Country where instrument is traded, e.g., `United States` or `US`
33    pub country: Option<String>
34}
35
36impl GetDirectHoldersParams {
37    /// Create a new builder for this parameter struct
38    pub fn builder() -> GetDirectHoldersParamsBuilder {
39        GetDirectHoldersParamsBuilder::default()
40    }
41}
42
43/// Builder for [`GetDirectHoldersParams`]
44#[derive(Clone, Debug, Default)]
45pub struct GetDirectHoldersParamsBuilder {
46    /// Symbol ticker of instrument. For preffered stocks use dot(.) delimiter. E.g. `BRK.A` or `BRK.B` will be correct
47    symbol: Option<String>,
48    /// Filter by financial instrument global identifier (FIGI)
49    figi: Option<String>,
50    /// Filter by international securities identification number (ISIN)
51    isin: Option<String>,
52    /// 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
53    cusip: Option<String>,
54    /// Exchange where instrument is traded
55    exchange: Option<String>,
56    /// Market Identifier Code (MIC) under ISO 10383 standard
57    mic_code: Option<String>,
58    /// Country where instrument is traded, e.g., `United States` or `US`
59    country: Option<String>
60}
61
62impl GetDirectHoldersParamsBuilder {
63    /// Symbol ticker of instrument. For preffered stocks use dot(.) delimiter. E.g. `BRK.A` or `BRK.B` will be correct
64    pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
65        self.symbol = Some(symbol.into());
66        self
67    }
68    /// Filter by financial instrument global identifier (FIGI)
69    pub fn figi(mut self, figi: impl Into<String>) -> Self {
70        self.figi = Some(figi.into());
71        self
72    }
73    /// Filter by international securities identification number (ISIN)
74    pub fn isin(mut self, isin: impl Into<String>) -> Self {
75        self.isin = Some(isin.into());
76        self
77    }
78    /// 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
79    pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
80        self.cusip = Some(cusip.into());
81        self
82    }
83    /// Exchange where instrument is traded
84    pub fn exchange(mut self, exchange: impl Into<String>) -> Self {
85        self.exchange = Some(exchange.into());
86        self
87    }
88    /// Market Identifier Code (MIC) under ISO 10383 standard
89    pub fn mic_code(mut self, mic_code: impl Into<String>) -> Self {
90        self.mic_code = Some(mic_code.into());
91        self
92    }
93    /// Country where instrument is traded, e.g., `United States` or `US`
94    pub fn country(mut self, country: impl Into<String>) -> Self {
95        self.country = Some(country.into());
96        self
97    }
98
99    /// Build the parameter struct
100    pub fn build(self) -> GetDirectHoldersParams {
101        GetDirectHoldersParams {
102            symbol: self.symbol,
103            figi: self.figi,
104            isin: self.isin,
105            cusip: self.cusip,
106            exchange: self.exchange,
107            mic_code: self.mic_code,
108            country: self.country
109        }
110    }
111}
112
113/// struct for passing parameters to the method [`get_fund_holders`]
114#[derive(Clone, Debug, Default, Serialize, Deserialize)]
115pub struct GetFundHoldersParams {
116    /// Symbol ticker of instrument. For preffered stocks use dot(.) delimiter. E.g. `BRK.A` or `BRK.B` will be correct
117    pub symbol: Option<String>,
118    /// Filter by financial instrument global identifier (FIGI)
119    pub figi: Option<String>,
120    /// Filter by international securities identification number (ISIN)
121    pub isin: Option<String>,
122    /// 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
123    pub cusip: Option<String>,
124    /// Exchange where instrument is traded
125    pub exchange: Option<String>,
126    /// Market Identifier Code (MIC) under ISO 10383 standard
127    pub mic_code: Option<String>,
128    /// Country where instrument is traded, e.g., `United States` or `US`
129    pub country: Option<String>
130}
131
132impl GetFundHoldersParams {
133    /// Create a new builder for this parameter struct
134    pub fn builder() -> GetFundHoldersParamsBuilder {
135        GetFundHoldersParamsBuilder::default()
136    }
137}
138
139/// Builder for [`GetFundHoldersParams`]
140#[derive(Clone, Debug, Default)]
141pub struct GetFundHoldersParamsBuilder {
142    /// Symbol ticker of instrument. For preffered stocks use dot(.) delimiter. E.g. `BRK.A` or `BRK.B` will be correct
143    symbol: Option<String>,
144    /// Filter by financial instrument global identifier (FIGI)
145    figi: Option<String>,
146    /// Filter by international securities identification number (ISIN)
147    isin: Option<String>,
148    /// 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
149    cusip: Option<String>,
150    /// Exchange where instrument is traded
151    exchange: Option<String>,
152    /// Market Identifier Code (MIC) under ISO 10383 standard
153    mic_code: Option<String>,
154    /// Country where instrument is traded, e.g., `United States` or `US`
155    country: Option<String>
156}
157
158impl GetFundHoldersParamsBuilder {
159    /// Symbol ticker of instrument. For preffered stocks use dot(.) delimiter. E.g. `BRK.A` or `BRK.B` will be correct
160    pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
161        self.symbol = Some(symbol.into());
162        self
163    }
164    /// Filter by financial instrument global identifier (FIGI)
165    pub fn figi(mut self, figi: impl Into<String>) -> Self {
166        self.figi = Some(figi.into());
167        self
168    }
169    /// Filter by international securities identification number (ISIN)
170    pub fn isin(mut self, isin: impl Into<String>) -> Self {
171        self.isin = Some(isin.into());
172        self
173    }
174    /// 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
175    pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
176        self.cusip = Some(cusip.into());
177        self
178    }
179    /// Exchange where instrument is traded
180    pub fn exchange(mut self, exchange: impl Into<String>) -> Self {
181        self.exchange = Some(exchange.into());
182        self
183    }
184    /// Market Identifier Code (MIC) under ISO 10383 standard
185    pub fn mic_code(mut self, mic_code: impl Into<String>) -> Self {
186        self.mic_code = Some(mic_code.into());
187        self
188    }
189    /// Country where instrument is traded, e.g., `United States` or `US`
190    pub fn country(mut self, country: impl Into<String>) -> Self {
191        self.country = Some(country.into());
192        self
193    }
194
195    /// Build the parameter struct
196    pub fn build(self) -> GetFundHoldersParams {
197        GetFundHoldersParams {
198            symbol: self.symbol,
199            figi: self.figi,
200            isin: self.isin,
201            cusip: self.cusip,
202            exchange: self.exchange,
203            mic_code: self.mic_code,
204            country: self.country
205        }
206    }
207}
208
209/// struct for passing parameters to the method [`get_insider_transactions`]
210#[derive(Clone, Debug, Default, Serialize, Deserialize)]
211pub struct GetInsiderTransactionsParams {
212    /// 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
213    pub symbol: Option<String>,
214    /// Filter by financial instrument global identifier (FIGI)
215    pub figi: Option<String>,
216    /// Filter by international securities identification number (ISIN)
217    pub isin: Option<String>,
218    /// 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
219    pub cusip: Option<String>,
220    /// Exchange where instrument is traded, e.g., `Nasdaq`, `NSE`
221    pub exchange: Option<String>,
222    /// Market Identifier Code (MIC) under ISO 10383 standard
223    pub mic_code: Option<String>,
224    /// Country where instrument is traded, e.g., United States or US.
225    pub country: Option<String>
226}
227
228impl GetInsiderTransactionsParams {
229    /// Create a new builder for this parameter struct
230    pub fn builder() -> GetInsiderTransactionsParamsBuilder {
231        GetInsiderTransactionsParamsBuilder::default()
232    }
233}
234
235/// Builder for [`GetInsiderTransactionsParams`]
236#[derive(Clone, Debug, Default)]
237pub struct GetInsiderTransactionsParamsBuilder {
238    /// 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
239    symbol: Option<String>,
240    /// Filter by financial instrument global identifier (FIGI)
241    figi: Option<String>,
242    /// Filter by international securities identification number (ISIN)
243    isin: Option<String>,
244    /// 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
245    cusip: Option<String>,
246    /// Exchange where instrument is traded, e.g., `Nasdaq`, `NSE`
247    exchange: Option<String>,
248    /// Market Identifier Code (MIC) under ISO 10383 standard
249    mic_code: Option<String>,
250    /// Country where instrument is traded, e.g., United States or US.
251    country: Option<String>
252}
253
254impl GetInsiderTransactionsParamsBuilder {
255    /// 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
256    pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
257        self.symbol = Some(symbol.into());
258        self
259    }
260    /// Filter by financial instrument global identifier (FIGI)
261    pub fn figi(mut self, figi: impl Into<String>) -> Self {
262        self.figi = Some(figi.into());
263        self
264    }
265    /// Filter by international securities identification number (ISIN)
266    pub fn isin(mut self, isin: impl Into<String>) -> Self {
267        self.isin = Some(isin.into());
268        self
269    }
270    /// 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
271    pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
272        self.cusip = Some(cusip.into());
273        self
274    }
275    /// Exchange where instrument is traded, e.g., `Nasdaq`, `NSE`
276    pub fn exchange(mut self, exchange: impl Into<String>) -> Self {
277        self.exchange = Some(exchange.into());
278        self
279    }
280    /// Market Identifier Code (MIC) under ISO 10383 standard
281    pub fn mic_code(mut self, mic_code: impl Into<String>) -> Self {
282        self.mic_code = Some(mic_code.into());
283        self
284    }
285    /// Country where instrument is traded, e.g., United States or US.
286    pub fn country(mut self, country: impl Into<String>) -> Self {
287        self.country = Some(country.into());
288        self
289    }
290
291    /// Build the parameter struct
292    pub fn build(self) -> GetInsiderTransactionsParams {
293        GetInsiderTransactionsParams {
294            symbol: self.symbol,
295            figi: self.figi,
296            isin: self.isin,
297            cusip: self.cusip,
298            exchange: self.exchange,
299            mic_code: self.mic_code,
300            country: self.country
301        }
302    }
303}
304
305/// struct for passing parameters to the method [`get_institutional_holders`]
306#[derive(Clone, Debug, Default, Serialize, Deserialize)]
307pub struct GetInstitutionalHoldersParams {
308    /// Symbol ticker of instrument. For preffered stocks use dot(.) delimiter. E.g. `BRK.A` or `BRK.B` will be correct
309    pub symbol: Option<String>,
310    /// Filter by financial instrument global identifier (FIGI)
311    pub figi: Option<String>,
312    /// Filter by international securities identification number (ISIN)
313    pub isin: Option<String>,
314    /// 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
315    pub cusip: Option<String>,
316    /// Exchange where instrument is traded
317    pub exchange: Option<String>,
318    /// Market Identifier Code (MIC) under ISO 10383 standard
319    pub mic_code: Option<String>,
320    /// Country where instrument is traded, e.g., `United States` or `US`
321    pub country: Option<String>
322}
323
324impl GetInstitutionalHoldersParams {
325    /// Create a new builder for this parameter struct
326    pub fn builder() -> GetInstitutionalHoldersParamsBuilder {
327        GetInstitutionalHoldersParamsBuilder::default()
328    }
329}
330
331/// Builder for [`GetInstitutionalHoldersParams`]
332#[derive(Clone, Debug, Default)]
333pub struct GetInstitutionalHoldersParamsBuilder {
334    /// Symbol ticker of instrument. For preffered stocks use dot(.) delimiter. E.g. `BRK.A` or `BRK.B` will be correct
335    symbol: Option<String>,
336    /// Filter by financial instrument global identifier (FIGI)
337    figi: Option<String>,
338    /// Filter by international securities identification number (ISIN)
339    isin: Option<String>,
340    /// 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
341    cusip: Option<String>,
342    /// Exchange where instrument is traded
343    exchange: Option<String>,
344    /// Market Identifier Code (MIC) under ISO 10383 standard
345    mic_code: Option<String>,
346    /// Country where instrument is traded, e.g., `United States` or `US`
347    country: Option<String>
348}
349
350impl GetInstitutionalHoldersParamsBuilder {
351    /// Symbol ticker of instrument. For preffered stocks use dot(.) delimiter. E.g. `BRK.A` or `BRK.B` will be correct
352    pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
353        self.symbol = Some(symbol.into());
354        self
355    }
356    /// Filter by financial instrument global identifier (FIGI)
357    pub fn figi(mut self, figi: impl Into<String>) -> Self {
358        self.figi = Some(figi.into());
359        self
360    }
361    /// Filter by international securities identification number (ISIN)
362    pub fn isin(mut self, isin: impl Into<String>) -> Self {
363        self.isin = Some(isin.into());
364        self
365    }
366    /// 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
367    pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
368        self.cusip = Some(cusip.into());
369        self
370    }
371    /// Exchange where instrument is traded
372    pub fn exchange(mut self, exchange: impl Into<String>) -> Self {
373        self.exchange = Some(exchange.into());
374        self
375    }
376    /// Market Identifier Code (MIC) under ISO 10383 standard
377    pub fn mic_code(mut self, mic_code: impl Into<String>) -> Self {
378        self.mic_code = Some(mic_code.into());
379        self
380    }
381    /// Country where instrument is traded, e.g., `United States` or `US`
382    pub fn country(mut self, country: impl Into<String>) -> Self {
383        self.country = Some(country.into());
384        self
385    }
386
387    /// Build the parameter struct
388    pub fn build(self) -> GetInstitutionalHoldersParams {
389        GetInstitutionalHoldersParams {
390            symbol: self.symbol,
391            figi: self.figi,
392            isin: self.isin,
393            cusip: self.cusip,
394            exchange: self.exchange,
395            mic_code: self.mic_code,
396            country: self.country
397        }
398    }
399}
400
401/// struct for passing parameters to the method [`get_source_sanctioned_entities`]
402#[derive(Clone, Debug, Default, Serialize, Deserialize)]
403pub struct GetSourceSanctionedEntitiesParams {
404    /// Sanctions source
405    pub source: String
406}
407
408impl GetSourceSanctionedEntitiesParams {
409    /// Create a new builder for this parameter struct
410    pub fn builder() -> GetSourceSanctionedEntitiesParamsBuilder {
411        GetSourceSanctionedEntitiesParamsBuilder::default()
412    }
413}
414
415/// Builder for [`GetSourceSanctionedEntitiesParams`]
416#[derive(Clone, Debug, Default)]
417pub struct GetSourceSanctionedEntitiesParamsBuilder {
418    /// Sanctions source
419    source: String
420}
421
422impl GetSourceSanctionedEntitiesParamsBuilder {
423    /// Sanctions source
424    pub fn source(mut self, source: impl Into<String>) -> Self {
425        self.source = source.into();
426        self
427    }
428
429    /// Build the parameter struct
430    pub fn build(self) -> GetSourceSanctionedEntitiesParams {
431        GetSourceSanctionedEntitiesParams {
432            source: self.source
433        }
434    }
435}
436
437/// struct for passing parameters to the method [`get_tax_info`]
438#[derive(Clone, Debug, Default, Serialize, Deserialize)]
439pub struct GetTaxInfoParams {
440    /// The ticker symbol of an instrument for which data is requested, e.g., `SKYQ`, `AIRE`, `ALM:BME`, `HSI:HKEX`.
441    pub symbol: Option<String>,
442    /// The ISIN of an instrument for which data is requested
443    pub isin: Option<String>,
444    /// The FIGI of an instrument for which data is requested
445    pub figi: Option<String>,
446    /// 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
447    pub cusip: Option<String>,
448    /// The exchange name where the instrument is traded, e.g., `Nasdaq`, `Euronext`
449    pub exchange: Option<String>,
450    /// The Market Identifier Code (MIC) of the exchange where the instrument is traded, e.g., `XNAS`, `XLON`
451    pub mic_code: Option<String>
452}
453
454impl GetTaxInfoParams {
455    /// Create a new builder for this parameter struct
456    pub fn builder() -> GetTaxInfoParamsBuilder {
457        GetTaxInfoParamsBuilder::default()
458    }
459}
460
461/// Builder for [`GetTaxInfoParams`]
462#[derive(Clone, Debug, Default)]
463pub struct GetTaxInfoParamsBuilder {
464    /// The ticker symbol of an instrument for which data is requested, e.g., `SKYQ`, `AIRE`, `ALM:BME`, `HSI:HKEX`.
465    symbol: Option<String>,
466    /// The ISIN of an instrument for which data is requested
467    isin: Option<String>,
468    /// The FIGI of an instrument for which data is requested
469    figi: Option<String>,
470    /// 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
471    cusip: Option<String>,
472    /// The exchange name where the instrument is traded, e.g., `Nasdaq`, `Euronext`
473    exchange: Option<String>,
474    /// The Market Identifier Code (MIC) of the exchange where the instrument is traded, e.g., `XNAS`, `XLON`
475    mic_code: Option<String>
476}
477
478impl GetTaxInfoParamsBuilder {
479    /// The ticker symbol of an instrument for which data is requested, e.g., `SKYQ`, `AIRE`, `ALM:BME`, `HSI:HKEX`.
480    pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
481        self.symbol = Some(symbol.into());
482        self
483    }
484    /// The ISIN of an instrument for which data is requested
485    pub fn isin(mut self, isin: impl Into<String>) -> Self {
486        self.isin = Some(isin.into());
487        self
488    }
489    /// The FIGI of an instrument for which data is requested
490    pub fn figi(mut self, figi: impl Into<String>) -> Self {
491        self.figi = Some(figi.into());
492        self
493    }
494    /// 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
495    pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
496        self.cusip = Some(cusip.into());
497        self
498    }
499    /// The exchange name where the instrument is traded, e.g., `Nasdaq`, `Euronext`
500    pub fn exchange(mut self, exchange: impl Into<String>) -> Self {
501        self.exchange = Some(exchange.into());
502        self
503    }
504    /// The Market Identifier Code (MIC) of the exchange where the instrument is traded, e.g., `XNAS`, `XLON`
505    pub fn mic_code(mut self, mic_code: impl Into<String>) -> Self {
506        self.mic_code = Some(mic_code.into());
507        self
508    }
509
510    /// Build the parameter struct
511    pub fn build(self) -> GetTaxInfoParams {
512        GetTaxInfoParams {
513            symbol: self.symbol,
514            isin: self.isin,
515            figi: self.figi,
516            cusip: self.cusip,
517            exchange: self.exchange,
518            mic_code: self.mic_code
519        }
520    }
521}
522
523
524/// struct for typed errors of method [`get_direct_holders`]
525#[derive(Debug, Clone, Serialize, Deserialize)]
526#[serde(untagged)]
527pub enum GetDirectHoldersError {
528    UnknownValue(serde_json::Value),
529}
530
531/// struct for typed errors of method [`get_fund_holders`]
532#[derive(Debug, Clone, Serialize, Deserialize)]
533#[serde(untagged)]
534pub enum GetFundHoldersError {
535    UnknownValue(serde_json::Value),
536}
537
538/// struct for typed errors of method [`get_insider_transactions`]
539#[derive(Debug, Clone, Serialize, Deserialize)]
540#[serde(untagged)]
541pub enum GetInsiderTransactionsError {
542    UnknownValue(serde_json::Value),
543}
544
545/// struct for typed errors of method [`get_institutional_holders`]
546#[derive(Debug, Clone, Serialize, Deserialize)]
547#[serde(untagged)]
548pub enum GetInstitutionalHoldersError {
549    UnknownValue(serde_json::Value),
550}
551
552/// struct for typed errors of method [`get_source_sanctioned_entities`]
553#[derive(Debug, Clone, Serialize, Deserialize)]
554#[serde(untagged)]
555pub enum GetSourceSanctionedEntitiesError {
556    UnknownValue(serde_json::Value),
557}
558
559/// struct for typed errors of method [`get_tax_info`]
560#[derive(Debug, Clone, Serialize, Deserialize)]
561#[serde(untagged)]
562pub enum GetTaxInfoError {
563    UnknownValue(serde_json::Value),
564}
565
566
567/// 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.
568pub async fn get_direct_holders(configuration: &configuration::Configuration, params: GetDirectHoldersParams) -> Result<models::GetDirectHolders200Response, 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/plain` content type response that cannot be converted to `models::GetDirectHolders200Response`"))),
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::GetDirectHolders200Response`")))),
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 { status, content, entity }))
636    }
637}
638
639/// 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.
640pub async fn get_fund_holders(configuration: &configuration::Configuration, params: GetFundHoldersParams) -> Result<models::GetFundHolders200Response, Error<GetFundHoldersError>> {
641    // Extract parameters from params struct
642    let p_query_symbol = params.symbol;
643    let p_query_figi = params.figi;
644    let p_query_isin = params.isin;
645    let p_query_cusip = params.cusip;
646    let p_query_exchange = params.exchange;
647    let p_query_mic_code = params.mic_code;
648    let p_query_country = params.country;
649
650    let uri_str = format!("{}/fund_holders", configuration.base_path);
651    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
652
653    if let Some(ref param_value) = p_query_symbol {
654        req_builder = req_builder.query(&[("symbol", &param_value.to_string())]);
655    }
656    if let Some(ref param_value) = p_query_figi {
657        req_builder = req_builder.query(&[("figi", &param_value.to_string())]);
658    }
659    if let Some(ref param_value) = p_query_isin {
660        req_builder = req_builder.query(&[("isin", &param_value.to_string())]);
661    }
662    if let Some(ref param_value) = p_query_cusip {
663        req_builder = req_builder.query(&[("cusip", &param_value.to_string())]);
664    }
665    if let Some(ref param_value) = p_query_exchange {
666        req_builder = req_builder.query(&[("exchange", &param_value.to_string())]);
667    }
668    if let Some(ref param_value) = p_query_mic_code {
669        req_builder = req_builder.query(&[("mic_code", &param_value.to_string())]);
670    }
671    if let Some(ref param_value) = p_query_country {
672        req_builder = req_builder.query(&[("country", &param_value.to_string())]);
673    }
674    if let Some(ref user_agent) = configuration.user_agent {
675        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
676    }
677    if let Some(ref apikey) = configuration.api_key {
678        let key = apikey.key.clone();
679        let value = match apikey.prefix {
680            Some(ref prefix) => format!("{} {}", prefix, key),
681            None => key,
682        };
683        req_builder = req_builder.header("Authorization", value);
684    };
685
686    let req = req_builder.build()?;
687    let resp = configuration.client.execute(req).await?;
688
689    let status = resp.status();
690    let content_type = resp
691        .headers()
692        .get("content-type")
693        .and_then(|v| v.to_str().ok())
694        .unwrap_or("application/octet-stream");
695    let content_type = super::ContentType::from(content_type);
696
697    if !status.is_client_error() && !status.is_server_error() {
698        let content = resp.text().await?;
699        match content_type {
700            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
701            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetFundHolders200Response`"))),
702            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::GetFundHolders200Response`")))),
703        }
704    } else {
705        let content = resp.text().await?;
706        let entity: Option<GetFundHoldersError> = serde_json::from_str(&content).ok();
707        Err(Error::ResponseError(ResponseContent { status, content, entity }))
708    }
709}
710
711/// 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.
712pub async fn get_insider_transactions(configuration: &configuration::Configuration, params: GetInsiderTransactionsParams) -> Result<models::GetInsiderTransactions200Response, Error<GetInsiderTransactionsError>> {
713    // Extract parameters from params struct
714    let p_query_symbol = params.symbol;
715    let p_query_figi = params.figi;
716    let p_query_isin = params.isin;
717    let p_query_cusip = params.cusip;
718    let p_query_exchange = params.exchange;
719    let p_query_mic_code = params.mic_code;
720    let p_query_country = params.country;
721
722    let uri_str = format!("{}/insider_transactions", configuration.base_path);
723    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
724
725    if let Some(ref param_value) = p_query_symbol {
726        req_builder = req_builder.query(&[("symbol", &param_value.to_string())]);
727    }
728    if let Some(ref param_value) = p_query_figi {
729        req_builder = req_builder.query(&[("figi", &param_value.to_string())]);
730    }
731    if let Some(ref param_value) = p_query_isin {
732        req_builder = req_builder.query(&[("isin", &param_value.to_string())]);
733    }
734    if let Some(ref param_value) = p_query_cusip {
735        req_builder = req_builder.query(&[("cusip", &param_value.to_string())]);
736    }
737    if let Some(ref param_value) = p_query_exchange {
738        req_builder = req_builder.query(&[("exchange", &param_value.to_string())]);
739    }
740    if let Some(ref param_value) = p_query_mic_code {
741        req_builder = req_builder.query(&[("mic_code", &param_value.to_string())]);
742    }
743    if let Some(ref param_value) = p_query_country {
744        req_builder = req_builder.query(&[("country", &param_value.to_string())]);
745    }
746    if let Some(ref user_agent) = configuration.user_agent {
747        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
748    }
749    if let Some(ref apikey) = configuration.api_key {
750        let key = apikey.key.clone();
751        let value = match apikey.prefix {
752            Some(ref prefix) => format!("{} {}", prefix, key),
753            None => key,
754        };
755        req_builder = req_builder.header("Authorization", value);
756    };
757
758    let req = req_builder.build()?;
759    let resp = configuration.client.execute(req).await?;
760
761    let status = resp.status();
762    let content_type = resp
763        .headers()
764        .get("content-type")
765        .and_then(|v| v.to_str().ok())
766        .unwrap_or("application/octet-stream");
767    let content_type = super::ContentType::from(content_type);
768
769    if !status.is_client_error() && !status.is_server_error() {
770        let content = resp.text().await?;
771        match content_type {
772            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
773            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetInsiderTransactions200Response`"))),
774            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::GetInsiderTransactions200Response`")))),
775        }
776    } else {
777        let content = resp.text().await?;
778        let entity: Option<GetInsiderTransactionsError> = serde_json::from_str(&content).ok();
779        Err(Error::ResponseError(ResponseContent { status, content, entity }))
780    }
781}
782
783/// 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.
784pub async fn get_institutional_holders(configuration: &configuration::Configuration, params: GetInstitutionalHoldersParams) -> Result<models::GetInstitutionalHolders200Response, Error<GetInstitutionalHoldersError>> {
785    // Extract parameters from params struct
786    let p_query_symbol = params.symbol;
787    let p_query_figi = params.figi;
788    let p_query_isin = params.isin;
789    let p_query_cusip = params.cusip;
790    let p_query_exchange = params.exchange;
791    let p_query_mic_code = params.mic_code;
792    let p_query_country = params.country;
793
794    let uri_str = format!("{}/institutional_holders", configuration.base_path);
795    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
796
797    if let Some(ref param_value) = p_query_symbol {
798        req_builder = req_builder.query(&[("symbol", &param_value.to_string())]);
799    }
800    if let Some(ref param_value) = p_query_figi {
801        req_builder = req_builder.query(&[("figi", &param_value.to_string())]);
802    }
803    if let Some(ref param_value) = p_query_isin {
804        req_builder = req_builder.query(&[("isin", &param_value.to_string())]);
805    }
806    if let Some(ref param_value) = p_query_cusip {
807        req_builder = req_builder.query(&[("cusip", &param_value.to_string())]);
808    }
809    if let Some(ref param_value) = p_query_exchange {
810        req_builder = req_builder.query(&[("exchange", &param_value.to_string())]);
811    }
812    if let Some(ref param_value) = p_query_mic_code {
813        req_builder = req_builder.query(&[("mic_code", &param_value.to_string())]);
814    }
815    if let Some(ref param_value) = p_query_country {
816        req_builder = req_builder.query(&[("country", &param_value.to_string())]);
817    }
818    if let Some(ref user_agent) = configuration.user_agent {
819        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
820    }
821    if let Some(ref apikey) = configuration.api_key {
822        let key = apikey.key.clone();
823        let value = match apikey.prefix {
824            Some(ref prefix) => format!("{} {}", prefix, key),
825            None => key,
826        };
827        req_builder = req_builder.header("Authorization", value);
828    };
829
830    let req = req_builder.build()?;
831    let resp = configuration.client.execute(req).await?;
832
833    let status = resp.status();
834    let content_type = resp
835        .headers()
836        .get("content-type")
837        .and_then(|v| v.to_str().ok())
838        .unwrap_or("application/octet-stream");
839    let content_type = super::ContentType::from(content_type);
840
841    if !status.is_client_error() && !status.is_server_error() {
842        let content = resp.text().await?;
843        match content_type {
844            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
845            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetInstitutionalHolders200Response`"))),
846            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::GetInstitutionalHolders200Response`")))),
847        }
848    } else {
849        let content = resp.text().await?;
850        let entity: Option<GetInstitutionalHoldersError> = serde_json::from_str(&content).ok();
851        Err(Error::ResponseError(ResponseContent { status, content, entity }))
852    }
853}
854
855/// 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.
856pub async fn get_source_sanctioned_entities(configuration: &configuration::Configuration, params: GetSourceSanctionedEntitiesParams) -> Result<models::GetSourceSanctionedEntities200Response, Error<GetSourceSanctionedEntitiesError>> {
857    // Extract parameters from params struct
858    let p_path_source = params.source;
859
860    let uri_str = format!("{}/sanctions/{source}", configuration.base_path, source=crate::apis::urlencode(p_path_source));
861    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
862
863    if let Some(ref user_agent) = configuration.user_agent {
864        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
865    }
866    if let Some(ref apikey) = configuration.api_key {
867        let key = apikey.key.clone();
868        let value = match apikey.prefix {
869            Some(ref prefix) => format!("{} {}", prefix, key),
870            None => key,
871        };
872        req_builder = req_builder.header("Authorization", value);
873    };
874
875    let req = req_builder.build()?;
876    let resp = configuration.client.execute(req).await?;
877
878    let status = resp.status();
879    let content_type = resp
880        .headers()
881        .get("content-type")
882        .and_then(|v| v.to_str().ok())
883        .unwrap_or("application/octet-stream");
884    let content_type = super::ContentType::from(content_type);
885
886    if !status.is_client_error() && !status.is_server_error() {
887        let content = resp.text().await?;
888        match content_type {
889            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
890            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetSourceSanctionedEntities200Response`"))),
891            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::GetSourceSanctionedEntities200Response`")))),
892        }
893    } else {
894        let content = resp.text().await?;
895        let entity: Option<GetSourceSanctionedEntitiesError> = serde_json::from_str(&content).ok();
896        Err(Error::ResponseError(ResponseContent { status, content, entity }))
897    }
898}
899
900/// 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.
901pub async fn get_tax_info(configuration: &configuration::Configuration, params: GetTaxInfoParams) -> Result<models::GetTaxInfo200Response, Error<GetTaxInfoError>> {
902    // Extract parameters from params struct
903    let p_query_symbol = params.symbol;
904    let p_query_isin = params.isin;
905    let p_query_figi = params.figi;
906    let p_query_cusip = params.cusip;
907    let p_query_exchange = params.exchange;
908    let p_query_mic_code = params.mic_code;
909
910    let uri_str = format!("{}/tax_info", configuration.base_path);
911    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
912
913    if let Some(ref param_value) = p_query_symbol {
914        req_builder = req_builder.query(&[("symbol", &param_value.to_string())]);
915    }
916    if let Some(ref param_value) = p_query_isin {
917        req_builder = req_builder.query(&[("isin", &param_value.to_string())]);
918    }
919    if let Some(ref param_value) = p_query_figi {
920        req_builder = req_builder.query(&[("figi", &param_value.to_string())]);
921    }
922    if let Some(ref param_value) = p_query_cusip {
923        req_builder = req_builder.query(&[("cusip", &param_value.to_string())]);
924    }
925    if let Some(ref param_value) = p_query_exchange {
926        req_builder = req_builder.query(&[("exchange", &param_value.to_string())]);
927    }
928    if let Some(ref param_value) = p_query_mic_code {
929        req_builder = req_builder.query(&[("mic_code", &param_value.to_string())]);
930    }
931    if let Some(ref user_agent) = configuration.user_agent {
932        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
933    }
934    if let Some(ref apikey) = configuration.api_key {
935        let key = apikey.key.clone();
936        let value = match apikey.prefix {
937            Some(ref prefix) => format!("{} {}", prefix, key),
938            None => key,
939        };
940        req_builder = req_builder.header("Authorization", value);
941    };
942
943    let req = req_builder.build()?;
944    let resp = configuration.client.execute(req).await?;
945
946    let status = resp.status();
947    let content_type = resp
948        .headers()
949        .get("content-type")
950        .and_then(|v| v.to_str().ok())
951        .unwrap_or("application/octet-stream");
952    let content_type = super::ContentType::from(content_type);
953
954    if !status.is_client_error() && !status.is_server_error() {
955        let content = resp.text().await?;
956        match content_type {
957            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
958            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetTaxInfo200Response`"))),
959            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::GetTaxInfo200Response`")))),
960        }
961    } else {
962        let content = resp.text().await?;
963        let entity: Option<GetTaxInfoError> = serde_json::from_str(&content).ok();
964        Err(Error::ResponseError(ResponseContent { status, content, entity }))
965    }
966}
967