Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
possibly_encoded, len(encoding) and encoding[0] == "gzip"
)
conn.close()
if result.status in (404, 410):
raise HubspotNotFound(result, request)
if result.status == 401:
raise HubspotUnauthorized(result, request)
if result.status == 409:
raise HubspotConflict(result, request)
if result.status == 429:
raise HubspotRateLimited(result, request)
if 400 <= result.status < 500 or result.status == 501:
raise HubspotBadRequest(result, request)
if result.status >= 500:
raise HubspotServerError(result, request)
return result
data["hs_context"] = json.dumps(context)
subpath = "{}/{}".format(portal_id, form_guid)
opts = {"content_type": "application/x-www-form-urlencoded"}
options.update(opts)
response = self._call(
subpath, method="POST", data=urlencode(data), raw=True, **options
)
if response.status in [
FormSubmissionClient.ResponseCode.SUCCESS,
FormSubmissionClient.ResponseCode.SUCCESS_AND_REDIRECT,
]:
return response
if response.status == FormSubmissionClient.ResponseCode.NOT_FOUND:
raise HubspotNotFound(response, None)
if response.status == FormSubmissionClient.ResponseCode.ERROR:
raise HubspotServerError(response, None)
# shouldn't ever get here, but raise anyways
raise HubspotServerError(response, None)