Skip to main content

ark_rest/apis/
indexer_service_api.rs

1/*
2 * Ark API
3 *
4 * Combined Ark Service, Indexer, Admin, Signer Manager, and Wallet API
5 *
6 * The version of the OpenAPI document: 1.0.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::configuration;
12use super::ContentType;
13use super::Error;
14use crate::apis::ResponseContent;
15use crate::models;
16use reqwest;
17use serde::de::Error as _;
18use serde::Deserialize;
19use serde::Serialize;
20
21/// struct for typed errors of method [`indexer_service_get_asset`]
22#[derive(Debug, Clone, Serialize, Deserialize)]
23#[serde(untagged)]
24pub enum IndexerServiceGetAssetError {
25    DefaultResponse(models::Status),
26    UnknownValue(serde_json::Value),
27}
28
29/// struct for typed errors of method [`indexer_service_get_batch_sweep_transactions`]
30#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum IndexerServiceGetBatchSweepTransactionsError {
33    DefaultResponse(models::Status),
34    UnknownValue(serde_json::Value),
35}
36
37/// struct for typed errors of method [`indexer_service_get_commitment_tx`]
38#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum IndexerServiceGetCommitmentTxError {
41    DefaultResponse(models::Status),
42    UnknownValue(serde_json::Value),
43}
44
45/// struct for typed errors of method [`indexer_service_get_connectors`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum IndexerServiceGetConnectorsError {
49    DefaultResponse(models::Status),
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`indexer_service_get_forfeit_txs`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum IndexerServiceGetForfeitTxsError {
57    DefaultResponse(models::Status),
58    UnknownValue(serde_json::Value),
59}
60
61/// struct for typed errors of method [`indexer_service_get_subscription`]
62#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum IndexerServiceGetSubscriptionError {
65    DefaultResponse(models::Status),
66    UnknownValue(serde_json::Value),
67}
68
69/// struct for typed errors of method [`indexer_service_get_virtual_txs`]
70#[derive(Debug, Clone, Serialize, Deserialize)]
71#[serde(untagged)]
72pub enum IndexerServiceGetVirtualTxsError {
73    DefaultResponse(models::Status),
74    UnknownValue(serde_json::Value),
75}
76
77/// struct for typed errors of method [`indexer_service_get_vtxo_chain`]
78#[derive(Debug, Clone, Serialize, Deserialize)]
79#[serde(untagged)]
80pub enum IndexerServiceGetVtxoChainError {
81    DefaultResponse(models::Status),
82    UnknownValue(serde_json::Value),
83}
84
85/// struct for typed errors of method [`indexer_service_get_vtxo_tree`]
86#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum IndexerServiceGetVtxoTreeError {
89    DefaultResponse(models::Status),
90    UnknownValue(serde_json::Value),
91}
92
93/// struct for typed errors of method [`indexer_service_get_vtxo_tree_leaves`]
94#[derive(Debug, Clone, Serialize, Deserialize)]
95#[serde(untagged)]
96pub enum IndexerServiceGetVtxoTreeLeavesError {
97    DefaultResponse(models::Status),
98    UnknownValue(serde_json::Value),
99}
100
101/// struct for typed errors of method [`indexer_service_get_vtxos`]
102#[derive(Debug, Clone, Serialize, Deserialize)]
103#[serde(untagged)]
104pub enum IndexerServiceGetVtxosError {
105    DefaultResponse(models::Status),
106    UnknownValue(serde_json::Value),
107}
108
109/// struct for typed errors of method [`indexer_service_subscribe_for_scripts`]
110#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum IndexerServiceSubscribeForScriptsError {
113    DefaultResponse(models::Status),
114    UnknownValue(serde_json::Value),
115}
116
117/// struct for typed errors of method [`indexer_service_unsubscribe_for_scripts`]
118#[derive(Debug, Clone, Serialize, Deserialize)]
119#[serde(untagged)]
120pub enum IndexerServiceUnsubscribeForScriptsError {
121    DefaultResponse(models::Status),
122    UnknownValue(serde_json::Value),
123}
124
125/// GetAsset returns the asset information and metadata for the specified asset ID.
126pub async fn indexer_service_get_asset(
127    configuration: &configuration::Configuration,
128    asset_id: &str,
129) -> Result<models::GetAssetResponse, Error<IndexerServiceGetAssetError>> {
130    // add a prefix to parameters to efficiently prevent name collisions
131    let p_asset_id = asset_id;
132
133    let uri_str = format!(
134        "{}/v1/indexer/asset/{}",
135        configuration.base_path,
136        crate::apis::urlencode(p_asset_id)
137    );
138    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
139
140    if let Some(ref user_agent) = configuration.user_agent {
141        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
142    }
143
144    let req = req_builder.build()?;
145    let resp = configuration.client.execute(req).await?;
146
147    let status = resp.status();
148    let content_type = resp
149        .headers()
150        .get("content-type")
151        .and_then(|v| v.to_str().ok())
152        .unwrap_or("application/octet-stream");
153    let content_type = super::ContentType::from(content_type);
154
155    if !status.is_client_error() && !status.is_server_error() {
156        let content = resp.text().await?;
157        match content_type {
158            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
159            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetAssetResponse`"))),
160            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::GetAssetResponse`")))),
161        }
162    } else {
163        let content = resp.text().await?;
164        let entity: Option<IndexerServiceGetAssetError> = serde_json::from_str(&content).ok();
165        Err(Error::ResponseError(ResponseContent {
166            status,
167            content,
168            entity,
169        }))
170    }
171}
172
173/// GetBatchSweepTransactions returns the list of transaction (txid) that swept a given batch
174/// output. In most cases the list contains only one txid, meaning that all the amount locked for a
175/// vtxo tree has been claimed back. If any of the leaves of the tree have been unrolled onchain
176/// before the expiration, the list will contain many txids instead. In a binary tree with 4 or more
177/// leaves, 1 unroll causes the server to broadcast 3 txs to sweep the whole rest of tree for
178/// example. If a whole vtxo tree has been unrolled onchain, the list of txids for that batch output
179/// is empty.
180pub async fn indexer_service_get_batch_sweep_transactions(
181    configuration: &configuration::Configuration,
182    batch_outpoint_period_txid: &str,
183    batch_outpoint_period_vout: i32,
184) -> Result<
185    models::GetBatchSweepTransactionsResponse,
186    Error<IndexerServiceGetBatchSweepTransactionsError>,
187> {
188    // add a prefix to parameters to efficiently prevent name collisions
189    let p_batch_outpoint_period_txid = batch_outpoint_period_txid;
190    let p_batch_outpoint_period_vout = batch_outpoint_period_vout;
191
192    let uri_str = format!(
193        "{}/v1/indexer/batch/{batch_outpoint_txid}/{batch_outpoint_vout}/sweepTxs",
194        configuration.base_path,
195        batch_outpoint_txid = crate::apis::urlencode(p_batch_outpoint_period_txid),
196        batch_outpoint_vout = p_batch_outpoint_period_vout
197    );
198    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
199
200    if let Some(ref user_agent) = configuration.user_agent {
201        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
202    }
203
204    let req = req_builder.build()?;
205    let resp = configuration.client.execute(req).await?;
206
207    let status = resp.status();
208    let content_type = resp
209        .headers()
210        .get("content-type")
211        .and_then(|v| v.to_str().ok())
212        .unwrap_or("application/octet-stream");
213    let content_type = super::ContentType::from(content_type);
214
215    if !status.is_client_error() && !status.is_server_error() {
216        let content = resp.text().await?;
217        match content_type {
218            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
219            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetBatchSweepTransactionsResponse`"))),
220            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::GetBatchSweepTransactionsResponse`")))),
221        }
222    } else {
223        let content = resp.text().await?;
224        let entity: Option<IndexerServiceGetBatchSweepTransactionsError> =
225            serde_json::from_str(&content).ok();
226        Err(Error::ResponseError(ResponseContent {
227            status,
228            content,
229            entity,
230        }))
231    }
232}
233
234/// GetCommitmentTx returns information about a specific commitment transaction identified by the
235/// provided txid.
236pub async fn indexer_service_get_commitment_tx(
237    configuration: &configuration::Configuration,
238    txid: &str,
239) -> Result<models::GetCommitmentTxResponse, Error<IndexerServiceGetCommitmentTxError>> {
240    // add a prefix to parameters to efficiently prevent name collisions
241    let p_txid = txid;
242
243    let uri_str = format!(
244        "{}/v1/indexer/commitmentTx/{txid}",
245        configuration.base_path,
246        txid = crate::apis::urlencode(p_txid)
247    );
248    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
249
250    if let Some(ref user_agent) = configuration.user_agent {
251        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
252    }
253
254    let req = req_builder.build()?;
255    let resp = configuration.client.execute(req).await?;
256
257    let status = resp.status();
258    let content_type = resp
259        .headers()
260        .get("content-type")
261        .and_then(|v| v.to_str().ok())
262        .unwrap_or("application/octet-stream");
263    let content_type = super::ContentType::from(content_type);
264
265    if !status.is_client_error() && !status.is_server_error() {
266        let content = resp.text().await?;
267        match content_type {
268            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
269            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetCommitmentTxResponse`"))),
270            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::GetCommitmentTxResponse`")))),
271        }
272    } else {
273        let content = resp.text().await?;
274        let entity: Option<IndexerServiceGetCommitmentTxError> =
275            serde_json::from_str(&content).ok();
276        Err(Error::ResponseError(ResponseContent {
277            status,
278            content,
279            entity,
280        }))
281    }
282}
283
284/// GetConnectors returns the tree of connectors for the provided commitment transaction. The
285/// response includes a list of connector txs with details on the tree posistion and may include
286/// pagination information if the results span multiple pages.
287pub async fn indexer_service_get_connectors(
288    configuration: &configuration::Configuration,
289    txid: &str,
290    page_period_size: Option<i32>,
291    page_period_index: Option<i32>,
292) -> Result<models::GetConnectorsResponse, Error<IndexerServiceGetConnectorsError>> {
293    // add a prefix to parameters to efficiently prevent name collisions
294    let p_txid = txid;
295    let p_page_period_size = page_period_size;
296    let p_page_period_index = page_period_index;
297
298    let uri_str = format!(
299        "{}/v1/indexer/commitmentTx/{txid}/connectors",
300        configuration.base_path,
301        txid = crate::apis::urlencode(p_txid)
302    );
303    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
304
305    if let Some(ref param_value) = p_page_period_size {
306        req_builder = req_builder.query(&[("page.size", &param_value.to_string())]);
307    }
308    if let Some(ref param_value) = p_page_period_index {
309        req_builder = req_builder.query(&[("page.index", &param_value.to_string())]);
310    }
311    if let Some(ref user_agent) = configuration.user_agent {
312        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
313    }
314
315    let req = req_builder.build()?;
316    let resp = configuration.client.execute(req).await?;
317
318    let status = resp.status();
319    let content_type = resp
320        .headers()
321        .get("content-type")
322        .and_then(|v| v.to_str().ok())
323        .unwrap_or("application/octet-stream");
324    let content_type = super::ContentType::from(content_type);
325
326    if !status.is_client_error() && !status.is_server_error() {
327        let content = resp.text().await?;
328        match content_type {
329            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
330            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetConnectorsResponse`"))),
331            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::GetConnectorsResponse`")))),
332        }
333    } else {
334        let content = resp.text().await?;
335        let entity: Option<IndexerServiceGetConnectorsError> = serde_json::from_str(&content).ok();
336        Err(Error::ResponseError(ResponseContent {
337            status,
338            content,
339            entity,
340        }))
341    }
342}
343
344/// GetForfeitTxs returns the list of forfeit transactions that were submitted for the provided
345/// commitment transaction. The response may include pagination information if the results span
346/// multiple pages.
347pub async fn indexer_service_get_forfeit_txs(
348    configuration: &configuration::Configuration,
349    txid: &str,
350    page_period_size: Option<i32>,
351    page_period_index: Option<i32>,
352) -> Result<models::GetForfeitTxsResponse, Error<IndexerServiceGetForfeitTxsError>> {
353    // add a prefix to parameters to efficiently prevent name collisions
354    let p_txid = txid;
355    let p_page_period_size = page_period_size;
356    let p_page_period_index = page_period_index;
357
358    let uri_str = format!(
359        "{}/v1/indexer/commitmentTx/{txid}/forfeitTxs",
360        configuration.base_path,
361        txid = crate::apis::urlencode(p_txid)
362    );
363    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
364
365    if let Some(ref param_value) = p_page_period_size {
366        req_builder = req_builder.query(&[("page.size", &param_value.to_string())]);
367    }
368    if let Some(ref param_value) = p_page_period_index {
369        req_builder = req_builder.query(&[("page.index", &param_value.to_string())]);
370    }
371    if let Some(ref user_agent) = configuration.user_agent {
372        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
373    }
374
375    let req = req_builder.build()?;
376    let resp = configuration.client.execute(req).await?;
377
378    let status = resp.status();
379    let content_type = resp
380        .headers()
381        .get("content-type")
382        .and_then(|v| v.to_str().ok())
383        .unwrap_or("application/octet-stream");
384    let content_type = super::ContentType::from(content_type);
385
386    if !status.is_client_error() && !status.is_server_error() {
387        let content = resp.text().await?;
388        match content_type {
389            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
390            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetForfeitTxsResponse`"))),
391            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::GetForfeitTxsResponse`")))),
392        }
393    } else {
394        let content = resp.text().await?;
395        let entity: Option<IndexerServiceGetForfeitTxsError> = serde_json::from_str(&content).ok();
396        Err(Error::ResponseError(ResponseContent {
397            status,
398            content,
399            entity,
400        }))
401    }
402}
403
404/// GetSubscription is a server-side streaming RPC which allows clients to receive real-time
405/// notifications on transactions related to the subscribed vtxo scripts. The subscription can be
406/// created or updated by using the SubscribeForScripts and UnsubscribeForScripts RPCs.
407pub async fn indexer_service_get_subscription(
408    configuration: &configuration::Configuration,
409    subscription_id: &str,
410) -> Result<models::GetSubscriptionResponse, Error<IndexerServiceGetSubscriptionError>> {
411    // add a prefix to parameters to efficiently prevent name collisions
412    let p_subscription_id = subscription_id;
413
414    let uri_str = format!(
415        "{}/v1/indexer/script/subscription/{}",
416        configuration.base_path,
417        crate::apis::urlencode(p_subscription_id)
418    );
419    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
420
421    if let Some(ref user_agent) = configuration.user_agent {
422        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
423    }
424
425    let req = req_builder.build()?;
426    let resp = configuration.client.execute(req).await?;
427
428    let status = resp.status();
429    let content_type = resp
430        .headers()
431        .get("content-type")
432        .and_then(|v| v.to_str().ok())
433        .unwrap_or("application/octet-stream");
434    let content_type = super::ContentType::from(content_type);
435
436    if !status.is_client_error() && !status.is_server_error() {
437        let content = resp.text().await?;
438        match content_type {
439            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
440            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetSubscriptionResponse`"))),
441            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::GetSubscriptionResponse`")))),
442        }
443    } else {
444        let content = resp.text().await?;
445        let entity: Option<IndexerServiceGetSubscriptionError> =
446            serde_json::from_str(&content).ok();
447        Err(Error::ResponseError(ResponseContent {
448            status,
449            content,
450            entity,
451        }))
452    }
453}
454
455/// GetVirtualTxs returns the virtual transactions in hex format for the specified txids. The
456/// response may be paginated if the results span multiple pages.
457pub async fn indexer_service_get_virtual_txs(
458    configuration: &configuration::Configuration,
459    txids: Vec<String>,
460    page_period_size: Option<i32>,
461    page_period_index: Option<i32>,
462) -> Result<models::GetVirtualTxsResponse, Error<IndexerServiceGetVirtualTxsError>> {
463    // add a prefix to parameters to efficiently prevent name collisions
464    let p_txids = txids;
465    let p_page_period_size = page_period_size;
466    let p_page_period_index = page_period_index;
467
468    let uri_str = format!(
469        "{}/v1/indexer/virtualTx/{txids}",
470        configuration.base_path,
471        txids = p_txids.join(",")
472    );
473    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
474
475    if let Some(ref param_value) = p_page_period_size {
476        req_builder = req_builder.query(&[("page.size", &param_value.to_string())]);
477    }
478    if let Some(ref param_value) = p_page_period_index {
479        req_builder = req_builder.query(&[("page.index", &param_value.to_string())]);
480    }
481    if let Some(ref user_agent) = configuration.user_agent {
482        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
483    }
484
485    let req = req_builder.build()?;
486    let resp = configuration.client.execute(req).await?;
487
488    let status = resp.status();
489    let content_type = resp
490        .headers()
491        .get("content-type")
492        .and_then(|v| v.to_str().ok())
493        .unwrap_or("application/octet-stream");
494    let content_type = super::ContentType::from(content_type);
495
496    if !status.is_client_error() && !status.is_server_error() {
497        let content = resp.text().await?;
498        match content_type {
499            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
500            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetVirtualTxsResponse`"))),
501            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::GetVirtualTxsResponse`")))),
502        }
503    } else {
504        let content = resp.text().await?;
505        let entity: Option<IndexerServiceGetVirtualTxsError> = serde_json::from_str(&content).ok();
506        Err(Error::ResponseError(ResponseContent {
507            status,
508            content,
509            entity,
510        }))
511    }
512}
513
514/// GetVtxoChain returns the the chain of ark txs that starts from spending any vtxo leaf and ends
515/// with the creation of the provided vtxo outpoint. The response may be paginated if the results
516/// span multiple pages.
517pub async fn indexer_service_get_vtxo_chain(
518    configuration: &configuration::Configuration,
519    outpoint_period_txid: &str,
520    outpoint_period_vout: i32,
521    page_period_size: Option<i32>,
522    page_period_index: Option<i32>,
523) -> Result<models::GetVtxoChainResponse, Error<IndexerServiceGetVtxoChainError>> {
524    // add a prefix to parameters to efficiently prevent name collisions
525    let p_outpoint_period_txid = outpoint_period_txid;
526    let p_outpoint_period_vout = outpoint_period_vout;
527    let p_page_period_size = page_period_size;
528    let p_page_period_index = page_period_index;
529
530    let uri_str = format!(
531        "{}/v1/indexer/vtxo/{outpoint_txid}/{outpoint_vout}/chain",
532        configuration.base_path,
533        outpoint_txid = crate::apis::urlencode(p_outpoint_period_txid),
534        outpoint_vout = p_outpoint_period_vout
535    );
536    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
537
538    if let Some(ref param_value) = p_page_period_size {
539        req_builder = req_builder.query(&[("page.size", &param_value.to_string())]);
540    }
541    if let Some(ref param_value) = p_page_period_index {
542        req_builder = req_builder.query(&[("page.index", &param_value.to_string())]);
543    }
544    if let Some(ref user_agent) = configuration.user_agent {
545        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
546    }
547
548    let req = req_builder.build()?;
549    let resp = configuration.client.execute(req).await?;
550
551    let status = resp.status();
552    let content_type = resp
553        .headers()
554        .get("content-type")
555        .and_then(|v| v.to_str().ok())
556        .unwrap_or("application/octet-stream");
557    let content_type = super::ContentType::from(content_type);
558
559    if !status.is_client_error() && !status.is_server_error() {
560        let content = resp.text().await?;
561        match content_type {
562            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
563            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetVtxoChainResponse`"))),
564            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::GetVtxoChainResponse`")))),
565        }
566    } else {
567        let content = resp.text().await?;
568        let entity: Option<IndexerServiceGetVtxoChainError> = serde_json::from_str(&content).ok();
569        Err(Error::ResponseError(ResponseContent {
570            status,
571            content,
572            entity,
573        }))
574    }
575}
576
577/// GetVtxoTree returns the vtxo tree for the provided batch outpoint. The response includes a list
578/// of txs with details on the tree posistion and may include pagination information if the results
579/// span multiple pages.
580pub async fn indexer_service_get_vtxo_tree(
581    configuration: &configuration::Configuration,
582    batch_outpoint_period_txid: &str,
583    batch_outpoint_period_vout: i32,
584    page_period_size: Option<i32>,
585    page_period_index: Option<i32>,
586) -> Result<models::GetVtxoTreeResponse, Error<IndexerServiceGetVtxoTreeError>> {
587    // add a prefix to parameters to efficiently prevent name collisions
588    let p_batch_outpoint_period_txid = batch_outpoint_period_txid;
589    let p_batch_outpoint_period_vout = batch_outpoint_period_vout;
590    let p_page_period_size = page_period_size;
591    let p_page_period_index = page_period_index;
592
593    let uri_str = format!(
594        "{}/v1/indexer/batch/{batch_outpoint_txid}/{batch_outpoint_vout}/tree",
595        configuration.base_path,
596        batch_outpoint_txid = crate::apis::urlencode(p_batch_outpoint_period_txid),
597        batch_outpoint_vout = p_batch_outpoint_period_vout
598    );
599    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
600
601    if let Some(ref param_value) = p_page_period_size {
602        req_builder = req_builder.query(&[("page.size", &param_value.to_string())]);
603    }
604    if let Some(ref param_value) = p_page_period_index {
605        req_builder = req_builder.query(&[("page.index", &param_value.to_string())]);
606    }
607    if let Some(ref user_agent) = configuration.user_agent {
608        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
609    }
610
611    let req = req_builder.build()?;
612    let resp = configuration.client.execute(req).await?;
613
614    let status = resp.status();
615    let content_type = resp
616        .headers()
617        .get("content-type")
618        .and_then(|v| v.to_str().ok())
619        .unwrap_or("application/octet-stream");
620    let content_type = super::ContentType::from(content_type);
621
622    if !status.is_client_error() && !status.is_server_error() {
623        let content = resp.text().await?;
624        match content_type {
625            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
626            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetVtxoTreeResponse`"))),
627            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::GetVtxoTreeResponse`")))),
628        }
629    } else {
630        let content = resp.text().await?;
631        let entity: Option<IndexerServiceGetVtxoTreeError> = serde_json::from_str(&content).ok();
632        Err(Error::ResponseError(ResponseContent {
633            status,
634            content,
635            entity,
636        }))
637    }
638}
639
640/// GetVtxoTreeLeaves returns the list of leaves (vtxo outpoints) of the tree(s) for the provided
641/// batch outpoint. The response may be paginated if the results span multiple pages.
642pub async fn indexer_service_get_vtxo_tree_leaves(
643    configuration: &configuration::Configuration,
644    batch_outpoint_period_txid: &str,
645    batch_outpoint_period_vout: i32,
646    page_period_size: Option<i32>,
647    page_period_index: Option<i32>,
648) -> Result<models::GetVtxoTreeLeavesResponse, Error<IndexerServiceGetVtxoTreeLeavesError>> {
649    // add a prefix to parameters to efficiently prevent name collisions
650    let p_batch_outpoint_period_txid = batch_outpoint_period_txid;
651    let p_batch_outpoint_period_vout = batch_outpoint_period_vout;
652    let p_page_period_size = page_period_size;
653    let p_page_period_index = page_period_index;
654
655    let uri_str = format!(
656        "{}/v1/indexer/batch/{batch_outpoint_txid}/{batch_outpoint_vout}/tree/leaves",
657        configuration.base_path,
658        batch_outpoint_txid = crate::apis::urlencode(p_batch_outpoint_period_txid),
659        batch_outpoint_vout = p_batch_outpoint_period_vout
660    );
661    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
662
663    if let Some(ref param_value) = p_page_period_size {
664        req_builder = req_builder.query(&[("page.size", &param_value.to_string())]);
665    }
666    if let Some(ref param_value) = p_page_period_index {
667        req_builder = req_builder.query(&[("page.index", &param_value.to_string())]);
668    }
669    if let Some(ref user_agent) = configuration.user_agent {
670        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
671    }
672
673    let req = req_builder.build()?;
674    let resp = configuration.client.execute(req).await?;
675
676    let status = resp.status();
677    let content_type = resp
678        .headers()
679        .get("content-type")
680        .and_then(|v| v.to_str().ok())
681        .unwrap_or("application/octet-stream");
682    let content_type = super::ContentType::from(content_type);
683
684    if !status.is_client_error() && !status.is_server_error() {
685        let content = resp.text().await?;
686        match content_type {
687            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
688            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetVtxoTreeLeavesResponse`"))),
689            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::GetVtxoTreeLeavesResponse`")))),
690        }
691    } else {
692        let content = resp.text().await?;
693        let entity: Option<IndexerServiceGetVtxoTreeLeavesError> =
694            serde_json::from_str(&content).ok();
695        Err(Error::ResponseError(ResponseContent {
696            status,
697            content,
698            entity,
699        }))
700    }
701}
702
703/// GetVtxos returns the list of vtxos based on the provided filter. Vtxos can be retrieved either
704/// by addresses or by outpoints, and optionally filtered by spendable or spent only. The response
705/// may be paginated if the results span multiple pages.
706pub async fn indexer_service_get_vtxos(
707    configuration: &configuration::Configuration,
708    scripts: Option<Vec<String>>,
709    outpoints: Option<Vec<String>>,
710    spendable_only: Option<bool>,
711    spent_only: Option<bool>,
712    recoverable_only: Option<bool>,
713    pending_only: Option<bool>,
714    after: Option<i64>,
715    before: Option<i64>,
716    page_period_size: Option<i32>,
717    page_period_index: Option<i32>,
718) -> Result<models::GetVtxosResponse, Error<IndexerServiceGetVtxosError>> {
719    // add a prefix to parameters to efficiently prevent name collisions
720    let p_scripts = scripts;
721    let p_outpoints = outpoints;
722    let p_spendable_only = spendable_only;
723    let p_spent_only = spent_only;
724    let p_recoverable_only = recoverable_only;
725    let p_pending_only = pending_only;
726    let p_after = after;
727    let p_before = before;
728    let p_page_period_size = page_period_size;
729    let p_page_period_index = page_period_index;
730
731    let uri_str = format!("{}/v1/indexer/vtxos", configuration.base_path);
732    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
733
734    if let Some(ref param_value) = p_scripts {
735        req_builder = match "csv" {
736            "multi" => req_builder.query(
737                &param_value
738                    .into_iter()
739                    .map(|p| ("scripts".to_owned(), p.to_string()))
740                    .collect::<Vec<(std::string::String, std::string::String)>>(),
741            ),
742            _ => req_builder.query(&[(
743                "scripts",
744                &param_value
745                    .into_iter()
746                    .map(|p| p.to_string())
747                    .collect::<Vec<String>>()
748                    .join(",")
749                    .to_string(),
750            )]),
751        };
752    }
753    if let Some(ref param_value) = p_outpoints {
754        req_builder = match "csv" {
755            "multi" => req_builder.query(
756                &param_value
757                    .into_iter()
758                    .map(|p| ("outpoints".to_owned(), p.to_string()))
759                    .collect::<Vec<(std::string::String, std::string::String)>>(),
760            ),
761            _ => req_builder.query(&[(
762                "outpoints",
763                &param_value
764                    .into_iter()
765                    .map(|p| p.to_string())
766                    .collect::<Vec<String>>()
767                    .join(",")
768                    .to_string(),
769            )]),
770        };
771    }
772    if let Some(ref param_value) = p_spendable_only {
773        req_builder = req_builder.query(&[("spendableOnly", &param_value.to_string())]);
774    }
775    if let Some(ref param_value) = p_spent_only {
776        req_builder = req_builder.query(&[("spentOnly", &param_value.to_string())]);
777    }
778    if let Some(ref param_value) = p_recoverable_only {
779        req_builder = req_builder.query(&[("recoverableOnly", &param_value.to_string())]);
780    }
781    if let Some(ref param_value) = p_pending_only {
782        req_builder = req_builder.query(&[("pendingOnly", &param_value.to_string())]);
783    }
784    if let Some(ref param_value) = p_after {
785        req_builder = req_builder.query(&[("after", &param_value.to_string())]);
786    }
787    if let Some(ref param_value) = p_before {
788        req_builder = req_builder.query(&[("before", &param_value.to_string())]);
789    }
790    if let Some(ref param_value) = p_page_period_size {
791        req_builder = req_builder.query(&[("page.size", &param_value.to_string())]);
792    }
793    if let Some(ref param_value) = p_page_period_index {
794        req_builder = req_builder.query(&[("page.index", &param_value.to_string())]);
795    }
796    if let Some(ref user_agent) = configuration.user_agent {
797        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
798    }
799
800    let req = req_builder.build()?;
801    let resp = configuration.client.execute(req).await?;
802
803    let status = resp.status();
804    let content_type = resp
805        .headers()
806        .get("content-type")
807        .and_then(|v| v.to_str().ok())
808        .unwrap_or("application/octet-stream");
809    let content_type = super::ContentType::from(content_type);
810
811    if !status.is_client_error() && !status.is_server_error() {
812        let content = resp.text().await?;
813        match content_type {
814            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
815            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetVtxosResponse`"))),
816            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::GetVtxosResponse`")))),
817        }
818    } else {
819        let content = resp.text().await?;
820        let entity: Option<IndexerServiceGetVtxosError> = serde_json::from_str(&content).ok();
821        Err(Error::ResponseError(ResponseContent {
822            status,
823            content,
824            entity,
825        }))
826    }
827}
828
829/// SubscribeForScripts allows to subscribe for tx notifications related to the provided vtxo
830/// scripts. It can also be used to update an existing subscribtion by adding new scripts to it.
831pub async fn indexer_service_subscribe_for_scripts(
832    configuration: &configuration::Configuration,
833    subscribe_for_scripts_request: models::SubscribeForScriptsRequest,
834) -> Result<models::SubscribeForScriptsResponse, Error<IndexerServiceSubscribeForScriptsError>> {
835    // add a prefix to parameters to efficiently prevent name collisions
836    let p_subscribe_for_scripts_request = subscribe_for_scripts_request;
837
838    let uri_str = format!("{}/v1/indexer/script/subscribe", configuration.base_path);
839    let mut req_builder = configuration
840        .client
841        .request(reqwest::Method::POST, &uri_str);
842
843    if let Some(ref user_agent) = configuration.user_agent {
844        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
845    }
846    req_builder = req_builder.json(&p_subscribe_for_scripts_request);
847
848    let req = req_builder.build()?;
849    let resp = configuration.client.execute(req).await?;
850
851    let status = resp.status();
852    let content_type = resp
853        .headers()
854        .get("content-type")
855        .and_then(|v| v.to_str().ok())
856        .unwrap_or("application/octet-stream");
857    let content_type = super::ContentType::from(content_type);
858
859    if !status.is_client_error() && !status.is_server_error() {
860        let content = resp.text().await?;
861        match content_type {
862            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
863            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SubscribeForScriptsResponse`"))),
864            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::SubscribeForScriptsResponse`")))),
865        }
866    } else {
867        let content = resp.text().await?;
868        let entity: Option<IndexerServiceSubscribeForScriptsError> =
869            serde_json::from_str(&content).ok();
870        Err(Error::ResponseError(ResponseContent {
871            status,
872            content,
873            entity,
874        }))
875    }
876}
877
878/// UnsubscribeForScripts allows to remove scripts from an existing subscription.
879pub async fn indexer_service_unsubscribe_for_scripts(
880    configuration: &configuration::Configuration,
881    unsubscribe_for_scripts_request: models::UnsubscribeForScriptsRequest,
882) -> Result<serde_json::Value, Error<IndexerServiceUnsubscribeForScriptsError>> {
883    // add a prefix to parameters to efficiently prevent name collisions
884    let p_unsubscribe_for_scripts_request = unsubscribe_for_scripts_request;
885
886    let uri_str = format!("{}/v1/indexer/script/unsubscribe", configuration.base_path);
887    let mut req_builder = configuration
888        .client
889        .request(reqwest::Method::POST, &uri_str);
890
891    if let Some(ref user_agent) = configuration.user_agent {
892        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
893    }
894    req_builder = req_builder.json(&p_unsubscribe_for_scripts_request);
895
896    let req = req_builder.build()?;
897    let resp = configuration.client.execute(req).await?;
898
899    let status = resp.status();
900    let content_type = resp
901        .headers()
902        .get("content-type")
903        .and_then(|v| v.to_str().ok())
904        .unwrap_or("application/octet-stream");
905    let content_type = super::ContentType::from(content_type);
906
907    if !status.is_client_error() && !status.is_server_error() {
908        let content = resp.text().await?;
909        match content_type {
910            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
911            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
912            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
913        }
914    } else {
915        let content = resp.text().await?;
916        let entity: Option<IndexerServiceUnsubscribeForScriptsError> =
917            serde_json::from_str(&content).ok();
918        Err(Error::ResponseError(ResponseContent {
919            status,
920            content,
921            entity,
922        }))
923    }
924}