sellapp-sdk 0.2.1

Official Rust SDK for the SellApp API: manage products, orders, subscriptions, and customers.
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
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
// This file is auto-generated by oagen. Do not edit.

use crate::client::Client;
#[allow(unused_imports)]
use crate::enums::*;
use crate::error::Error;
#[allow(unused_imports)]
use crate::models::*;
#[allow(unused_imports)]
use serde::Serialize;

pub struct SubscriptionsApi<'a> {
    pub(crate) client: &'a Client,
}

#[derive(Debug, Clone, Serialize)]
pub struct CancelParams {
    /// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(rename = "X-STORE")]
    pub x_store: Option<String>,
    /// Request body sent with this call.
    ///
    /// Required.
    #[serde(skip)]
    pub body: SdkCancelSubscriptionRequestApplicationJson,
}

impl CancelParams {
    /// Construct a new `CancelParams` with the required fields set.
    #[allow(deprecated)]
    pub fn new(body: SdkCancelSubscriptionRequestApplicationJson) -> Self {
        Self {
            x_store: Default::default(),
            body,
        }
    }
}

#[derive(Debug, Clone, Serialize)]
pub struct ListSubscriptionsParams {
    /// Number of items to return per page.
    ///
    /// Defaults to `15`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub limit: Option<i64>,
    /// Page number to return.
    ///
    /// Defaults to `1`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub page: Option<i64>,
    /// Set to false to return at most 100 matching items in one data array without pagination links or metadata.
    ///
    /// Defaults to `true`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pagination: Option<bool>,
    /// Filter by one or more subscription statuses. Repeat the parameter to select several; a single `status=ACTIVE` works too. A status outside the list is rejected with a validation error.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(rename = "status[]")]
    pub status: Option<Vec<SubscriptionsStatus>>,
    /// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(rename = "X-STORE")]
    pub x_store: Option<String>,
}

impl Default for ListSubscriptionsParams {
    #[allow(deprecated)]
    fn default() -> Self {
        Self {
            limit: Some(15),
            page: Some(1),
            pagination: Some(true),
            status: Default::default(),
            x_store: Default::default(),
        }
    }
}

#[derive(Debug, Clone, Serialize)]
pub struct SearchSubscriptionsParams {
    /// Number of items to return per page.
    ///
    /// Defaults to `15`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub limit: Option<i64>,
    /// Page number to return.
    ///
    /// Defaults to `1`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub page: Option<i64>,
    /// Set to false to return at most 100 matching items in one data array without pagination links or metadata.
    ///
    /// Defaults to `true`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pagination: Option<bool>,
    /// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(rename = "X-STORE")]
    pub x_store: Option<String>,
    /// Request body sent with this call.
    ///
    /// Required.
    #[serde(skip)]
    pub body: SdkSearchSubscriptionsRequestApplicationJson,
}

impl SearchSubscriptionsParams {
    /// Construct a new `SearchSubscriptionsParams` with the required fields set.
    #[allow(deprecated)]
    pub fn new(body: SdkSearchSubscriptionsRequestApplicationJson) -> Self {
        Self {
            limit: Some(15),
            page: Some(1),
            pagination: Some(true),
            x_store: Default::default(),
            body,
        }
    }
}

#[derive(Debug, Clone, Default, Serialize)]
pub struct GetSubscriptionParams {
    /// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(rename = "X-STORE")]
    pub x_store: Option<String>,
}

#[derive(Debug, Clone, Default, Serialize)]
pub struct GetCapabilitiesParams {
    /// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(rename = "X-STORE")]
    pub x_store: Option<String>,
}

#[derive(Debug, Clone, Serialize)]
pub struct CancelAtPeriodEndParams {
    /// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(rename = "X-STORE")]
    pub x_store: Option<String>,
    /// Request body sent with this call.
    ///
    /// Required.
    #[serde(skip)]
    pub body: SdkCancelSubscriptionAtPeriodEndRequestApplicationJson,
}

impl CancelAtPeriodEndParams {
    /// Construct a new `CancelAtPeriodEndParams` with the required fields set.
    #[allow(deprecated)]
    pub fn new(body: SdkCancelSubscriptionAtPeriodEndRequestApplicationJson) -> Self {
        Self {
            x_store: Default::default(),
            body,
        }
    }
}

#[derive(Debug, Clone, Serialize)]
pub struct CancelImmediatelyParams {
    /// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(rename = "X-STORE")]
    pub x_store: Option<String>,
    /// Request body sent with this call.
    ///
    /// Required.
    #[serde(skip)]
    pub body: SdkCancelSubscriptionImmediatelyRequestApplicationJson,
}

impl CancelImmediatelyParams {
    /// Construct a new `CancelImmediatelyParams` with the required fields set.
    #[allow(deprecated)]
    pub fn new(body: SdkCancelSubscriptionImmediatelyRequestApplicationJson) -> Self {
        Self {
            x_store: Default::default(),
            body,
        }
    }
}

