Skip to content

Commit 782cb9c

Browse files
SP-883 Python 5.0.3 - Pydantic validation
1 parent dbae5d0 commit 782cb9c

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

src/bitpay/models/invoice/invoice.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
Invoice
33
"""
44

5-
from typing import List, Union
5+
from typing import List, Union, Dict
66
from pydantic import Field
77
from .buyer import Buyer
88
from .buyer_provided_info import BuyerProvidedInfo
9+
from .invoice_refund_address import InvoiceRefundAddress
910
from .miner_fees import MinerFees
1011
from .refund_info import RefundInfo
1112
from .shopper import Shopper
@@ -47,7 +48,7 @@ class Invoice(BitPayModel):
4748
payment_codes: Union[dict, None] = None
4849
acceptance_window: Union[int, None] = None
4950
buyer: Union[Buyer, None] = None
50-
refund_addresses: Union[List[str], None] = None
51+
refund_addresses: Union[List[Dict[str, InvoiceRefundAddress]], None] = None
5152
close_url: Union[str, None] = Field(alias="closeURL", default=None)
5253
auto_redirect: Union[bool, None] = False
5354
json_paypro_required: bool = False
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""
2+
InvoiceRefundAddress
3+
"""
4+
5+
from typing import Union
6+
7+
from bitpay.models.bitpay_model import BitPayModel
8+
9+
10+
class InvoiceRefundAddress(BitPayModel):
11+
type: str
12+
date: str
13+
tag: Union[int, None] = None
14+
email: Union[str, None] = None

tests/unit/json/create_invoice_response.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@
3131
"notify": true
3232
},
3333
"autoRedirect": true,
34-
"refundAddresses": [],
34+
"refundAddresses": [
35+
{
36+
"n2MDYgEhxCAnuoVd1JpPmvxZShE6rQA6zv": {
37+
"type": "buyerSupplied",
38+
"date": "2024-01-08T23:50:56.556Z",
39+
"email": "[email protected]"
40+
}
41+
}
42+
],
3543
"refundAddressRequestPending": false,
3644
"buyerProvidedEmail": "[email protected]",
3745
"buyerProvidedInfo": {

0 commit comments

Comments
 (0)