Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ print(message.return_cost) # get message payback
```

### Get message delivery statuses

Status Code Explanation:
0 for Send
1 for pending
2 for delivered
3 for failed
4 for blaklisted
```python
message_id = "message-tracking-code"

Expand All @@ -79,7 +84,6 @@ statuses, pagination_info = sms.fetch_statuses(message_id, 0, 10)
for status in statuses {
print("Recipient: %s, Status: %s" % (status.recipient, status.status))
}

print("Total: ", pagination_info.total)
```

Expand Down Expand Up @@ -132,10 +136,15 @@ from ippanel import HTTPError, Error, ResponseCode
try:
message_id = sms.send("9810001", ["98912xxxxx"], "ippanel is awesome")
except Error as e: # ippanel sms error
print(f"Error handled => code: {e.code}, message: {e.message}")
if e.code == ResponseCode.ErrUnprocessableEntity.value:
for field in e.message:
print(f"Field: {field} , Errors: {e.message[field]}")
elif e.code == ResponseCode.ErrForbidden.value:
print(f"Ippanel Error Forbidden => code: {e.code}, message: {e.message}")
elif e.code == ResponseCode.ErrInternalServer.value:
print(f"Ippanel Internal Server Error => code: {e.code}, message: {e.message}")
elif e.code == ResponseCode.ErrNotFound.value:
print(f"Ippanel Error Not Found => code: {e.code}, message: {e.message}")
except HTTPError as e: # http error like network error, not found, ...
print(f"Error handled => code: {e}")

Expand Down
2 changes: 1 addition & 1 deletion ippanel/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ class HTTPError(Exception):
pass

def parse_errors(response: Response):
if response.error_message is not None:
if response.error_message is not None and response.code!=200 and response.code!=201 and response.code!=204:
return Error(response.code, response.error_message)
return