diff --git a/sendgrid/base/values.py b/sendgrid/base/values.py new file mode 100644 index 00000000..16032b11 --- /dev/null +++ b/sendgrid/base/values.py @@ -0,0 +1,13 @@ +from typing import Dict + +unset = object() + + +def of(d: Dict[str, object]) -> Dict[str, object]: + """ + Remove unset values from a dict. + + :param d: A dict to strip. + :return A dict with unset values removed. + """ + return {k: v for k, v in d.items() if v != unset} diff --git a/sendgrid/http/response.py b/sendgrid/http/response.py index 6d86c2d5..8c947516 100644 --- a/sendgrid/http/response.py +++ b/sendgrid/http/response.py @@ -27,5 +27,20 @@ def text(self) -> str: def is_success(self): return self.status_code in HTTPStatus.SUCCESS - def __repr__(self) -> str: - return "HTTP {} {}".format(self.status_code, self.content) \ No newline at end of file + def __str__(self) -> str: + return f"Response(status_code={self.status_code}, text={self.text}, headers={self.headers}, ok={self.ok})" + + +class ApiResponse(object): + def __init__( + self, + status_code, + model, + headers + ): + self.status_code = status_code + self.model = model + self.headers = headers + + def __str__(self) -> str: + return f"ApiResponse(status_code={self.status_code}, model={self.model}, headers={self.headers})"