def _put_or_post_json(self, method, url, data):
if self.parsed_endpoint.scheme == '<STR_LIT>':<EOL><INDENT>conn = http.client.HTTPSConnection(self.parsed_endpoint.netloc)<EOL><DEDENT>else:<EOL><INDENT>conn = http.client.HTTPConnection(self.parsed_endpoint.netloc)<EOL><DEDENT>head = {<EOL>"<STR_LIT:Content-Type>": "<STR_LIT:application/json>",<EOL>"<STR_LIT>": "<STR_LIT:application/json>",<EOL>"<STR_LIT>": USER_AGENT,<EOL>API_TOKEN_HEADER_NAME: self.api_token,<EOL>}<EOL>if self.api_version in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>head[API_VERSION_HEADER_NAME] = self.api_version<EOL><DEDENT>conn.request(method, url, json.dumps(data), head)<EOL>resp = conn.getresponse()<EOL>self._handle_response_errors(method, url, resp)<EOL>return json.loads(resp.read())<EOL>
urlencodes the data and PUTs it to the url
the response is parsed as JSON and the resulting data type is returned