photon-api 0.56.0

Solana indexer for general compression
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
//! Photon API client generated from OpenAPI spec using progenitor.
//!
//! This crate provides a Rust client for the Photon indexer API.
//! Types are pre-generated by progenitor and checked in; HTTP calls use reqwest directly.
//! To regenerate after spec changes: `cargo build -p photon-api --features generate`

#![allow(unused_imports, clippy::all, dead_code)]
#![allow(mismatched_lifetime_syntaxes)]

// Include the pre-generated progenitor types (checked in).
// To regenerate after OpenAPI spec changes: cargo build -p photon-api --features generate
include!("codegen.rs");

pub mod apis {
    use super::*;

    /// Configuration for the Photon API client.
    #[derive(Clone)]
    pub struct Configuration {
        pub base_path: String,
        pub api_key: Option<String>,
        pub client: reqwest::Client,
    }

    impl std::fmt::Debug for Configuration {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            f.debug_struct("Configuration")
                .field("base_path", &self.base_path)
                .finish()
        }
    }

    impl Default for Configuration {
        fn default() -> Self {
            Self {
                base_path: "https://devnet.helius-rpc.com".to_string(),
                api_key: None,
                client: reqwest::Client::new(),
            }
        }
    }

    impl Configuration {
        /// Create a new configuration from a URL string.
        ///
        /// If the URL contains an `api-key` query parameter, it is extracted
        /// and appended to every request as `?api-key=KEY`.
        ///
        /// ```ignore
        /// // Without API key
        /// let config = Configuration::new("https://rpc.example.com".to_string());
        ///
        /// // With API key
        /// let config = Configuration::new("https://rpc.example.com?api-key=YOUR_KEY".to_string());
        /// ```
        pub fn new(url: String) -> Self {
            let (base_path, api_key) = Self::parse_url(&url);
            Self {
                base_path,
                api_key,
                client: reqwest::Client::new(),
            }
        }

        fn build_url(&self, endpoint: &str) -> String {
            match &self.api_key {
                Some(key) => format!("{}/{}?api-key={}", self.base_path, endpoint, key),
                None => format!("{}/{}", self.base_path, endpoint),
            }
        }

        pub(crate) fn parse_url(url: &str) -> (String, Option<String>) {
            if let Some(query_start) = url.find('?') {
                let base = &url[..query_start];
                let query = &url[query_start + 1..];
                for param in query.split('&') {
                    if let Some(value) = param.strip_prefix("api-key=") {
                        return (base.to_string(), Some(value.to_string()));
                    }
                }
                (url.to_string(), None)
            } else {
                (url.to_string(), None)
            }
        }
    }

    pub mod configuration {
        pub use super::Configuration;
    }

    /// Error type for API calls.
    #[derive(Debug)]
    pub enum Error<T> {
        Reqwest(reqwest::Error),
        ResponseError {
            status: u16,
            body: String,
        },
        #[doc(hidden)]
        _Phantom(std::marker::PhantomData<T>),
    }

    impl<T> std::fmt::Display for Error<T> {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                Error::Reqwest(e) => write!(f, "HTTP error: {}", e),
                Error::ResponseError { status, body } => {
                    write!(f, "Error response (status {}): {}", status, body)
                }
                Error::_Phantom(_) => unreachable!(),
            }
        }
    }

    /// Default API module providing function-style API calls.
    pub mod default_api {
        use super::*;

        // ----------------------------------------------------------------
        // Body construction helper functions
        // ----------------------------------------------------------------

        pub fn make_get_compressed_account_body(
            params: types::PostGetCompressedAccountBodyParams,
        ) -> types::PostGetCompressedAccountBody {
            types::PostGetCompressedAccountBody {
                id: types::PostGetCompressedAccountBodyId::TestAccount,
                jsonrpc: types::PostGetCompressedAccountBodyJsonrpc::X20,
                method: types::PostGetCompressedAccountBodyMethod::GetCompressedAccount,
                params,
            }
        }

        pub fn make_get_compressed_account_balance_body(
            params: types::PostGetCompressedAccountBalanceBodyParams,
        ) -> types::PostGetCompressedAccountBalanceBody {
            types::PostGetCompressedAccountBalanceBody {
                id: types::PostGetCompressedAccountBalanceBodyId::TestAccount,
                jsonrpc: types::PostGetCompressedAccountBalanceBodyJsonrpc::X20,
                method:
                    types::PostGetCompressedAccountBalanceBodyMethod::GetCompressedAccountBalance,
                params,
            }
        }

        pub fn make_get_compressed_accounts_by_owner_v2_body(
            params: types::PostGetCompressedAccountsByOwnerV2BodyParams,
        ) -> types::PostGetCompressedAccountsByOwnerV2Body {
            types::PostGetCompressedAccountsByOwnerV2Body {
                id: types::PostGetCompressedAccountsByOwnerV2BodyId::TestAccount,
                jsonrpc: types::PostGetCompressedAccountsByOwnerV2BodyJsonrpc::X20,
                method: types::PostGetCompressedAccountsByOwnerV2BodyMethod::GetCompressedAccountsByOwnerV2,
                params,
            }
        }

        pub fn make_get_compressed_balance_by_owner_body(
            params: types::PostGetCompressedBalanceByOwnerBodyParams,
        ) -> types::PostGetCompressedBalanceByOwnerBody {
            types::PostGetCompressedBalanceByOwnerBody {
                id: types::PostGetCompressedBalanceByOwnerBodyId::TestAccount,
                jsonrpc: types::PostGetCompressedBalanceByOwnerBodyJsonrpc::X20,
                method:
                    types::PostGetCompressedBalanceByOwnerBodyMethod::GetCompressedBalanceByOwner,
                params,
            }
        }

        pub fn make_get_compressed_mint_token_holders_body(
            params: types::PostGetCompressedMintTokenHoldersBodyParams,
        ) -> types::PostGetCompressedMintTokenHoldersBody {
            types::PostGetCompressedMintTokenHoldersBody {
                id: types::PostGetCompressedMintTokenHoldersBodyId::TestAccount,
                jsonrpc: types::PostGetCompressedMintTokenHoldersBodyJsonrpc::X20,
                method: types::PostGetCompressedMintTokenHoldersBodyMethod::GetCompressedMintTokenHolders,
                params,
            }
        }

        pub fn make_get_compressed_token_account_balance_body(
            params: types::PostGetCompressedTokenAccountBalanceBodyParams,
        ) -> types::PostGetCompressedTokenAccountBalanceBody {
            types::PostGetCompressedTokenAccountBalanceBody {
                id: types::PostGetCompressedTokenAccountBalanceBodyId::TestAccount,
                jsonrpc: types::PostGetCompressedTokenAccountBalanceBodyJsonrpc::X20,
                method: types::PostGetCompressedTokenAccountBalanceBodyMethod::GetCompressedTokenAccountBalance,
                params,
            }
        }

        pub fn make_get_validity_proof_v2_body(
            params: types::PostGetValidityProofV2BodyParams,
        ) -> types::PostGetValidityProofV2Body {
            types::PostGetValidityProofV2Body {
                id: types::PostGetValidityProofV2BodyId::TestAccount,
                jsonrpc: types::PostGetValidityProofV2BodyJsonrpc::X20,
                method: types::PostGetValidityProofV2BodyMethod::GetValidityProofV2,
                params,
            }
        }

        pub fn make_get_multiple_new_address_proofs_v2_body(
            params: Vec<types::AddressWithTree>,
        ) -> types::PostGetMultipleNewAddressProofsV2Body {
            types::PostGetMultipleNewAddressProofsV2Body {
                id: types::PostGetMultipleNewAddressProofsV2BodyId::TestAccount,
                jsonrpc: types::PostGetMultipleNewAddressProofsV2BodyJsonrpc::X20,
                method: types::PostGetMultipleNewAddressProofsV2BodyMethod::GetMultipleNewAddressProofsV2,
                params,
            }
        }

        pub fn make_get_compressed_token_accounts_by_delegate_v2_body(
            params: types::PostGetCompressedTokenAccountsByDelegateV2BodyParams,
        ) -> types::PostGetCompressedTokenAccountsByDelegateV2Body {
            types::PostGetCompressedTokenAccountsByDelegateV2Body {
                id: types::PostGetCompressedTokenAccountsByDelegateV2BodyId::TestAccount,
                jsonrpc: types::PostGetCompressedTokenAccountsByDelegateV2BodyJsonrpc::X20,
                method: types::PostGetCompressedTokenAccountsByDelegateV2BodyMethod::GetCompressedTokenAccountsByDelegateV2,
                params,
            }
        }

        pub fn make_get_compressed_token_accounts_by_owner_v2_body(
            params: types::PostGetCompressedTokenAccountsByOwnerV2BodyParams,
        ) -> types::PostGetCompressedTokenAccountsByOwnerV2Body {
            types::PostGetCompressedTokenAccountsByOwnerV2Body {
                id: types::PostGetCompressedTokenAccountsByOwnerV2BodyId::TestAccount,
                jsonrpc: types::PostGetCompressedTokenAccountsByOwnerV2BodyJsonrpc::X20,
                method: types::PostGetCompressedTokenAccountsByOwnerV2BodyMethod::GetCompressedTokenAccountsByOwnerV2,
                params,
            }
        }

        pub fn make_get_compressed_token_balances_by_owner_v2_body(
            params: types::PostGetCompressedTokenBalancesByOwnerV2BodyParams,
        ) -> types::PostGetCompressedTokenBalancesByOwnerV2Body {
            types::PostGetCompressedTokenBalancesByOwnerV2Body {
                id: types::PostGetCompressedTokenBalancesByOwnerV2BodyId::TestAccount,
                jsonrpc: types::PostGetCompressedTokenBalancesByOwnerV2BodyJsonrpc::X20,
                method: types::PostGetCompressedTokenBalancesByOwnerV2BodyMethod::GetCompressedTokenBalancesByOwnerV2,
                params,
            }
        }

        pub fn make_get_compression_signatures_for_account_body(
            params: types::PostGetCompressionSignaturesForAccountBodyParams,
        ) -> types::PostGetCompressionSignaturesForAccountBody {
            types::PostGetCompressionSignaturesForAccountBody {
                id: types::PostGetCompressionSignaturesForAccountBodyId::TestAccount,
                jsonrpc: types::PostGetCompressionSignaturesForAccountBodyJsonrpc::X20,
                method: types::PostGetCompressionSignaturesForAccountBodyMethod::GetCompressionSignaturesForAccount,
                params,
            }
        }

        pub fn make_get_compression_signatures_for_address_body(
            params: types::PostGetCompressionSignaturesForAddressBodyParams,
        ) -> types::PostGetCompressionSignaturesForAddressBody {
            types::PostGetCompressionSignaturesForAddressBody {
                id: types::PostGetCompressionSignaturesForAddressBodyId::TestAccount,
                jsonrpc: types::PostGetCompressionSignaturesForAddressBodyJsonrpc::X20,
                method: types::PostGetCompressionSignaturesForAddressBodyMethod::GetCompressionSignaturesForAddress,
                params,
            }
        }

        pub fn make_get_compression_signatures_for_owner_body(
            params: types::PostGetCompressionSignaturesForOwnerBodyParams,
        ) -> types::PostGetCompressionSignaturesForOwnerBody {
            types::PostGetCompressionSignaturesForOwnerBody {
                id: types::PostGetCompressionSignaturesForOwnerBodyId::TestAccount,
                jsonrpc: types::PostGetCompressionSignaturesForOwnerBodyJsonrpc::X20,
                method: types::PostGetCompressionSignaturesForOwnerBodyMethod::GetCompressionSignaturesForOwner,
                params,
            }
        }

        pub fn make_get_compression_signatures_for_token_owner_body(
            params: types::PostGetCompressionSignaturesForTokenOwnerBodyParams,
        ) -> types::PostGetCompressionSignaturesForTokenOwnerBody {
            types::PostGetCompressionSignaturesForTokenOwnerBody {
                id: types::PostGetCompressionSignaturesForTokenOwnerBodyId::TestAccount,
                jsonrpc: types::PostGetCompressionSignaturesForTokenOwnerBodyJsonrpc::X20,
                method: types::PostGetCompressionSignaturesForTokenOwnerBodyMethod::GetCompressionSignaturesForTokenOwner,
                params,
            }
        }

        pub fn make_get_indexer_health_body() -> types::PostGetIndexerHealthBody {
            types::PostGetIndexerHealthBody {
                id: types::PostGetIndexerHealthBodyId::TestAccount,
                jsonrpc: types::PostGetIndexerHealthBodyJsonrpc::X20,
                method: types::PostGetIndexerHealthBodyMethod::GetIndexerHealth,
            }
        }

        pub fn make_get_indexer_slot_body() -> types::PostGetIndexerSlotBody {
            types::PostGetIndexerSlotBody {
                id: types::PostGetIndexerSlotBodyId::TestAccount,
                jsonrpc: types::PostGetIndexerSlotBodyJsonrpc::X20,
                method: types::PostGetIndexerSlotBodyMethod::GetIndexerSlot,
            }
        }

        pub fn make_get_multiple_compressed_account_proofs_body(
            params: Vec<types::Hash>,
        ) -> types::PostGetMultipleCompressedAccountProofsBody {
            types::PostGetMultipleCompressedAccountProofsBody {
                id: types::PostGetMultipleCompressedAccountProofsBodyId::TestAccount,
                jsonrpc: types::PostGetMultipleCompressedAccountProofsBodyJsonrpc::X20,
                method: types::PostGetMultipleCompressedAccountProofsBodyMethod::GetMultipleCompressedAccountProofs,
                params,
            }
        }

        pub fn make_get_multiple_compressed_accounts_body(
            params: types::PostGetMultipleCompressedAccountsBodyParams,
        ) -> types::PostGetMultipleCompressedAccountsBody {
            types::PostGetMultipleCompressedAccountsBody {
                id: types::PostGetMultipleCompressedAccountsBodyId::TestAccount,
                jsonrpc: types::PostGetMultipleCompressedAccountsBodyJsonrpc::X20,
                method: types::PostGetMultipleCompressedAccountsBodyMethod::GetMultipleCompressedAccounts,
                params,
            }
        }

        pub fn make_get_validity_proof_body(
            params: types::PostGetValidityProofBodyParams,
        ) -> types::PostGetValidityProofBody {
            types::PostGetValidityProofBody {
                id: types::PostGetValidityProofBodyId::TestAccount,
                jsonrpc: types::PostGetValidityProofBodyJsonrpc::X20,
                method: types::PostGetValidityProofBodyMethod::GetValidityProof,
                params,
            }
        }

        pub fn make_get_queue_elements_body(
            params: types::PostGetQueueElementsBodyParams,
        ) -> types::PostGetQueueElementsBody {
            types::PostGetQueueElementsBody {
                id: types::PostGetQueueElementsBodyId::TestAccount,
                jsonrpc: types::PostGetQueueElementsBodyJsonrpc::X20,
                method: types::PostGetQueueElementsBodyMethod::GetQueueElements,
                params,
            }
        }

        pub fn make_get_queue_info_body(
            params: types::PostGetQueueInfoBodyParams,
        ) -> types::PostGetQueueInfoBody {
            types::PostGetQueueInfoBody {
                id: types::PostGetQueueInfoBodyId::TestAccount,
                jsonrpc: types::PostGetQueueInfoBodyJsonrpc::X20,
                method: types::PostGetQueueInfoBodyMethod::GetQueueInfo,
                params,
            }
        }

        pub fn make_get_account_interface_body(
            params: types::PostGetAccountInterfaceBodyParams,
        ) -> types::PostGetAccountInterfaceBody {
            types::PostGetAccountInterfaceBody {
                id: types::PostGetAccountInterfaceBodyId::TestAccount,
                jsonrpc: types::PostGetAccountInterfaceBodyJsonrpc::X20,
                method: types::PostGetAccountInterfaceBodyMethod::GetAccountInterface,
                params,
            }
        }

        pub fn make_get_multiple_account_interfaces_body(
            params: types::PostGetMultipleAccountInterfacesBodyParams,
        ) -> types::PostGetMultipleAccountInterfacesBody {
            types::PostGetMultipleAccountInterfacesBody {
                id: types::PostGetMultipleAccountInterfacesBodyId::TestAccount,
                jsonrpc: types::PostGetMultipleAccountInterfacesBodyJsonrpc::X20,
                method:
                    types::PostGetMultipleAccountInterfacesBodyMethod::GetMultipleAccountInterfaces,
                params,
            }
        }

        // ----------------------------------------------------------------
        // API call functions — direct reqwest, progenitor types for serde
        // ----------------------------------------------------------------

        macro_rules! api_call {
            ($fn_name:ident, $endpoint:expr, $body_type:ty, $response_type:ty) => {
                pub async fn $fn_name(
                    configuration: &Configuration,
                    body: $body_type,
                ) -> Result<$response_type, Error<$response_type>> {
                    let url = configuration.build_url($endpoint);
                    let response = configuration
                        .client
                        .post(&url)
                        .header(reqwest::header::ACCEPT, "application/json")
                        .json(&body)
                        .send()
                        .await
                        .map_err(Error::Reqwest)?;

                    let status = response.status().as_u16();
                    if status == 200 {
                        response
                            .json::<$response_type>()
                            .await
                            .map_err(Error::Reqwest)
                    } else {
                        let body = response.text().await.unwrap_or_default();
                        Err(Error::ResponseError { status, body })
                    }
                }
            };
        }

        api_call!(
            get_compressed_account_post,
            "getCompressedAccount",
            types::PostGetCompressedAccountBody,
            types::PostGetCompressedAccountResponse
        );
        api_call!(
            get_compressed_account_balance_post,
            "getCompressedAccountBalance",
            types::PostGetCompressedAccountBalanceBody,
            types::PostGetCompressedAccountBalanceResponse
        );
        api_call!(
            get_compressed_accounts_by_owner_post,
            "getCompressedAccountsByOwner",
            types::PostGetCompressedAccountsByOwnerBody,
            types::PostGetCompressedAccountsByOwnerResponse
        );
        api_call!(
            get_compressed_accounts_by_owner_v2_post,
            "getCompressedAccountsByOwnerV2",
            types::PostGetCompressedAccountsByOwnerV2Body,
            types::PostGetCompressedAccountsByOwnerV2Response
        );
        api_call!(
            get_compressed_balance_by_owner_post,
            "getCompressedBalanceByOwner",
            types::PostGetCompressedBalanceByOwnerBody,
            types::PostGetCompressedBalanceByOwnerResponse
        );
        api_call!(
            get_compressed_mint_token_holders_post,
            "getCompressedMintTokenHolders",
            types::PostGetCompressedMintTokenHoldersBody,
            types::PostGetCompressedMintTokenHoldersResponse
        );
        api_call!(
            get_compressed_token_account_balance_post,
            "getCompressedTokenAccountBalance",
            types::PostGetCompressedTokenAccountBalanceBody,
            types::PostGetCompressedTokenAccountBalanceResponse
        );
        api_call!(
            get_compressed_token_accounts_by_delegate_post,
            "getCompressedTokenAccountsByDelegate",
            types::PostGetCompressedTokenAccountsByDelegateBody,
            types::PostGetCompressedTokenAccountsByDelegateResponse
        );
        api_call!(
            get_compressed_token_accounts_by_delegate_v2_post,
            "getCompressedTokenAccountsByDelegateV2",
            types::PostGetCompressedTokenAccountsByDelegateV2Body,
            types::PostGetCompressedTokenAccountsByDelegateV2Response
        );
        api_call!(
            get_compressed_token_accounts_by_owner_post,
            "getCompressedTokenAccountsByOwner",
            types::PostGetCompressedTokenAccountsByOwnerBody,
            types::PostGetCompressedTokenAccountsByOwnerResponse
        );
        api_call!(
            get_compressed_token_accounts_by_owner_v2_post,
            "getCompressedTokenAccountsByOwnerV2",
            types::PostGetCompressedTokenAccountsByOwnerV2Body,
            types::PostGetCompressedTokenAccountsByOwnerV2Response
        );
        api_call!(
            get_compressed_token_balances_by_owner_post,
            "getCompressedTokenBalancesByOwner",
            types::PostGetCompressedTokenBalancesByOwnerBody,
            types::PostGetCompressedTokenBalancesByOwnerResponse
        );
        api_call!(
            get_compressed_token_balances_by_owner_v2_post,
            "getCompressedTokenBalancesByOwnerV2",
            types::PostGetCompressedTokenBalancesByOwnerV2Body,
            types::PostGetCompressedTokenBalancesByOwnerV2Response
        );
        api_call!(
            get_compression_signatures_for_account_post,
            "getCompressionSignaturesForAccount",
            types::PostGetCompressionSignaturesForAccountBody,
            types::PostGetCompressionSignaturesForAccountResponse
        );
        api_call!(
            get_compression_signatures_for_address_post,
            "getCompressionSignaturesForAddress",
            types::PostGetCompressionSignaturesForAddressBody,
            types::PostGetCompressionSignaturesForAddressResponse
        );
        api_call!(
            get_compression_signatures_for_owner_post,
            "getCompressionSignaturesForOwner",
            types::PostGetCompressionSignaturesForOwnerBody,
            types::PostGetCompressionSignaturesForOwnerResponse
        );
        api_call!(
            get_compression_signatures_for_token_owner_post,
            "getCompressionSignaturesForTokenOwner",
            types::PostGetCompressionSignaturesForTokenOwnerBody,
            types::PostGetCompressionSignaturesForTokenOwnerResponse
        );
        api_call!(
            get_indexer_health_post,
            "getIndexerHealth",
            types::PostGetIndexerHealthBody,
            types::PostGetIndexerHealthResponse
        );
        api_call!(
            get_indexer_slot_post,
            "getIndexerSlot",
            types::PostGetIndexerSlotBody,
            types::PostGetIndexerSlotResponse
        );
        api_call!(
            get_multiple_compressed_account_proofs_post,
            "getMultipleCompressedAccountProofs",
            types::PostGetMultipleCompressedAccountProofsBody,
            types::PostGetMultipleCompressedAccountProofsResponse
        );
        api_call!(
            get_multiple_compressed_accounts_post,
            "getMultipleCompressedAccounts",
            types::PostGetMultipleCompressedAccountsBody,
            types::PostGetMultipleCompressedAccountsResponse
        );
        api_call!(
            get_multiple_new_address_proofs_v2_post,
            "getMultipleNewAddressProofsV2",
            types::PostGetMultipleNewAddressProofsV2Body,
            types::PostGetMultipleNewAddressProofsV2Response
        );
        api_call!(
            get_validity_proof_post,
            "getValidityProof",
            types::PostGetValidityProofBody,
            types::PostGetValidityProofResponse
        );
        api_call!(
            get_validity_proof_v2_post,
            "getValidityProofV2",
            types::PostGetValidityProofV2Body,
            types::PostGetValidityProofV2Response
        );
        api_call!(
            get_queue_elements_post,
            "getQueueElements",
            types::PostGetQueueElementsBody,
            types::PostGetQueueElementsResponse
        );
        api_call!(
            get_queue_info_post,
            "getQueueInfo",
            types::PostGetQueueInfoBody,
            types::PostGetQueueInfoResponse
        );
        api_call!(
            get_account_interface_post,
            "getAccountInterface",
            types::PostGetAccountInterfaceBody,
            types::PostGetAccountInterfaceResponse
        );
        api_call!(
            get_multiple_account_interfaces_post,
            "getMultipleAccountInterfaces",
            types::PostGetMultipleAccountInterfacesBody,
            types::PostGetMultipleAccountInterfacesResponse
        );
    }
}

