Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
Add amount field to ProductBarcode (#278)
Browse files Browse the repository at this point in the history
* feat: add amount to ProductBarcode

* fix(model): 修复 ProductDetailsResponse 中 ProductBarcode amount 不能为 None 的问题

* refactor: Update .gitignore and setup.py according to review
  • Loading branch information
looching authored Mar 10, 2024
1 parent 68aa607 commit 99ec242
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pygrocy/data_models/product.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from typing import List
from typing import List, Optional

from pygrocy.base import DataModel
from pygrocy.grocy_api_client import (
Expand All @@ -19,11 +19,16 @@
class ProductBarcode(DataModel):
def __init__(self, data: ProductBarcodeData):
self._barcode = data.barcode
self._amount = float(data.amount) if data.amount else None

@property
def barcode(self) -> str:
return self._barcode

@property
def amount(self) -> Optional[float]:
return self._amount


class QuantityUnit(DataModel):
def __init__(self, data: QuantityUnitData):
Expand Down
1 change: 1 addition & 0 deletions pygrocy/grocy_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class CurrentVolatilStockResponse(BaseModel):

class ProductBarcodeData(BaseModel):
barcode: str
amount: Optional[float] = None


class ProductDetailsResponse(BaseModel):
Expand Down

0 comments on commit 99ec242

Please sign in to comment.