Skip to content

Commit

Permalink
Create rule to not try Receipt when is not processed
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Polo authored and lucaspolo committed Mar 6, 2020
1 parent f9e1131 commit 62f8876
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion correios/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ def build_post_info(self, data, user: User, validate_package: bool = True) -> Po
)
return post_info

def build_receipt(self, data) -> Receipt:
def build_receipt(self, data) -> Optional[Receipt]:
if data.status_processamento != Receipt.STATUS_PROCESSED:
return None

receipt = Receipt(
number=data.numero_comprovante_postagem,
post_date=data.data_postagem_sara.text,
Expand Down
3 changes: 3 additions & 0 deletions correios/models/posting.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,9 @@ def _validate_weight(cls, weight, service: Optional[Union[Service, str, int]] =

class Receipt:

STATUS_UNPROCESSED = 0
STATUS_PROCESSED = 1

def __init__(
self,
number: Union[int, str],
Expand Down

0 comments on commit 62f8876

Please sign in to comment.