#[derive(Debug, Clone, Serialize)]
pub struct KeepParams {
    /// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(rename = "X-STORE")]
    pub x_store: Option<String>,
    /// Request body sent with this call.
    ///
    /// Required.
    #[serde(skip)]
    pub body: SdkKeepSubscriptionRequestApplicationJson,
}

impl KeepParams {
    /// Construct a new `KeepParams` with the required fields set.
    #[allow(deprecated)]
    pub fn new(body: SdkKeepSubscriptionRequestApplicationJson) -> Self {
        Self {
            x_store: Default::default(),
            body,
        }
    }
}

#[derive(Debug, Clone, Serialize)]
pub struct PauseParams {
    /// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(rename = "X-STORE")]
    pub x_store: Option<String>,
    /// Request body sent with this call.
    ///
    /// Required.
    #[serde(skip)]
    pub body: SdkPauseSubscriptionRequestApplicationJson,
}

impl PauseParams {
    /// Construct a new `PauseParams` with the required fields set.
    #[allow(deprecated)]
    pub fn new(body: SdkPauseSubscriptionRequestApplicationJson) -> Self {
        Self {
            x_store: Default::default(),
            body,
        }
    }
}

#[derive(Debug, Clone, Serialize)]
pub struct ResumeParams {
    /// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(rename = "X-STORE")]
    pub x_store: Option<String>,
    /// Request body sent with this call.
    ///
    /// Required.
    #[serde(skip)]
    pub body: SdkResumeSubscriptionRequestApplicationJson,
}

impl ResumeParams {
    /// Construct a new `ResumeParams` with the required fields set.
    #[allow(deprecated)]
    pub fn new(body: SdkResumeSubscriptionRequestApplicationJson) -> Self {
        Self {
            x_store: Default::default(),
            body,
        }
    }
}

#[derive(Debug, Clone, Serialize)]
pub struct UpdatePaymentMethodParams {
    /// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(rename = "X-STORE")]
    pub x_store: Option<String>,
    /// Request body sent with this call.
    ///
    /// Required.
    #[serde(skip)]
    pub body: SdkUpdateSubscriptionPaymentMethodRequestApplicationJson,
}

impl UpdatePaymentMethodParams {
    /// Construct a new `UpdatePaymentMethodParams` with the required fields set.
    #[allow(deprecated)]
    pub fn new(body: SdkUpdateSubscriptionPaymentMethodRequestApplicationJson) -> Self {
        Self {
            x_store: Default::default(),
            body,
        }
    }
}

#[derive(Debug, Clone, Serialize)]
pub struct PreviewPlanChangeParams {
    /// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(rename = "X-STORE")]
    pub x_store: Option<String>,
    /// Request body sent with this call.
    ///
    /// Required.
    #[serde(skip)]
    pub body: SdkPreviewSubscriptionPlanChangeRequestApplicationJson,
}

impl PreviewPlanChangeParams {
    /// Construct a new `PreviewPlanChangeParams` with the required fields set.
    #[allow(deprecated)]
    pub fn new(body: SdkPreviewSubscriptionPlanChangeRequestApplicationJson) -> Self {
        Self {
            x_store: Default::default(),
            body,
        }
    }
}

#[derive(Debug, Clone, Serialize)]
pub struct ConfirmPlanChangeParams {
    /// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(rename = "X-STORE")]
    pub x_store: Option<String>,
    /// Request body sent with this call.
    ///
    /// Required.
    #[serde(skip)]
    pub body: SdkConfirmSubscriptionPlanChangeRequestApplicationJson,
}

impl ConfirmPlanChangeParams {
    /// Construct a new `ConfirmPlanChangeParams` with the required fields set.
    #[allow(deprecated)]
    pub fn new(body: SdkConfirmSubscriptionPlanChangeRequestApplicationJson) -> Self {
        Self {
            x_store: Default::default(),
            body,
        }
    }
}

#[derive(Debug, Clone, Serialize)]
pub struct PreviewRenewalDateParams {
    /// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(rename = "X-STORE")]
    pub x_store: Option<String>,
    /// Request body sent with this call.
    ///
    /// Required.
    #[serde(skip)]
    pub body: SdkPreviewSubscriptionRenewalDateChangeRequestApplicationJson,
}

impl PreviewRenewalDateParams {
    /// Construct a new `PreviewRenewalDateParams` with the required fields set.
    #[allow(deprecated)]
    pub fn new(body: SdkPreviewSubscriptionRenewalDateChangeRequestApplicationJson) -> Self {
        Self {
            x_store: Default::default(),
            body,
        }
    }
}

#[derive(Debug, Clone, Serialize)]
pub struct ConfirmRenewalDateParams {
    /// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(rename = "X-STORE")]
    pub x_store: Option<String>,
    /// Request body sent with this call.
    ///
    /// Required.
    #[serde(skip)]
    pub body: SdkConfirmSubscriptionRenewalDateChangeRequestApplicationJson,
}

