sumup 0.6.0

Rust SDK for the SumUp API.
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
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
// The contents of this file are generated; do not modify them.

//! Retrieve structured receipt data for a transaction, including payment, merchant, and acquirer details. Use this data to display a receipt in your application. The response is JSON, rather than a rendered receipt document.
use super::common::*;
/// Structured receipt details for a transaction. The transaction's `amount`, `vat_amount`, and `tip_amount`, as well as event amounts, are returned as decimal strings in major currency units, for example `"10.10"` for EUR 10.10.
#[derive(
    Debug,
    Clone,
    Default,
    PartialEq,
    serde::Serialize,
    serde::Deserialize,
    typed_builder::TypedBuilder,
)]
#[builder(doc)]
pub struct Receipt {
    /// Acquirer-specific metadata related to the card authorization.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(strip_option, doc = "Sets [`acquirer_data`](Receipt::acquirer_data).")
    )]
    pub acquirer_data: Option<ReceiptAcquirerData>,
    /// EMV-specific metadata returned for card-present payments.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(strip_option, doc = "Sets [`emv_data`](Receipt::emv_data).")
    )]
    pub emv_data: Option<serde_json::Value>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(strip_option, doc = "Sets [`merchant_data`](Receipt::merchant_data).")
    )]
    pub merchant_data: Option<ReceiptMerchantData>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            doc = "Sets [`transaction_data`](Receipt::transaction_data)."
        )
    )]
    pub transaction_data: Option<ReceiptTransaction>,
}
/// Payment card details displayed on the receipt.
#[derive(
    Debug,
    Clone,
    Default,
    PartialEq,
    serde::Serialize,
    serde::Deserialize,
    typed_builder::TypedBuilder,
)]
#[builder(doc)]
pub struct ReceiptCard {
    /// Last four digits of the payment card number.
    ///
    /// Example: `3456`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`last_4_digits`](ReceiptCard::last_4_digits)."
        )
    )]
    pub last_4_digits: Option<String>,
    /// Issuing card network of the payment card.
    ///
    /// Example: `VISA`
    #[serde(rename = "type")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(strip_option, into, doc = "Sets [`r#type`](ReceiptCard::r#type).")
    )]
    pub r#type: Option<String>,
}
/// Transaction event details as rendered on the receipt.
#[derive(
    Debug,
    Clone,
    Default,
    PartialEq,
    serde::Serialize,
    serde::Deserialize,
    typed_builder::TypedBuilder,
)]
#[builder(doc)]
pub struct ReceiptEvent {
    /// Amount associated with the transaction event, in major units.
    ///
    /// Example: `10.10`
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        deserialize_with = "crate::string_or_number::deserialize_option"
    )]
    #[builder(
        default,
        setter(strip_option, doc = "Sets [`amount`](ReceiptEvent::amount).")
    )]
    pub amount: Option<f64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(default, setter(strip_option, doc = "Sets [`id`](ReceiptEvent::id)."))]
    pub id: Option<TransactionEventId>,
    /// Receipt number associated with the event.
    ///
    /// Example: `123456`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`receipt_no`](ReceiptEvent::receipt_no)."
        )
    )]
    pub receipt_no: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(strip_option, doc = "Sets [`status`](ReceiptEvent::status).")
    )]
    pub status: Option<TransactionEventStatus>,
    /// The timestamp of when the transaction event occurred.
    ///
    /// Example: `2020-05-25T10:49:42.784Z`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(strip_option, doc = "Sets [`timestamp`](ReceiptEvent::timestamp).")
    )]
    pub timestamp: Option<crate::datetime::DateTime>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`transaction_id`](ReceiptEvent::transaction_id)."
        )
    )]
    pub transaction_id: Option<TransactionId>,
    #[serde(rename = "type")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(strip_option, doc = "Sets [`r#type`](ReceiptEvent::r#type).")
    )]
    pub r#type: Option<TransactionEventType>,
}
/// Merchant details displayed on a transaction receipt.
#[derive(
    Debug,
    Clone,
    Default,
    PartialEq,
    serde::Serialize,
    serde::Deserialize,
    typed_builder::TypedBuilder,
)]
#[builder(doc)]
pub struct ReceiptMerchantData {
    /// Locale used for rendering localized receipt fields.
    ///
    /// Example: `de-DE`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`locale`](ReceiptMerchantData::locale)."
        )
    )]
    pub locale: Option<String>,
    /// Merchant profile details displayed on the receipt.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            doc = "Sets [`merchant_profile`](ReceiptMerchantData::merchant_profile)."
        )
    )]
    pub merchant_profile: Option<ReceiptMerchantDataMerchantProfile>,
}
/// Card reader details displayed on the receipt.
#[derive(
    Debug,
    Clone,
    Default,
    PartialEq,
    serde::Serialize,
    serde::Deserialize,
    typed_builder::TypedBuilder,
)]
#[builder(doc)]
pub struct ReceiptReader {
    /// Unique identifier of the physical card reader.
    ///
    /// Example: `U1DT3NA00-CN`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(strip_option, into, doc = "Sets [`code`](ReceiptReader::code).")
    )]
    pub code: Option<String>,
    /// Model of the physical card reader.
    ///
    /// Example: `solo`
    #[serde(rename = "type")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(strip_option, into, doc = "Sets [`r#type`](ReceiptReader::r#type).")
    )]
    pub r#type: Option<String>,
}
/// Transaction details displayed on a receipt.
#[derive(
    Debug,
    Clone,
    Default,
    PartialEq,
    serde::Serialize,
    serde::Deserialize,
    typed_builder::TypedBuilder,
)]
#[builder(doc)]
pub struct ReceiptTransaction {
    /// Total transaction amount, in major units.
    ///
    /// Example: `10.10`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`amount`](ReceiptTransaction::amount)."
        )
    )]
    pub amount: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(strip_option, doc = "Sets [`card`](ReceiptTransaction::card).")
    )]
    pub card: Option<ReceiptCard>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            doc = "Sets [`card_reader`](ReceiptTransaction::card_reader)."
        )
    )]
    pub card_reader: Option<ReceiptReader>,
    /// Three-letter ISO 4217 currency code of the transaction.
    ///
    /// Example: `EUR`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`currency`](ReceiptTransaction::currency)."
        )
    )]
    pub currency: Option<String>,
    /// Entry mode of the payment details.
    ///
    /// Example: `CUSTOMER_ENTRY`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`entry_mode`](ReceiptTransaction::entry_mode)."
        )
    )]
    pub entry_mode: Option<String>,
    /// Transaction events displayed on the receipt.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(strip_option, doc = "Sets [`events`](ReceiptTransaction::events).")
    )]
    pub events: Option<Vec<ReceiptEvent>>,
    /// Number of installments.
    ///
    /// Example: `1`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            doc = "Sets [`installments_count`](ReceiptTransaction::installments_count)."
        )
    )]
    pub installments_count: Option<i64>,
    /// Short unique identifier for the merchant.
    ///
    /// Example: `MH4H92C7`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`merchant_code`](ReceiptTransaction::merchant_code)."
        )
    )]
    pub merchant_code: Option<String>,
    /// Payment type used for the transaction.
    ///
    /// Example: `ECOM`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`payment_type`](ReceiptTransaction::payment_type)."
        )
    )]
    pub payment_type: Option<String>,
    /// Whether the transaction was processed as credit or debit.
    ///
    /// Example: `CREDIT`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            doc = "Sets [`process_as`](ReceiptTransaction::process_as)."
        )
    )]
    pub process_as: Option<ReceiptTransactionProcessAs>,
    /// Products associated with the transaction.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(strip_option, doc = "Sets [`products`](ReceiptTransaction::products).")
    )]
    pub products: Option<Vec<ReceiptTransactionProductsItem>>,
    /// Receipt number associated with the transaction.
    ///
    /// Example: `123456`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`receipt_no`](ReceiptTransaction::receipt_no)."
        )
    )]
    pub receipt_no: Option<String>,
    /// Current processing status of the transaction.
    ///
    /// Example: `SUCCESSFUL`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`status`](ReceiptTransaction::status)."
        )
    )]
    pub status: Option<String>,
    /// The timestamp of when the transaction was created.
    ///
    /// Example: `2020-02-29T10:56:56.876Z`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            doc = "Sets [`timestamp`](ReceiptTransaction::timestamp)."
        )
    )]
    pub timestamp: Option<crate::datetime::DateTime>,
    /// Tip included in the transaction amount, in major units.
    ///
    /// Example: `3.00`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`tip_amount`](ReceiptTransaction::tip_amount)."
        )
    )]
    pub tip_amount: Option<String>,
    /// Transaction code returned after processing the transaction.
    ///
    /// Example: `TEENSK4W2K`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`transaction_code`](ReceiptTransaction::transaction_code)."
        )
    )]
    pub transaction_code: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`transaction_id`](ReceiptTransaction::transaction_id)."
        )
    )]
    pub transaction_id: Option<TransactionId>,
    /// VAT included in the transaction amount, in major units.
    ///
    /// Example: `6.00`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`vat_amount`](ReceiptTransaction::vat_amount)."
        )
    )]
    pub vat_amount: Option<String>,
    /// VAT breakdown for the transaction.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            doc = "Sets [`vat_rates`](ReceiptTransaction::vat_rates)."
        )
    )]
    pub vat_rates: Option<Vec<ReceiptTransactionVatRatesItem>>,
    /// Cardholder verification method.
    ///
    /// Example: `none`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`verification_method`](ReceiptTransaction::verification_method)."
        )
    )]
    pub verification_method: Option<String>,
}
/// Acquirer-specific metadata related to the card authorization.
#[derive(
    Debug,
    Clone,
    Default,
    PartialEq,
    serde::Serialize,
    serde::Deserialize,
    typed_builder::TypedBuilder,
)]
#[builder(doc)]
pub struct ReceiptAcquirerData {
    /// Authorization code returned by the acquirer.
    ///
    /// Example: `053201`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`authorization_code`](ReceiptAcquirerData::authorization_code)."
        )
    )]
    pub authorization_code: Option<String>,
    /// Local timestamp of the card authorization.
    ///
    /// Example: `2020-02-29T11:56:56+01:00`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`local_time`](ReceiptAcquirerData::local_time)."
        )
    )]
    pub local_time: Option<String>,
    /// Return code reported by the acquirer.
    ///
    /// Example: `00`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`return_code`](ReceiptAcquirerData::return_code)."
        )
    )]
    pub return_code: Option<String>,
    /// Identifier of the terminal used for the authorization.
    ///
    /// Example: `12345678`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(strip_option, into, doc = "Sets [`tid`](ReceiptAcquirerData::tid).")
    )]
    pub tid: Option<String>,
}
/// Business address of the merchant.
#[derive(
    Debug,
    Clone,
    Default,
    PartialEq,
    serde::Serialize,
    serde::Deserialize,
    typed_builder::TypedBuilder,
)]
#[builder(doc)]
pub struct ReceiptMerchantDataMerchantProfileAddress {
    /// First line of the merchant address.
    ///
    /// Example: `Sample street 1`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`address_line1`](ReceiptMerchantDataMerchantProfileAddress::address_line1)."
        )
    )]
    pub address_line1: Option<String>,
    /// Second line of the merchant address.
    ///
    /// Example: `Floor 2`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`address_line2`](ReceiptMerchantDataMerchantProfileAddress::address_line2)."
        )
    )]
    pub address_line2: Option<String>,
    /// City of the merchant address.
    ///
    /// Example: `Berlin`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`city`](ReceiptMerchantDataMerchantProfileAddress::city)."
        )
    )]
    pub city: Option<String>,
    /// Two-letter ISO 3166-1 alpha-2 country code of the merchant address.
    ///
    /// Example: `DE`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`country`](ReceiptMerchantDataMerchantProfileAddress::country)."
        )
    )]
    pub country: Option<String>,
    /// English name of the country in the merchant address.
    ///
    /// Example: `Germany`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`country_en_name`](ReceiptMerchantDataMerchantProfileAddress::country_en_name)."
        )
    )]
    pub country_en_name: Option<String>,
    /// Localized name of the country in the merchant address.
    ///
    /// Example: `Deutschland`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`country_native_name`](ReceiptMerchantDataMerchantProfileAddress::country_native_name)."
        )
    )]
    pub country_native_name: Option<String>,
    /// Landline phone number of the merchant.
    ///
    /// Example: `+493012345678`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`landline`](ReceiptMerchantDataMerchantProfileAddress::landline)."
        )
    )]
    pub landline: Option<String>,
    /// Postal code of the merchant address.
    ///
    /// Example: `10115`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`post_code`](ReceiptMerchantDataMerchantProfileAddress::post_code)."
        )
    )]
    pub post_code: Option<String>,
    /// Region or state of the merchant address.
    ///
    /// Example: `Berlin`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`region_name`](ReceiptMerchantDataMerchantProfileAddress::region_name)."
        )
    )]
    pub region_name: Option<String>,
}
/// Merchant profile details displayed on the receipt.
#[derive(
    Debug,
    Clone,
    Default,
    PartialEq,
    serde::Serialize,
    serde::Deserialize,
    typed_builder::TypedBuilder,
)]
#[builder(doc)]
pub struct ReceiptMerchantDataMerchantProfile {
    /// Business address of the merchant.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            doc = "Sets [`address`](ReceiptMerchantDataMerchantProfile::address)."
        )
    )]
    pub address: Option<ReceiptMerchantDataMerchantProfileAddress>,
    /// Business name of the merchant.
    ///
    /// Example: `Coffee House`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`business_name`](ReceiptMerchantDataMerchantProfile::business_name)."
        )
    )]
    pub business_name: Option<String>,
    /// Company registration number of the merchant.
    ///
    /// Example: `HRB 123456`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`company_registration_number`](ReceiptMerchantDataMerchantProfile::company_registration_number)."
        )
    )]
    pub company_registration_number: Option<String>,
    /// Email address of the merchant.
    ///
    /// Example: `merchant@example.com`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`email`](ReceiptMerchantDataMerchantProfile::email)."
        )
    )]
    pub email: Option<String>,
    /// Language configured for the merchant profile.
    ///
    /// Example: `de`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`language`](ReceiptMerchantDataMerchantProfile::language)."
        )
    )]
    pub language: Option<String>,
    /// Short unique identifier for the merchant.
    ///
    /// Example: `MH4H92C7`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`merchant_code`](ReceiptMerchantDataMerchantProfile::merchant_code)."
        )
    )]
    pub merchant_code: Option<String>,
    /// VAT identification number of the merchant.
    ///
    /// Example: `DE123456789`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`vat_id`](ReceiptMerchantDataMerchantProfile::vat_id)."
        )
    )]
    pub vat_id: Option<String>,
    /// Website of the merchant.
    ///
    /// Example: `https://example.com`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`website`](ReceiptMerchantDataMerchantProfile::website)."
        )
    )]
    pub website: Option<String>,
}
/// Whether the transaction was processed as credit or debit.
///
/// Example: `CREDIT`
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum ReceiptTransactionProcessAs {
    #[serde(rename = "CREDIT")]
    Credit,
    #[serde(rename = "DEBIT")]
    Debit,
    #[serde(untagged)]
    Other(String),
}
#[derive(
    Debug,
    Clone,
    Default,
    PartialEq,
    serde::Serialize,
    serde::Deserialize,
    typed_builder::TypedBuilder,
)]
#[builder(doc)]
pub struct ReceiptTransactionProductsItem {
    /// Product description.
    ///
    /// Example: `Cappuccino`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`description`](ReceiptTransactionProductsItem::description)."
        )
    )]
    pub description: Option<String>,
    /// Product name.
    ///
    /// Example: `Coffee`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            into,
            doc = "Sets [`name`](ReceiptTransactionProductsItem::name)."
        )
    )]
    pub name: Option<String>,
    /// Product price.
    ///
    /// Example: `150.0`
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        deserialize_with = "crate::string_or_number::deserialize_option"
    )]
    #[builder(
        default,
        setter(
            strip_option,
            doc = "Sets [`price`](ReceiptTransactionProductsItem::price)."
        )
    )]
    pub price: Option<f64>,
    /// Product price including VAT.
    ///
    /// Example: `150.0`
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        deserialize_with = "crate::string_or_number::deserialize_option"
    )]
    #[builder(
        default,
        setter(
            strip_option,
            doc = "Sets [`price_with_vat`](ReceiptTransactionProductsItem::price_with_vat)."
        )
    )]
    pub price_with_vat: Option<f64>,
    /// Product quantity.
    ///
    /// Example: `1`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            doc = "Sets [`quantity`](ReceiptTransactionProductsItem::quantity)."
        )
    )]
    pub quantity: Option<i64>,
    /// VAT amount for a single product.
    ///
    /// Example: `0.0`
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        deserialize_with = "crate::string_or_number::deserialize_option"
    )]
    #[builder(
        default,
        setter(
            strip_option,
            doc = "Sets [`single_vat_amount`](ReceiptTransactionProductsItem::single_vat_amount)."
        )
    )]
    pub single_vat_amount: Option<f64>,
    /// Total price calculated as the product price multiplied by the quantity.
    ///
    /// Example: `150.0`
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        deserialize_with = "crate::string_or_number::deserialize_option"
    )]
    #[builder(
        default,
        setter(
            strip_option,
            doc = "Sets [`total_price`](ReceiptTransactionProductsItem::total_price)."
        )
    )]
    pub total_price: Option<f64>,
    /// Total product price including VAT.
    ///
    /// Example: `150.0`
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        deserialize_with = "crate::string_or_number::deserialize_option"
    )]
    #[builder(
        default,
        setter(
            strip_option,
            doc = "Sets [`total_with_vat`](ReceiptTransactionProductsItem::total_with_vat)."
        )
    )]
    pub total_with_vat: Option<f64>,
    /// Total VAT amount for the product quantity.
    ///
    /// Example: `0.0`
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        deserialize_with = "crate::string_or_number::deserialize_option"
    )]
    #[builder(
        default,
        setter(
            strip_option,
            doc = "Sets [`vat_amount`](ReceiptTransactionProductsItem::vat_amount)."
        )
    )]
    pub vat_amount: Option<f64>,
    /// VAT rate.
    ///
    /// Example: `0.0`
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        deserialize_with = "crate::string_or_number::deserialize_option"
    )]
    #[builder(
        default,
        setter(
            strip_option,
            doc = "Sets [`vat_rate`](ReceiptTransactionProductsItem::vat_rate)."
        )
    )]
    pub vat_rate: Option<f64>,
}
#[derive(
    Debug,
    Clone,
    Default,
    PartialEq,
    serde::Serialize,
    serde::Deserialize,
    typed_builder::TypedBuilder,
)]
#[builder(doc)]
pub struct ReceiptTransactionVatRatesItem {
    /// Gross amount to which the VAT rate applies.
    ///
    /// Example: `10.1`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            doc = "Sets [`gross`](ReceiptTransactionVatRatesItem::gross)."
        )
    )]
    pub gross: Option<f32>,
    /// Net amount to which the VAT rate applies.
    ///
    /// Example: `8.49`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            doc = "Sets [`net`](ReceiptTransactionVatRatesItem::net)."
        )
    )]
    pub net: Option<f32>,
    /// VAT rate applied to the transaction amount.
    ///
    /// Example: `0.19`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            doc = "Sets [`rate`](ReceiptTransactionVatRatesItem::rate)."
        )
    )]
    pub rate: Option<f32>,
    /// VAT amount included in the gross amount.
    ///
    /// Example: `1.61`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(
            strip_option,
            doc = "Sets [`vat`](ReceiptTransactionVatRatesItem::vat)."
        )
    )]
    pub vat: Option<f32>,
}
#[derive(
    Debug,
    Clone,
    Default,
    PartialEq,
    serde::Serialize,
    serde::Deserialize,
    typed_builder::TypedBuilder,
)]
#[builder(doc)]
pub struct GetParams {
    /// Short unique identifier for the merchant.
    ///
    /// Example: `MH4H92C7`
    #[builder(setter(into, doc = "Sets [`mid`](GetParams::mid)."))]
    pub mid: String,
    /// Unique identifier of the transaction event to include on the receipt.
    ///
    /// Example: `9567461191`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[builder(
        default,
        setter(strip_option, doc = "Sets [`tx_event_id`](GetParams::tx_event_id).")
    )]
    pub tx_event_id: Option<i64>,
}
use crate::client::Client;
#[derive(Debug, PartialEq)]
pub enum GetErrorBody {
    BadRequest(Error),
    Unauthorized(Problem),
    NotFound(Error),
}
impl crate::error::ProblemDetails for GetErrorBody {
    fn problem(&self) -> Option<&crate::resources::common::Problem> {
        match self {
            Self::Unauthorized(problem) => Some(problem),
            _ => None,
        }
    }
}
/// Client for the Receipts API endpoints.
#[derive(Debug)]
pub struct ReceiptsClient<'a> {
    client: &'a Client,
}
impl<'a> ReceiptsClient<'a> {
    pub(crate) fn new(client: &'a Client) -> Self {
        Self { client }
    }
    /// Returns a reference to the underlying client.
    pub fn client(&self) -> &Client {
        self.client
    }
    /// Retrieve receipt details
    ///
    /// Retrieves structured receipt data for a transaction belonging to the merchant specified by `mid`. The path accepts either the SumUp transaction ID or transaction code. Provide `tx_event_id` to include a specific transaction event, such as a refund, on the receipt.
    ///
    /// Responses:
    /// - 200: Returns receipt details for the requested transaction.
    /// - 400: The request is invalid for the submitted parameters.
    /// - 401: The request is not authorized.
    /// - 404: The requested transaction event does not exist for the provided transaction.
    pub async fn get(
        &self,
        transaction_id: impl AsRef<str>,
        params: GetParams,
    ) -> crate::error::SdkResult<Receipt, GetErrorBody> {
        let path = format!("/v1.1/receipts/{}", transaction_id.as_ref());
        let url = format!("{}{}", self.client.base_url(), path);
        let mut request = self
            .client
            .http_client()
            .get(&url)
            .header("User-Agent", crate::version::user_agent())
            .timeout(self.client.timeout());
        if let Some(authorization) = self.client.authorization() {
            request = request.header("Authorization", format!("Bearer {}", authorization));
        }
        for (header_name, header_value) in self.client.runtime_headers() {
            request = request.header(*header_name, header_value);
        }
        request = request.query(&[("mid", &params.mid)]);
        if let Some(ref value) = params.tx_event_id {
            request = request.query(&[("tx_event_id", value)]);
        }
        let response = request.send().await?;
        let status = response.status();
        match status {
            reqwest::StatusCode::OK => {
                let data: Receipt = response.json().await?;
                Ok(data)
            }
            reqwest::StatusCode::BAD_REQUEST => {
                Err(crate::error::SdkError::from_response(response, |raw| {
                    serde_json::from_slice::<Error>(raw).map(GetErrorBody::BadRequest)
                })
                .await)
            }
            reqwest::StatusCode::UNAUTHORIZED => {
                Err(crate::error::SdkError::from_response(response, |raw| {
                    serde_json::from_slice::<Problem>(raw).map(GetErrorBody::Unauthorized)
                })
                .await)
            }
            reqwest::StatusCode::NOT_FOUND => {
                Err(crate::error::SdkError::from_response(response, |raw| {
                    serde_json::from_slice::<Error>(raw).map(GetErrorBody::NotFound)
                })
                .await)
            }
            _ => Err(crate::error::SdkError::unexpected_response(response).await),
        }
    }
}