Python SDK Samples - Rest Client Operations

Get Organization Details

# Get Organization details:
# -------------------------           
def get_org_details(self):
    try:
        resp = zcrmsdk.ZCRMRestClient.get_instance().get_organization_details() # to get the APIResponse in form of organization details
        print(resp.status_code)
        org_ins=resp.data # to get the organization in form of ZCRMOrganization instance
        print(org_ins.company_name) # to get the company name of the organization
        print(org_ins.org_id) # to get the organization id of the organization
        print(org_ins.alias) # to get the alias  of the organization
        print(org_ins.primary_zuid) # to get the primary zoho user id of the organization
        print(org_ins.zgid) # to get the zoho group id of the organization
        print(org_ins.primary_email) # to get the primary email of the organization
        print(org_ins.website) # to get the website  of the organization
        print(org_ins.mobile) # to get the mobile number of the organization
        print(org_ins.phone) # to get the phone number of the organization
        print(org_ins.employee_count) # to get the employee count of the organization
        print(org_ins.description) # to get the description of the organization
        print(org_ins.time_zone) # to get the time zone of the organization
        print(org_ins.iso_code) # to get the iso code of the organization
        print(org_ins.currency_locale) # to get the country locale of the organization
        print(org_ins.currency_symbol) # to get the currency symbol of the organization
        print(org_ins.street) # to get the street name of the organization
        print(org_ins.state) # to get the state  of the organization
        print(org_ins.city) # to get the city name  of the organization
        print(org_ins.country) # to get the the country of the organization
        print(org_ins.zip_code) # to get the zip code of the organization
        print(org_ins.country_code) # to get the country code of the organization
        print(org_ins.fax) # to get the fax number of the organization
        print(org_ins.mc_status) # to get the multicurrency status of the organization
        print(org_ins.is_gapps_enabled) # to check whether the google apps is enabled
        print(org_ins.paid_expiry) # to get the paid expiration
        print(org_ins.trial_type) # to get the trial type
        print(org_ins.trial_expiry) # to get the trial expiration
        print(org_ins.is_paid_account) # to check whether the account is paid account
        print(org_ins.paid_type) # to get the paid type
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code) # to get the status code
        print(ex.error_message) # to get the error message
        print(ex.error_code) # to get the error code
        print(ex.error_details) # to get the error details
        print(ex.error_content) # to get the error content
 
Get Current User Data

# Get Current User:
# ------------------
def get_current_user(self):
    try:
        resp = zcrmsdk.ZCRMOrganization.get_instance().get_current_user() # to get the BulkAPIResponse in form of current users details
        print(resp.status_code)
        if resp.status_code!=200:
            return
        users=resp.data # to get the users in form of ZCRMUser instances array
        for user in users:
            print("\n\n")
            print(user.id) # to get the user id
            print(user.name) # to get the user name
            print(user.signature) # to get the signature of the user
            print(user.country) # to get the country of the user
            crm_role= user.role # to get the role of the user in form of ZCRMRole instance
            if crm_role is not None:
                print(crm_role.name) # to get the role name
                print(crm_role.id) # to get the role id
            customize_info= user.customize_info # to get the customization information of the user in for of the ZCRMUserCustomizeInfo form
            if customize_info is not None:
                print(customize_info.notes_desc) # to get the note description
                print(customize_info.is_to_show_right_panel) # to check whether the right panel is shown
                print(customize_info.is_bc_view) # to check whether the business card view is enabled
                print(customize_info.is_to_show_home) # to check whether the home is shown
                print(customize_info.is_to_show_detail_view) # to check whether the detail view is shows
                print(customize_info.unpin_recent_item) # to get the unpinned recent items
            print(user.city) # to get the city of the user
            print(user.name_format) # to get the name format of the user
            print(user.language) # to get the language of the user
            print(user.locale) # to get the locale of the user
            print(user.is_personal_account) # to check whther this is a personal account
            print(user.default_tab_group) # to get the default tab group
            print(user.street) # to get the street name of the user
            print(user.alias) # to get the alias of the user
            user_theme=user.theme # to get the theme of the user in form of the ZCRMUserTheme
            if user_theme is not None:
                print(user_theme.normal_tab_font_color) # to get the normal tab font color
                print(user_theme.normal_tab_background) # to get the normal tab background
                print(user_theme.selected_tab_font_color) # to get the selected tab font color
                print(user_theme.selected_tab_background) # to get the selected tab background
            print(user.state) # to get the state of the user
            print(user.country_locale) # to get the country locale of the user
            print(user.fax) # to get the fax number of the user
            print(user.first_name) # to get the first name of the user
            print(user.email) # to get the email id of the user
            print(user.zip) # to get the zip code of the user
            print(user.decimal_separator) # to get the decimal separator
            print(user.website) # to get the website of the user
            print(user.time_format) # to get the time format of the user
            crm_profile= user.profile # to get the user's profile in form of ZCRMProfile
            if crm_profile is not None:
                print(crm_profile.id) # to get the profile id
                print(crm_profile.name) # to get the name of the profile
            print(user.mobile) # to get the mobile number of the user
            print(user.last_name) # to get the last name of the user
            print(user.time_zone) # to get the time zone of the user
            print(user.zuid) # to get the zoho user id of the user
            print(user.is_confirm) # to check whether it is a confirmed user
            print(user.full_name) # to get the full name of the user
            print(user.phone) # to get the phone number of the user
            print(user.dob) # to get the date of birth of the user
            print(user.date_format) # to get the date format
            print(user.status) # to get the status of the user
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code) # to get the status code
        print(ex.error_message) # to get the error message
        print(ex.error_code) # to get the error code
        print(ex.error_details) # to get the error details
        print(ex.error_content) # to get the error content
 