impl ConfirmRenewalDateParams {
    /// Construct a new `ConfirmRenewalDateParams` with the required fields set.
    #[allow(deprecated)]
    pub fn new(body: SdkConfirmSubscriptionRenewalDateChangeRequestApplicationJson) -> Self {
        Self {
            x_store: Default::default(),
            body,
        }
    }
}

impl<'a> SubscriptionsApi<'a> {
    /// Cancel a subscription
    ///
    /// Cancel an active subscription now or at period end, or one with a payment still owed now: a past due one the store bills in house, or a past due or unpaid Stripe, PayPal, or Razorpay subscription. cancel_at_period_end is required. Refund flags are valid only when it is false; period-end cancellation does not refund the last payment. New integrations should use the cancel-at-period-end and cancel-immediately lifecycle actions instead. A provider refusal, or a state check such as a change already in progress or a subscription that is no longer active, returns `422` with the refusal sentence under `errors.subscription`. Requires the `invoice` Sanctum ability. Refunds are off by default. refund_last_payment requests a real refund; pro_rated_refund requires refund_last_payment and defaults to false. While a Stripe, PayPal, or Razorpay subscription is past due or unpaid, its current period was never paid for, so a pro-rated refund returns `422`; a full refund or no refund still works. Cancellation can succeed even if the requested refund fails. A 200 response or confirmed cancellation does not prove a refund, and the action response does not expose the provider refund result. Check the order and payment-provider refund records before retrying; do not replay cancellation as a refund-recovery step. Reuse an idempotency key only with identical action input and actor. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
    #[deprecated]
    #[allow(deprecated)]
    pub async fn cancel(
        &self,
        subscription: &str,
        params: CancelParams,
    ) -> Result<SdkCancelSubscriptionResponseValue200ApplicationJson, Error> {
        self.cancel_with_options(subscription, params, None).await
    }