#[cfg(test)]
mod tests {
    use super::apis::{configuration::Configuration, default_api};

    #[test]
    fn test_parse_url_with_api_key() {
        let (base, key) = Configuration::parse_url("https://rpc.example.com?api-key=MY_KEY");
        assert_eq!(base, "https://rpc.example.com");
        assert_eq!(key, Some("MY_KEY".to_string()));
    }

    #[test]
    fn test_parse_url_without_api_key() {
        let (base, key) = Configuration::parse_url("https://rpc.example.com");
        assert_eq!(base, "https://rpc.example.com");
        assert_eq!(key, None);
    }

    #[test]
    fn test_parse_url_with_other_query_params() {
        let (base, key) =
            Configuration::parse_url("https://rpc.example.com?other=value&api-key=KEY123");
        assert_eq!(base, "https://rpc.example.com");
        assert_eq!(key, Some("KEY123".to_string()));
    }

    #[test]
    fn test_new_with_api_key_in_url() {
        let config = Configuration::new("https://rpc.example.com?api-key=SECRET".to_string());
        assert_eq!(config.base_path, "https://rpc.example.com");
        assert_eq!(config.api_key, Some("SECRET".to_string()));
    }

    #[test]
    fn test_make_get_compressed_account_body() {
        let params = super::types::PostGetCompressedAccountBodyParams {
            address: Some(super::types::SerializablePubkey(
                "11111111111111111111111111111111".to_string(),
            )),
            hash: None,
        };
        let body = default_api::make_get_compressed_account_body(params);
        let json = serde_json::to_value(&body).unwrap();
        assert_eq!(json["jsonrpc"], "2.0");
        assert_eq!(json["method"], "getCompressedAccount");
        assert_eq!(json["id"], "test-account");
        assert_eq!(
            json["params"]["address"],
            "11111111111111111111111111111111"
        );
    }

