Skip to content

Commit a29a355

Browse files
committed
fix: TT-418 problems solved
1 parent a3b09de commit a29a355

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

V2/serverless.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,5 @@ functions:
104104
x-azure-settings:
105105
methods:
106106
- POST
107-
route: customer/
107+
route: customers/
108108
authLevel: anonymous

V2/time_tracker/customers/_application/_customers/_create_customer.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import dataclasses
22
import json
3+
import typing
34

45
import azure.functions as func
56

67
from ... import _domain
78
from ... import _infrastructure
89
from time_tracker._infrastructure import DB
910

10-
DEFAULT_FIELDS = ["id", "deleted", "status"]
11-
1211

1312
def create_customer(req: func.HttpRequest) -> func.HttpResponse:
1413
try:
@@ -23,7 +22,9 @@ def create_customer(req: func.HttpRequest) -> func.HttpResponse:
2322
raise ValueError
2423

2524
customer_to_create = _domain.Customer(
26-
**dict.fromkeys(DEFAULT_FIELDS),
25+
id=None,
26+
deleted=None,
27+
status=None,
2728
name=str(customer_data["name"]).strip(),
2829
description=str(customer_data["description"]),
2930
)
@@ -51,6 +52,6 @@ def create_customer(req: func.HttpRequest) -> func.HttpResponse:
5152

5253
def _validate_customer(customer_data: dict) -> bool:
5354
if [field.name for field in dataclasses.fields(_domain.Customer)
54-
if (field.name not in customer_data) and (field.name not in DEFAULT_FIELDS)]:
55+
if (field.name not in customer_data) and (field.type != typing.Optional[field.type])]:
5556
return False
5657
return True
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from dataclasses import dataclass
2+
import typing
23

34

45
@dataclass(frozen=True)
56
class Customer:
6-
id: int
7+
id: typing.Optional[int]
78
name: str
89
description: str
9-
deleted: bool
10-
status: int
10+
deleted: typing.Optional[bool]
11+
status: typing.Optional[int]

V2/time_tracker/customers/_infrastructure/_data_persistence/_customer_dao.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import dataclasses
2+
23
import sqlalchemy as sq
34

45
import time_tracker.customers._domain as domain

0 commit comments

Comments
 (0)