    /// Variant of [`Self::cancel`] that accepts per-request [`crate::RequestOptions`].
    #[deprecated]
    #[allow(deprecated)]
    pub async fn cancel_with_options(
        &self,
        subscription: &str,
        params: CancelParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkCancelSubscriptionResponseValue200ApplicationJson, Error> {
        self.cancel_raw(subscription, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    #[deprecated]
    pub async fn cancel_raw(
        &self,
        subscription: &str,
        params: CancelParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkCancelSubscriptionResponseValue200ApplicationJson>, Error>
    {
        let subscription = crate::client::path_segment(subscription);
        let path = format!("/v2/subscriptions/{subscription}/cancel");
        let method = http::Method::PATCH;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = true;
        merged.operation_id = Some("cancelSubscription".to_string());
        let options = Some(&merged);
        self.client
            .request_with_body_schema_opts_raw(
                method,
                &path,
                &params,
                Some(&params.body),
                options,
                "PATCH /v2/subscriptions/{subscription}/cancel",
            )
            .await
    }

    /// List subscriptions
    ///
    /// List the subscriptions belonging to the authenticated store, ordered by identifier ascending. Requires the `invoice` Sanctum ability. Use `status[]` to keep only the states you care about. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
    pub async fn list_subscriptions(
        &self,
        params: ListSubscriptionsParams,
    ) -> Result<SdkListSubscriptionsResponseValue200ApplicationJson, Error> {
        self.list_subscriptions_with_options(params, None).await
    }

    /// Variant of [`Self::list_subscriptions`] that accepts per-request [`crate::RequestOptions`].
    pub async fn list_subscriptions_with_options(
        &self,
        params: ListSubscriptionsParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkListSubscriptionsResponseValue200ApplicationJson, Error> {
        self.list_subscriptions_raw(params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn list_subscriptions_raw(
        &self,
        params: ListSubscriptionsParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkListSubscriptionsResponseValue200ApplicationJson>, Error>
    {
        let path = "/v2/subscriptions".to_string();
        let method = http::Method::GET;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("listSubscriptions".to_string());
        let options = Some(&merged);
        self.client
            .request_with_query_schema_opts_raw(
                method,
                &path,
                &params,
                options,
                "GET /v2/subscriptions",
            )
            .await
    }

    /// Search subscriptions
    ///
    /// Search the store's subscriptions, ordered by identifier ascending unless `sort` says otherwise. `search.value` matches the provider subscription ID, the provider customer ID, and the customer email. Filter on `id`, `customer_id` (the SellApp customer ID, as in `customer.id`), `provider`, `status`, or `product_variant_id`, and sort on `id`, `status`, `current_period_start`, `current_period_end`, `created_at`, or `updated_at`. Requires the `invoice` Sanctum ability. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
    pub async fn search_subscriptions(
        &self,
        params: SearchSubscriptionsParams,
    ) -> Result<SdkSearchSubscriptionsResponseValue200ApplicationJson, Error> {
        self.search_subscriptions_with_options(params, None).await
    }

    /// Variant of [`Self::search_subscriptions`] that accepts per-request [`crate::RequestOptions`].
    pub async fn search_subscriptions_with_options(
        &self,
        params: SearchSubscriptionsParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkSearchSubscriptionsResponseValue200ApplicationJson, Error> {
        self.search_subscriptions_raw(params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn search_subscriptions_raw(
        &self,
        params: SearchSubscriptionsParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkSearchSubscriptionsResponseValue200ApplicationJson>, Error>
    {
        let path = "/v2/subscriptions/search".to_string();
        let method = http::Method::POST;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("searchSubscriptions".to_string());
        let options = Some(&merged);
        self.client
            .request_with_body_schema_opts_raw(
                method,
                &path,
                &params,
                Some(&params.body),
                options,
                "POST /v2/subscriptions/search",
            )
            .await
    }

    /// Retrieve a subscription
    ///
    /// Retrieve one subscription by its SellApp subscription record identifier. Requires the `invoice` Sanctum ability. Foreign-store identifiers return not found. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
    pub async fn get_subscription(
        &self,
        product_subscription: &str,
        params: GetSubscriptionParams,
    ) -> Result<SdkGetSubscriptionResponseValue200ApplicationJson, Error> {
        self.get_subscription_with_options(product_subscription, params, None)
            .await
    }

    /// Variant of [`Self::get_subscription`] that accepts per-request [`crate::RequestOptions`].
    pub async fn get_subscription_with_options(
        &self,
        product_subscription: &str,
        params: GetSubscriptionParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkGetSubscriptionResponseValue200ApplicationJson, Error> {
        self.get_subscription_raw(product_subscription, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn get_subscription_raw(
        &self,
        product_subscription: &str,
        params: GetSubscriptionParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkGetSubscriptionResponseValue200ApplicationJson>, Error> {
        let product_subscription = crate::client::path_segment(product_subscription);
        let path = format!("/v2/subscriptions/{product_subscription}");
        let method = http::Method::GET;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("getSubscription".to_string());
        let options = Some(&merged);
        self.client
            .request_with_query_schema_opts_raw(
                method,
                &path,
                &params,
                options,
                "GET /v2/subscriptions/{productSubscription}",
            )
            .await
    }

    /// View subscription capabilities
    ///
    /// Return the lifecycle actions currently supported for a subscription, each with the reason the customer and the seller are shown. A `customer_only` status names who owns the action rather than who may call the API: a store token carries a plan change and a payment method update on the customer's behalf, while a `customer_only` auto-renewal switch stays with the customer portal. `set_auto_renew` has no API route at all. While a Stripe, PayPal, or Razorpay subscription is past due or unpaid, every action except `cancel_immediately` and, on Razorpay, `update_payment_method`, is `unsupported`, and a subscription the store bills in house that is on hold for an unpaid renewal reports `resume` as `customer_only`, because only the customer can pay to resume it. Requires the `invoice` Sanctum ability. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
    pub async fn get_capabilities(
        &self,
        product_subscription: &str,
        params: GetCapabilitiesParams,
    ) -> Result<SdkGetSubscriptionCapabilitiesResponseValue200ApplicationJson, Error> {
        self.get_capabilities_with_options(product_subscription, params, None)
            .await
    }

    /// Variant of [`Self::get_capabilities`] that accepts per-request [`crate::RequestOptions`].
    pub async fn get_capabilities_with_options(
        &self,
        product_subscription: &str,
        params: GetCapabilitiesParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkGetSubscriptionCapabilitiesResponseValue200ApplicationJson, Error> {
        self.get_capabilities_raw(product_subscription, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn get_capabilities_raw(
        &self,
        product_subscription: &str,
        params: GetCapabilitiesParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<
        crate::RawResponse<SdkGetSubscriptionCapabilitiesResponseValue200ApplicationJson>,
        Error,
    > {
        let product_subscription = crate::client::path_segment(product_subscription);
        let path = format!("/v2/subscriptions/{product_subscription}/capabilities");
        let method = http::Method::GET;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = false;
        merged.operation_id = Some("getSubscriptionCapabilities".to_string());
        let options = Some(&merged);
        self.client
            .request_with_query_schema_opts_raw(
                method,
                &path,
                &params,
                options,
                "GET /v2/subscriptions/{productSubscription}/capabilities",
            )
            .await
    }

    /// Cancel a subscription at period end
    ///
    /// Schedule cancellation at the end of the current billing period without requesting a refund. Inspect capabilities first. PayPal has no cancellation at period end, so on a PayPal subscription this cancels it with PayPal straight away and keeps the customer's access until the period ends; it can't be kept afterwards. The response records the cancellation action; retrieve the subscription to observe its current state. Reuse an idempotency key only with identical action input and actor. A provider refusal, or a state check such as a change already in progress or a subscription that is no longer active, returns `422` with the refusal sentence under `errors.subscription`. Requires the `invoice` Sanctum ability. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
    pub async fn cancel_at_period_end(
        &self,
        product_subscription: &str,
        params: CancelAtPeriodEndParams,
    ) -> Result<SdkCancelSubscriptionAtPeriodEndResponseValue200ApplicationJson, Error> {
        self.cancel_at_period_end_with_options(product_subscription, params, None)
            .await
    }

    /// Variant of [`Self::cancel_at_period_end`] that accepts per-request [`crate::RequestOptions`].
    pub async fn cancel_at_period_end_with_options(
        &self,
        product_subscription: &str,
        params: CancelAtPeriodEndParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkCancelSubscriptionAtPeriodEndResponseValue200ApplicationJson, Error> {
        self.cancel_at_period_end_raw(product_subscription, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn cancel_at_period_end_raw(
        &self,
        product_subscription: &str,
        params: CancelAtPeriodEndParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<
        crate::RawResponse<SdkCancelSubscriptionAtPeriodEndResponseValue200ApplicationJson>,
        Error,
    > {
        let product_subscription = crate::client::path_segment(product_subscription);
        let path = format!("/v2/subscriptions/{product_subscription}/actions/cancel-period-end");
        let method = http::Method::POST;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = true;
        merged.operation_id = Some("cancelSubscriptionAtPeriodEnd".to_string());
        let options = Some(&merged);
        self.client
            .request_with_body_schema_opts_raw(
                method,
                &path,
                &params,
                Some(&params.body),
                options,
                "POST /v2/subscriptions/{productSubscription}/actions/cancel-period-end",
            )
            .await
    }

    /// Cancel a subscription immediately
    ///
    /// Request immediate subscription cancellation. Inspect capabilities for provider support. This ends future billing and can change customer access. It is the one action left on a Stripe or PayPal subscription that is past due or unpaid, and one of two left on a Razorpay one alongside a payment method update. A provider refusal, or a state check such as a change already in progress or a subscription that is no longer active, returns `422` with the refusal sentence under `errors.subscription`. Requires the `invoice` Sanctum ability. Refunds are off by default. refund_last_payment requests a real refund; pro_rated_refund requires refund_last_payment and defaults to false. While a Stripe, PayPal, or Razorpay subscription is past due or unpaid, its current period was never paid for, so a pro-rated refund returns `422`; a full refund or no refund still works. Cancellation can succeed even if the requested refund fails. A 200 response or confirmed cancellation does not prove a refund, and the action response does not expose the provider refund result. Check the order and payment-provider refund records before retrying; do not replay cancellation as a refund-recovery step. Reuse an idempotency key only with identical action input and actor. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
    pub async fn cancel_immediately(
        &self,
        product_subscription: &str,
        params: CancelImmediatelyParams,
    ) -> Result<SdkCancelSubscriptionImmediatelyResponseValue200ApplicationJson, Error> {
        self.cancel_immediately_with_options(product_subscription, params, None)
            .await
    }

    /// Variant of [`Self::cancel_immediately`] that accepts per-request [`crate::RequestOptions`].
    pub async fn cancel_immediately_with_options(
        &self,
        product_subscription: &str,
        params: CancelImmediatelyParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkCancelSubscriptionImmediatelyResponseValue200ApplicationJson, Error> {
        self.cancel_immediately_raw(product_subscription, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn cancel_immediately_raw(
        &self,
        product_subscription: &str,
        params: CancelImmediatelyParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<
        crate::RawResponse<SdkCancelSubscriptionImmediatelyResponseValue200ApplicationJson>,
        Error,
    > {
        let product_subscription = crate::client::path_segment(product_subscription);
        let path = format!("/v2/subscriptions/{product_subscription}/actions/cancel-immediately");
        let method = http::Method::POST;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = true;
        merged.operation_id = Some("cancelSubscriptionImmediately".to_string());
        let options = Some(&merged);
        self.client
            .request_with_body_schema_opts_raw(
                method,
                &path,
                &params,
                Some(&params.body),
                options,
                "POST /v2/subscriptions/{productSubscription}/actions/cancel-immediately",
            )
            .await
    }

    /// Keep a subscription
    ///
    /// Stop a scheduled cancellation so the subscription keeps renewing, which is the undo for cancelling at period end. The subscription has to still be active, still be scheduled to cancel, and its period must not have ended yet. Any of those, a provider that cannot undo its own schedule (a PayPal subscription or a Razorpay trial, both already cancelled with the provider), or a change already in progress returns `422` with the refusal sentence under `errors.subscription`. Requires the `invoice` Sanctum ability. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
    pub async fn keep(
        &self,
        product_subscription: &str,
        params: KeepParams,
    ) -> Result<SdkKeepSubscriptionResponseValue200ApplicationJson, Error> {
        self.keep_with_options(product_subscription, params, None)
            .await
    }

    /// Variant of [`Self::keep`] that accepts per-request [`crate::RequestOptions`].
    pub async fn keep_with_options(
        &self,
        product_subscription: &str,
        params: KeepParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkKeepSubscriptionResponseValue200ApplicationJson, Error> {
        self.keep_raw(product_subscription, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn keep_raw(
        &self,
        product_subscription: &str,
        params: KeepParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkKeepSubscriptionResponseValue200ApplicationJson>, Error> {
        let product_subscription = crate::client::path_segment(product_subscription);
        let path = format!("/v2/subscriptions/{product_subscription}/actions/keep");
        let method = http::Method::POST;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = true;
        merged.operation_id = Some("keepSubscription".to_string());
        let options = Some(&merged);
        self.client
            .request_with_body_schema_opts_raw(
                method,
                &path,
                &params,
                Some(&params.body),
                options,
                "POST /v2/subscriptions/{productSubscription}/actions/keep",
            )
            .await
    }

    /// Pause a subscription
    ///
    /// Pause a subscription after checking capabilities. Automatic resume dates are supported by Stripe and by subscriptions the store bills in house; use a future resume_at when supplied. Other provider pauses may need an explicit resume action. Customer-originated pauses are also subject to store pause policies. Reuse an idempotency key only with identical input and actor, and retrieve the subscription after the action. A provider refusal, or a state check such as a change already in progress or a subscription that is no longer active, returns `422` with the refusal sentence under `errors.subscription`. Requires the `invoice` Sanctum ability. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
    pub async fn pause(
        &self,
        product_subscription: &str,
        params: PauseParams,
    ) -> Result<SdkPauseSubscriptionResponseValue200ApplicationJson, Error> {
        self.pause_with_options(product_subscription, params, None)
            .await
    }

    /// Variant of [`Self::pause`] that accepts per-request [`crate::RequestOptions`].
    pub async fn pause_with_options(
        &self,
        product_subscription: &str,
        params: PauseParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkPauseSubscriptionResponseValue200ApplicationJson, Error> {
        self.pause_raw(product_subscription, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn pause_raw(
        &self,
        product_subscription: &str,
        params: PauseParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkPauseSubscriptionResponseValue200ApplicationJson>, Error>
    {
        let product_subscription = crate::client::path_segment(product_subscription);
        let path = format!("/v2/subscriptions/{product_subscription}/actions/pause");
        let method = http::Method::POST;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = true;
        merged.operation_id = Some("pauseSubscription".to_string());
        let options = Some(&merged);
        self.client
            .request_with_body_schema_opts_raw(
                method,
                &path,
                &params,
                Some(&params.body),
                options,
                "POST /v2/subscriptions/{productSubscription}/actions/pause",
            )
            .await
    }

    /// Resume a subscription
    ///
    /// Resume a paused subscription and restore related entitlements where possible. A subscription that is not paused, a subscription the store bills in house that is on hold for an unpaid renewal (only the customer can resume it, by paying that renewal from the customer portal), a provider refusal, or a change already in progress returns `422` with the refusal sentence under `errors.subscription`. Requires the `invoice` Sanctum ability. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
    pub async fn resume(
        &self,
        product_subscription: &str,
        params: ResumeParams,
    ) -> Result<SdkResumeSubscriptionResponseValue200ApplicationJson, Error> {
        self.resume_with_options(product_subscription, params, None)
            .await
    }

    /// Variant of [`Self::resume`] that accepts per-request [`crate::RequestOptions`].
    pub async fn resume_with_options(
        &self,
        product_subscription: &str,
        params: ResumeParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkResumeSubscriptionResponseValue200ApplicationJson, Error> {
        self.resume_raw(product_subscription, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn resume_raw(
        &self,
        product_subscription: &str,
        params: ResumeParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<crate::RawResponse<SdkResumeSubscriptionResponseValue200ApplicationJson>, Error>
    {
        let product_subscription = crate::client::path_segment(product_subscription);
        let path = format!("/v2/subscriptions/{product_subscription}/actions/resume");
        let method = http::Method::POST;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = true;
        merged.operation_id = Some("resumeSubscription".to_string());
        let options = Some(&merged);
        self.client
            .request_with_body_schema_opts_raw(
                method,
                &path,
                &params,
                Some(&params.body),
                options,
                "POST /v2/subscriptions/{productSubscription}/actions/resume",
            )
            .await
    }

    /// Update a subscription payment method
    ///
    /// Request a subscription payment method update. A payment method belongs to the customer, and a store token requests the update on their behalf. The customer still enters the new card themselves, so the action stays `pending` and `redirect_url` is where they finish it: Stripe's hosted page for a Stripe subscription, or a SellApp page for a Razorpay one. `return_url` chooses where Stripe sends the customer afterwards; Razorpay ignores it. PayPal subscriptions and subscriptions the store bills in house don't support the update. Read `update_payment_method` in the capabilities response before calling: an unsupported payment method, or a state check such as a change already in progress, a subscription that is no longer active, or a Stripe subscription with a payment still owed, returns `422` with the refusal sentence under `errors.subscription`. Requires the `invoice` Sanctum ability. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
    pub async fn update_payment_method(
        &self,
        product_subscription: &str,
        params: UpdatePaymentMethodParams,
    ) -> Result<SdkUpdateSubscriptionPaymentMethodResponseValue200ApplicationJson, Error> {
        self.update_payment_method_with_options(product_subscription, params, None)
            .await
    }

    /// Variant of [`Self::update_payment_method`] that accepts per-request [`crate::RequestOptions`].
    pub async fn update_payment_method_with_options(
        &self,
        product_subscription: &str,
        params: UpdatePaymentMethodParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkUpdateSubscriptionPaymentMethodResponseValue200ApplicationJson, Error> {
        self.update_payment_method_raw(product_subscription, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn update_payment_method_raw(
        &self,
        product_subscription: &str,
        params: UpdatePaymentMethodParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<
        crate::RawResponse<SdkUpdateSubscriptionPaymentMethodResponseValue200ApplicationJson>,
        Error,
    > {
        let product_subscription = crate::client::path_segment(product_subscription);
        let path =
            format!("/v2/subscriptions/{product_subscription}/actions/update-payment-method");
        let method = http::Method::POST;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = true;
        merged.operation_id = Some("updateSubscriptionPaymentMethod".to_string());
        let options = Some(&merged);
        self.client
            .request_with_body_schema_opts_raw(
                method,
                &path,
                &params,
                Some(&params.body),
                options,
                "POST /v2/subscriptions/{productSubscription}/actions/update-payment-method",
            )
            .await
    }

    /// Preview a subscription plan change
    ///
    /// Preview a subscription plan change before confirming it. The preview stores the change it was taken for and returns a `preview_token` the confirmation must send back, alongside the provider's own pricing preview. On Stripe and in-house subscriptions, `preview_payload.payment_required` says whether confirming charges `amount_due` today or leaves any amount to the next invoice, and `preview_payload.renewal_date` says when the subscription renews next. A plan change belongs to the customer, and a store token previews it on their behalf; a provider refusal, or a state check such as a change already in progress or a subscription that is no longer active, returns `422` with the refusal sentence under `errors.subscription`. Requires the `invoice` Sanctum ability. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
    pub async fn preview_plan_change(
        &self,
        product_subscription: &str,
        params: PreviewPlanChangeParams,
    ) -> Result<SdkPreviewSubscriptionPlanChangeResponseValue200ApplicationJson, Error> {
        self.preview_plan_change_with_options(product_subscription, params, None)
            .await
    }

    /// Variant of [`Self::preview_plan_change`] that accepts per-request [`crate::RequestOptions`].
    pub async fn preview_plan_change_with_options(
        &self,
        product_subscription: &str,
        params: PreviewPlanChangeParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkPreviewSubscriptionPlanChangeResponseValue200ApplicationJson, Error> {
        self.preview_plan_change_raw(product_subscription, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn preview_plan_change_raw(
        &self,
        product_subscription: &str,
        params: PreviewPlanChangeParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<
        crate::RawResponse<SdkPreviewSubscriptionPlanChangeResponseValue200ApplicationJson>,
        Error,
    > {
        let product_subscription = crate::client::path_segment(product_subscription);
        let path = format!("/v2/subscriptions/{product_subscription}/actions/change-plan/preview");
        let method = http::Method::POST;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = true;
        merged.operation_id = Some("previewSubscriptionPlanChange".to_string());
        let options = Some(&merged);
        self.client
            .request_with_body_schema_opts_raw(
                method,
                &path,
                &params,
                Some(&params.body),
                options,
                "POST /v2/subscriptions/{productSubscription}/actions/change-plan/preview",
            )
            .await
    }

    /// Confirm a subscription plan change
    ///
    /// Confirm a previously previewed subscription plan change, sending back the `preview_token` for a preview of the same change. A plan change belongs to the customer, and a store token confirms it on their behalf; a provider refusal, or a state check such as a change already in progress or a subscription that is no longer active, returns `422` with the refusal sentence under `errors.subscription`. `approval_url` accompanies a `pending` action whenever the customer still has to approve the revision at the provider or pay the proration order `proration_order_id` names, and is left out entirely when the provider applied the change itself. Requires the `invoice` Sanctum ability. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
    pub async fn confirm_plan_change(
        &self,
        product_subscription: &str,
        params: ConfirmPlanChangeParams,
    ) -> Result<SdkConfirmSubscriptionPlanChangeResponseValue200ApplicationJson, Error> {
        self.confirm_plan_change_with_options(product_subscription, params, None)
            .await
    }

    /// Variant of [`Self::confirm_plan_change`] that accepts per-request [`crate::RequestOptions`].
    pub async fn confirm_plan_change_with_options(
        &self,
        product_subscription: &str,
        params: ConfirmPlanChangeParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkConfirmSubscriptionPlanChangeResponseValue200ApplicationJson, Error> {
        self.confirm_plan_change_raw(product_subscription, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn confirm_plan_change_raw(
        &self,
        product_subscription: &str,
        params: ConfirmPlanChangeParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<
        crate::RawResponse<SdkConfirmSubscriptionPlanChangeResponseValue200ApplicationJson>,
        Error,
    > {
        let product_subscription = crate::client::path_segment(product_subscription);
        let path = format!("/v2/subscriptions/{product_subscription}/actions/change-plan/confirm");
        let method = http::Method::POST;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = true;
        merged.operation_id = Some("confirmSubscriptionPlanChange".to_string());
        let options = Some(&merged);
        self.client
            .request_with_body_schema_opts_raw(
                method,
                &path,
                &params,
                Some(&params.body),
                options,
                "POST /v2/subscriptions/{productSubscription}/actions/change-plan/confirm",
            )
            .await
    }

    /// Preview a subscription renewal date change
    ///
    /// Preview a new renewal date before confirmation when the subscription's billing-date policy requires one. No payment method supports renewal-date changes today: Stripe, PayPal, Razorpay, and subscriptions the store bills in house all report `shift_billing_date` as `unsupported`, so this returns `422` with the refusal sentence under `errors.subscription`. Read the capabilities response first. Requires the `invoice` Sanctum ability. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
    pub async fn preview_renewal_date(
        &self,
        product_subscription: &str,
        params: PreviewRenewalDateParams,
    ) -> Result<SdkPreviewSubscriptionRenewalDateChangeResponseValue200ApplicationJson, Error> {
        self.preview_renewal_date_with_options(product_subscription, params, None)
            .await
    }

    /// Variant of [`Self::preview_renewal_date`] that accepts per-request [`crate::RequestOptions`].
    pub async fn preview_renewal_date_with_options(
        &self,
        product_subscription: &str,
        params: PreviewRenewalDateParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkPreviewSubscriptionRenewalDateChangeResponseValue200ApplicationJson, Error> {
        self.preview_renewal_date_raw(product_subscription, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn preview_renewal_date_raw(
        &self,
        product_subscription: &str,
        params: PreviewRenewalDateParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<
        crate::RawResponse<SdkPreviewSubscriptionRenewalDateChangeResponseValue200ApplicationJson>,
        Error,
    > {
        let product_subscription = crate::client::path_segment(product_subscription);
        let path =
            format!("/v2/subscriptions/{product_subscription}/actions/change-renewal-date/preview");
        let method = http::Method::POST;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = true;
        merged.operation_id = Some("previewSubscriptionRenewalDateChange".to_string());
        let options = Some(&merged);
        self.client
            .request_with_body_schema_opts_raw(
                method,
                &path,
                &params,
                Some(&params.body),
                options,
                "POST /v2/subscriptions/{productSubscription}/actions/change-renewal-date/preview",
            )
            .await
    }

    /// Confirm a subscription renewal date change
    ///
    /// Confirm a subscription renewal date change, sending a `preview_token` when the variant's billing-date policy requires previews. No payment method supports renewal-date changes today: Stripe, PayPal, Razorpay, and subscriptions the store bills in house all report `shift_billing_date` as `unsupported`, so this returns `422` with the refusal sentence under `errors.subscription`. Read the capabilities response first. Requires the `invoice` Sanctum ability. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
    pub async fn confirm_renewal_date(
        &self,
        product_subscription: &str,
        params: ConfirmRenewalDateParams,
    ) -> Result<SdkConfirmSubscriptionRenewalDateChangeResponseValue200ApplicationJson, Error> {
        self.confirm_renewal_date_with_options(product_subscription, params, None)
            .await
    }

    /// Variant of [`Self::confirm_renewal_date`] that accepts per-request [`crate::RequestOptions`].
    pub async fn confirm_renewal_date_with_options(
        &self,
        product_subscription: &str,
        params: ConfirmRenewalDateParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<SdkConfirmSubscriptionRenewalDateChangeResponseValue200ApplicationJson, Error> {
        self.confirm_renewal_date_raw(product_subscription, params, options)
            .await
            .map(|response| response.data)
    }

    /// Returns the typed result together with status, headers, and request ID.
    pub async fn confirm_renewal_date_raw(
        &self,
        product_subscription: &str,
        params: ConfirmRenewalDateParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<
        crate::RawResponse<SdkConfirmSubscriptionRenewalDateChangeResponseValue200ApplicationJson>,
        Error,
    > {
        let product_subscription = crate::client::path_segment(product_subscription);
        let path =
            format!("/v2/subscriptions/{product_subscription}/actions/change-renewal-date/confirm");
        let method = http::Method::POST;
        let mut merged = options.cloned().unwrap_or_default();
        merged.idempotency_supported = true;
        merged.operation_id = Some("confirmSubscriptionRenewalDateChange".to_string());
        let options = Some(&merged);
        self.client
            .request_with_body_schema_opts_raw(
                method,
                &path,
                &params,
                Some(&params.body),
                options,
                "POST /v2/subscriptions/{productSubscription}/actions/change-renewal-date/confirm",
            )
            .await
    }
}