def update_params_for_auth(self, headers, querys, auth_settings): """Updates header and query params based on authentication setting. :param headers: Header parameters dict to be updated. :param querys: Query parameters tuple list to be updated. :param auth_settings: Authentication setting identifiers list. """ if not auth_settings: return for auth in auth_settings: auth_setting = self.configuration.auth_settings().get(auth) if auth_setting: if auth_setting["in"] == "cookie": headers["Cookie"] = auth_setting["value"] elif auth_setting["in"] == "header": headers[auth_setting["key"]] = auth_setting["value"] elif auth_setting["in"] == "query": querys.append((auth_setting["key"], auth_setting["value"])) else: raise ApiValueError( "Authentication token must be in `query` or `header`")
def update_params_for_auth(self, headers, querys, auth_settings): """Updates header and query params based on authentication setting. :param headers: Header parameters dict to be updated. :param querys: Query parameters tuple list to be updated. :param auth_settings: Authentication setting identifiers list. """ if not auth_settings: return for auth in auth_settings: auth_setting = self.configuration.auth_settings().get(auth) if auth_setting: if auth_setting['in'] == 'cookie': headers['Cookie'] = auth_setting['value'] elif auth_setting['in'] == 'header': headers[auth_setting['key']] = auth_setting['value'] elif auth_setting['in'] == 'query': querys.append((auth_setting['key'], auth_setting['value'])) else: raise ApiValueError( 'Authentication token must be in `query` or `header`')
def request( self, method, url, query_params=None, headers=None, post_params=None, body=None, _preload_content=True, _request_timeout=None, ): """Makes the HTTP request using RESTClient.""" if method == "GET": return self.rest_client.GET( url, query_params=query_params, _preload_content=_preload_content, _request_timeout=_request_timeout, headers=headers, ) elif method == "HEAD": return self.rest_client.HEAD( url, query_params=query_params, _preload_content=_preload_content, _request_timeout=_request_timeout, headers=headers, ) elif method == "OPTIONS": return self.rest_client.OPTIONS( url, query_params=query_params, headers=headers, _preload_content=_preload_content, _request_timeout=_request_timeout, ) elif method == "POST": return self.rest_client.POST( url, query_params=query_params, headers=headers, post_params=post_params, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body, ) elif method == "PUT": return self.rest_client.PUT( url, query_params=query_params, headers=headers, post_params=post_params, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body, ) elif method == "PATCH": return self.rest_client.PATCH( url, query_params=query_params, headers=headers, post_params=post_params, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body, ) elif method == "DELETE": return self.rest_client.DELETE( url, query_params=query_params, headers=headers, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body, ) else: raise ApiValueError("http method must be `GET`, `HEAD`, `OPTIONS`," " `POST`, `PATCH`, `PUT` or `DELETE`.")
def archive_with_http_info(self, event_template_id, app_id, **kwargs): # noqa: E501 """Deletes an event template for the app # noqa: E501 This will delete the event template. All events associated with it will be removed from search and the timeline UI. There is no recovery from this option, so it's highly recommended that you stop using any events for a template before deleting it. # 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(event_template_id, app_id, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str event_template_id: The event template ID. (required) :param int app_id: The ID of the target app. (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 = ["event_template_id", "app_id"] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") all_params.append("_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 'event_template_id' is set if self.api_client.client_side_validation and ( "event_template_id" not in local_var_params or local_var_params["event_template_id"] is None # noqa: E501 ): # noqa: E501 raise ApiValueError( "Missing the required parameter `event_template_id` when calling `archive`" ) # noqa: E501 # 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 `archive`" ) # noqa: E501 collection_formats = {} path_params = {} if "event_template_id" in local_var_params: path_params["eventTemplateId"] = local_var_params[ "event_template_id"] # noqa: E501 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 # 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/timeline/{appId}/event-templates/{eventTemplateId}", "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 update_with_http_info(self, event_template_id, app_id, **kwargs): # noqa: E501 """Update an existing event template # noqa: E501 Updates an existing template and its tokens. This is primarily used to update the headerTemplate/detailTemplate, and those changes will take effect for existing events. You can also update or replace all the tokens in the template here instead of doing individual API calls on the `/tokens` endpoint. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.update_with_http_info(event_template_id, app_id, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str event_template_id: The event template ID. (required) :param int app_id: The ID of the target app. (required) :param TimelineEventTemplateUpdateRequest timeline_event_template_update_request: The updated event template definition. :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(TimelineEventTemplate, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = [ "event_template_id", "app_id", "timeline_event_template_update_request", ] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") all_params.append("_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 update" % key) local_var_params[key] = val del local_var_params["kwargs"] # verify the required parameter 'event_template_id' is set if self.api_client.client_side_validation and ( "event_template_id" not in local_var_params or local_var_params["event_template_id"] is None # noqa: E501 ): # noqa: E501 raise ApiValueError( "Missing the required parameter `event_template_id` when calling `update`" ) # noqa: E501 # 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 `update`" ) # noqa: E501 collection_formats = {} path_params = {} if "event_template_id" in local_var_params: path_params["eventTemplateId"] = local_var_params[ "event_template_id"] # noqa: E501 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 "timeline_event_template_update_request" in local_var_params: body_params = local_var_params[ "timeline_event_template_update_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/timeline/{appId}/event-templates/{eventTemplateId}", "PUT", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type="TimelineEventTemplate", # 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 get_all_with_http_info(self, app_id, **kwargs): # noqa: E501 """List all event templates for your app # noqa: E501 Use this to list all event templates owned by your app. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_all_with_http_info(app_id, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param int app_id: The ID of the target app. (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(CollectionResponseTimelineEventTemplate, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ["app_id"] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") all_params.append("_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 get_all" % 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 `get_all`" ) # 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 # HTTP header `Accept` header_params["Accept"] = self.api_client.select_header_accept( ["application/json", "*/*"]) # noqa: E501 # Authentication setting auth_settings = ["hapikey", "oauth2"] # noqa: E501 return self.api_client.call_api( "/crm/v3/timeline/{appId}/event-templates", "GET", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type= "CollectionResponseTimelineEventTemplate", # 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 create_with_http_info(self, app_id, **kwargs): # noqa: E501 """Create an event template for your app # noqa: E501 Event templates define the general structure for a custom timeline event. This includes formatted copy for its heading and details, as well as any custom property definitions. The event could be something like viewing a video, registering for a webinar, or filling out a survey. A single app can define multiple event templates. Event templates will be created for contacts by default, but they can be created for companies and deals as well. Each event template contains its own set of tokens and `Markdown` templates. These tokens can be associated with any CRM object properties via the `objectPropertyName` field to fully build out CRM objects. You must create an event template before you can create events. # 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_with_http_info(app_id, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param int app_id: The ID of the target app. (required) :param TimelineEventTemplateCreateRequest timeline_event_template_create_request: The new event template definition. :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(TimelineEventTemplate, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ["app_id", "timeline_event_template_create_request"] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") all_params.append("_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" % 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`" ) # 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 "timeline_event_template_create_request" in local_var_params: body_params = local_var_params[ "timeline_event_template_create_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/timeline/{appId}/event-templates", "POST", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type="TimelineEventTemplate", # 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, event_template_id, token_name, app_id, **kwargs): # noqa: E501 """Removes a token from the event template # noqa: E501 This will remove the token from an existing template. Existing events and CRM objects will still retain the token and its mapped object properties, but new ones will not. The timeline will still display this property for older CRM objects if it's still referenced in the template `Markdown`. New events will not. Any lists or reports referencing deleted tokens will no longer return new contacts, but old ones will still exist in the lists. # 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(event_template_id, token_name, app_id, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str event_template_id: The event template ID. (required) :param str token_name: The token name. (required) :param int app_id: The ID of the target app. (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 = ["event_template_id", "token_name", "app_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 'event_template_id' is set if self.api_client.client_side_validation and ( "event_template_id" not in local_var_params or local_var_params["event_template_id"] is None # noqa: E501 ): # noqa: E501 raise ApiValueError( "Missing the required parameter `event_template_id` when calling `archive`" ) # noqa: E501 # verify the required parameter 'token_name' is set if self.api_client.client_side_validation and ( "token_name" not in local_var_params or local_var_params["token_name"] is None # noqa: E501 ): # noqa: E501 raise ApiValueError( "Missing the required parameter `token_name` when calling `archive`" ) # noqa: E501 # 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 `archive`" ) # noqa: E501 collection_formats = {} path_params = {} if "event_template_id" in local_var_params: path_params["eventTemplateId"] = local_var_params[ "event_template_id"] # noqa: E501 if "token_name" in local_var_params: path_params["tokenName"] = local_var_params[ "token_name"] # noqa: E501 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 # HTTP header `Accept` header_params["Accept"] = self.api_client.select_header_accept( ["*/*"]) # noqa: E501 # Authentication setting auth_settings = ["developer_hapikey"] # noqa: E501 return self.api_client.call_api( "/crm/v3/timeline/{appId}/event-templates/{eventTemplateId}/tokens/{tokenName}", "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 create_with_http_info(self, event_template_id, app_id, timeline_event_template_token, **kwargs): # noqa: E501 """Adds a token to an existing event template # noqa: E501 Once you've defined an event template, it's likely that you'll want to define tokens for it as well. You can do this on the event template itself or update individual tokens here. Event type tokens allow you to attach custom data to events displayed in a timeline or used for list segmentation. You can also use `objectPropertyName` to associate any CRM object properties. This will allow you to fully build out CRM objects. Token names should be unique across the template. # 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_with_http_info(event_template_id, app_id, timeline_event_template_token, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str event_template_id: The event template ID. (required) :param int app_id: The ID of the target app. (required) :param TimelineEventTemplateToken timeline_event_template_token: The new token definition. (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(TimelineEventTemplateToken, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = [ "event_template_id", "app_id", "timeline_event_template_token" ] 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" % key) local_var_params[key] = val del local_var_params["kwargs"] # verify the required parameter 'event_template_id' is set if self.api_client.client_side_validation and ( "event_template_id" not in local_var_params or local_var_params["event_template_id"] is None # noqa: E501 ): # noqa: E501 raise ApiValueError( "Missing the required parameter `event_template_id` when calling `create`" ) # noqa: E501 # 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`" ) # noqa: E501 # verify the required parameter 'timeline_event_template_token' is set if self.api_client.client_side_validation and ( "timeline_event_template_token" not in local_var_params or local_var_params["timeline_event_template_token"] is None # noqa: E501 ): # noqa: E501 raise ApiValueError( "Missing the required parameter `timeline_event_template_token` when calling `create`" ) # noqa: E501 collection_formats = {} path_params = {} if "event_template_id" in local_var_params: path_params["eventTemplateId"] = local_var_params[ "event_template_id"] # noqa: E501 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 "timeline_event_template_token" in local_var_params: body_params = local_var_params["timeline_event_template_token"] # 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 = ["developer_hapikey"] # noqa: E501 return self.api_client.call_api( "/crm/v3/timeline/{appId}/event-templates/{eventTemplateId}/tokens", "POST", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type="TimelineEventTemplateToken", # 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 get_render_by_id_with_http_info(self, event_template_id, event_id, **kwargs): # noqa: E501 """Renders the header or detail as HTML # noqa: E501 This will take either the `headerTemplate` or `detailTemplate` from the event template and render for the specified event as HTML. If the template references `extraData` that isn't found in the event, it will be ignored and we'll render without it. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_render_by_id_with_http_info(event_template_id, event_id, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str event_template_id: The event template ID. (required) :param str event_id: The event ID. (required) :param bool detail: Set to 'true', we want to render the `detailTemplate` instead of the `headerTemplate`. :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(str, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ["event_template_id", "event_id", "detail"] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") all_params.append("_preload_content") all_params.append("_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 get_render_by_id" % key) local_var_params[key] = val del local_var_params["kwargs"] # verify the required parameter 'event_template_id' is set if self.api_client.client_side_validation and ( "event_template_id" not in local_var_params or local_var_params["event_template_id"] is None # noqa: E501 ): # noqa: E501 raise ApiValueError( "Missing the required parameter `event_template_id` when calling `get_render_by_id`" ) # noqa: E501 # verify the required parameter 'event_id' is set if self.api_client.client_side_validation and ( "event_id" not in local_var_params or local_var_params["event_id"] is None # noqa: E501 ): # noqa: E501 raise ApiValueError( "Missing the required parameter `event_id` when calling `get_render_by_id`" ) # noqa: E501 collection_formats = {} path_params = {} if "event_template_id" in local_var_params: path_params["eventTemplateId"] = local_var_params[ "event_template_id"] # noqa: E501 if "event_id" in local_var_params: path_params["eventId"] = local_var_params["event_id"] # noqa: E501 query_params = [] if ("detail" in local_var_params and local_var_params["detail"] is not None): # noqa: E501 query_params.append( ("detail", local_var_params["detail"])) # noqa: E501 header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params["Accept"] = self.api_client.select_header_accept( ["text/html", "*/*"]) # noqa: E501 # Authentication setting auth_settings = ["hapikey", "oauth2"] # noqa: E501 return self.api_client.call_api( "/crm/v3/timeline/events/{eventTemplateId}/{eventId}/render", "GET", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type="str", # 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 update_event_template_token_with_http_info(self, event_template_id, token_name, app_id, **kwargs): # noqa: E501 """Updates an existing token on an event template # noqa: E501 This will update the existing token on an event template. Name and type can't be changed on existing tokens. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.update_event_template_token_with_http_info(event_template_id, token_name, app_id, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str event_template_id: The event template ID. (required) :param str token_name: The token name. (required) :param int app_id: The ID of the target app. (required) :param TimelineEventTemplateTokenUpdateRequest timeline_event_template_token_update_request: The updated token definition. :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(TimelineEventTemplateToken, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = [ 'event_template_id', 'token_name', 'app_id', 'timeline_event_template_token_update_request' ] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_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 update_event_template_token" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'event_template_id' is set if self.api_client.client_side_validation and ( 'event_template_id' not in local_var_params or # noqa: E501 local_var_params['event_template_id'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `event_template_id` when calling `update_event_template_token`" ) # noqa: E501 # verify the required parameter 'token_name' is set if self.api_client.client_side_validation and ( 'token_name' not in local_var_params or # noqa: E501 local_var_params['token_name'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `token_name` when calling `update_event_template_token`" ) # noqa: E501 # verify the required parameter 'app_id' is set if self.api_client.client_side_validation and ( 'app_id' not in local_var_params or # noqa: E501 local_var_params['app_id'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `app_id` when calling `update_event_template_token`" ) # noqa: E501 collection_formats = {} path_params = {} if 'event_template_id' in local_var_params: path_params['eventTemplateId'] = local_var_params[ 'event_template_id'] # noqa: E501 if 'token_name' in local_var_params: path_params['tokenName'] = local_var_params[ 'token_name'] # noqa: E501 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 'timeline_event_template_token_update_request' in local_var_params: body_params = local_var_params[ 'timeline_event_template_token_update_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/timeline/{appId}/event-templates/{eventTemplateId}/tokens/{tokenName}', 'PUT', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='TimelineEventTemplateToken', # 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 create_with_http_info(self, timeline_event, **kwargs): # noqa: E501 """Create a single event # noqa: E501 Creates an instance of a timeline event based on an event template. Once created, this event is immutable on the object timeline and cannot be modified. If the event template was configured to update object properties via `objectPropertyName`, this call will also attempt to updates those properties, or add them if they don't exist. # 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_with_http_info(timeline_event, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param TimelineEvent timeline_event: The timeline event definition. (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(TimelineEventResponse, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ["timeline_event"] 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" % key) local_var_params[key] = val del local_var_params["kwargs"] # verify the required parameter 'timeline_event' is set if self.api_client.client_side_validation and ( "timeline_event" not in local_var_params or local_var_params["timeline_event"] is None # noqa: E501 ): # noqa: E501 raise ApiValueError( "Missing the required parameter `timeline_event` when calling `create`" ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if "timeline_event" in local_var_params: body_params = local_var_params["timeline_event"] # 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 = ["oauth2"] # noqa: E501 return self.api_client.call_api( "/crm/v3/timeline/events", "POST", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type="TimelineEventResponse", # 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 get_detail_by_id_with_http_info(self, event_template_id, event_id, **kwargs): # noqa: E501 """Gets the detailTemplate as rendered # noqa: E501 This will take the `detailTemplate` from the event template and return an object rendering the specified event. If the template references `extraData` that isn't found in the event, it will be ignored and we'll render without it. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_detail_by_id_with_http_info(event_template_id, event_id, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str event_template_id: The event template ID. (required) :param str event_id: The event ID. (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(EventDetail, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['event_template_id', 'event_id'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_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 get_detail_by_id" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'event_template_id' is set if self.api_client.client_side_validation and ('event_template_id' not in local_var_params or # noqa: E501 local_var_params['event_template_id'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `event_template_id` when calling `get_detail_by_id`") # noqa: E501 # verify the required parameter 'event_id' is set if self.api_client.client_side_validation and ('event_id' not in local_var_params or # noqa: E501 local_var_params['event_id'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `event_id` when calling `get_detail_by_id`") # noqa: E501 collection_formats = {} path_params = {} if 'event_template_id' in local_var_params: path_params['eventTemplateId'] = local_var_params['event_template_id'] # noqa: E501 if 'event_id' in local_var_params: path_params['eventId'] = local_var_params['event_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( ['application/json', '*/*']) # noqa: E501 # Authentication setting auth_settings = ['hapikey', 'oauth2'] # noqa: E501 return self.api_client.call_api( '/crm/v3/timeline/events/{eventTemplateId}/{eventId}/detail', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='EventDetail', # 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)