    #[test]
    fn test_make_get_indexer_health_body() {
        let body = default_api::make_get_indexer_health_body();
        let json = serde_json::to_value(&body).unwrap();
        assert_eq!(json["jsonrpc"], "2.0");
        assert_eq!(json["method"], "getIndexerHealth");
    }

    #[test]
    fn test_make_get_indexer_slot_body() {
        let body = default_api::make_get_indexer_slot_body();
        let json = serde_json::to_value(&body).unwrap();
        assert_eq!(json["jsonrpc"], "2.0");
        assert_eq!(json["method"], "getIndexerSlot");
    }

    #[test]
    fn test_make_get_validity_proof_body() {
        let params = super::types::PostGetValidityProofBodyParams {
            hashes: vec![super::types::Hash("abc123".to_string())],
            new_addresses_with_trees: vec![],
        };
        let body = default_api::make_get_validity_proof_body(params);
        let json = serde_json::to_value(&body).unwrap();
        assert_eq!(json["jsonrpc"], "2.0");
        assert_eq!(json["method"], "getValidityProof");
        assert_eq!(json["params"]["hashes"][0], "abc123");
    }

    #[tokio::test]
    async fn test_api_call_sends_correct_request() {
        use wiremock::{
            matchers::{header, method, path, query_param},
            Mock, MockServer, ResponseTemplate,
        };

        let mock_server = MockServer::start().await;

        let response_json = serde_json::json!({
            "jsonrpc": "2.0",
            "result": "ok",
            "id": "test-account"
        });

        Mock::given(method("POST"))
            .and(path("/getIndexerHealth"))
            .and(query_param("api-key", "TEST_KEY"))
            .and(header("accept", "application/json"))
            .respond_with(ResponseTemplate::new(200).set_body_json(&response_json))
            .mount(&mock_server)
            .await;

        let config = Configuration::new(format!("{}?api-key=TEST_KEY", mock_server.uri()));

        let body = default_api::make_get_indexer_health_body();
        let result = default_api::get_indexer_health_post(&config, body).await;

        result.expect("API call with api-key should succeed");
    }