Get List of Modules

# Get all modules:
# ----------------
def get_all_modules(self):
    try:
        resp = zcrmsdk.ZCRMRestClient.get_instance().get_all_modules()
        modules = resp.data # to get the the modules in form of ZCRMModule instances array
        print(resp.status_code)
        for module in modules:
            print("\n\n::MODULE::")
            print(module.api_name)
            print(module.is_convertable)
            print(module.is_creatable)
            print(module.is_editable)
            print(module.is_deletable)
            print(module.web_link)
            print(module.singular_label)
            print(module.plural_label)
            modified_by = module.modified_by
            if modified_by is not None:
                print(modified_by.id)
                print(modified_by.name)
            print(module.modified_time)
            print(module.is_viewable)
            print(module.is_api_supported)
            print(module.is_custom_module)
            print(module.is_scoring_supported)
            print(module.id)
            print(module.module_name)
            print(module.business_card_field_limit)
            print(module.business_card_fields)
            profiles = module.profiles
            if profiles is not None:
                for profile in profiles:
                    print(profile.name)
                    print(profile.id)
            print(module.display_field_name)
            print(module.display_field_id)
            if module.related_lists is not None:
                for relatedlist in module.related_lists:
                    print(relatedlist.display_label)
                    print(relatedlist.is_visible)
                    print(relatedlist.api_name)
                    print(relatedlist.module)
                    print(relatedlist.name)
                    print(relatedlist.id)
                    print(relatedlist.href)
                    print(relatedlist.type)
            if module.layouts is not None:
                for layout in module.layouts:
                    self.print_layout(layout)
            if module.fields is not None:
                for field_ins in module.fields:
                    self.print_field(field_ins)
            if module.related_list_properties is not None:
                print(module.related_list_properties.sort_by)
                print(module.related_list_properties.sort_order)
                print(module.related_list_properties.fields)
            print(module.properties)
            print(module.per_page)
            print(module.search_layout_fields)
            print(module.default_territory_name)
            print(module.default_territory_id)
            print(module.default_custom_view_id)
            default_custom_view = module.default_custom_view
            if default_custom_view is not None:
                print(default_custom_view.id)
                print(default_custom_view.name)
            print(module.is_global_search_supported)
            print(module.sequence_number)
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code) # to get the status code
        print(ex.error_message) # to get the error message
        print(ex.error_code) # to get the error code
        print(ex.error_details) # to get the error details
        print(ex.error_content) # to get the error content
 
Module Meta Data

# Get module meta data
# --------------------
def get_module(self):
    try:
        resp = zcrmsdk.ZCRMRestClient.get_instance().get_module("Leads")# Module API Name
        module = resp.data
        print("\n\n::MODULE::")
        print(resp.status_code)
        print(module.api_name)
        print(module.is_convertable)
        print(module.is_creatable)
        print(module.is_editable)
        print(module.is_deletable)
        print(module.web_link)
        print(module.singular_label)
        print(module.plural_label)
        modified_by = module.modified_by
        if modified_by is not None:
            print(modified_by.id)
            print(modified_by.name)
        print(module.modified_time)
        print(module.is_viewable)
        print(module.is_api_supported)
        print(module.is_custom_module)
        print(module.is_scoring_supported)
        print(module.id)
        print(module.module_name)
        print(module.business_card_field_limit)
        print(module.business_card_fields)
        profiles = module.profiles
        if profiles is not None:
            for profile in profiles:
                print(profile.name)
                print(profile.id)
        print(module.display_field_name)
        print(module.display_field_id)
        if module.related_lists is not None:
            for relatedlist in module.related_lists:
                print(relatedlist.display_label)
                print(relatedlist.is_visible)
                print(relatedlist.api_name)
                print(relatedlist.module)
                print(relatedlist.name)
                print(relatedlist.id)
                print(relatedlist.href)
                print(relatedlist.type)
        if module.layouts is not None:
            for layout in module.layouts:
                self.print_layout(layout)
        if module.fields is not None:
            for field_ins in module.fields:
                self.print_field(field_ins)
        if module.related_list_properties is not None:
            print(module.related_list_properties.sort_by)
            print(module.related_list_properties.sort_order)
            print(module.related_list_properties.fields)
        print(module.properties)
        print(module.per_page)
        print(module.search_layout_fields)
        print(module.default_territory_name)
        print(module.default_territory_id)
        print(module.default_custom_view_id)
        default_custom_view = module.default_custom_view
        if default_custom_view is not None:
            print(default_custom_view.id)
            print(default_custom_view.name)
        print(module.is_global_search_supported)
        print(module.sequence_number)
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code) # to get the status code
        print(ex.error_message) # to get the error message
        print(ex.error_code) # to get the error code
        print(ex.error_details) # to get the error details
        print(ex.error_content) # to get the error content