def get_wizard(wizard_id): """ This method is used to get wizard' details with ID and print(the response. """ # Get instance of WizardOperations Class wizard_operations = WizardsOperations() # Possible parameters for Get Wizard Operation param_instance = ParameterMap() param_instance.add(GetWizardbyIDParam.layout_id, "34770610091055") # Call get_wizard method that takes ParameterMap instance as parameter response = wizard_operations.get_wizard_by_id(wizard_id, param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) if response.get_status_code() in [204, 304]: print('No Content' if response.get_status_code() == 204 else 'Not Modified') return # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ResponseWrapper instance is received if isinstance(response_object, ResponseWrapper): wizard_list = response_object.get_wizards() for wizard in wizard_list: # Get the ID of each Wizard print(" ID " + str(wizard.get_id())) # Get the name of each Wizard print("Name: " + str(wizard.get_name())) # Get the Modified Time of each Wizard print("Modified Time: " + str(wizard.get_modified_time())) # Get the Created Time of each Wizard print("Created Time: " + str(wizard.get_created_time())) # Get the Draft of each Wizard print("Draft: " + str(wizard.get_draft())) # Get the active of each Wizard print("active: " + str(wizard.get_active())) created_by = wizard.get_created_by() # Check if created_by is not None if created_by is not None: # Get the Name of the created_by User print("Created By - Name: " + created_by.get_name()) # Get the ID of the created_by User print("Created By - ID: " + str(created_by.get_id())) # Get the email of the created_by User print("Created By - email: " + str(created_by.get_email())) # Check if parent_wizard is not None parent_wizard = wizard.get_parent_wizard() if parent_wizard is not None: # Get the ID of the folder print("Wizard parent_wizard ID: " + parent_wizard.get_parent_wizard()) # Get the Name of the folder print("Wizard parent_wizard Name:" + str(parent_wizard.get_id())) # get module module = wizard.get_module() if module is not None: # Get the API Name of the module print("Module - API Name: " + module.get_api_name()) # Get the ID of the module print("Module - ID: " + str(module.get_id())) # get profiles profiles = wizard.get_profiles() for profile in profiles: print("Wizard Profile ID: " + str(profile.get_id)) print("Wizard Profile Name: " + profile.get_name()) # Get the modified_by User instance of each Wizard modified_by = wizard.get_modified_by() # Check if modified_by is not None if modified_by is not None: # Get the Name of the modifiedBy User print("Modified By - Name: " + modified_by.get_name()) # Get the ID of the modifiedBy User print("Modified By - ID: " + str(modified_by.get_id())) # Get the email of the created_by User print("Modified By - ID: " + str(modified_by.get_email())) # Get the Containers of each Wizard containers = wizard.get_containers() if containers is not None: for container in containers: # Get the Container ID print("\n Container Id: " + str(container.get_id())) # Get the Layout layout = container.get_layout() if layout is not None: print("\n Layout id" + str(layout.get_id())) print("\n Layout name" + layout.get_name()) # Get the Chart Data chart_data = container.get_chart_data() if chart_data is not None: # Get the nodes nodes = chart_data.get_nodes() for node in nodes: print( "\n Chart Data Node poistion y: ") print(node.get_pos_y()) print( "\n Chart Data Node poistion x: ") print(node.get_pos_x()) print( "\n Chart Data Node start node : ") print(node.get_start_node()) node_screen = node.get_screen() if node_screen is not None: print("\n Screen id") print(node_screen.get_id()) print("\n Screen display label") print(node_screen. get_display_label()) # Get the connections connections = chart_data.get_connections() if connections is not None: for connection in connections: # Get the target screen connection_screen = connection.get_target_screen( ) if connection_screen is not None: print( "\n connection_screen id") print( connection_screen.get_id()) print( "\n connection_screen display label" ) print(connection_screen. get_display_label()) # Get the connection source button connection_button = connection_screen.get_source_button( ) if connection_button is not None: print( "\n connection_button id") print( connection_button.get_id()) print( "\n connection_button display label" ) print(connection_button. get_display_label()) # Get chart data chart_data = container.get_chart_data() if chart_data is not None: print("\n Chart Data Canvas width: ") print(chart_data.get_canvas_width()) print("\n Chart Data Canvas height: ") print(chart_data.get_canvas_height()) # Get container screens screens = container.get_screens() if screens is not None: for screen in screens: print("\n screen id") print(screen.get_id()) print("\n screen display label") print(screen.get_display_label()) # Get container screens segments segments = screen.get_segments() for segment in segments: print("\n segment id") print(segment.get_id()) print("\n segment display label") print(segment.get_display_label()) print("\n segment sequence number") print(segment.get_sequence_number()) print("\n segment type") print(segment.get_type()) print("\n segment column count") print(segment.get_column_count()) fields = segment.get_fields() if fields is not None: for field in fields: print("\n field id") print(field.get_id()) print("\n field api_name") print(field.get_api_name()) buttons = segment.get_buttons() if buttons is not None: for button in buttons: criteria = button.get_criteria( ) if criteria is not None: Wizard.print_criteria( criteria) target_screen = button.get_target_screen( ) if target_screen is not None: print( "\n target screen id") print( target_screen.get_id()) print( "\n target screen display label" ) print(target_screen. get_display_label()) print( "\n Button display label:" ) print( button.get_display_label()) print("\n Button id:") print(button.get_id()) print("\n Button type:") print(button.get_type()) print( "\n Button background color:" ) print(button. get_background_color()) print( "\n Button sequence number:" ) print(button. get_sequence_number()) print("\n Button color:") print(button.get_color()) print("\n Button type:") print(button.get_type()) print("\n Button shape:") print(button.get_shape()) elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() if details is not None: if details is not None: for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def upload_link_attachment(module_api_name, record_id, attachment_url): """ This method is used to upload link attachment and print the response. :param module_api_name: The API Name of the record's module :param record_id: The ID of the record to upload Link attachment :param attachment_url: The attachment url of the doc or image link to be attached """ """ example module_api_name = "Leads"; record_id = 3409643000002267003 attachment_url = "https://5.imimg.com/data5/KJ/UP/MY-8655440/zoho-crm-500x500.png"; """ # Get instance of AttachmentsOperations Class that takes module_api_name and record_id as parameter attachments_operations = AttachmentsOperations(module_api_name, record_id) # Get instance of ParameterMap Class param_instance = ParameterMap() # Add the attachment_url to parameter Instance param_instance.add(UploadLinkAttachmentParam.attachmenturl, attachment_url) # Call upload_link_attachment method that takes ParameterMap instance as parameter response = attachments_operations.upload_link_attachment(param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ActionWrapper instance is received. if isinstance(response_object, ActionWrapper): action_response_list = response_object.get_data() for action_response in action_response_list: # Check if the request is successful if isinstance(action_response, SuccessResponse): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(action_response, APIException): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def get_custom_views(module_api_name): """ Create an instance of Logger Class that takes two parameters 1 -> Level of the log messages to be logged. Can be configured by typing Logger.Levels "." and choose any level from the list displayed. 2 -> Absolute file path, where messages need to be logged. """ logger = Logger.get_instance( level=Logger.Levels.INFO, file_path= '/home/simon/commerce_cube/ecom-ds-PropensityReporting/data/python_sdk_log.log' ) # Create an UserSignature instance that takes user Email as parameter user = UserSignature(email='*****@*****.**') """ Configure the environment which is of the pattern Domain.Environment Available Domains: USDataCenter, EUDataCenter, INDataCenter, CNDataCenter, AUDataCenter Available Environments: PRODUCTION(), DEVELOPER(), SANDBOX() """ environment = USDataCenter.PRODUCTION() """ Create a Token instance that takes the following parameters 1 -> OAuth client id. 2 -> OAuth client secret. 3 -> REFRESH/GRANT token. 4 -> token type. 5 -> OAuth redirect URL. """ token = OAuthToken( client_id=os.getenv('zoho_client_id'), client_secret=os.getenv('zoho_client_secret'), token= '1000.4ceee886d212fe2f4bae575841b2d9d1.8716ba1d1d064921e67612fce4a1cc5b', token_type=TokenType.GRANT, redirect_url='https://www.brightermonday.co.ke') """ Create an instance of TokenStore 1 -> Absolute file path of the file to persist tokens """ store = FileStore( file_path= '/home/simon/commerce_cube/ecom-ds-PropensityReporting/data/python_sdk_tokens.txt' ) """ Create an instance of TokenStore 1 -> DataBase host name. Default value "localhost" 2 -> DataBase name. Default value "zohooauth" 3 -> DataBase user name. Default value "root" 4 -> DataBase password. Default value "" 5 -> DataBase port number. Default value "3306" """ # store = DBStore() # store = DBStore(host='host_name', database_name='database_name', user_name='user_name', password='******',port_number='port_number') """ auto_refresh_fields if True - all the modules' fields will be auto-refreshed in the background, every hour. if False - the fields will not be auto-refreshed in the background. The user can manually delete the file(s) or refresh the fields using methods from ModuleFieldsHandler(zcrmsdk/src/com/zoho/crm/api/util/module_fields_handler.py) pick_list_validation A boolean field that validates user input for a pick list field and allows or disallows the addition of a new value to the list. if True - the SDK validates the input. If the value does not exist in the pick list, the SDK throws an error. if False - the SDK does not validate the input and makes the API request with the user’s input to the pick list """ config = SDKConfig(auto_refresh_fields=True, pick_list_validation=False) """ The path containing the absolute directory path (in the key resource_path) to store user-specific files containing information about fields in modules. """ resource_path = '/home/simon/commerce_cube/ecom-ds-PropensityReporting/data' """ Create an instance of RequestProxy class that takes the following parameters 1 -> Host 2 -> Port Number 3 -> User Name. Default value is None 4 -> Password. Default value is None """ # request_proxy = RequestProxy(host='proxyHost', port=8080) # request_proxy = RequestProxy(host='proxyHost', port=8080, user='******', password='******') """ Call the static initialize method of Initializer class that takes the following arguments 1 -> UserSignature instance 2 -> Environment instance 3 -> Token instance 4 -> TokenStore instance 5 -> SDKConfig instance 6 -> resource_path 7 -> Logger instance. Default value is None 8 -> RequestProxy instance. Default value is None """ Initializer.initialize(user=user, environment=environment, token=token, store=store, sdk_config=config, resource_path=resource_path, logger=logger) """ This method is used to get the custom views data of a particular module. Specify the module name in your API request whose custom view data you want to retrieve. :param module_api_name: the API name of the required module. """ """ example module_api_name = "Leads"; """ # Get instance of CustomViewOperations Class that takes module_api_name as parameter custom_views_operations = CustomViewsOperations(module_api_name) # Get instance of ParameterMap Class param_instance = ParameterMap() # Possible parameters of Get CustomViews operation param_instance.add(GetCustomViewsParam.page, 1) param_instance.add(GetCustomViewsParam.per_page, 20) # Call get_custom_views method that takes ParameterMap instance as parameter response = custom_views_operations.get_custom_views(param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) if response.get_status_code() in [204, 304]: print('No Content' if response.get_status_code() == 204 else 'Not Modified') return # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ResponseWrapper instance is received if isinstance(response_object, ResponseWrapper): # Get the list of obtained CustomView instances custom_views_list = response_object.get_custom_views() for custom_view in custom_views_list: # Get the ID of each CustomView print('CustomView ID: ' + str(custom_view.get_id())) # Get the Name of each CustomView print('CustomView Name: ' + str(custom_view.get_name())) # Get the System Name of each CustomView print('CustomView System Name: ' + str(custom_view.get_system_name())) # Get the Category of each CustomView print('CustomView Category: ' + str(custom_view.get_category())) # Get the DisplayValue of each CustomView print('CustomView Display Value: ' + str(custom_view.get_display_value())) # Get the Offline value of each CustomView print('CustomView Is offline: ' + str(custom_view.get_offline())) # Get the default value of each CustomView print('CustomView Is default: ' + str(custom_view.get_default())) # Get the SystemDefined of each CustomView print('CustomView Is System Defined: ' + str(custom_view.get_system_defined())) if custom_view.get_favorite() is not None: # Get the Favorite of each CustomView print('CustomView Favorite: ' + str(custom_view.get_favorite())) info = response_object.get_info() if info is not None: print("CustomView Info") if info.get_per_page() is not None: # Get the PerPage from Info print('PerPage: ' + str(info.get_per_page())) if info.get_page() is not None: # Get the Page from Info print('Page: ' + str(info.get_page())) if info.get_more_records() is not None: # Get the MoreRecords from Info print('MoreRecords: ' + str(info.get_more_records())) if info.get_default() is not None: # Get the Default from Info print('Default: ' + info.get_default()) if info.get_count() is not None: # Get the Count from Info print('Count: ' + str(info.get_count())) translation = info.get_translation() if translation is not None: print("Translation details") # Get the PublicViews of the Translation print('PublicViews: ' + translation.get_public_views()) # Get the OtherUsersViews of the Translation print('OtherUsersViews: ' + translation.get_other_users_views()) # Get the SharedWithMe of the Translation print('SharedWithMe: ' + translation.get_shared_with_me()) # Get the CreatedByMe of the Translation print('CreatedByMe: ' + translation.get_created_by_me()) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def update_tag(module_api_name, tag_id): """ This method is used to update single tag and print the response. :param module_api_name: The API Name of the module to update tag. :param tag_id: The ID of the tag to be updated """ """ example module_api_name = "Leads" tag_id = 3409643000000661047 """ # Get instance of TagsOperations Class tags_operations = TagsOperations() # Get instance of ParameterMap Class param_instance = ParameterMap() # Possible parameters of Update Tag operation param_instance.add(UpdateTagParam.module, module_api_name) # Get instance of BodyWrapper Class that will contain the request body request = BodyWrapper() # List to hold Tag instances tags_list = [] # Get instance of Tag Class tag_1 = ZCRMTag() # Set name tag_1.set_name("py- tagname") # Add the instance to list tags_list.append(tag_1) # Set the list to tags in BodyWrapper instance request.set_tags(tags_list) # Call update_tag method that takes BodyWrapper instance, ParameterMap instance and tag_id as parameter response = tags_operations.update_tag(tag_id, request, param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ActionWrapper instance is received. if isinstance(response_object, ActionWrapper): # Get the list of obtained ActionResponse instances action_response_list = response_object.get_tags() for action_response in action_response_list: # Check if the request is successful if isinstance(action_response, SuccessResponse): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(action_response, APIException): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def add_tags_to_multiple_records(module_api_name, record_ids, tag_names): """ This method is used to add tags to multiple records simultaneously and print the response. :param module_api_name: The API Name of the module to add tags. :param record_ids: The list of the record IDs to add tags :param tag_names: The list of tag names to be added """ """ example module_api_name = "Leads" record_ids = [3409643000002157023, 3409643000002157045] tag_names = ["addtag1,addtag12"] """ # Get instance of TagsOperations Class tags_operations = TagsOperations() # Get instance of ParameterMap Class param_instance = ParameterMap() # Possible parameters for Add Tags To Multiple Records operation for record_id in record_ids: param_instance.add(AddTagsToMultipleRecordsParam.ids, record_id) for tag_name in tag_names: param_instance.add(AddTagsToMultipleRecordsParam.tag_names, tag_name) param_instance.add(AddTagsToMultipleRecordsParam.over_write, 'false') # Call add_tags_to_multiple_records method that takes ParameterMap instance and module_api_name as parameter response = tags_operations.add_tags_to_multiple_records( module_api_name, param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected RecordActionWrapper instance is received. if isinstance(response_object, RecordActionWrapper): # Get the list of obtained ActionResponse instances action_response_list = response_object.get_data() for action_response in action_response_list: # Check if the request is successful if isinstance(action_response, SuccessResponse): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(action_response, APIException): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def delete_variables(variable_ids): """ This method is used to delete details of multiple variables in CRM simultaneously and print the response. :param variable_ids: The list of Variable IDs to be deleted """ """ example variable_ids = [34096432275025, 34096432275035] """ # Get instance of VariablesOperations Class variables_operations = VariablesOperations() # Get instance of ParameterMap Class param_instance = ParameterMap() # Possible parameters of Delete Variables operation for variable_id in variable_ids: param_instance.add(DeleteVariablesParam.ids, variable_id) # Call delete_variables method that takes ParameterMap instance as parameter response = variables_operations.delete_variables(param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ActionWrapper instance is received. if isinstance(response_object, ActionWrapper): # Get the list of obtained ActionResponse instances action_response_list = response_object.get_variables() for action_response in action_response_list: # Check if the request is successful if isinstance(action_response, SuccessResponse): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(action_response, APIException): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def get_record_count_for_tag(module_api_name, tag_id): """ This method is used to get the total number of records under a tag and print the response. :param module_api_name: The API Name of the module. :param tag_id: The ID of the tag to get the count """ """ example module_api_name = "Leads" tag_id = 3409643000000661047 """ # Get instance of TagsOperations Class tags_operations = TagsOperations() # Get instance of ParameterMap Class param_instance = ParameterMap() # Possible parameters for Get Record Count operation param_instance.add(GetRecordCountForTagParam.module, module_api_name) # Call get_record_count_for_tag method that takes param_instance and tag_id as parameter response = tags_operations.get_record_count_for_tag( tag_id, param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) if response.get_status_code() in [204, 304]: print('No Content' if response.get_status_code() == 204 else 'Not Modified') return # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected CountWrapper instance is received. if isinstance(response_object, CountWrapper): # Get the obtained tag count print("Tag Count: " + response_object.get_count()) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def get_shared_record_details(module_api_name, record_id): """ This method is used to get the details of a shared record and print the response. :param module_api_name: The API Name of the module to get shared record details. :param record_id: The ID of the record to be obtain shared information :return: """ """ example module_api_name = Contacts record_id = 3409643000002112011 """ # Get instance of ShareRecordsOperations Class that takes module_api_name and record_id as parameter shared_records_operations = ShareRecordsOperations( record_id, module_api_name) # Get instance of ParameterMap Class param_instance = ParameterMap() # Possible parameters of Get Shared Record Details operation # Allowed values - summary, manage param_instance.add(GetSharedRecordDetailsParam.view, 'manage') # param_instance.add(GetSharedRecordDetailsParam.sharedto, 3409643000000302031) # Call get_shared_record_details method that takes ParameterMap instance as parameter response = shared_records_operations.get_shared_record_details( param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) if response.get_status_code() in [204, 304]: print('No Content' if response.get_status_code() == 204 else 'Not Modified') return # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ResponseWrapper instance is received. if isinstance(response_object, ResponseWrapper): # Get the list of obtained ShareRecord instances share_records_list = response_object.get_share() for share_record in share_records_list: # Get the ShareRelatedRecords of each ShareRecord print("ShareRecord ShareRelatedRecords: " + str(share_record.get_share_related_records())) # Get the SharedThrough instance of each ShareRecord shared_through = share_record.get_shared_through() # Check if sharedThrough is not null if shared_through is not None: # Get the Module instance of each ShareRecord module = shared_through.get_module() if module is not None: # Get the ID of the Module print("ShareRecord SharedThrough Module ID: " + str(module.get_id())) # Get the Name of the Module print( "ShareRecord SharedThrough Module Name: " + str(module.get_name())) # Get the ID of the SharedThrough print("ShareRecord SharedThrough ID: " + str(shared_through.get_id())) # Get the Permission of each ShareRecord print("ShareRecord Permission: " + str(share_record.get_permission())) # Get the SharedTime of each ShareRecord print("ShareRecord SharedTime: " + str(share_record.get_shared_time())) # Get the SharedBy User instance shared_by = share_record.get_shared_by() if shared_by is not None: # Get the ID of the User print("ShareRecord SharedBy-ID: " + str(shared_by.get_id())) # Get the FullName of the User print("ShareRecord SharedBy-FullName: " + shared_by.get_full_name()) # Get the Zuid of the User print("ShareRecord SharedBy-Zuid: " + str(shared_by.get_zuid())) # Get the shared User instance of each ShareRecord user = share_record.get_user() if user is not None: # Get the ID of the shared User print("ShareRecord User-ID: " + str(user.get_id())) # Get the FullName of the shared User print("ShareRecord User-FullName: " + str(user.get_full_name())) # Get the Zuid of the shared User print("ShareRecord User-Zuid: " + str(user.get_zuid())) # Get the list of obtained Shareable User instances shareable_users = response_object.get_shareable_user() if shareable_users is not None: for shareable_user in shareable_users: # Get the ID of the shareable User print("Shareable User-ID: " + str(shareable_user.get_id())) # Get the FullName of the shareable User print("Shareable User-FullName: " + str(shareable_user.get_full_name())) # Get the Zuid of the shareable User print("Shareable User-Zuid: " + str(shareable_user.get_zuid())) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def get_file(id, destination_folder): """ This method is used to download the file with ID and write in the destinationFolder :param id: The ID of the uploaded File. :param destination_folder: The absolute path of the destination folder to store the File """ """ example id = "ae9c7cefa418aec1d6a5cc2d9ab35c3231aae3bfeef7d5e00a54b7563c0dd42b"; destination_folder = "/Users/user_name/Desktop" """ # Get instance of FileOperations Class file_operations = FileOperations() # Get instance of ParameterMap Class param_instance = ParameterMap() # Add the id to ParameterMap instance param_instance.add(GetFileParam.id, id) # Call get_file method that takes ParameterMap instance as parameter response = file_operations.get_file(param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) if response.get_status_code() in [204, 304]: print('No Content' if response.get_status_code() == 204 else 'Not Modified') return # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected FileBodyWrapper instance is received. if isinstance(response_object, FileBodyWrapper): # Get StreamWrapper instance from the returned FileBodyWrapper instance stream_wrapper = response_object.get_file() # Construct the file name by joining the destinationFolder and the name from StreamWrapper instance file_name = os.path.join(destination_folder, stream_wrapper.get_name()) # Open the destination file where the file needs to be written in 'wb' mode with open(file_name, 'wb') as f: # Get the stream from StreamWrapper instance for chunk in stream_wrapper.get_stream(): f.write(chunk) f.close() # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def get_notification_details(): """ This method is used to get details of the Notification and print the response. """ # Get instance of NotificationOperations Class notification_operations = NotificationOperations() # Get instance of ParameterMap Class param_instance = ParameterMap() param_instance.add(GetNotificationDetailsParam.module, 'Deals') param_instance.add(GetNotificationDetailsParam.page, 1) param_instance.add(GetNotificationDetailsParam.per_page, 20) param_instance.add(GetNotificationDetailsParam.channel_id, 100000006800211) # Call get_notification_details method that takes param_instance as parameter response = notification_operations.get_notification_details( param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) if response.get_status_code() in [204, 304]: print('No Content' if response.get_status_code() == 204 else 'Not Modified') return # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ResponseWrapper instance is received. if isinstance(response_object, ResponseWrapper): # Get the list of obtained Notification instances notification_list = response_object.get_watch() for notification in notification_list: # Get the NotifyOnRelatedAction of each Notification print("Notification NotifyOnRelatedAction: " + str(notification.get_notify_on_related_action())) # Get the ChannelExpiry of each Notification print("Notification ChannelExpiry: " + str(notification.get_channel_expiry())) # Get the ResourceUri of each Notification print("Notification ResourceUri: " + notification.get_resource_uri()) # Get the ResourceId of each Notification print("Notification ResourceId: " + notification.get_resource_id()) # Get the ResourceName of each Notification print("Notification ResourceName: " + notification.get_resource_name()) # Get the ChannelId of each Notification print("Notification ChannelId: " + str(notification.get_channel_id())) # Get the NotifyUrl each Notification print("Notification NotifyUrl: " + notification.get_notify_url()) # Get the events List of each Notification events = notification.get_events() if events is not None: for event in events: # Get the Events print("Notification Events: " + event) # Get the Token each Notification print("Notification Token: " + notification.get_token()) info = response_object.get_info() if info is not None: if info.get_per_page() is not None: # Get the PerPage from Info print('Notification Info PerPage: ' + str(info.get_per_page())) if info.get_page() is not None: # Get the Page from Info print('Notification Info Page: ' + str(info.get_page())) if info.get_count() is not None: # Get the Count from Info print('Notification Info Count: ' + str(info.get_count())) if info.get_more_records() is not None: # Get the MoreRecords from Info print('Notification Info MoreRecords: ' + str(info.get_more_records())) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def disable_notifications(channel_ids): """ To stop all the instant notifications enabled by the user for a channel. :param channel_ids: A list containing the unique IDs of the notification channels to be disabled. """ """ example channel_ids = [1000000068002, 1000000068020, 1000000068101] """ # Get instance of NotificationOperations Class notification_operations = NotificationOperations() # Get instance of ParameterMap Class param_instance = ParameterMap() for channel_id in channel_ids: param_instance.add(DisableNotificationsParam.channel_ids, channel_id) # Call disable_notifications method that takes paramInstance as parameter response = notification_operations.disable_notifications( param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ActionWrapper instance is received. if isinstance(response_object, ActionWrapper): # Get the list of obtained ActionResponse instances action_response_list = response_object.get_watch() for action_response in action_response_list: # Check if the request is successful if isinstance(action_response, SuccessResponse): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(action_response, APIException): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def get_custom_views(module_api_name): """ This method is used to get the custom views data of a particular module. Specify the module name in your API request whose custom view data you want to retrieve. :param module_api_name: the API name of the required module. """ """ example module_api_name = "Leads"; """ # Get instance of CustomViewOperations Class that takes module_api_name as parameter custom_views_operations = CustomViewsOperations(module_api_name) # Get instance of ParameterMap Class param_instance = ParameterMap() # Possible parameters of Get CustomViews operation param_instance.add(GetCustomViewsParam.page, 1) param_instance.add(GetCustomViewsParam.per_page, 20) # Call get_custom_views method that takes ParameterMap instance as parameter response = custom_views_operations.get_custom_views(param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) if response.get_status_code() in [204, 304]: print('No Content' if response.get_status_code() == 204 else 'Not Modified') return # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ResponseWrapper instance is received if isinstance(response_object, ResponseWrapper): # Get the list of obtained CustomView instances custom_views_list = response_object.get_custom_views() for custom_view in custom_views_list: # Get the ID of each CustomView print('CustomView ID: ' + str(custom_view.get_id())) # Get the Name of each CustomView print('CustomView Name: ' + str(custom_view.get_name())) created_by = custom_view.get_created_by() # Check if created_by is not None if created_by is not None: # Get the Name of the created_by User print("CustomView Created By - Name: " + created_by.get_name()) # Get the ID of the created_by User print("CustomView Created By - ID: " + str(created_by.get_id())) if custom_view.get_modified_time() is not None: # Get the ModifiedTime of each custom_view print("Record ModifiedTime: " + str(custom_view.get_modified_time())) # Get the modified_by User instance of the Record modified_by = custom_view.get_modified_by() # Check if modified_by is not None if modified_by is not None: # Get the Name of the modified_by User print("Record Modified By - Name: " + modified_by.get_name()) # Get the ID of the modified_by User print("Record Modified By - ID: " + str(modified_by.get_id())) # Get the System Name of each CustomView print('CustomView System Name: ' + str(custom_view.get_system_name())) # Get the Category of each CustomView print('CustomView Category: ' + str(custom_view.get_category())) # Get the last_accessed_time of each CustomView print('CustomView __last_accessed_time: ' + str(custom_view.get_last_accessed_time())) # Get the DisplayValue of each CustomView print('CustomView Display Value: ' + str(custom_view.get_display_value())) # Get the AccessType of each CustomView print('CustomView AccessType: ' + str(custom_view.get_access_type())) # Get the default value of each CustomView print('CustomView Is default: ' + str(custom_view.get_default())) # Get the SystemDefined of each CustomView print('CustomView Is System Defined: ' + str(custom_view.get_system_defined())) if custom_view.get_favorite() is not None: # Get the Favorite of each CustomView print('CustomView Favorite: ' + str(custom_view.get_favorite())) info = response_object.get_info() if info is not None: print("CustomView Info") if info.get_per_page() is not None: # Get the PerPage from Info print('PerPage: ' + str(info.get_per_page())) if info.get_page() is not None: # Get the Page from Info print('Page: ' + str(info.get_page())) if info.get_more_records() is not None: # Get the MoreRecords from Info print('MoreRecords: ' + str(info.get_more_records())) if info.get_default() is not None: # Get the Default from Info print('Default: ' + info.get_default()) if info.get_count() is not None: # Get the Count from Info print('Count: ' + str(info.get_count())) translation = info.get_translation() if translation is not None: print("Translation details") # Get the PublicViews of the Translation print('PublicViews: ' + translation.get_public_views()) # Get the OtherUsersViews of the Translation print('OtherUsersViews: ' + translation.get_other_users_views()) # Get the SharedWithMe of the Translation print('SharedWithMe: ' + translation.get_shared_with_me()) # Get the CreatedByMe of the Translation print('CreatedByMe: ' + translation.get_created_by_me()) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def delete_contact_roles(contact_role_ids): """ This method is used to delete Contact Roles and print the response. :param contact_role_ids: The list of ContactRole IDs to be deleted. """ """ example contact_role_ids = [34096432157002n, 34096431619001n, 34096436883n] """ # Get instance of ContactRolesOperations Class contact_roles_operations = ContactRolesOperations() # Get instance of ParameterMap Class param_instance = ParameterMap() # Add ids to ParameterMap instance for contact_role_id in contact_role_ids: param_instance.add(DeleteContactRolesParam.ids, contact_role_id) # Call delete_contact_roles method that takes ParameterMap instance as parameter response = contact_roles_operations.delete_contact_roles(param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ActionWrapper instance is received. if isinstance(response_object, ActionWrapper): action_response_list = response_object.get_contact_roles() for action_response in action_response_list: # Check if the request is successful if isinstance(action_response, SuccessResponse): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(action_response, APIException): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def get_attachments(module_api_name, record_id): """ This method is used to get a single record's attachments' details with ID and print the response. :param module_api_name: The API Name of the record's module :param record_id: The ID of the record to get attachments """ """ example module_api_name = 'Leads' record_id = 3409643000002267003 """ # Get instance of AttachmentsOperations Class that takes module_api_name and record_id as parameters attachments_operations = AttachmentsOperations(module_api_name, record_id) # Possible parameters for Get Attachments Operation param_instance = ParameterMap() param_instance.add(GetAttachmentsParam.fields, "id") param_instance.add(GetAttachmentsParam.page, 2) param_instance.add(GetAttachmentsParam.per_page, 10) # Call get_attachments method that takes ParameterMap instance as parameter response = attachments_operations.get_attachments(param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) if response.get_status_code() in [204, 304]: print('No Content' if response.get_status_code() == 204 else 'Not Modified') return # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ResponseWrapper instance is received if isinstance(response_object, ResponseWrapper): attachments_list = response_object.get_data() for attachment in attachments_list: # Get the ID of each attachment print('Attachment ID : ' + str(attachment.get_id())) # Get the owner User instance of each attachment owner = attachment.get_owner() # Check if owner is not None if owner is not None: # Get the Name of the Owner print("Attachment Owner - Name: " + owner.get_name()) # Get the ID of the Owner print("Attachment Owner - ID: " + str(owner.get_id())) # Get the Email of the Owner print("Attachment Owner - Email: " + owner.get_email()) # Get the modified time of each attachment print("Attachment Modified Time: " + str(attachment.get_modified_time())) # Get the name of the File print("Attachment File Name: " + str(attachment.get_file_name())) # Get the created time of each attachment print("Attachment Created Time: " + str(attachment.get_created_time())) # Get the Attachment file size print("Attachment File Size: " + str(attachment.get_size())) # Get the parentId Record instance of each attachment parent_id = attachment.get_parent_id() if parent_id is not None: # Get the parent record Name of each attachment print("Attachment parent record Name: " + parent_id.get_key_value("name")) # Get the parent record ID of each attachment print("Attachment parent record ID: " + str(parent_id.get_id())) # Check if the attachment is Editable print("Attachment is Editable: " + str(attachment.get_editable())) # Get the file ID of each attachment print("Attachment File ID: " + str(attachment.get_file_id())) # Get the type of each attachment print("Attachment File Type: " + str(attachment.get_type())) # Get the seModule of each attachment print("Attachment seModule: " + str(attachment.get_se_module())) # Get the modifiedBy User instance of each attachment modified_by = attachment.get_modified_by() # Check if modifiedBy is not None if modified_by is not None: # Get the Name of the modifiedBy User print("Attachment Modified By - Name: " + modified_by.get_name()) # Get the ID of the modifiedBy User print("Attachment Modified By - ID: " + str(modified_by.get_id())) # Get the Email of the modifiedBy User print("Attachment Modified By - Email: " + modified_by.get_email()) # Get the state of each attachment print("Attachment State: " + str(attachment.get_state())) # Get the modifiedBy User instance of each attachment created_by = attachment.get_created_by() # Check if created_by is not None if created_by is not None: # Get the Name of the modifiedBy User print("Attachment Created By - Name: " + created_by.get_name()) # Get the ID of the modifiedBy User print("Attachment Created By - ID: " + str(created_by.get_id())) # Get the Email of the modifiedBy User print("Attachment Created By - Email: " + created_by.get_email()) # Get the linkUrl of each attachment print("Attachment LinkUrl: " + str(attachment.get_link_url())) info = response_object.get_info() if info is not None: if info.get_per_page() is not None: # Get the PerPage from Info print('Record Info PerPage: ' + str(info.get_per_page())) if info.get_page() is not None: # Get the Page from Info print('Record Info Page: ' + str(info.get_page())) if info.get_count() is not None: # Get the Count from Info print('Record Info Count: ' + str(info.get_count())) if info.get_more_records() is not None: # Get the MoreRecords from Info print('Record Info MoreRecords: ' + str(info.get_more_records())) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() if details is not None: if details is not None: for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def delete_taxes(tax_ids): """ This method is used to delete Organization Taxes and print the response. :param tax_ids: The List of the tax IDs to be deleted :return: """ """ example tax_ids = [3409643000002407046, 3409643000002407047] """ # Get instance of TaxesOperations Class taxes_operations = TaxesOperations() # Get instance of TaxesOperations Class param_instance = ParameterMap() # Possible parameters for Delete Taxes operation for tax_id in tax_ids: param_instance.add(DeleteTaxesParam.ids, tax_id) # Call delete_taxes method that takes ParameterMap instance as parameter response = taxes_operations.delete_taxes(param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ActionWrapper instance is received. if isinstance(response_object, ActionWrapper): # Get the list of obtained ActionResponse instances action_response_list = response_object.get_taxes() for action_response in action_response_list: # Check if the request is successful if isinstance(action_response, SuccessResponse): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(action_response, APIException): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def upload_files(): """ This method is used to upload files and print the response. """ # Get instance of FileOperations Class file_operations = FileOperations() # Get instance of ParameterMap Class param_instance = ParameterMap() # Possible parameters of UploadFile operation param_instance.add(UploadFilesParam.type, "inline") # Get instance of FileBodyWrapper Class that will contain the request body request = BodyWrapper() """ StreamWrapper can be initialized in any of the following ways * param 1 -> fileName * param 2 -> Read Stream. """ # stream_wrapper = StreamWrapper(stream=open(absolute_file_path, 'rb')) """ * param 1 -> fileName * param 2 -> Read Stream * param 3 -> Absolute File Path of the file to be attached """ stream_wrapper1 = StreamWrapper( file_path='/Users/Documents/download.png') stream_wrapper2 = StreamWrapper( file_path='/Users/Documents/download.png') stream_wrapper3 = StreamWrapper( file_path='/Users/Documents/download.png') # Set list of files to the BodyWrapper instance request.set_file([stream_wrapper1, stream_wrapper2, stream_wrapper3]) # Call upload_files method that takes BodyWrapper instance and ParameterMap instance as parameter. response = file_operations.upload_files(request, param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ActionWrapper instance is received. if isinstance(response_object, ActionWrapper): action_response_list = response_object.get_data() for action_response in action_response_list: # Check if the request is successful if isinstance(action_response, SuccessResponse): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(action_response, APIException): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def get_assignment_rule(rule_id): """ This method is used to get assignment_rules' details with ID and print the response. """ # Get instance of AssignmentRulesOperations Class assignment_rules_operations = AssignmentRulesOperations() # Possible parameters for Get AssignmentRules Operation param_instance = ParameterMap() param_instance.add(GetAssignmentRuleParam.module, "Leads") # Call get_assignment_rules method that takes ParameterMap instance as parameter response = assignment_rules_operations.get_assignment_rule( rule_id, param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) if response.get_status_code() in [204, 304]: print('No Content' if response.get_status_code() == 204 else 'Not Modified') return # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ResponseWrapper instance is received if isinstance(response_object, ResponseWrapper): assignment_rules_list = response_object.get_assignment_rules() for assignment_rule in assignment_rules_list: # Get the ID of each Assignment Rule print(" ID " + str(assignment_rule.get_id())) # Get the name of each Assignment Rule print("Name: " + str(assignment_rule.get_name())) # Get the description of each Assignment Rule print("description: " + str(assignment_rule.get_description())) # Get the Modified Time of each Assignment Rule print("Modified Time: " + str(assignment_rule.get_modified_time())) # Get the Created Time of each Assignment Rule print("Created Time: " + str(assignment_rule.get_created_time())) created_by = assignment_rule.get_created_by() # Check if created_by is not None if created_by is not None: # Get the Name of the created_by User print("Created By - Name: " + created_by.get_name()) # Get the ID of the created_by User print("Created By - ID: " + str(created_by.get_id())) # Get the email of the created_by User print("Created By - email: " + str(created_by.get_email())) # Check if DefaultUser is not None default_assignee = assignment_rule.get_default_assignee() if default_assignee is not None: # Get the Name of the default_assignee User print("Created By - Name: " + default_assignee.get_name()) # Get the ID of the default_assignee User print("Created By - ID: " + str(default_assignee.get_id())) # Check if Module is not None module = assignment_rule.get_module() if module is not None: # Get the API Name of the module User print("Module - API Name: " + module.get_api_name()) # Get the ID of the default_assignee User print("Module - ID: " + str(module.get_id())) # Get the modified_by User instance of each currency modified_by = assignment_rule.get_modified_by() # Check if modified_by is not None if modified_by is not None: # Get the Name of the modifiedBy User print("Modified By - Name: " + modified_by.get_name()) # Get the ID of the modifiedBy User print("Modified By - ID: " + str(modified_by.get_id())) # Get the email of the created_by User print("Modified By - ID: " + str(modified_by.get_email())) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() if details is not None: if details is not None: for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def get_note(note_id): """ This method is used to get the note with id and print the response. :param note_id: The ID of the Note to be obtained """ """ example note_id = 3409643000000549003 """ # Get instance of NotesOperations Class notes_operations = NotesOperations() # Get instance of ParameterMap Class param_instance = ParameterMap() # Possible parameters of Get Note Operation param_instance.add(GetNoteParam.fields, "id,Note_Content") # Get instance of HeaderMap Class header_instance = HeaderMap() # Possible headers of Get Note Operation header_instance.add(GetNoteHeader.if_modified_since, datetime(2020, 6, 6, 10, 11, 12)) # Call get_note method that takes note_id, ParameterMap instance, HeaderMap instance as parameter response = notes_operations.get_note(note_id, param_instance, header_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) if response.get_status_code() in [204, 304]: print('No Content' if response.get_status_code() == 204 else 'Not Modified') return # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ResponseWrapper instance is received. if isinstance(response_object, ResponseWrapper): # Get the list of obtained Note instances notes_list = response_object.get_data() for note in notes_list: # Get the Id of each Note print("Note Id: " + str(note.get_id())) # Get the NoteTitle of each Note print("Note NoteTitle: " + str(note.get_note_title())) # Get the NoteContent of each Note print("Note NoteContent: " + str(note.get_note_content())) # Get the owner User instance of each Note owner = note.get_owner() # Check if owner is not None if owner is not None: # Get the Name of the Owner print("Note Owner - Name: " + str(owner.get_name())) # Get the ID of the Owner print("Note Owner - ID: " + str(owner.get_id())) # Get the Email of the Owner print("Note Owner - Email: " + str(owner.get_email())) # Get the ModifiedTime of each Note if note.get_modified_time() is not None: print("Note ModifiedTime: " + str(note.get_modified_time())) # Get the list of Attachment instances of each Note attachments = note.get_attachments() # Check if attachments is not None if attachments is not None: for attachment in attachments: Note.print_attachment(attachment) # Get the CreatedTime of each Note print("Note CreatedTime: " + str(note.get_created_time())) # Get the parentId Record instance of each Note parent_id = note.get_parent_id() # Check if parent_id is not None if parent_id is not None: # Get the parent record Name of each Note if parent_id.get_key_value('name') is not None: print('Note parent record Name: ' + str(parent_id.get_key_value('name'))) # Get the parent record ID of each Note print('Note parent record ID: ' + str(parent_id.get_id())) # Get the Editable of each Note print("Note Editable: " + str(note.get_editable())) # Get the SeModule of each Note print("Note SeModule: " + str(note.get_se_module())) # Get the IsSharedToClient of each Note print("Note IsSharedToClient: " + str(note.get_is_shared_to_client())) # Get the modifiedBy User instance of each Note modified_by = note.get_modified_by() # Check if owner is not None if modified_by is not None: # Get the Name of the modifiedBy User print("Note Modified By - Name: " + str(modified_by.get_name())) # Get the ID of the modifiedBy User print("Note Modified By - ID: " + str(modified_by.get_id())) # Get the Email of the modifiedBy User print("Note Modified By - Email: " + str(modified_by.get_email())) # Get the Size of each Note print("Note Size: " + str(note.get_size())) # Get the State of each Note print("Note State: " + str(note.get_state())) # Get the VoiceNote of each Note print("Note VoiceNote: " + str(note.get_voice_note())) # Get the createdBy User instance of each Note created_by = note.get_created_by() # Check if created_by is not None if created_by is not None: # Get the Name of the created_by User print("Note Created By - Name: " + created_by.get_name()) # Get the ID of the created_by User print("Note Created By - ID: " + created_by.get_id()) # Get the Email of the created_by User print("Note Created By - Email: " + created_by.get_email()) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def get_variables(): """ This method is used to retrieve all the available variables through an API request and print the response. """ # Get instance of VariablesOperations Class variables_operations = VariablesOperations() # Get instance of ParameterMap Class param_instance = ParameterMap() # Possible parameters of Get Variables operation param_instance.add(GetVariablesParam.group, 'General') # Call get_variables method that takes ParameterMap instance as parameter response = variables_operations.get_variables(param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) if response.get_status_code() in [204, 304]: print('No Content' if response.get_status_code() == 204 else 'Not Modified') return # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ResponseWrapper instance is received. if isinstance(response_object, ResponseWrapper): # Get the list of obtained Variable instances variable_list = response_object.get_variables() for variable in variable_list: # Get the ID of each Variable print("Variable ID: " + str(variable.get_id())) # Get the APIName of each Variable print("Variable APIName: " + variable.get_api_name()) # Get the Name of each Variable print("Variable Name: " + variable.get_name()) # Get the Description of each Variable print("Variable Description: " + variable.get_description()) # Get the Type of each Variable print("Variable Type: " + variable.get_type()) # Get the VariableGroup instance of each Variable variable_group = variable.get_variable_group() if variable_group is not None: # Get the APIName of the VariableGroup print("Variable VariableGroup APIName: " + variable_group.get_api_name()) # Get the ID of the VariableGroup print("Variable VariableGroup ID: " + str(variable_group.get_id())) # Get the Value of each Variable print("Variable Value: " + variable.get_value()) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def delete_notes(note_ids): """ This method is used to delete notes in bulk and print the response. :param note_ids: The list of Note IDs to be deleted """ """ example note_ids = [3409643000000648001, 3409643000000648005] """ # Get instance of NotesOperations Class notes_operations = NotesOperations() # Get instance of ParameterMap Class param_instance = ParameterMap() # Add the ids to ParameterMap instance for note_id in note_ids: param_instance.add(DeleteNotesParam.ids, note_id) # Call delete_notes method that takes param_instance as parameter response = notes_operations.delete_notes(param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ActionWrapper instance is received. if isinstance(response_object, ActionWrapper): # Get the list of obtained ActionResponse instances action_response_list = response_object.get_data() for action_response in action_response_list: # Check if the request is successful if isinstance(action_response, SuccessResponse): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(action_response, APIException): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def create_tags(module_api_name): """ This method is used to create new tags and print the response. :param module_api_name: The API Name of the module to create tags. """ """ example module_api_name = "Leads" """ # Get instance of TagsOperations Class tags_operations = TagsOperations() # Get instance of ParameterMap Class param_instance = ParameterMap() # Possible parameters of Create Tags operation param_instance.add(CreateTagsParam.module, module_api_name) # Get instance of BodyWrapper Class that will contain the request body request = BodyWrapper() # List to hold Tag instances tags_list = [] for i in range(1, 3): # Get instance of Tag Class tag = ZCRMTag() # Set Name to tag tag.set_name("python-tags" + str(i)) # Add the Tag instance to list tags_list.append(tag) # Set the list to tags in BodyWrapper instance request.set_tags(tags_list) # Call create_tags method that takes BodyWrapper instance and ParameterMap instance as parameter response = tags_operations.create_tags(request, param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ActionWrapper instance is received. if isinstance(response_object, ActionWrapper): # Get the list of obtained ActionResponse instances action_response_list = response_object.get_tags() for action_response in action_response_list: # Check if the request is successful if isinstance(action_response, SuccessResponse): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(action_response, APIException): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def get_notes(): """ This method is used to get the list of notes and print the response. """ # Get instance of NotesOperations Class notes_operations = NotesOperations() # Get instance of ParameterMap Class param_instance = ParameterMap() # Possible parameters for Get Notes param_instance.add(GetNotesParam.page, 1) param_instance.add(GetNotesParam.per_page, 200) param_instance.add(GetNotesParam.fields, "id") # Get instance of HeaderMap Class header_instance = HeaderMap() header_instance.add( GetNotesHeader.if_modified_since, datetime.fromisoformat('2019-06-01T00:00:00+05:30')) # Call get_notes method that takes paramInstance and headerInstance as parameters response = notes_operations.get_notes(param_instance, header_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) if response.get_status_code() in [204, 304]: print('No Content' if response.get_status_code() == 204 else 'Not Modified') return # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ResponseWrapper instance is received. if isinstance(response_object, ResponseWrapper): # Get the list of obtained Note instances notes_list = response_object.get_data() for note in notes_list: # Get the Id of each Note print("Note Id: " + str(note.get_id())) # Get the NoteTitle of each Note print("Note NoteTitle: " + str(note.get_note_title())) # Get the NoteContent of each Note print("Note NoteContent: " + str(note.get_note_content())) # Get the owner User instance of each Note owner = note.get_owner() # Check if owner is not None if owner is not None: # Get the Name of the Owner print("Note Owner - Name: " + str(owner.get_name())) # Get the ID of the Owner print("Note Owner - ID: " + str(owner.get_id())) # Get the Email of the Owner print("Note Owner - Email: " + str(owner.get_email())) # Get the ModifiedTime of each Note if note.get_modified_time() is not None: print("Note ModifiedTime: " + str(note.get_modified_time())) # Get the list of Attachment instances of each Note attachments = note.get_attachments() # Check if attachments is not None if attachments is not None: for attachment in attachments: Note.print_attachment(attachment) # Get the CreatedTime of each Note print("Note CreatedTime: " + str(note.get_created_time())) # Get the parentId Record instance of each Note parent_id = note.get_parent_id() # Check if parent_id is not None if parent_id is not None: # Get the parent record Name of each Note if parent_id.get_key_value('name') is not None: print('Note parent record Name: ' + str(parent_id.get_key_value('name'))) # Get the parent record ID of each Note print('Note parent record ID: ' + str(parent_id.get_id())) # Get the Editable of each Note print("Note Editable: " + str(note.get_editable())) # Get the SeModule of each Note print("Note SeModule: " + str(note.get_se_module())) # Get the IsSharedToClient of each Note print("Note IsSharedToClient: " + str(note.get_is_shared_to_client())) # Get the modifiedBy User instance of each Note modified_by = note.get_modified_by() # Check if modified_by is not None if modified_by is not None: # Get the Name of the modifiedBy User print("Note Modified By - Name: " + str(modified_by.get_name())) # Get the ID of the modifiedBy User print("Note Modified By - ID: " + str(modified_by.get_id())) # Get the Email of the modifiedBy User print("Note Modified By - Email: " + str(modified_by.get_email())) # Get the Size of each Note print("Note Size: " + str(note.get_size())) # Get the State of each Note print("Note State: " + str(note.get_state())) # Get the VoiceNote of each Note print("Note VoiceNote: " + str(note.get_voice_note())) # Get the createdBy User instance of each Note created_by = note.get_created_by() # Check if created_by is not None if created_by is not None: # Get the Name of the created_by User print("Note Created By - Name: " + created_by.get_name()) # Get the ID of the created_by User print("Note Created By - ID: " + str(created_by.get_id())) # Get the Email of the created_by User print("Note Created By - Email: " + created_by.get_email()) # Get the Info object from obtained response info = response_object.get_info() if info is not None: if info.get_per_page() is not None: # Get the PerPage of the Info print('Note Info PerPage: ' + str(info.get_per_page())) if info.get_count() is not None: # Get the Count of the Info print('Note Info Count: ' + str(info.get_count())) if info.get_page() is not None: # Get the Page of the Info print('Note Info Page: ' + str(info.get_page())) if info.get_more_records() is not None: # Get the MoreRecords of the Info print('Note Info MoreRecords: ' + str(info.get_more_records())) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def get_tags(module_api_name): """ This method is used to get all the tags in a module :param module_api_name: The API Name of the module to get tags. """ """ example module_api_name = "Leads" """ # Get instance of TagsOperations Class tags_operations = TagsOperations() # Get instance of ParameterMap Class param_instance = ParameterMap() # Possible parameters of Get Tags operation param_instance.add(GetTagsParam.module, module_api_name) # param_instance.add(GetTagsParam.my_tags, 'true') # Call get_tags method that takes ParameterMap instance as parameter response = tags_operations.get_tags(param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) if response.get_status_code() in [204, 304]: print('No Content' if response.get_status_code() == 204 else 'Not Modified') return # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ResponseWrapper instance is received. if isinstance(response_object, ResponseWrapper): # Get the list of obtained Tag instances tags_list = response_object.get_tags() for tag in tags_list: # Get the CreatedTime of each Tag print("Tag CreatedTime: " + str(tag.get_created_time())) if tag.get_modified_time() is not None: # Get the ModifiedTime of each Tag print("Tag ModifiedTime: " + str(tag.get_modified_time())) # Get the Name of each Tag print("Tag Name: " + tag.get_name()) # Get the modifiedBy User instance of each Tag modified_by = tag.get_modified_by() # Check if modifiedBy is not None if modified_by is not None: # Get the Name of the modifiedBy User print("Tag Modified By - Name: " + modified_by.get_name()) # Get the ID of the modifiedBy User print("Tag Modified By - ID: " + str(modified_by.get_id())) # Get the ID of each Tag print("Tag ID: " + str(tag.get_id())) # Get the createdBy User instance of each Tag created_by = tag.get_created_by() # Check if createdBy is not None if created_by is not None: # Get the Name of the createdBy User print("Tag Created By - Name: " + created_by.get_name()) # Get the ID of the createdBy User print("Tag Created By - ID: " + str(created_by.get_id())) # Get the obtained Info object info = response_object.get_info() # Check if info is not None if info is not None: if info.get_count() is not None: # Get the Count of the Info print("Tag Info Count: " + str(info.get_count())) if info.get_allowed_count() is not None: # Get the AllowedCount of the Info print("Tag Info AllowedCount: " + str(info.get_allowed_count())) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def get_users(): """ This method is used to retrieve the users data specified in the API request. """ # Get instance of UsersOperations Class users_operations = UsersOperations() # Get instance of ParameterMap Class param_instance = ParameterMap() # Possible parameters for Get Users operation param_instance.add(GetUsersParam.page, 1) param_instance.add(GetUsersParam.per_page, 200) param_instance.add(GetUsersParam.type, 'ActiveConfirmedUsers') # Get instance of ParameterMap Class header_instance = HeaderMap() # Possible headers for Get Users operation header_instance.add(GetUsersHeader.if_modified_since, datetime.fromisoformat('2019-07-07T10:00:00+05:30')) # Call get_users method that takes ParameterMap instance and HeaderMap instance as parameters response = users_operations.get_users(param_instance, header_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) if response.get_status_code() in [204, 304]: print('No Content' if response.get_status_code() == 204 else 'Not Modified') return # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ResponseWrapper instance is received. if isinstance(response_object, ResponseWrapper): # Get the list of obtained User instances user_list = response_object.get_users() for user in user_list: # Get the Country of each User print("User Country: " + str(user.get_country())) # Get the CustomizeInfo instance of each User customize_info = user.get_customize_info() # Check if customizeInfo is not None if customize_info is not None: if customize_info.get_notes_desc() is not None: # Get the NotesDesc of each User print("User CustomizeInfo NotesDesc: " + str(customize_info.get_notes_desc())) if customize_info.get_show_right_panel() is not None: # Get the ShowRightPanel of each User print("User CustomizeInfo ShowRightPanel: " + str(customize_info.get_show_right_panel())) if customize_info.get_bc_view() is not None: # Get the BcView of each User print("User CustomizeInfo BcView: " + str(customize_info.get_bc_view())) if customize_info.get_show_home() is not None: # Get the ShowHome of each User print("User CustomizeInfo ShowHome: " + str(customize_info.get_show_home())) if customize_info.get_show_detail_view() is not None: # Get the ShowDetailView of each User print("User CustomizeInfo ShowDetailView: " + str(customize_info.get_show_detail_view())) if customize_info.get_unpin_recent_item() is not None: # Get the UnpinRecentItem of each User print("User CustomizeInfo UnpinRecentItem: " + str(customize_info.get_unpin_recent_item())) # Get the Role instance of each User role = user.get_role() if role is not None: # Get the Name of Role print("User Role Name: " + str(role.get_name())) # Get the ID of Role print("User Role ID: " + str(role.get_id())) # Get the Signature of each User print("User Signature: " + str(user.get_signature())) # Get the City of each User print("User City: " + str(user.get_city())) # Get the NameFormat of each User print("User NameFormat: " + str(user.get_name_format())) # Get the Language of each User print("User Language: " + str(user.get_language())) # Get the Locale of each User print("User Locale: " + str(user.get_locale())) # Get the Microsoft of each User print("User Microsoft: " + str(user.get_microsoft())) if user.get_personal_account() is not None: # Get the PersonalAccount of each User print("User PersonalAccount: " + str(user.get_personal_account())) # Get the DefaultTabGroup of each User print("User DefaultTabGroup: " + str(user.get_default_tab_group())) # Get the Isonline of each User print("User Isonline: " + str(user.get_isonline())) # Get the modifiedBy User instance of each User modified_by = user.get_modified_by() # Check if modified_by is not null if modified_by is not None: # Get the Name of the modifiedBy User print("User Modified By User-Name: " + str(modified_by.get_name())) # Get the ID of the modifiedBy User print("User Modified By User-ID: " + str(modified_by.get_id())) # Get the Street of each User print("User Street: " + str(user.get_street())) # Get the Currency of each User print("User Currency: " + str(user.get_currency())) # Get the Alias of each User print("User Alias: " + str(user.get_alias())) # Get the Theme instance of each User theme = user.get_theme() # Check if theme is not None if theme is not None: # Get the TabTheme instance of Theme normal_tab = theme.get_normal_tab() # Check if normal_tab is not null if normal_tab is not None: # Get the FontColor of NormalTab print("User Theme NormalTab FontColor: " + str(normal_tab.get_font_color())) # Get the Background of NormalTab print("User Theme NormalTab Background: " + str(normal_tab.get_background())) # Get the TabTheme instance of Theme selected_tab = theme.get_selected_tab() # Check if selected_tab is not null if selected_tab is not None: # Get the FontColor of selected_tab print("User Theme Selected Tab FontColor: " + str(selected_tab.get_font_color())) # Get the Background of selected_tab print("User Theme Selected Tab Background: " + str(selected_tab.get_background())) # Get the NewBackground of each Theme print("User Theme NewBackground: " + str(theme.get_new_background())) # Get the Background of each Theme print("User Theme Background: " + str(theme.get_background())) # Get the Screen of each Theme print("User Theme Screen: " + str(theme.get_screen())) # Get the Type of each Theme print("User Theme Type: " + str(theme.get_type())) # Get the ID of each User print("User ID: " + str(user.get_id())) # Get the State of each User print("User State: " + str(user.get_state())) # Get the Fax of each User print("User Fax: " + str(user.get_fax())) # Get the CountryLocale of each User print("User CountryLocale: " + str(user.get_country_locale())) # Get the FirstName of each User print("User FirstName: " + str(user.get_first_name())) # Get the Email of each User print("User Email: " + str(user.get_email())) # Get the reportingTo User instance of each User reporting_to = user.get_reporting_to() # Check if reporting_to is not None if reporting_to is not None: # Get the Name of the reporting_to User print("User ReportingTo User-Name: " + str(reporting_to.get_name())) # Get the ID of the reporting_to User print("User ReportingTo User-ID: " + str(reporting_to.get_id())) # Get the DecimalSeparator of each User print("User DecimalSeparator: " + str(user.get_decimal_separator())) # Get the Zip of each User print("User Zip: " + str(user.get_zip())) # Get the CreatedTime of each User print("User CreatedTime: " + str(user.get_created_time())) # Get the Website of each User print("User Website: " + str(user.get_website())) if user.get_modified_time() is not None: # Get the ModifiedTime of each User print("User ModifiedTime: " + str(user.get_modified_time())) # Get the TimeFormat of each User print("User TimeFormat: " + str(user.get_time_format())) # Get the Offset of each User print("User Offset: " + str(user.get_offset())) # Get the Profile instance of each User profile = user.get_profile() # Check if profile is not None if profile is not None: # Get the Name of the profile print("User Profile Name: " + str(profile.get_name())) # Get the ID of the profile print("User Profile ID: " + str(profile.get_id())) # Get the Mobile of each User print("User Mobile: " + str(user.get_mobile())) # Get the LastName of each User print("User LastName: " + str(user.get_last_name())) # Get the TimeZone of each User print("User TimeZone: " + str(user.get_time_zone())) # Get the Custom Fields, if any print("Custom Field: " + str(user.get_key_value('Custom_Field'))) # Get the created_by User instance of each User created_by = user.get_created_by() # Check if created_by is not None if created_by is not None: # Get the Name of the created_by User print("User Created By User-Name: " + str(created_by.get_name())) # Get the ID of the created_by User print("User Created By User-ID: " + str(created_by.get_id())) # Get the Zuid of each User print("User Zuid: " + str(user.get_zuid())) # Get the Confirm of each User print("User Confirm: " + str(user.get_confirm())) # Get the FullName of each User print("User FullName: " + str(user.get_full_name())) # Get the list of obtained Territory instances territories = user.get_territories() # Check if territories is not None if territories is not None: for territory in territories: # Get the Manager of the Territory print("User Territory Manager: " + str(territory.get_manager())) # Get the Name of the Territory print("User Territory Name: " + str(territory.get_name())) # Get the ID of the Territory print("User Territory ID: " + str(territory.get_id())) # Get the Phone of each User print("User Phone: " + str(user.get_phone())) # Get the DOB of each User print("User DOB: " + str(user.get_dob())) # Get the DateFormat of each User print("User DateFormat: " + str(user.get_date_format())) # Get the Status of each User print("User Status: " + str(user.get_status())) # Get the obtained Info object info = response_object.get_info() if info is not None: if info.get_per_page() is not None: # Get the PerPage of the Info print("User Info PerPage: " + str(info.get_per_page())) if info.get_count() is not None: # Get the Count of the Info print("User Info Count: " + str(info.get_count())) if info.get_page() is not None: # Get the Page of the Info print("User Info Page: " + str(info.get_page())) if info.get_more_records() is not None: # Get the MoreRecords of the Info print("User Info MoreRecords: " + str(info.get_more_records())) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def remove_tags_from_record(module_api_name, record_id, tag_names): """ This method is used to delete the tags associated with a specific record and print the response. :param module_api_name: The API Name of the module to remove tags :param record_id: The ID of the record to delete tags :param tag_names: The list of the tag names to be removed. :return: """ """ example module_api_name = "Leads" record_id = 3409643000002157023 tag_names = ["addtag1,addtag12"] """ # Get instance of TagsOperations Class tags_operations = TagsOperations() # Get instance of ParameterMap Class param_instance = ParameterMap() # Possible parameters for Remove Tags from Record operation for tag_name in tag_names: param_instance.add(RemoveTagsFromRecordParam.tag_names, tag_name) # Call remove_tags_from_record method that takes ParameterMap instance, module_api_name and record_id as parameter response = tags_operations.remove_tags_from_record( record_id, module_api_name, param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected RecordActionWrapper instance is received. if isinstance(response_object, RecordActionWrapper): # Get the list of obtained ActionResponse instances action_response_list = response_object.get_data() for action_response in action_response_list: # Check if the request is successful if isinstance(action_response, SuccessResponse): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(action_response, APIException): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())
def delete_attachments(module_api_name, record_id, attachment_ids): """ This method is used to Delete attachments of a single record with ID and print the response. :param module_api_name: The API Name of the record's module :param record_id: The ID of the record to delete attachments :param attachment_ids: The list of attachment IDs to be deleted """ """ example module_api_name= "Leads" record_id = 3409643000002267003 attachment_ids = [3409643000002267012, 3409643000002267018, 3409643000002267010] """ # Get instance of AttachmentsOperations Class that takes module_api_name and record_id as parameter attachments_operations = AttachmentsOperations(module_api_name, record_id) # Get instance of ParameterMap Class param_instance = ParameterMap() # Add the ids to parameter map instance for attachment_id in attachment_ids: param_instance.add(DeleteAttachmentsParam.ids, attachment_id) # Call delete_attachments method that takes paramInstance as parameter response = attachments_operations.delete_attachments(param_instance) if response is not None: # Get the status code from response print('Status Code: ' + str(response.get_status_code())) # Get object from response response_object = response.get_object() if response_object is not None: # Check if expected ActionWrapper instance is received. if isinstance(response_object, ActionWrapper): action_response_list = response_object.get_data() for action_response in action_response_list: # Check if the request is successful if isinstance(action_response, SuccessResponse): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(action_response, APIException): # Get the Status print("Status: " + action_response.get_status().get_value()) # Get the Code print("Code: " + action_response.get_code().get_value()) print("Details") # Get the details dict details = action_response.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + action_response.get_message().get_value()) # Check if the request returned an exception elif isinstance(response_object, APIException): # Get the Status print("Status: " + response_object.get_status().get_value()) # Get the Code print("Code: " + response_object.get_code().get_value()) print("Details") # Get the details dict details = response_object.get_details() for key, value in details.items(): print(key + ' : ' + str(value)) # Get the Message print("Message: " + response_object.get_message().get_value())