    #[tokio::test]
    async fn test_api_call_without_api_key() {
        use wiremock::{
            matchers::{header, method, path},
            Mock, MockServer, ResponseTemplate,
        };

        let mock_server = MockServer::start().await;

        let response_json = serde_json::json!({
            "jsonrpc": "2.0",
            "result": "ok",
            "id": "test-account"
        });

        Mock::given(method("POST"))
            .and(path("/getIndexerHealth"))
            .and(header("accept", "application/json"))
            .respond_with(ResponseTemplate::new(200).set_body_json(&response_json))
            .mount(&mock_server)
            .await;

        let config = Configuration::new(mock_server.uri());

        let body = default_api::make_get_indexer_health_body();
        let result = default_api::get_indexer_health_post(&config, body).await;

        result.expect("API call without api-key should succeed");
    }

    #[tokio::test]
    async fn test_api_call_error_response() {
        use wiremock::{
            matchers::{method, path},
            Mock, MockServer, ResponseTemplate,
        };

        let mock_server = MockServer::start().await;

        Mock::given(method("POST"))
            .and(path("/getIndexerHealth"))
            .respond_with(ResponseTemplate::new(500).set_body_string("Internal Server Error"))
            .mount(&mock_server)
            .await;

        let config = Configuration::new(mock_server.uri());

        let body = default_api::make_get_indexer_health_body();
        let result = default_api::get_indexer_health_post(&config, body).await;

        match result {
            Err(super::apis::Error::ResponseError { status, body }) => {
                assert_eq!(status, 500);
                assert_eq!(body, "Internal Server Error");
            }
            other => panic!("Expected ResponseError, got {:?}", other),
        }
    }
}