Skip to content

Commit f241c42

Browse files
committed
Refactor customer and invoice resource methods to use model_dump for data cleaning
1 parent 31fdb00 commit f241c42

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

facturapi/resources/customers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def create(cls, data: CustomerRequest) -> 'Customer':
103103
Customer: The created customer resource.
104104
105105
"""
106-
cleaned_data = data.dict(exclude_unset=True, exclude_none=True)
106+
cleaned_data = data.model_dump(exclude_unset=True, exclude_none=True)
107107
return cast('Customer', cls._create(**cleaned_data))
108108

109109
@classmethod
@@ -118,5 +118,5 @@ def update(cls, id: str, data: CustomerUpdateRequest) -> 'Customer':
118118
Customer: The udpated customer resource.
119119
120120
"""
121-
cleaned_data = data.dict(exclude_unset=True, exclude_none=True)
121+
cleaned_data = data.model_dump(exclude_unset=True, exclude_none=True)
122122
return cast('Customer', cls._update(id=id, **cleaned_data))

facturapi/resources/invoices.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def create(cls, data: InvoiceRequest) -> 'Invoice':
174174
Invoice: The created resource.
175175
176176
"""
177-
cleaned_data = data.dict(exclude_unset=True, exclude_none=True)
177+
cleaned_data = data.model_dump(exclude_unset=True, exclude_none=True)
178178
return cast('Invoice', cls._create(**cleaned_data))
179179

180180
@classmethod

tests/types/test_queries.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
def test_base_query():
88
q = BaseQuery(q='Frida')
9-
assert q.dict() == dict(q='Frida')
9+
assert q.model_dump(exclude_unset=True, exclude_none=True) == dict(
10+
q='Frida'
11+
)
1012

1113

1214
def test_base_query_page_size():

0 commit comments

Comments
 (0)