Exemplo n.º 1
0
    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())
Exemplo n.º 2
0
    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())
Exemplo n.º 3
0
    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())
Exemplo n.º 4
0
    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())
Exemplo n.º 5
0
    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())
Exemplo n.º 6
0
    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())
Exemplo n.º 7
0
    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())
Exemplo n.º 8
0
    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())
Exemplo n.º 9
0
    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())
Exemplo n.º 10
0
    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())
Exemplo n.º 11
0
    def get_fields(module_api_name):

        """
        This method is used to get metadata about all the fields of a module and print the response.
        :param module_api_name: The API Name of the module to get fields
        """

        """
        example
        module_api_name = "Leads";
        """

        # Get instance of FieldsOperations Class that takes module_api_name as parameter
        fields_operations = FieldsOperations(module_api_name)

        # Get instance of ParameterMap Class
        param_instance = ParameterMap()

        # Possible parameters for get_fields operation
        # param_instance.add(GetFieldsParam.type, "Unused")

        # Call get_fields method that takes paramInstance as parameter
        response = fields_operations.get_fields(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 Field instances
                    fields_list = response_object.get_fields()

                    for field in fields_list:

                        # Get the ID of each Field
                        print('Field ID: ' + str(field.get_id()))

                        # Get the SystemMandatory of each Field
                        print("Field SystemMandatory: " + str(field.get_system_mandatory()))

                        # Get the Webhook of each Field
                        print("Field Webhook: " + str(field.get_webhook()))

                        # Get the JsonType of each Field
                        print("Field JsonType: " + str(field.get_json_type()))

                        # Get the private info of each field
                        private = field.get_private()

                        if private is not None:
                            # Get the type
                            print("Field Private Type: " + str(private.get_type()))

                            # Get the Export
                            print("Field Private Export: " + str(private.get_export()))

                            # Get the Restricted
                            print("Field Private Restricted: " + str(private.get_restricted()))

                        # Get the obtained Crypt instance
                        crypt = field.get_crypt()

                        if crypt is not None:
                            print("Crypt Details")

                            # Get the Crypt Mode
                            print("Mode: " + crypt.get_mode())

                            # Get the Crypt Column
                            print("Column: " + crypt.get_column())

                            # Get the Crypt Table
                            print("Table: " + crypt.get_table())

                            # Get the Crypt Status
                            print("Status: " + str(crypt.get_status()))

                        # Get the FieldLabel of each Field
                        print("Field FieldLabel: " + field.get_field_label())

                        tool_tip = field.get_tooltip()

                        if tool_tip is not None:
                            # Get the Name of the ToolTip
                            print("Field ToolTip Name: " + tool_tip.get_name())

                            # Get the Value of the ToolTip
                            print("Field ToolTip Value: " + tool_tip.get_value())

                        # Get the CreatedSource of each Field
                        print("Field CreatedSource: " + field.get_created_source())

                        # Get the FieldReadOnly of each Field
                        print("Field FieldReadOnly: " + str(field.get_field_read_only()))

                        # Get the DisplayLabel of each Field
                        print("Field DisplayLabel: " + field.get_display_label())

                        # Get the ReadOnly of each Field
                        print("Field ReadOnly: " + str(field.get_read_only()))

                        # Get the obtained AssociationDetails instance
                        association_details = field.get_association_details()

                        if association_details is not None:

                            # Get the obtained LookupField instance
                            lookup_field = association_details.get_lookup_field()

                            if lookup_field is not None:
                                # Get the ID of the LookupField
                                print("Field AssociationDetails LookupField ID: " + str(lookup_field.get_id()))

                                # Get the Name of the LookupField
                                print('Field AssociationDetails LookupField Name: ' + lookup_field.get_name())

                            # Get the obtained LookupField instance
                            related_field = association_details.get_related_field()

                            if related_field is not None:
                                # Get the ID of the RelatedField
                                print("Field AssociationDetails RelatedField ID: " + str(related_field.get_id()))

                                # Get the Name of the RelatedField
                                print('Field AssociationDetails RelatedField Name: ' + related_field.get_name())

                        if field.get_quick_sequence_number() is not None:
                            # Get the QuickSequenceNumber of each Field
                            print('Field QuickSequenceNumber: ' + str(field.get_quick_sequence_number()))

                        if field.get_businesscard_supported() is not None:
                            # Get the BusinesscardSupported of each Field
                            print('Field BusinesscardSupported: ' + str(field.get_businesscard_supported()))

                        # Check if MultiModuleLookup is not None
                        if field.get_multi_module_lookup() is not None:
                            # Get the MultiModuleLookup dict
                            for key, value in field.get_multi_module_lookup().items():
                                print(key + " : " + value)

                        # Get the obtained Currency instance
                        currency = field.get_currency()

                        if currency is not None:
                            # Get the RoundingOption of the Currency
                            print("Field Currency RoundingOption: " + str(currency.get_rounding_option()))

                            if currency.get_precision() is not None:
                                # Get the Precision of the Currency
                                print("Field Currency Precision: " + str(currency.get_precision()))

                        if field.get_custom_field() is not None:
                            # Get if the Field is a CustomField
                            print("Field CustomField: " + str(field.get_custom_field()))

                        lookup = field.get_lookup()

                        if lookup is not None:
                            # Get the obtained Layout instance
                            layout = lookup.get_layout()

                            # Check if layout is not null
                            if layout is not None:
                                # Get the ID of the Layout
                                print("Field ModuleLookup Layout ID: " + str(layout.get_id()))

                                # Get the Name of the Layout
                                print("Field ModuleLookup Layout Name: " + layout.get_name())

                            # Get the DisplayLabel of the Module
                            print("Field ModuleLookup DisplayLabel: " + str(lookup.get_display_label()))

                            # Get the APIName of the Module
                            print("Field ModuleLookup APIName: " + str(lookup.get_api_name()))

                            # Get the Module of the ModuleLookup
                            print("Field ModuleLookup Module: " + str(lookup.get_module()))

                            if lookup.get_id() is not None:
                                # Get the ID of the Module
                                print("Field ModuleLookup ID: " + str(lookup.get_id()))

                        if field.get_visible() is not None:
                            # Get the Visible of each Field
                            print("Field Visible: " + str(field.get_visible()))

                        if field.get_length() is not None:
                            # Get the Length of each Field
                            print("Field Length: " + str(field.get_length()))

                        view_type = field.get_view_type()

                        if view_type is not None:
                            # Get the View of the ViewType
                            print("Field ViewType View: " + str(view_type.get_view()))

                            # Get the Edit of the ViewType
                            print("Field ViewType Edit: " + str(view_type.get_edit()))

                            # Get the Create of the ViewType
                            print("Field ViewType Create: " + str(view_type.get_create()))

                            # Get the QuickCreate of the ViewType
                            print("Field ViewType QuickCreate: " + str(view_type.get_quick_create()))

                        subform = field.get_subform()

                        if subform is not None:
                            # Get the obtained Layout instance
                            layout = subform.get_layout()

                            # Check if layout is not null
                            if layout is not None:
                                # Get the ID of the Layout
                                print("Field Subform Layout ID: " + str(layout.get_id()))

                                # Get the Name of the Layout
                                print("Field Subform Layout Name: " + layout.get_name())

                            # Get the DisplayLabel of the Module
                            print("Field Subform DisplayLabel: " + str(subform.get_display_label()))

                            # Get the APIName of the Module
                            print("Field Subform APIName: " + str(subform.get_api_name()))

                            # Get the Module of the ModuleLookup
                            print("Field Subform Module: " + str(subform.get_module()))

                            if subform.get_id() is not None:
                                # Get the ID of the Module
                                print("Field Subform ID: " + str(subform.get_id()))

                        # Get the APIName of each Field
                        print("Field APIName : " + field.get_api_name())

                        # Get the obtained Unique instance
                        unique = field.get_unique()

                        if unique is not None:
                            # Get the Casesensitive of the Unique
                            print("Field Unique Casesensitive : " + str(unique.get_casesensitive()))

                        if field.get_history_tracking() is not None:
                            # Get the HistoryTracking of each Field
                            print("Field HistoryTracking: " + str(field.get_history_tracking()))

                        # Get the DataType of each Field
                        print("Field DataType: " + field.get_data_type())

                        # Get the obtained Formula instance
                        formula = field.get_formula()

                        # Check if formula is not null
                        if formula is not None:
                            # Get the ReturnType of the Formula
                            print('Field Formula ReturnType : ' + str(formula.get_return_type()))

                            if formula.get_expression() is not None:
                                # Get the Expression of the Formula
                                print("Field Formula Expression : " + str(formula.get_expression()))

                        if field.get_decimal_place() is not None:
                            # Get the DecimalPlace of each Field
                            print("Field DecimalPlace: " + str(field.get_decimal_place()))

                        # Get the MassUpdate of each Field
                        print("Field MassUpdate: " + str(field.get_mass_update()))

                        if field.get_blueprint_supported() is not None:
                            # Get the BlueprintSupported of each Field
                            print("Field BlueprintSupported: " + str(field.get_blueprint_supported()))

                        multi_select_lookup = field.get_multiselectlookup()

                        # Check if multiSelectLookup is not None
                        if multi_select_lookup is not None:
                            # Get the DisplayLabel of the MultiSelectLookup
                            print("Field MultiSelectLookup DisplayLabel: " + str(multi_select_lookup.get_display_label()))

                            # Get the LinkingModule of the MultiSelectLookup
                            print("Field MultiSelectLookup LinkingModule: " + str(multi_select_lookup.get_linking_module()))

                            # Get the LookupApiname of the MultiSelectLookup
                            print("Field MultiSelectLookup LookupApiname: " + str(multi_select_lookup.get_lookup_apiname()))

                            # Get the APIName of the MultiSelectLookup
                            print("Field MultiSelectLookup APIName: " + str(multi_select_lookup.get_api_name()))

                            # Get the ConnectedlookupApiname of the MultiSelectLookup
                            print("Field MultiSelectLookup ConnectedlookupApiname: " + str(multi_select_lookup.get_connectedlookup_apiname()))

                            # Get the ID of the MultiSelectLookup
                            print("Field MultiSelectLookup ID: " + str(multi_select_lookup.get_id()))

                        pick_list_values = field.get_pick_list_values()

                        if pick_list_values is not None:
                            for pick_list_value in pick_list_values:

                                # Get the DisplayValue of each PickListValue
                                print("Field PickListValue DisplayValue: " + pick_list_value.get_display_value())

                                if pick_list_value.get_sequence_number() is not None:
                                    # Get the SequenceNumber of each PickListValue
                                    print("Field PickListValue SequenceNumber: " + str(pick_list_value.get_sequence_number()))

                                # Get the ExpectedDataType of each PickListValue
                                print("Field PickListValue ExpectedDataType: " + str(pick_list_value.get_expected_data_type()))

                                # Get the ActualValue of each PickListValue
                                print("Field PickListValue ActualValue: " + pick_list_value.get_actual_value())

                                if pick_list_value.get_maps() is not None:
                                    # Get each value from the map
                                    for map in pick_list_value.get_maps():
                                        print(map)

                                # Get the SysRefName of each PickListValues
                                print("Field PickListValue SysRefName: " + str(pick_list_value.get_sys_ref_name()))

                                # Get the Type of each PickListValues
                                print("Field PickListValue Type: " + str(pick_list_value.get_type()))

                        auto_number = field.get_auto_number()

                        # Check if autoNumber is not None
                        if auto_number is not None:
                            # Get the Prefix of the AutoNumber
                            print('Prefix: ' + str(auto_number.get_prefix()))

                            # Get the Suffix of the AutoNumber
                            print('Suffix: ' + str(auto_number.get_suffix()))

                            if auto_number.get_start_number() is not None:
                                # Get the StartNumber of the AutoNumber
                                print('Start Number: ' + str(auto_number.get_start_number()))

                        if field.get_default_value() is not None:
                            # Get the DefaultValue of each Field
                            print("Field DefaultValue: " + str(field.get_default_value()))

                        if field.get_section_id() is not None:
                            # Get the SectionId of each Field
                            print("Field SectionId: " + str(field.get_section_id()))

                        # Check if ValidationRule is not None
                        if field.get_validation_rule() is not None:
                            # Get the validationRule dict
                            for key, value in field.get_validation_rule().items():
                                print(key + " : " + value)

                        # Check if ConvertMapping is not None
                        if field.get_convert_mapping() is not None:
                            # Get the ConvertMapping dict
                            for key, value in field.get_convert_mapping().items():
                                print(key + " : " + str(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())
Exemplo n.º 12
0
    def get_all_contact_roles_of_deal(deal_id):
        # Get instance of ContactRolesOperations Class
        contact_roles_operations = ContactRolesOperations()

        # Get instance of ParameterMap Class
        param_instance = ParameterMap()

        # Call get_all_contact_roles_of_deal method that takes Param instance as parameter
        response = contact_roles_operations.get_all_contact_roles_of_deal(deal_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 RecordResponseWrapper instance is received.
                if isinstance(response_object, RecordResponseWrapper):
                    # Get the list of obtained Record instances
                    record_list = response_object.get_data()

                    for record in record_list:
                        # Get the ID of each Record
                        print("Record ID: ")

                        print(record.get_id())

                        # Get the createdBy User instance of each Record
                        created_by = record.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("Record Created By - Name: " + created_by.get_name())

                            # Get the ID of the created_by User
                            print("Record Created By - ID: ")

                            print(created_by.get_id())

                            # Get the Email of the created_by User
                            print("Record Created By - Email: " + created_by.get_email())

                        # Get the CreatedTime of each Record
                        print("Record CreatedTime: " + str(record.get_created_time()))

                        if record.get_modified_time() is not None:
                            # Get the ModifiedTime of each Record
                            print("Record ModifiedTime: " + str(record.get_modified_time()))

                        # Get the modified_by User instance of each Record
                        modified_by = record.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: ")

                            print(modified_by.get_id())

                            # Get the Email of the modified_by User
                            print("Record Modified By - Email: " + modified_by.get_email())

                        print('Record KeyValues: ')

                        key_values = record.get_key_values()

                        for key_name, value in key_values.items():

                            if isinstance(value, list):
                                print("Record KeyName : " + key_name)

                                for data in value:
                                    if isinstance(data, dict):
                                        for dict_key, dict_value in data.items():
                                            print(dict_key + " : " + str(dict_value))

                                    else:
                                        print(str(data))

                            elif isinstance(value, dict):
                                print("Record KeyName : " + key_name + " -  Value : ")

                                for dict_key, dict_value in value.items():
                                    print(dict_key + " : " + str(dict_value))

                            else:
                                print("Record KeyName : " + key_name + " -  Value : " + str(value))

                        info = response_object.get_info()

                        if info is not None:
                            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()

                    for key, value in details.items():
                        print(key + ' : ' + str(value))

                    # Get the Message
                    print("Message: " + response_object.get_message().get_value())
Exemplo n.º 13
0
    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())
Exemplo n.º 14
0
    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 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())
Exemplo n.º 16
0
    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())
Exemplo n.º 17
0
    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())
Exemplo n.º 18
0
    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())
Exemplo n.º 19
0
    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())
Exemplo n.º 20
0
    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())
Exemplo n.º 21
0
    def get_variable_by_id(variable_id):

        """
        This method is used to get the details of any specific variable with ID and print the response
        :param variable_id: The ID of the Variable to be obtained
        """

        """
        example
        variable_id = 34096432275025
        """

        # Get instance of VariablesOperations Class
        variables_operations = VariablesOperations()

        # Get instance of ParameterMap Class
        param_instance = ParameterMap()

        # Possible parameters of Get Variable By ID operation
        # param_instance.add(GetVariableByIDParam.group, '34096432275023')

        # Call get_variable_by_id method that takes ParameterMap instance and variable_id as parameters
        response = variables_operations.get_variable_by_id(variable_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):

                    # 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())
Exemplo n.º 22
0
    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())
Exemplo n.º 23
0
    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())
Exemplo n.º 24
0
    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())
Exemplo n.º 25
0
    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())
Exemplo n.º 26
0
    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())
Exemplo n.º 27
0
    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())
Exemplo n.º 28
0
    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())