From 400a174d5a5fe2a530d2c99fff4acd192476caf6 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Mon, 4 Dec 2017 14:32:14 -0800 Subject: [PATCH] Simplify _from_response --- acme/acme/client.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/acme/acme/client.py b/acme/acme/client.py index fd4c6d6a8..204114937 100644 --- a/acme/acme/client.py +++ b/acme/acme/client.py @@ -177,18 +177,16 @@ class Client(object): # pylint: disable=too-many-instance-attributes return authzr def _order_resource_from_response(self, response, uri=None): + body = messages.Order.from_json(response.json()), authorizations = [] - for authz_uri in response.json()["authorizations"]: - authz_response = self.net.get(authz_uri) - authorizations.append(self._authzr_from_response(authz_response)) - fullchain_pem = None - if "certificate" in response.json(): - certificate_response = self.net.get(response.json()["certificate"], - content_type=None) + for url in body.authorizations: + authorizations.append(self._authzr_from_response(self.net.get(url))) + if body.certificate is not None: + certificate_response = self.net.get(body.certificate, content_type=None) if certificate_response.ok: fullchain_pem = certificate_response.text return messages.OrderResource( - body=messages.Order.from_json(response.json()), + body=body, uri=response.headers.get('Location', uri), fullchain_pem=fullchain_pem, authorizations=authorizations)