def create_contact_with_http_info( self, app_id, sync_contacts_request, **kwargs ): # noqa: E501 """Import contacts # noqa: E501 Imports contacts' properties from an external accounting system to HubSpot. Import details, including property mappings, must be configured previously in HubSpot infrastructure. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.create_contact_with_http_info(app_id, sync_contacts_request, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param int app_id: The ID of the accounting app. This is the identifier of the application created in your HubSpot developer portal. (required) :param SyncContactsRequest sync_contacts_request: (required) :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: tuple(ActionResponse, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ["app_id", "sync_contacts_request"] all_params.extend( [ "async_req", "_return_http_data_only", "_preload_content", "_request_timeout", ] ) for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method create_contact" % key ) local_var_params[key] = val del local_var_params["kwargs"] # verify the required parameter 'app_id' is set if self.api_client.client_side_validation and ( "app_id" not in local_var_params or local_var_params["app_id"] is None # noqa: E501 ): # noqa: E501 raise ApiValueError( "Missing the required parameter `app_id` when calling `create_contact`" ) # noqa: E501 # verify the required parameter 'sync_contacts_request' is set if self.api_client.client_side_validation and ( "sync_contacts_request" not in local_var_params or local_var_params["sync_contacts_request"] is None # noqa: E501 ): # noqa: E501 raise ApiValueError( "Missing the required parameter `sync_contacts_request` when calling `create_contact`" ) # noqa: E501 collection_formats = {} path_params = {} if "app_id" in local_var_params: path_params["appId"] = local_var_params["app_id"] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if "sync_contacts_request" in local_var_params: body_params = local_var_params["sync_contacts_request"] # HTTP header `Accept` header_params["Accept"] = self.api_client.select_header_accept( ["application/json", "*/*"] ) # noqa: E501 # HTTP header `Content-Type` header_params[ "Content-Type" ] = self.api_client.select_header_content_type( # noqa: E501 ["application/json"] ) # noqa: E501 # Authentication setting auth_settings = ["hapikey", "oauth2"] # noqa: E501 return self.api_client.call_api( "/crm/v3/extensions/accounting/sync/{appId}/contacts", "POST", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type="ActionResponse", # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get("async_req"), _return_http_data_only=local_var_params.get( "_return_http_data_only" ), # noqa: E501 _preload_content=local_var_params.get("_preload_content", True), _request_timeout=local_var_params.get("_request_timeout"), collection_formats=collection_formats, )
def archive_with_http_info(self, account_id, **kwargs): # noqa: E501 """Delete user account # noqa: E501 Deletes a user account from HubSpot, meaning that HubSpot will no longer send requests to the external accounting system for this user. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.archive_with_http_info(account_id, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str account_id: The ID of the user account to delete. (required) :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: None If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ["account_id"] all_params.extend([ "async_req", "_return_http_data_only", "_preload_content", "_request_timeout", ]) for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method archive" % key) local_var_params[key] = val del local_var_params["kwargs"] # verify the required parameter 'account_id' is set if self.api_client.client_side_validation and ( "account_id" not in local_var_params or local_var_params["account_id"] is None # noqa: E501 ): # noqa: E501 raise ApiValueError( "Missing the required parameter `account_id` when calling `archive`" ) # noqa: E501 collection_formats = {} path_params = {} if "account_id" in local_var_params: path_params["accountId"] = local_var_params[ "account_id"] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params["Accept"] = self.api_client.select_header_accept( ["*/*"]) # noqa: E501 # Authentication setting auth_settings = ["hapikey", "oauth2"] # noqa: E501 return self.api_client.call_api( "/crm/v3/extensions/accounting/user-accounts/{accountId}", "DELETE", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type=None, # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get("async_req"), _return_http_data_only=local_var_params.get( "_return_http_data_only"), # noqa: E501 _preload_content=local_var_params.get("_preload_content", True), _request_timeout=local_var_params.get("_request_timeout"), collection_formats=collection_formats, )
def request( self, method, url, query_params=None, headers=None, body=None, post_params=None, _preload_content=True, _request_timeout=None, ): """Perform requests. :param method: http request method :param url: http request url :param query_params: query parameters in the url :param headers: http request headers :param body: request json body, for `application/json` :param post_params: request post parameters, `application/x-www-form-urlencoded` and `multipart/form-data` :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. """ method = method.upper() assert method in [ "GET", "HEAD", "DELETE", "POST", "PUT", "PATCH", "OPTIONS" ] if post_params and body: raise ApiValueError( "body parameter cannot be used with post_params parameter.") post_params = post_params or {} headers = headers or {} timeout = None if _request_timeout: if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821 timeout = urllib3.Timeout(total=_request_timeout) elif isinstance(_request_timeout, tuple) and len(_request_timeout) == 2: timeout = urllib3.Timeout(connect=_request_timeout[0], read=_request_timeout[1]) if "Content-Type" not in headers: headers["Content-Type"] = "application/json" try: # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` if method in ["POST", "PUT", "PATCH", "OPTIONS", "DELETE"]: if query_params: url += "?" + urlencode(query_params) if re.search("json", headers["Content-Type"], re.IGNORECASE): request_body = None if body is not None: request_body = json.dumps(body) r = self.pool_manager.request( method, url, body=request_body, preload_content=_preload_content, timeout=timeout, headers=headers, ) elif (headers["Content-Type"] == "application/x-www-form-urlencoded"): # noqa: E501 r = self.pool_manager.request( method, url, fields=post_params, encode_multipart=False, preload_content=_preload_content, timeout=timeout, headers=headers, ) elif headers["Content-Type"] == "multipart/form-data": # must del headers['Content-Type'], or the correct # Content-Type which generated by urllib3 will be # overwritten. del headers["Content-Type"] r = self.pool_manager.request( method, url, fields=post_params, encode_multipart=True, preload_content=_preload_content, timeout=timeout, headers=headers, ) # Pass a `string` parameter directly in the body to support # other content types than Json when `body` argument is # provided in serialized form elif isinstance(body, str) or isinstance(body, bytes): request_body = body r = self.pool_manager.request( method, url, body=request_body, preload_content=_preload_content, timeout=timeout, headers=headers, ) else: # Cannot generate the request from given parameters msg = """Cannot prepare a request message for provided arguments. Please check that your arguments match declared content type.""" raise ApiException(status=0, reason=msg) # For `GET`, `HEAD` else: r = self.pool_manager.request( method, url, fields=query_params, preload_content=_preload_content, timeout=timeout, headers=headers, ) except urllib3.exceptions.SSLError as e: msg = "{0}\n{1}".format(type(e).__name__, str(e)) raise ApiException(status=0, reason=msg) if _preload_content: r = RESTResponse(r) # log response body logger.debug("response body: %s", r.data) if not 200 <= r.status <= 299: raise ApiException(http_resp=r) return r
def replace_with_http_info(self, create_user_account_request_external, **kwargs): # noqa: E501 """Create a user account # noqa: E501 Creates an account which contains the information about the account in the external accounting system. This *must* be called after a user connects their HubSpot account to the external accounting system, as there is no other way for HubSpot to obtain the external account details. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.replace_with_http_info(create_user_account_request_external, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param CreateUserAccountRequestExternal create_user_account_request_external: The external accounting system user account information. (required) :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: None If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ["create_user_account_request_external"] all_params.extend([ "async_req", "_return_http_data_only", "_preload_content", "_request_timeout", ]) for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method replace" % key) local_var_params[key] = val del local_var_params["kwargs"] # verify the required parameter 'create_user_account_request_external' is set if self.api_client.client_side_validation and ( "create_user_account_request_external" not in local_var_params or local_var_params[ "create_user_account_request_external"] # noqa: E501 is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `create_user_account_request_external` when calling `replace`" ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if "create_user_account_request_external" in local_var_params: body_params = local_var_params[ "create_user_account_request_external"] # HTTP header `Accept` header_params["Accept"] = self.api_client.select_header_accept( ["*/*"]) # noqa: E501 # HTTP header `Content-Type` header_params[ "Content-Type"] = self.api_client.select_header_content_type( # noqa: E501 ["application/json"]) # noqa: E501 # Authentication setting auth_settings = ["hapikey", "oauth2"] # noqa: E501 return self.api_client.call_api( "/crm/v3/extensions/accounting/user-accounts", "PUT", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type=None, # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get("async_req"), _return_http_data_only=local_var_params.get( "_return_http_data_only"), # noqa: E501 _preload_content=local_var_params.get("_preload_content", True), _request_timeout=local_var_params.get("_request_timeout"), collection_formats=collection_formats, )