ZCRMSDK 1.0.5 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/src/ZCRMSDK.rb +362 -0
- data/src/com/zoho/api/authenticator/oauth_token.rb +217 -0
- data/src/com/zoho/api/authenticator/store/db_store.rb +149 -0
- data/src/com/zoho/api/authenticator/store/file_store.rb +165 -0
- data/src/com/zoho/api/authenticator/store/token_store.rb +26 -0
- data/src/com/zoho/api/authenticator/token.rb +10 -0
- data/src/com/zoho/api/logger/sdk_logger.rb +69 -0
- data/src/com/zoho/crm/api/attachments/action_handler.rb +10 -0
- data/src/com/zoho/crm/api/attachments/action_response.rb +10 -0
- data/src/com/zoho/crm/api/attachments/action_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/attachments/api_exception.rb +125 -0
- data/src/com/zoho/crm/api/attachments/attachment.rb +367 -0
- data/src/com/zoho/crm/api/attachments/attachments_operations.rb +196 -0
- data/src/com/zoho/crm/api/attachments/file_body_wrapper.rb +64 -0
- data/src/com/zoho/crm/api/attachments/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/attachments/response_wrapper.rb +83 -0
- data/src/com/zoho/crm/api/attachments/success_response.rb +121 -0
- data/src/com/zoho/crm/api/blue_print/action_response.rb +10 -0
- data/src/com/zoho/crm/api/blue_print/api_exception.rb +123 -0
- data/src/com/zoho/crm/api/blue_print/blue_print.rb +119 -0
- data/src/com/zoho/crm/api/blue_print/blue_print_operations.rb +67 -0
- data/src/com/zoho/crm/api/blue_print/body_wrapper.rb +61 -0
- data/src/com/zoho/crm/api/blue_print/next_transition.rb +80 -0
- data/src/com/zoho/crm/api/blue_print/process_info.rb +251 -0
- data/src/com/zoho/crm/api/blue_print/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/blue_print/response_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/blue_print/success_response.rb +121 -0
- data/src/com/zoho/crm/api/blue_print/transition.rb +253 -0
- data/src/com/zoho/crm/api/blue_print/validation_error.rb +80 -0
- data/src/com/zoho/crm/api/bulk_read/action_handler.rb +10 -0
- data/src/com/zoho/crm/api/bulk_read/action_response.rb +10 -0
- data/src/com/zoho/crm/api/bulk_read/action_wrapper.rb +82 -0
- data/src/com/zoho/crm/api/bulk_read/api_exception.rb +125 -0
- data/src/com/zoho/crm/api/bulk_read/bulk_read_operations.rb +74 -0
- data/src/com/zoho/crm/api/bulk_read/call_back.rb +81 -0
- data/src/com/zoho/crm/api/bulk_read/criteria.rb +135 -0
- data/src/com/zoho/crm/api/bulk_read/file_body_wrapper.rb +64 -0
- data/src/com/zoho/crm/api/bulk_read/job_detail.rb +196 -0
- data/src/com/zoho/crm/api/bulk_read/query.rb +137 -0
- data/src/com/zoho/crm/api/bulk_read/request_wrapper.rb +100 -0
- data/src/com/zoho/crm/api/bulk_read/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/bulk_read/response_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/bulk_read/result.rb +137 -0
- data/src/com/zoho/crm/api/bulk_read/success_response.rb +121 -0
- data/src/com/zoho/crm/api/bulk_write/action_response.rb +10 -0
- data/src/com/zoho/crm/api/bulk_write/api_exception.rb +239 -0
- data/src/com/zoho/crm/api/bulk_write/bulk_write_operations.rb +112 -0
- data/src/com/zoho/crm/api/bulk_write/bulk_write_response.rb +216 -0
- data/src/com/zoho/crm/api/bulk_write/call_back.rb +81 -0
- data/src/com/zoho/crm/api/bulk_write/field_mapping.rb +156 -0
- data/src/com/zoho/crm/api/bulk_write/file.rb +157 -0
- data/src/com/zoho/crm/api/bulk_write/file_body_wrapper.rb +64 -0
- data/src/com/zoho/crm/api/bulk_write/request_wrapper.rb +119 -0
- data/src/com/zoho/crm/api/bulk_write/resource.rb +195 -0
- data/src/com/zoho/crm/api/bulk_write/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/bulk_write/response_wrapper.rb +10 -0
- data/src/com/zoho/crm/api/bulk_write/result.rb +61 -0
- data/src/com/zoho/crm/api/bulk_write/success_response.rb +121 -0
- data/src/com/zoho/crm/api/contact_roles/action_handler.rb +10 -0
- data/src/com/zoho/crm/api/contact_roles/action_response.rb +10 -0
- data/src/com/zoho/crm/api/contact_roles/action_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/contact_roles/api_exception.rb +125 -0
- data/src/com/zoho/crm/api/contact_roles/body_wrapper.rb +61 -0
- data/src/com/zoho/crm/api/contact_roles/contact_role.rb +99 -0
- data/src/com/zoho/crm/api/contact_roles/contact_roles_operations.rb +161 -0
- data/src/com/zoho/crm/api/contact_roles/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/contact_roles/response_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/contact_roles/success_response.rb +121 -0
- data/src/com/zoho/crm/api/currencies/action_handler.rb +10 -0
- data/src/com/zoho/crm/api/currencies/action_response.rb +10 -0
- data/src/com/zoho/crm/api/currencies/action_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/currencies/api_exception.rb +127 -0
- data/src/com/zoho/crm/api/currencies/base_currency_action_handler.rb +10 -0
- data/src/com/zoho/crm/api/currencies/base_currency_action_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/currencies/base_currency_wrapper.rb +61 -0
- data/src/com/zoho/crm/api/currencies/body_wrapper.rb +61 -0
- data/src/com/zoho/crm/api/currencies/currencies_operations.rb +156 -0
- data/src/com/zoho/crm/api/currencies/currency.rb +290 -0
- data/src/com/zoho/crm/api/currencies/format.rb +100 -0
- data/src/com/zoho/crm/api/currencies/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/currencies/response_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/currencies/success_response.rb +121 -0
- data/src/com/zoho/crm/api/custom_views/api_exception.rb +121 -0
- data/src/com/zoho/crm/api/custom_views/criteria.rb +135 -0
- data/src/com/zoho/crm/api/custom_views/custom_view.rb +327 -0
- data/src/com/zoho/crm/api/custom_views/custom_views_operations.rb +75 -0
- data/src/com/zoho/crm/api/custom_views/info.rb +156 -0
- data/src/com/zoho/crm/api/custom_views/range.rb +80 -0
- data/src/com/zoho/crm/api/custom_views/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/custom_views/response_wrapper.rb +82 -0
- data/src/com/zoho/crm/api/custom_views/shared_details.rb +118 -0
- data/src/com/zoho/crm/api/custom_views/translation.rb +118 -0
- data/src/com/zoho/crm/api/dc/au_datacenter.rb +18 -0
- data/src/com/zoho/crm/api/dc/cn_datacenter.rb +18 -0
- data/src/com/zoho/crm/api/dc/datacenter.rb +20 -0
- data/src/com/zoho/crm/api/dc/eu_datacenter.rb +18 -0
- data/src/com/zoho/crm/api/dc/in_datacenter.rb +18 -0
- data/src/com/zoho/crm/api/dc/us_datacenter.rb +18 -0
- data/src/com/zoho/crm/api/exception/sdk_exception.rb +47 -0
- data/src/com/zoho/crm/api/fields/api_exception.rb +121 -0
- data/src/com/zoho/crm/api/fields/association_details.rb +80 -0
- data/src/com/zoho/crm/api/fields/auto_number.rb +99 -0
- data/src/com/zoho/crm/api/fields/crypt.rb +156 -0
- data/src/com/zoho/crm/api/fields/currency.rb +80 -0
- data/src/com/zoho/crm/api/fields/field.rb +956 -0
- data/src/com/zoho/crm/api/fields/fields_operations.rb +71 -0
- data/src/com/zoho/crm/api/fields/formula.rb +80 -0
- data/src/com/zoho/crm/api/fields/lookup_field.rb +80 -0
- data/src/com/zoho/crm/api/fields/module.rb +157 -0
- data/src/com/zoho/crm/api/fields/multi_select_lookup.rb +156 -0
- data/src/com/zoho/crm/api/fields/pick_list_value.rb +175 -0
- data/src/com/zoho/crm/api/fields/private.rb +99 -0
- data/src/com/zoho/crm/api/fields/related_details.rb +137 -0
- data/src/com/zoho/crm/api/fields/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/fields/response_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/fields/tool_tip.rb +80 -0
- data/src/com/zoho/crm/api/fields/unique.rb +61 -0
- data/src/com/zoho/crm/api/fields/view_type.rb +118 -0
- data/src/com/zoho/crm/api/files/action_handler.rb +10 -0
- data/src/com/zoho/crm/api/files/action_response.rb +10 -0
- data/src/com/zoho/crm/api/files/action_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/files/api_exception.rb +125 -0
- data/src/com/zoho/crm/api/files/body_wrapper.rb +62 -0
- data/src/com/zoho/crm/api/files/file_body_wrapper.rb +64 -0
- data/src/com/zoho/crm/api/files/file_operations.rb +75 -0
- data/src/com/zoho/crm/api/files/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/files/success_response.rb +121 -0
- data/src/com/zoho/crm/api/header.rb +10 -0
- data/src/com/zoho/crm/api/header_map.rb +55 -0
- data/src/com/zoho/crm/api/initializer.rb +192 -0
- data/src/com/zoho/crm/api/layouts/api_exception.rb +121 -0
- data/src/com/zoho/crm/api/layouts/layout.rb +272 -0
- data/src/com/zoho/crm/api/layouts/layouts_operations.rb +61 -0
- data/src/com/zoho/crm/api/layouts/properties.rb +100 -0
- data/src/com/zoho/crm/api/layouts/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/layouts/response_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/layouts/section.rb +233 -0
- data/src/com/zoho/crm/api/modules/action_handler.rb +10 -0
- data/src/com/zoho/crm/api/modules/action_response.rb +10 -0
- data/src/com/zoho/crm/api/modules/action_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/modules/api_exception.rb +125 -0
- data/src/com/zoho/crm/api/modules/argument.rb +80 -0
- data/src/com/zoho/crm/api/modules/body_wrapper.rb +61 -0
- data/src/com/zoho/crm/api/modules/module.rb +882 -0
- data/src/com/zoho/crm/api/modules/modules_operations.rb +111 -0
- data/src/com/zoho/crm/api/modules/related_list_properties.rb +99 -0
- data/src/com/zoho/crm/api/modules/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/modules/response_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/modules/success_response.rb +121 -0
- data/src/com/zoho/crm/api/modules/territory.rb +99 -0
- data/src/com/zoho/crm/api/notes/action_handler.rb +10 -0
- data/src/com/zoho/crm/api/notes/action_response.rb +10 -0
- data/src/com/zoho/crm/api/notes/action_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/notes/api_exception.rb +125 -0
- data/src/com/zoho/crm/api/notes/body_wrapper.rb +61 -0
- data/src/com/zoho/crm/api/notes/info.rb +118 -0
- data/src/com/zoho/crm/api/notes/note.rb +349 -0
- data/src/com/zoho/crm/api/notes/notes_operations.rb +219 -0
- data/src/com/zoho/crm/api/notes/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/notes/response_wrapper.rb +82 -0
- data/src/com/zoho/crm/api/notes/success_response.rb +121 -0
- data/src/com/zoho/crm/api/notification/action_handler.rb +10 -0
- data/src/com/zoho/crm/api/notification/action_response.rb +10 -0
- data/src/com/zoho/crm/api/notification/action_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/notification/api_exception.rb +125 -0
- data/src/com/zoho/crm/api/notification/body_wrapper.rb +61 -0
- data/src/com/zoho/crm/api/notification/info.rb +118 -0
- data/src/com/zoho/crm/api/notification/notification.rb +251 -0
- data/src/com/zoho/crm/api/notification/notification_operations.rb +164 -0
- data/src/com/zoho/crm/api/notification/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/notification/response_wrapper.rb +82 -0
- data/src/com/zoho/crm/api/notification/success_response.rb +121 -0
- data/src/com/zoho/crm/api/org/action_response.rb +10 -0
- data/src/com/zoho/crm/api/org/api_exception.rb +123 -0
- data/src/com/zoho/crm/api/org/file_body_wrapper.rb +62 -0
- data/src/com/zoho/crm/api/org/license_details.rb +156 -0
- data/src/com/zoho/crm/api/org/org.rb +631 -0
- data/src/com/zoho/crm/api/org/org_operations.rb +49 -0
- data/src/com/zoho/crm/api/org/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/org/response_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/org/success_response.rb +121 -0
- data/src/com/zoho/crm/api/param.rb +10 -0
- data/src/com/zoho/crm/api/parameter_map.rb +54 -0
- data/src/com/zoho/crm/api/profiles/api_exception.rb +121 -0
- data/src/com/zoho/crm/api/profiles/category.rb +99 -0
- data/src/com/zoho/crm/api/profiles/permission_detail.rb +137 -0
- data/src/com/zoho/crm/api/profiles/profile.rb +290 -0
- data/src/com/zoho/crm/api/profiles/profiles_operations.rb +61 -0
- data/src/com/zoho/crm/api/profiles/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/profiles/response_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/profiles/section.rb +80 -0
- data/src/com/zoho/crm/api/query/api_exception.rb +121 -0
- data/src/com/zoho/crm/api/query/body_wrapper.rb +61 -0
- data/src/com/zoho/crm/api/query/query_operations.rb +35 -0
- data/src/com/zoho/crm/api/query/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/query/response_wrapper.rb +84 -0
- data/src/com/zoho/crm/api/record/action_handler.rb +10 -0
- data/src/com/zoho/crm/api/record/action_response.rb +10 -0
- data/src/com/zoho/crm/api/record/action_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/record/api_exception.rb +143 -0
- data/src/com/zoho/crm/api/record/body_wrapper.rb +156 -0
- data/src/com/zoho/crm/api/record/carry_over_tags.rb +99 -0
- data/src/com/zoho/crm/api/record/comment.rb +118 -0
- data/src/com/zoho/crm/api/record/consent.rb +185 -0
- data/src/com/zoho/crm/api/record/convert_action_handler.rb +10 -0
- data/src/com/zoho/crm/api/record/convert_action_response.rb +10 -0
- data/src/com/zoho/crm/api/record/convert_action_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/record/convert_body_wrapper.rb +61 -0
- data/src/com/zoho/crm/api/record/criteria.rb +135 -0
- data/src/com/zoho/crm/api/record/deleted_record.rb +157 -0
- data/src/com/zoho/crm/api/record/deleted_records_handler.rb +10 -0
- data/src/com/zoho/crm/api/record/deleted_records_wrapper.rb +82 -0
- data/src/com/zoho/crm/api/record/download_handler.rb +10 -0
- data/src/com/zoho/crm/api/record/field.rb +2109 -0
- data/src/com/zoho/crm/api/record/file_body_wrapper.rb +66 -0
- data/src/com/zoho/crm/api/record/file_details.rb +327 -0
- data/src/com/zoho/crm/api/record/file_handler.rb +10 -0
- data/src/com/zoho/crm/api/record/info.rb +118 -0
- data/src/com/zoho/crm/api/record/inventory_line_items.rb +235 -0
- data/src/com/zoho/crm/api/record/lead_converter.rb +194 -0
- data/src/com/zoho/crm/api/record/line_item_product.rb +65 -0
- data/src/com/zoho/crm/api/record/line_tax.rb +118 -0
- data/src/com/zoho/crm/api/record/mass_update.rb +140 -0
- data/src/com/zoho/crm/api/record/mass_update_action_handler.rb +10 -0
- data/src/com/zoho/crm/api/record/mass_update_action_response.rb +10 -0
- data/src/com/zoho/crm/api/record/mass_update_action_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/record/mass_update_body_wrapper.rb +156 -0
- data/src/com/zoho/crm/api/record/mass_update_response.rb +10 -0
- data/src/com/zoho/crm/api/record/mass_update_response_handler.rb +10 -0
- data/src/com/zoho/crm/api/record/mass_update_response_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/record/mass_update_success_response.rb +121 -0
- data/src/com/zoho/crm/api/record/options.rb +10 -0
- data/src/com/zoho/crm/api/record/participants.rb +116 -0
- data/src/com/zoho/crm/api/record/pricing_details.rb +65 -0
- data/src/com/zoho/crm/api/record/record.rb +192 -0
- data/src/com/zoho/crm/api/record/record_operations.rb +677 -0
- data/src/com/zoho/crm/api/record/recurring_activity.rb +61 -0
- data/src/com/zoho/crm/api/record/remind_at.rb +61 -0
- data/src/com/zoho/crm/api/record/reminder.rb +80 -0
- data/src/com/zoho/crm/api/record/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/record/response_wrapper.rb +82 -0
- data/src/com/zoho/crm/api/record/success_response.rb +161 -0
- data/src/com/zoho/crm/api/record/successful_convert.rb +101 -0
- data/src/com/zoho/crm/api/record/territory.rb +80 -0
- data/src/com/zoho/crm/api/related_lists/api_exception.rb +121 -0
- data/src/com/zoho/crm/api/related_lists/related_list.rb +251 -0
- data/src/com/zoho/crm/api/related_lists/related_lists_operations.rb +61 -0
- data/src/com/zoho/crm/api/related_lists/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/related_lists/response_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/related_records/action_handler.rb +10 -0
- data/src/com/zoho/crm/api/related_records/action_response.rb +10 -0
- data/src/com/zoho/crm/api/related_records/action_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/related_records/api_exception.rb +125 -0
- data/src/com/zoho/crm/api/related_records/body_wrapper.rb +62 -0
- data/src/com/zoho/crm/api/related_records/file_body_wrapper.rb +64 -0
- data/src/com/zoho/crm/api/related_records/related_records_operations.rb +235 -0
- data/src/com/zoho/crm/api/related_records/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/related_records/response_wrapper.rb +84 -0
- data/src/com/zoho/crm/api/related_records/success_response.rb +121 -0
- data/src/com/zoho/crm/api/request_proxy.rb +16 -0
- data/src/com/zoho/crm/api/roles/api_exception.rb +121 -0
- data/src/com/zoho/crm/api/roles/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/roles/response_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/roles/role.rb +195 -0
- data/src/com/zoho/crm/api/roles/roles_operations.rb +47 -0
- data/src/com/zoho/crm/api/sdk_config.rb +78 -0
- data/src/com/zoho/crm/api/share_records/action_handler.rb +10 -0
- data/src/com/zoho/crm/api/share_records/action_response.rb +10 -0
- data/src/com/zoho/crm/api/share_records/action_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/share_records/api_exception.rb +129 -0
- data/src/com/zoho/crm/api/share_records/body_wrapper.rb +61 -0
- data/src/com/zoho/crm/api/share_records/delete_action_handler.rb +10 -0
- data/src/com/zoho/crm/api/share_records/delete_action_response.rb +10 -0
- data/src/com/zoho/crm/api/share_records/delete_action_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/share_records/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/share_records/response_wrapper.rb +83 -0
- data/src/com/zoho/crm/api/share_records/share_record.rb +157 -0
- data/src/com/zoho/crm/api/share_records/share_records_operations.rb +128 -0
- data/src/com/zoho/crm/api/share_records/shared_through.rb +100 -0
- data/src/com/zoho/crm/api/share_records/success_response.rb +123 -0
- data/src/com/zoho/crm/api/tags/action_handler.rb +10 -0
- data/src/com/zoho/crm/api/tags/action_response.rb +10 -0
- data/src/com/zoho/crm/api/tags/action_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/tags/api_exception.rb +131 -0
- data/src/com/zoho/crm/api/tags/body_wrapper.rb +61 -0
- data/src/com/zoho/crm/api/tags/conflict_wrapper.rb +61 -0
- data/src/com/zoho/crm/api/tags/count_handler.rb +10 -0
- data/src/com/zoho/crm/api/tags/count_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/tags/info.rb +80 -0
- data/src/com/zoho/crm/api/tags/merge_wrapper.rb +61 -0
- data/src/com/zoho/crm/api/tags/record_action_handler.rb +10 -0
- data/src/com/zoho/crm/api/tags/record_action_response.rb +10 -0
- data/src/com/zoho/crm/api/tags/record_action_wrapper.rb +120 -0
- data/src/com/zoho/crm/api/tags/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/tags/response_wrapper.rb +82 -0
- data/src/com/zoho/crm/api/tags/success_response.rb +123 -0
- data/src/com/zoho/crm/api/tags/tag.rb +157 -0
- data/src/com/zoho/crm/api/tags/tags_operations.rb +387 -0
- data/src/com/zoho/crm/api/taxes/action_handler.rb +10 -0
- data/src/com/zoho/crm/api/taxes/action_response.rb +10 -0
- data/src/com/zoho/crm/api/taxes/action_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/taxes/api_exception.rb +125 -0
- data/src/com/zoho/crm/api/taxes/body_wrapper.rb +61 -0
- data/src/com/zoho/crm/api/taxes/preference.rb +80 -0
- data/src/com/zoho/crm/api/taxes/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/taxes/response_wrapper.rb +82 -0
- data/src/com/zoho/crm/api/taxes/success_response.rb +121 -0
- data/src/com/zoho/crm/api/taxes/tax.rb +137 -0
- data/src/com/zoho/crm/api/taxes/taxes_operations.rb +136 -0
- data/src/com/zoho/crm/api/territories/api_exception.rb +121 -0
- data/src/com/zoho/crm/api/territories/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/territories/response_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/territories/territories_operations.rb +47 -0
- data/src/com/zoho/crm/api/territories/territory.rb +234 -0
- data/src/com/zoho/crm/api/user_signature.rb +27 -0
- data/src/com/zoho/crm/api/users/action_handler.rb +10 -0
- data/src/com/zoho/crm/api/users/action_response.rb +10 -0
- data/src/com/zoho/crm/api/users/action_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/users/api_exception.rb +125 -0
- data/src/com/zoho/crm/api/users/body_wrapper.rb +61 -0
- data/src/com/zoho/crm/api/users/customize_info.rb +156 -0
- data/src/com/zoho/crm/api/users/info.rb +118 -0
- data/src/com/zoho/crm/api/users/request_wrapper.rb +61 -0
- data/src/com/zoho/crm/api/users/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/users/response_wrapper.rb +82 -0
- data/src/com/zoho/crm/api/users/shift.rb +80 -0
- data/src/com/zoho/crm/api/users/success_response.rb +121 -0
- data/src/com/zoho/crm/api/users/tab_theme.rb +80 -0
- data/src/com/zoho/crm/api/users/territory.rb +99 -0
- data/src/com/zoho/crm/api/users/theme.rb +156 -0
- data/src/com/zoho/crm/api/users/user.rb +696 -0
- data/src/com/zoho/crm/api/users/users_operations.rb +181 -0
- data/src/com/zoho/crm/api/util/api_http_connector.rb +111 -0
- data/src/com/zoho/crm/api/util/api_response.rb +16 -0
- data/src/com/zoho/crm/api/util/choice.rb +9 -0
- data/src/com/zoho/crm/api/util/common_api_handler.rb +235 -0
- data/src/com/zoho/crm/api/util/constants.rb +536 -0
- data/src/com/zoho/crm/api/util/converter.rb +213 -0
- data/src/com/zoho/crm/api/util/data_type_converter.rb +162 -0
- data/src/com/zoho/crm/api/util/downloader.rb +83 -0
- data/src/com/zoho/crm/api/util/form_data_converter.rb +167 -0
- data/src/com/zoho/crm/api/util/header_param_validator.rb +55 -0
- data/src/com/zoho/crm/api/util/json_converter.rb +726 -0
- data/src/com/zoho/crm/api/util/model.rb +5 -0
- data/src/com/zoho/crm/api/util/module_fields_handler.rb +78 -0
- data/src/com/zoho/crm/api/util/stream_wrapper.rb +37 -0
- data/src/com/zoho/crm/api/util/utility.rb +727 -0
- data/src/com/zoho/crm/api/variable_groups/api_exception.rb +121 -0
- data/src/com/zoho/crm/api/variable_groups/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/variable_groups/response_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/variable_groups/variable_group.rb +137 -0
- data/src/com/zoho/crm/api/variable_groups/variable_groups_operations.rb +66 -0
- data/src/com/zoho/crm/api/variables/action_handler.rb +10 -0
- data/src/com/zoho/crm/api/variables/action_response.rb +10 -0
- data/src/com/zoho/crm/api/variables/action_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/variables/api_exception.rb +125 -0
- data/src/com/zoho/crm/api/variables/body_wrapper.rb +61 -0
- data/src/com/zoho/crm/api/variables/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/variables/response_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/variables/success_response.rb +121 -0
- data/src/com/zoho/crm/api/variables/variable.rb +173 -0
- data/src/com/zoho/crm/api/variables/variables_operations.rb +241 -0
- data/src/resources/JSONDetails.json +1 -0
- data/src/version.rb +3 -0
- metadata +393 -42
- data/lib/ZCRMSDK.rb +0 -14
- data/lib/ZCRMSDK/handler.rb +0 -3299
- data/lib/ZCRMSDK/oauth_client.rb +0 -257
- data/lib/ZCRMSDK/oauth_utility.rb +0 -161
- data/lib/ZCRMSDK/operations.rb +0 -1091
- data/lib/ZCRMSDK/org.rb +0 -174
- data/lib/ZCRMSDK/persistence.rb +0 -129
- data/lib/ZCRMSDK/request.rb +0 -83
- data/lib/ZCRMSDK/response.rb +0 -216
- data/lib/ZCRMSDK/restclient.rb +0 -65
- data/lib/ZCRMSDK/utility.rb +0 -310
- data/lib/ZCRMSDK/version.rb +0 -5
data/lib/ZCRMSDK.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'ZCRMSDK/oauth_utility'
|
4
|
-
require 'ZCRMSDK/operations'
|
5
|
-
require 'ZCRMSDK/handler'
|
6
|
-
require 'ZCRMSDK/oauth_client'
|
7
|
-
require 'ZCRMSDK/operations'
|
8
|
-
require 'ZCRMSDK/org'
|
9
|
-
require 'ZCRMSDK/persistence'
|
10
|
-
require 'ZCRMSDK/request'
|
11
|
-
require 'ZCRMSDK/response'
|
12
|
-
require 'ZCRMSDK/utility'
|
13
|
-
require 'ZCRMSDK/restclient'
|
14
|
-
require 'ZCRMSDK/version'
|
data/lib/ZCRMSDK/handler.rb
DELETED
@@ -1,3299 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'utility'
|
4
|
-
require_relative 'operations'
|
5
|
-
require_relative 'request'
|
6
|
-
require_relative 'org'
|
7
|
-
require 'json'
|
8
|
-
module ZCRMSDK
|
9
|
-
module Handler
|
10
|
-
# THIS CLASS SERVES AS A PARENT CLASS TO OTHER HANDLER CLASSES
|
11
|
-
class APIHandler
|
12
|
-
attr_accessor :request_url_path, :request_body, :request_headers, :request_params, :request_method, :request_api_key
|
13
|
-
def initialize
|
14
|
-
@request_url_path = nil
|
15
|
-
@request_body = nil
|
16
|
-
@request_headers = nil
|
17
|
-
@request_params = nil
|
18
|
-
@request_method = nil
|
19
|
-
@request_api_key = nil
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.get_instance
|
23
|
-
APIHandler.new
|
24
|
-
end
|
25
|
-
|
26
|
-
def add_param(key, value)
|
27
|
-
@request_params = {} if @request_params.nil?
|
28
|
-
@request_params.store(key, value)
|
29
|
-
end
|
30
|
-
|
31
|
-
def add_header(key, value)
|
32
|
-
@request_headers = {} if @request_headers.nil?
|
33
|
-
@request_headers.store(key, value)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
# THIS CLASS IS USED TO HANDLE SINGLE ENTITY RELATED FUNCTIONALITY
|
37
|
-
class EntityAPIHandler < APIHandler
|
38
|
-
def initialize(zcrm_record)
|
39
|
-
@zcrmrecord = zcrm_record
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.get_instance(zcrm_record)
|
43
|
-
EntityAPIHandler.new(zcrm_record)
|
44
|
-
end
|
45
|
-
|
46
|
-
def get_record
|
47
|
-
if @zcrmrecord.entity_id.nil?
|
48
|
-
raise Utility::ZCRMException.get_instance('get_record', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'id should be set for the record', 'ID IS NOT PROVIDED')
|
49
|
-
end
|
50
|
-
|
51
|
-
handler_ins = APIHandler.get_instance
|
52
|
-
handler_ins.request_url_path = ''
|
53
|
-
handler_ins.request_url_path = @zcrmrecord.module_api_name + '/' + @zcrmrecord.entity_id.to_s
|
54
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_GET
|
55
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
56
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
57
|
-
obj = EntityAPIHandlerHelper.get_instance
|
58
|
-
obj.set_record_properties(@zcrmrecord, api_response.response_json.dig(Utility::APIConstants::DATA, 0))
|
59
|
-
api_response.data = @zcrmrecord
|
60
|
-
api_response
|
61
|
-
end
|
62
|
-
|
63
|
-
def create_record
|
64
|
-
unless @zcrmrecord.entity_id.nil?
|
65
|
-
raise Utility::ZCRMException.get_instance('create_record', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'id should not be set for the record', 'ID PROVIDED')
|
66
|
-
end
|
67
|
-
|
68
|
-
handler_ins = APIHandler.get_instance
|
69
|
-
handler_ins.request_url_path = ''
|
70
|
-
handler_ins.request_url_path = @zcrmrecord.module_api_name
|
71
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_POST
|
72
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
73
|
-
helper_obj = EntityAPIHandlerHelper.get_instance
|
74
|
-
input_json = helper_obj.get_zcrmrecord_as_json(@zcrmrecord)
|
75
|
-
handler_ins.request_body = Utility::CommonUtil.create_api_supported_input_json(input_json, Utility::APIConstants::DATA)
|
76
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
77
|
-
response_details = api_response.response_json.dig(Utility::APIConstants::DATA, 0, 'details')
|
78
|
-
@zcrmrecord.entity_id = response_details['id']
|
79
|
-
@zcrmrecord.created_time = response_details['Created_Time']
|
80
|
-
created_by = response_details['Created_By']
|
81
|
-
@zcrmrecord.created_by = Operations::ZCRMUser.get_instance(created_by['id'], created_by['name'])
|
82
|
-
api_response.data = @zcrmrecord
|
83
|
-
api_response
|
84
|
-
end
|
85
|
-
|
86
|
-
def update_record
|
87
|
-
if @zcrmrecord.entity_id.nil?
|
88
|
-
raise Utility::ZCRMException.get_instance('update_record', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'id should be set for the record', 'ID IS NOT PROVIDED')
|
89
|
-
end
|
90
|
-
|
91
|
-
handler_ins = APIHandler.get_instance
|
92
|
-
handler_ins.request_url_path = ''
|
93
|
-
handler_ins.request_url_path = @zcrmrecord.module_api_name + '/' + @zcrmrecord.entity_id.to_s
|
94
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_PUT
|
95
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
96
|
-
helper_obj = EntityAPIHandlerHelper.get_instance
|
97
|
-
input_json = helper_obj.get_zcrmrecord_as_json(@zcrmrecord)
|
98
|
-
handler_ins.request_body = Utility::CommonUtil.create_api_supported_input_json(input_json, Utility::APIConstants::DATA)
|
99
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
100
|
-
response_details = api_response.response_json.dig(Utility::APIConstants::DATA, 0, 'details')
|
101
|
-
@zcrmrecord.entity_id = response_details['id']
|
102
|
-
@zcrmrecord.created_time = response_details['Created_Time']
|
103
|
-
@zcrmrecord.modified_time = response_details['Modified_Time']
|
104
|
-
created_by = response_details['Created_By']
|
105
|
-
@zcrmrecord.created_by = Operations::ZCRMUser.get_instance(created_by['id'], created_by['name'])
|
106
|
-
modified_by = response_details['Modified_By']
|
107
|
-
@zcrmrecord.modified_by = Operations::ZCRMUser.get_instance(modified_by['id'], modified_by['name'])
|
108
|
-
api_response.data = @zcrmrecord
|
109
|
-
api_response
|
110
|
-
end
|
111
|
-
|
112
|
-
def delete_record
|
113
|
-
if @zcrmrecord.entity_id.nil?
|
114
|
-
raise Utility::ZCRMException.get_instance('delete_record', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'id should be set for the record', 'ID IS NOT PROVIDED')
|
115
|
-
end
|
116
|
-
|
117
|
-
handler_ins = APIHandler.get_instance
|
118
|
-
handler_ins.request_url_path = ''
|
119
|
-
handler_ins.request_url_path = @zcrmrecord.module_api_name + '/' + @zcrmrecord.entity_id.to_s
|
120
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_DELETE
|
121
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
122
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
123
|
-
api_response
|
124
|
-
end
|
125
|
-
|
126
|
-
def convert_record(potential_record, details)
|
127
|
-
if @zcrmrecord.entity_id.nil?
|
128
|
-
raise Utility::ZCRMException.get_instance('convert_record', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'id should be set for the record', 'ID IS NOT PROVIDED')
|
129
|
-
end
|
130
|
-
|
131
|
-
handler_ins = APIHandler.get_instance
|
132
|
-
handler_ins.request_url_path = ''
|
133
|
-
handler_ins.request_url_path = @zcrmrecord.module_api_name + '/' + @zcrmrecord.entity_id.to_s + '/actions/convert'
|
134
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_POST
|
135
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
136
|
-
input_json = {}
|
137
|
-
unless details.nil?
|
138
|
-
details.each do |key, value|
|
139
|
-
input_json[key] = value
|
140
|
-
end
|
141
|
-
end
|
142
|
-
unless potential_record.nil?
|
143
|
-
entity_helper = EntityAPIHandlerHelper.get_instance
|
144
|
-
input_json['Deals'] = entity_helper.get_zcrmrecord_as_json(potential_record)
|
145
|
-
end
|
146
|
-
unless details.nil? && potential_record.nil?
|
147
|
-
input_json_arr = []
|
148
|
-
input_json_arr.push(input_json)
|
149
|
-
req_body_json = {}
|
150
|
-
req_body_json.store(Utility::APIConstants::DATA, input_json_arr)
|
151
|
-
handler_ins.request_body = req_body_json
|
152
|
-
end
|
153
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
154
|
-
converted_dict = {}
|
155
|
-
converted_ids_json = api_response.response_json.dig(Utility::APIConstants::DATA, 0)
|
156
|
-
if converted_ids_json.key?(Utility::APIConstants::CONTACTS) && !converted_ids_json.dig(Utility::APIConstants::CONTACTS).nil?
|
157
|
-
converted_dict.store(Utility::APIConstants::CONTACTS, converted_ids_json.dig(Utility::APIConstants::CONTACTS))
|
158
|
-
end
|
159
|
-
if converted_ids_json.key?(Utility::APIConstants::ACCOUNTS) && !converted_ids_json.dig(Utility::APIConstants::ACCOUNTS).nil?
|
160
|
-
converted_dict.store(Utility::APIConstants::ACCOUNTS, converted_ids_json.dig(Utility::APIConstants::ACCOUNTS))
|
161
|
-
end
|
162
|
-
if converted_ids_json.key?(Utility::APIConstants::DEALS) && !converted_ids_json.dig(Utility::APIConstants::DEALS).nil?
|
163
|
-
converted_dict.store(Utility::APIConstants::DEALS, converted_ids_json.dig(Utility::APIConstants::DEALS))
|
164
|
-
end
|
165
|
-
converted_dict
|
166
|
-
end
|
167
|
-
|
168
|
-
def upload_photo(file_path)
|
169
|
-
if file_path.nil?
|
170
|
-
raise Utility::ZCRMException.get_instance('upload_photo', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'file path must be given', 'FILEPATH NOT PROVIDED')
|
171
|
-
end
|
172
|
-
if @zcrmrecord.entity_id.nil?
|
173
|
-
raise Utility::ZCRMException.get_instance('upload_photo', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'id should be set for the record for uploading', 'ID IS NOT PROVIDED')
|
174
|
-
end
|
175
|
-
|
176
|
-
handler_ins = APIHandler.get_instance
|
177
|
-
handler_ins.request_url_path = ''
|
178
|
-
handler_ins.request_url_path = @zcrmrecord.module_api_name + '/' + @zcrmrecord.entity_id.to_s + '/photo'
|
179
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_POST
|
180
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
181
|
-
api_response = Request::APIRequest.get_instance(handler_ins).upload_file(file_path)
|
182
|
-
api_response
|
183
|
-
end
|
184
|
-
|
185
|
-
def download_photo
|
186
|
-
if @zcrmrecord.entity_id.nil?
|
187
|
-
raise Utility::ZCRMException.get_instance('download_photo', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'id should be set for the record for uploading', 'ID IS NOT PROVIDED')
|
188
|
-
end
|
189
|
-
|
190
|
-
handler_ins = APIHandler.get_instance
|
191
|
-
handler_ins.request_url_path = ''
|
192
|
-
handler_ins.request_url_path = @zcrmrecord.module_api_name + '/' + @zcrmrecord.entity_id.to_s + '/photo'
|
193
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
194
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
195
|
-
Request::APIRequest.get_instance(handler_ins).download_file
|
196
|
-
end
|
197
|
-
|
198
|
-
def delete_photo
|
199
|
-
if @zcrmrecord.entity_id.nil?
|
200
|
-
raise Utility::ZCRMException.get_instance('delete_photo', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'id should be set for the record for uploading', 'ID IS NOT PROVIDED')
|
201
|
-
end
|
202
|
-
|
203
|
-
handler_ins = APIHandler.get_instance
|
204
|
-
handler_ins.request_url_path = ''
|
205
|
-
handler_ins.request_url_path = @zcrmrecord.module_api_name + '/' + @zcrmrecord.entity_id.to_s + '/photo'
|
206
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_DELETE
|
207
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
208
|
-
Request::APIRequest.get_instance(handler_ins).get_api_response
|
209
|
-
end
|
210
|
-
end
|
211
|
-
# THIS CLASS IS USED TO HANDLE MASS ENTITY RELATED FUNCTIONALITY
|
212
|
-
class MassEntityAPIHandler < APIHandler
|
213
|
-
def initialize(module_ins)
|
214
|
-
@module_instance = module_ins
|
215
|
-
end
|
216
|
-
|
217
|
-
def self.get_instance(module_ins)
|
218
|
-
MassEntityAPIHandler.new(module_ins)
|
219
|
-
end
|
220
|
-
|
221
|
-
def get_records(cvid, sort_by, sort_order, page, per_page, headers)
|
222
|
-
handler_ins = APIHandler.get_instance
|
223
|
-
handler_ins.request_url_path = ''
|
224
|
-
handler_ins.request_url_path += @module_instance.api_name
|
225
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_GET
|
226
|
-
handler_ins.add_param('cvid', cvid) unless cvid.nil?
|
227
|
-
handler_ins.add_param('sort_by', sort_by) unless sort_by.nil?
|
228
|
-
handler_ins.add_param('sort_order', sort_order) unless sort_order.nil?
|
229
|
-
unless headers.nil?
|
230
|
-
headers.each do |key, value|
|
231
|
-
handler_ins.add_header(key, value)
|
232
|
-
end
|
233
|
-
end
|
234
|
-
handler_ins.add_param('page', page)
|
235
|
-
handler_ins.add_param('per_page', per_page)
|
236
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
237
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
238
|
-
data_arr = bulk_api_response.response_json[Utility::APIConstants::DATA]
|
239
|
-
entity_helper = EntityAPIHandlerHelper.get_instance
|
240
|
-
record_ins_list = []
|
241
|
-
unless data_arr.nil?
|
242
|
-
data_arr.each do |record_data|
|
243
|
-
zcrm_record = Operations::ZCRMRecord.get_instance(@module_instance.api_name, record_data['id'])
|
244
|
-
entity_helper.set_record_properties(zcrm_record, record_data)
|
245
|
-
record_ins_list.push(zcrm_record)
|
246
|
-
end
|
247
|
-
end
|
248
|
-
bulk_api_response.data = record_ins_list
|
249
|
-
bulk_api_response
|
250
|
-
end
|
251
|
-
|
252
|
-
def create_records(record_ins_array, lar_id)
|
253
|
-
if record_ins_array.length > 100
|
254
|
-
raise Utility::ZCRMException.get_instance('create_records', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'records count must be less than or equals to 100', 'MORE RECORDS PROVIDED')
|
255
|
-
end
|
256
|
-
|
257
|
-
if record_ins_array.length < 1
|
258
|
-
raise Utility::ZCRMException.get_instance('create_records', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'records count must be at least 1', 'NO RECORDS PROVIDED')
|
259
|
-
end
|
260
|
-
|
261
|
-
handler_ins = APIHandler.get_instance
|
262
|
-
handler_ins.request_url_path = ''
|
263
|
-
handler_ins.request_url_path += @module_instance.api_name
|
264
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_POST
|
265
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
266
|
-
helper_obj = EntityAPIHandlerHelper.get_instance
|
267
|
-
data_array = []
|
268
|
-
record_ins_array.each do |zcrm_record|
|
269
|
-
if zcrm_record.entity_id.nil?
|
270
|
-
data_array.push(helper_obj.get_zcrmrecord_as_json(zcrm_record))
|
271
|
-
else
|
272
|
-
raise Utility::ZCRMException.get_instance('Records_Create', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'record id must be nil', 'ID IS PROVIDED')
|
273
|
-
end
|
274
|
-
end
|
275
|
-
request_json = {}
|
276
|
-
request_json[Utility::APIConstants::DATA] = data_array
|
277
|
-
request_json['lar_id'] = lar_id unless lar_id.nil?
|
278
|
-
handler_ins.request_body = request_json
|
279
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
280
|
-
created_records = []
|
281
|
-
entity_responses = bulk_api_response.bulk_entity_response
|
282
|
-
length = entity_responses.length
|
283
|
-
length -= 1
|
284
|
-
(0..length).each do |i|
|
285
|
-
entity_response_ins = entity_responses[i]
|
286
|
-
next unless entity_response_ins.status == Utility::APIConstants::STATUS_SUCCESS
|
287
|
-
|
288
|
-
record_create_details = entity_response_ins.details
|
289
|
-
new_record = record_ins_array[i]
|
290
|
-
entity_helper = EntityAPIHandlerHelper.get_instance
|
291
|
-
entity_helper.set_record_properties(new_record, record_create_details)
|
292
|
-
created_records.push(new_record)
|
293
|
-
entity_response_ins.data = new_record
|
294
|
-
end
|
295
|
-
bulk_api_response.data = created_records
|
296
|
-
bulk_api_response
|
297
|
-
end
|
298
|
-
|
299
|
-
def upsert_records(record_ins_array, duplicate_check_fields, lar_id)
|
300
|
-
if record_ins_array.length > 100
|
301
|
-
raise Utility::ZCRMException.get_instance('upsert_records', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'records count must be less than or equals to 100', 'MORE RECORDS PROVIDED')
|
302
|
-
end
|
303
|
-
|
304
|
-
if record_ins_array.length < 1
|
305
|
-
raise Utility::ZCRMException.get_instance('upsert_records', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'records count must be at least 1', 'NO RECORDS PROVIDED')
|
306
|
-
end
|
307
|
-
|
308
|
-
handler_ins = APIHandler.get_instance
|
309
|
-
handler_ins.request_url_path = ''
|
310
|
-
handler_ins.request_url_path = @module_instance.api_name + '/upsert'
|
311
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_POST
|
312
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
313
|
-
helper_obj = EntityAPIHandlerHelper.get_instance
|
314
|
-
data_array = []
|
315
|
-
record_ins_array.each do |zcrm_record|
|
316
|
-
input_json = helper_obj.get_zcrmrecord_as_json(zcrm_record)
|
317
|
-
unless zcrm_record.entity_id.nil?
|
318
|
-
input_json['id'] = zcrm_record.entity_id.to_s
|
319
|
-
end
|
320
|
-
data_array.push(input_json)
|
321
|
-
end
|
322
|
-
request_json['lar_id'] = lar_id unless lar_id.nil?
|
323
|
-
unless duplicate_check_fields.nil?
|
324
|
-
ids_as_string = ''
|
325
|
-
duplicate_check_fields.each do |duplicate_check_field|
|
326
|
-
ids_as_string += duplicate_check_field.to_s + ','
|
327
|
-
end
|
328
|
-
handler_ins.add_param('duplicate_check_fields', ids_as_string)
|
329
|
-
end
|
330
|
-
|
331
|
-
request_json = {}
|
332
|
-
request_json[Utility::APIConstants::DATA] = data_array
|
333
|
-
handler_ins.request_body = request_json
|
334
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
335
|
-
upsert_records = []
|
336
|
-
entity_responses = bulk_api_response.bulk_entity_response
|
337
|
-
length = entity_responses.length
|
338
|
-
length -= 1
|
339
|
-
(0..length).each do |i|
|
340
|
-
entity_response_ins = entity_responses[i]
|
341
|
-
next unless entity_response_ins.status == Utility::APIConstants::STATUS_SUCCESS
|
342
|
-
|
343
|
-
record_upsert_details = entity_response_ins.details
|
344
|
-
new_record = record_ins_array[i]
|
345
|
-
entity_helper = EntityAPIHandlerHelper.get_instance
|
346
|
-
entity_helper.set_record_properties(new_record, record_upsert_details)
|
347
|
-
upsert_records.push(new_record)
|
348
|
-
entity_response_ins.data = new_record
|
349
|
-
end
|
350
|
-
bulk_api_response.data = upsert_records
|
351
|
-
bulk_api_response
|
352
|
-
end
|
353
|
-
|
354
|
-
def update_records(record_ins_array)
|
355
|
-
if record_ins_array.length > 100
|
356
|
-
raise Utility::ZCRMException.get_instance('update_records', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'records count must be less than or equals to 100', 'MORE RECORDS PROVIDED')
|
357
|
-
end
|
358
|
-
|
359
|
-
if record_ins_array.length < 1
|
360
|
-
raise Utility::ZCRMException.get_instance('update_records', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'records count must be at least 1', 'NO RECORDS PROVIDED')
|
361
|
-
end
|
362
|
-
|
363
|
-
handler_ins = APIHandler.get_instance
|
364
|
-
handler_ins.request_url_path = ''
|
365
|
-
handler_ins.request_url_path += @module_instance.api_name
|
366
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_PUT
|
367
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
368
|
-
helper_obj = EntityAPIHandlerHelper.get_instance
|
369
|
-
data_array = []
|
370
|
-
record_ins_array.each do |zcrm_record|
|
371
|
-
input_json = helper_obj.get_zcrmrecord_as_json(zcrm_record)
|
372
|
-
if !zcrm_record.entity_id.nil?
|
373
|
-
input_json['id'] = zcrm_record.entity_id.to_s
|
374
|
-
else
|
375
|
-
raise Utility::ZCRMException.get_instance('Records_Update', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'record id must not be nil', 'RECORD ID NOT PROVIDED')
|
376
|
-
end
|
377
|
-
data_array.push(input_json)
|
378
|
-
end
|
379
|
-
request_json = {}
|
380
|
-
request_json[Utility::APIConstants::DATA] = data_array
|
381
|
-
handler_ins.request_body = request_json
|
382
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
383
|
-
updated_records = []
|
384
|
-
entity_responses = bulk_api_response.bulk_entity_response
|
385
|
-
length = entity_responses.length
|
386
|
-
length -= 1
|
387
|
-
(0..length).each do |i|
|
388
|
-
entity_response_ins = entity_responses[i]
|
389
|
-
next unless entity_response_ins.status == Utility::APIConstants::STATUS_SUCCESS
|
390
|
-
|
391
|
-
record_update_details = entity_response_ins.details
|
392
|
-
new_record = record_ins_array[i]
|
393
|
-
entity_helper = EntityAPIHandlerHelper.get_instance
|
394
|
-
entity_helper.set_record_properties(new_record, record_update_details)
|
395
|
-
updated_records.push(new_record)
|
396
|
-
entity_response_ins.data = new_record
|
397
|
-
end
|
398
|
-
bulk_api_response.data = updated_records
|
399
|
-
bulk_api_response
|
400
|
-
end
|
401
|
-
|
402
|
-
def mass_update_records(entityid_list, field_api_name, value)
|
403
|
-
if entityid_list.length > 100
|
404
|
-
raise Utility::ZCRMException.get_instance('mass_update_records', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'records count must be less than or equals to 100', 'MORE RECORDS PROVIDED')
|
405
|
-
end
|
406
|
-
|
407
|
-
if entityid_list.length < 1
|
408
|
-
raise Utility::ZCRMException.get_instance('mass_update_records', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'records count must be at least 1', 'NO RECORDS PROVIDED')
|
409
|
-
end
|
410
|
-
|
411
|
-
if field_api_name.nil?
|
412
|
-
raise Utility::ZCRMException.get_instance('mass_update_records', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'field api name must be provided', 'NO FIELD APINAME PROVIDED')
|
413
|
-
end
|
414
|
-
|
415
|
-
if value.nil?
|
416
|
-
raise Utility::ZCRMException.get_instance('mass_update_records', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'value must be provided', 'NO VALUE PROVIDED')
|
417
|
-
end
|
418
|
-
|
419
|
-
handler_ins = APIHandler.get_instance
|
420
|
-
handler_ins.request_url_path = ''
|
421
|
-
handler_ins.request_url_path += @module_instance.api_name
|
422
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_PUT
|
423
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
424
|
-
massentity_helper = MassEntityAPIHandlerHelper.get_instance
|
425
|
-
handler_ins.request_body = massentity_helper.construct_json_for_massupdate(entityid_list, field_api_name, value)
|
426
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
427
|
-
updated_records = []
|
428
|
-
entity_responses = bulk_api_response.bulk_entity_response
|
429
|
-
length = entity_responses.length - 1
|
430
|
-
(0..length).each do |i|
|
431
|
-
entity_response_ins = entity_responses[i]
|
432
|
-
next unless entity_response_ins.status == Utility::APIConstants::STATUS_SUCCESS
|
433
|
-
|
434
|
-
record_update_details = entity_response_ins.details
|
435
|
-
new_record = Operations::ZCRMRecord.get_instance(@module_instance.api_name, record_update_details['id'])
|
436
|
-
updated_records.push(new_record)
|
437
|
-
entity_response_ins.data = new_record
|
438
|
-
end
|
439
|
-
bulk_api_response.data = updated_records
|
440
|
-
bulk_api_response
|
441
|
-
end
|
442
|
-
|
443
|
-
def delete_records(entityid_list)
|
444
|
-
if entityid_list.length > 100
|
445
|
-
raise Utility::ZCRMException.get_instance('delete_records', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'records count must be less than or equals to 100', 'MORE RECORDS PROVIDED')
|
446
|
-
end
|
447
|
-
|
448
|
-
if entityid_list.length < 1
|
449
|
-
raise Utility::ZCRMException.get_instance('delete_records', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'records count must be at least 1', 'NO RECORDS PROVIDED')
|
450
|
-
end
|
451
|
-
|
452
|
-
handler_ins = APIHandler.get_instance
|
453
|
-
handler_ins.request_url_path = ''
|
454
|
-
handler_ins.request_url_path += @module_instance.api_name
|
455
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_DELETE
|
456
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
457
|
-
ids_as_string = ''
|
458
|
-
entityid_list.each do |entity_id|
|
459
|
-
ids_as_string += entity_id.to_s + ','
|
460
|
-
end
|
461
|
-
handler_ins.add_param('ids', ids_as_string)
|
462
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
463
|
-
entity_responses = bulk_api_response.bulk_entity_response
|
464
|
-
length = entity_responses.length - 1
|
465
|
-
(0..length).each do |i|
|
466
|
-
entity_response_ins = entity_responses[i]
|
467
|
-
record_delete_details = entity_response_ins.details
|
468
|
-
entity_response_ins.data = Operations::ZCRMRecord.get_instance(@module_instance.api_name, record_delete_details['id'])
|
469
|
-
end
|
470
|
-
bulk_api_response
|
471
|
-
end
|
472
|
-
|
473
|
-
def search_records(search_word, page, per_page, type)
|
474
|
-
if search_word.nil?
|
475
|
-
raise Utility::ZCRMException.get_instance('search_records', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'search word must be given', 'SEARCH WORD NOT PROVIDED')
|
476
|
-
end
|
477
|
-
|
478
|
-
handler_ins = APIHandler.get_instance
|
479
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
480
|
-
handler_ins.request_url_path = @module_instance.api_name + '/search'
|
481
|
-
case type
|
482
|
-
when 'word'
|
483
|
-
handler_ins.add_param('word', search_word)
|
484
|
-
when 'phone'
|
485
|
-
handler_ins.add_param('phone', search_word)
|
486
|
-
when 'email'
|
487
|
-
handler_ins.add_param('email', search_word)
|
488
|
-
when 'criteria'
|
489
|
-
handler_ins.add_param('criteria', search_word)
|
490
|
-
end
|
491
|
-
handler_ins.add_param('page', page)
|
492
|
-
handler_ins.add_param('per_page', per_page)
|
493
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
494
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
495
|
-
data_arr = bulk_api_response.response_json[Utility::APIConstants::DATA]
|
496
|
-
entity_helper = EntityAPIHandlerHelper.get_instance
|
497
|
-
record_ins_list = []
|
498
|
-
data_arr.each do |record_data|
|
499
|
-
zcrm_record = Operations::ZCRMRecord.get_instance(@module_instance.api_name, record_data['id'])
|
500
|
-
entity_helper.set_record_properties(zcrm_record, record_data)
|
501
|
-
record_ins_list.push(zcrm_record)
|
502
|
-
end
|
503
|
-
bulk_api_response.data = record_ins_list
|
504
|
-
bulk_api_response
|
505
|
-
end
|
506
|
-
|
507
|
-
def get_deleted_records(trashed_type, page, per_page)
|
508
|
-
handler_ins = APIHandler.get_instance
|
509
|
-
handler_ins.request_url_path = ''
|
510
|
-
handler_ins.request_url_path = @module_instance.api_name + '/deleted'
|
511
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
512
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
513
|
-
handler_ins.add_param('page', page)
|
514
|
-
handler_ins.add_param('per_page', per_page)
|
515
|
-
handler_ins.add_param('type', trashed_type) unless trashed_type.nil?
|
516
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
517
|
-
data_arr = bulk_api_response.response_json[Utility::APIConstants::DATA]
|
518
|
-
record_ins_list = []
|
519
|
-
massentity_helper = MassEntityAPIHandlerHelper.get_instance
|
520
|
-
data_arr.each do |record_data|
|
521
|
-
trash_record = Operations::ZCRMTrashRecord.get_instance(@module_instance.api_name, record_data['type'], record_data['id'])
|
522
|
-
massentity_helper.set_trash_record_properties(trash_record, record_data)
|
523
|
-
record_ins_list.push(trash_record)
|
524
|
-
end
|
525
|
-
bulk_api_response.data = record_ins_list
|
526
|
-
bulk_api_response
|
527
|
-
end
|
528
|
-
end
|
529
|
-
# THIS CLASS IS USED TO HANDLE MODULE RELATED FUNCTIONALITY
|
530
|
-
class ModuleAPIHandler < APIHandler
|
531
|
-
def initialize(module_instance)
|
532
|
-
@module_instance = module_instance
|
533
|
-
end
|
534
|
-
|
535
|
-
def self.get_instance(module_ins)
|
536
|
-
ModuleAPIHandler.new(module_ins)
|
537
|
-
end
|
538
|
-
|
539
|
-
def get_field(field_id)
|
540
|
-
if field_id.nil?
|
541
|
-
raise Utility::ZCRMException.get_instance('get_field', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'field id must be given', 'FIELD ID IS NOT PROVIDED')
|
542
|
-
end
|
543
|
-
|
544
|
-
handler_ins = APIHandler.get_instance
|
545
|
-
handler_ins.request_url_path = 'settings/fields/' + field_id.to_s
|
546
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
547
|
-
handler_ins.request_api_key = Utility::APIConstants::FIELDS
|
548
|
-
handler_ins.add_param('module', @module_instance.api_name)
|
549
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
550
|
-
module_api_helper = ModuleAPIHandlerHelper.get_instance
|
551
|
-
api_response.data = module_api_helper.get_zcrmfield(api_response.response_json[Utility::APIConstants::FIELDS][0])
|
552
|
-
api_response
|
553
|
-
end
|
554
|
-
|
555
|
-
def get_all_fields
|
556
|
-
handler_ins = APIHandler.get_instance
|
557
|
-
handler_ins.request_url_path = 'settings/fields'
|
558
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
559
|
-
handler_ins.request_api_key = Utility::APIConstants::FIELDS
|
560
|
-
handler_ins.add_param('module', @module_instance.api_name)
|
561
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
562
|
-
fields = bulk_api_response.response_json[Utility::APIConstants::FIELDS]
|
563
|
-
field_instance_arr = []
|
564
|
-
module_api_helper = ModuleAPIHandlerHelper.get_instance
|
565
|
-
fields.each do |field|
|
566
|
-
field_instance_arr.push(module_api_helper.get_zcrmfield(field))
|
567
|
-
end
|
568
|
-
bulk_api_response.data = field_instance_arr
|
569
|
-
bulk_api_response
|
570
|
-
end
|
571
|
-
|
572
|
-
def get_all_layouts
|
573
|
-
handler_ins = APIHandler.get_instance
|
574
|
-
handler_ins.request_url_path = 'settings/layouts'
|
575
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
576
|
-
handler_ins.request_api_key = Utility::APIConstants::LAYOUTS
|
577
|
-
handler_ins.add_param('module', @module_instance.api_name)
|
578
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
579
|
-
layouts = bulk_api_response.response_json[Utility::APIConstants::LAYOUTS]
|
580
|
-
layout_instance_arr = []
|
581
|
-
module_api_helper = ModuleAPIHandlerHelper.get_instance
|
582
|
-
layouts.each do |layout|
|
583
|
-
layout_instance_arr.push(module_api_helper.get_zcrmlayout(layout))
|
584
|
-
end
|
585
|
-
bulk_api_response.data = layout_instance_arr
|
586
|
-
bulk_api_response
|
587
|
-
end
|
588
|
-
|
589
|
-
def get_layout(layout_id)
|
590
|
-
if layout_id.nil?
|
591
|
-
raise Utility::ZCRMException.get_instance('get_layout', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'layout id must be given', 'LAYOUT ID IS NOT PROVIDED')
|
592
|
-
end
|
593
|
-
|
594
|
-
handler_ins = APIHandler.get_instance
|
595
|
-
handler_ins.request_url_path = 'settings/layouts/' + layout_id.to_s
|
596
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
597
|
-
handler_ins.request_api_key = Utility::APIConstants::LAYOUTS
|
598
|
-
handler_ins.add_param('module', @module_instance.api_name)
|
599
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
600
|
-
module_api_helper = ModuleAPIHandlerHelper.get_instance
|
601
|
-
api_response.data = module_api_helper.get_zcrmlayout(api_response.response_json[Utility::APIConstants::LAYOUTS][0])
|
602
|
-
api_response
|
603
|
-
end
|
604
|
-
|
605
|
-
def get_all_customviews
|
606
|
-
handler_ins = APIHandler.get_instance
|
607
|
-
handler_ins.request_url_path = 'settings/custom_views'
|
608
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
609
|
-
handler_ins.request_api_key = Utility::APIConstants::CUSTOM_VIEWS
|
610
|
-
handler_ins.add_param('module', @module_instance.api_name)
|
611
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
612
|
-
response_json = bulk_api_response.response_json
|
613
|
-
categories = response_json['info'].key?('translation') ? response_json['info']['translation'] : nil
|
614
|
-
customviews = response_json[Utility::APIConstants::CUSTOM_VIEWS]
|
615
|
-
customview_instances = []
|
616
|
-
meta_data_api_helper = MetaDataAPIHandlerHelper.get_instance
|
617
|
-
customviews.each do |customview|
|
618
|
-
customview_instances.push(meta_data_api_helper.get_zcrm_customview(customview, @module_instance.api_name, categories))
|
619
|
-
end
|
620
|
-
bulk_api_response.data = customview_instances
|
621
|
-
bulk_api_response
|
622
|
-
end
|
623
|
-
|
624
|
-
def get_customview(customview_id)
|
625
|
-
if customview_id.nil?
|
626
|
-
raise Utility::ZCRMException.get_instance('get_customview', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'custom view id must be given', 'CUSTOM VIEW ID IS NOT PROVIDED')
|
627
|
-
end
|
628
|
-
|
629
|
-
handler_ins = APIHandler.get_instance
|
630
|
-
handler_ins.request_url_path = 'settings/custom_views/' + customview_id.to_s
|
631
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
632
|
-
handler_ins.request_api_key = Utility::APIConstants::CUSTOM_VIEWS
|
633
|
-
handler_ins.add_param('module', @module_instance.api_name)
|
634
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
635
|
-
response_json = api_response.response_json
|
636
|
-
categories = response_json['info'].key?('translation') ? response_json['info']['translation'] : nil
|
637
|
-
meta_data_api_helper = MetaDataAPIHandlerHelper.get_instance
|
638
|
-
api_response.data = meta_data_api_helper.get_zcrm_customview(response_json[Utility::APIConstants::CUSTOM_VIEWS][0], @module_instance.api_name, categories)
|
639
|
-
api_response
|
640
|
-
end
|
641
|
-
|
642
|
-
def update_customview(customview_instance)
|
643
|
-
if customview_instance.nil?
|
644
|
-
raise Utility::ZCRMException.get_instance('update_customview', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'custom view instance must be given', 'NO CUSTOM VIEW INSTANCE PROVIDED')
|
645
|
-
end
|
646
|
-
|
647
|
-
handler_ins = APIHandler.get_instance
|
648
|
-
handler_ins.request_url_path = 'settings/custom_views/' + customview_instance.id.to_s
|
649
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_PUT
|
650
|
-
handler_ins.add_param('module', @module_instance.api_name)
|
651
|
-
module_api_helper = ModuleAPIHandlerHelper.get_instance
|
652
|
-
handler_ins.request_body = module_api_helper.construct_json_for_cv_update(customview_instance)
|
653
|
-
Request::APIRequest.get_instance(handler_ins).get_api_response
|
654
|
-
end
|
655
|
-
|
656
|
-
def get_all_relatedlists
|
657
|
-
handler_ins = APIHandler.get_instance
|
658
|
-
handler_ins.request_url_path = 'settings/related_lists'
|
659
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
660
|
-
handler_ins.add_param('module', @module_instance.api_name)
|
661
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
662
|
-
response_json = bulk_api_response.response_json
|
663
|
-
related_lists = response_json[Utility::APIConstants::RELATED_LISTS]
|
664
|
-
relatedlist_instances = []
|
665
|
-
module_api_helper = ModuleAPIHandlerHelper.get_instance
|
666
|
-
related_lists.each do |related_list|
|
667
|
-
relatedlist_instances.push(module_api_helper.get_zcrm_module_related_list(related_list))
|
668
|
-
end
|
669
|
-
bulk_api_response.data = relatedlist_instances
|
670
|
-
bulk_api_response
|
671
|
-
end
|
672
|
-
|
673
|
-
def get_relatedlist(relatedlist_id)
|
674
|
-
if relatedlist_id.nil?
|
675
|
-
raise Utility::ZCRMException.get_instance('get_relatedlist', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'Related list id must be given', 'NO RELATED LIST ID PROVIDED')
|
676
|
-
end
|
677
|
-
|
678
|
-
handler_ins = APIHandler.get_instance
|
679
|
-
handler_ins.request_url_path = 'settings/related_lists/' + relatedlist_id.to_s
|
680
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
681
|
-
handler_ins.add_param('module', @module_instance.api_name)
|
682
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
683
|
-
response_json = api_response.response_json
|
684
|
-
related_list = response_json[Utility::APIConstants::RELATED_LISTS][0]
|
685
|
-
module_api_helper = ModuleAPIHandlerHelper.get_instance
|
686
|
-
api_response.data = module_api_helper.get_zcrm_module_related_list(related_list)
|
687
|
-
api_response
|
688
|
-
end
|
689
|
-
end
|
690
|
-
# THIS CLASS SERVES THE MassEntityAPIHandler CLASS CONSTRUCTING JSON BODY AND INSTANCES
|
691
|
-
class MassEntityAPIHandlerHelper
|
692
|
-
def initialize; end
|
693
|
-
|
694
|
-
def self.get_instance
|
695
|
-
MassEntityAPIHandlerHelper.new
|
696
|
-
end
|
697
|
-
|
698
|
-
def set_trash_record_properties(trash_record_ins, record_data)
|
699
|
-
if record_data.key?('display_name')
|
700
|
-
trash_record_ins.display_name = record_data['display_name']
|
701
|
-
end
|
702
|
-
if record_data.key?('created_by')
|
703
|
-
unless record_data['created_by'].nil?
|
704
|
-
trash_record_ins.created_by = Operations::ZCRMUser.get_instance(record_data['created_by']['id'], record_data['created_by']['name'])
|
705
|
-
end
|
706
|
-
end
|
707
|
-
if record_data.key?('deleted_by')
|
708
|
-
unless record_data['deleted_by'].nil?
|
709
|
-
trash_record_ins.deleted_by = Operations::ZCRMUser.get_instance(record_data['deleted_by']['id'], record_data['deleted_by']['name'])
|
710
|
-
end
|
711
|
-
end
|
712
|
-
trash_record_ins.deleted_time = record_data['deleted_time']
|
713
|
-
end
|
714
|
-
|
715
|
-
def construct_json_for_massupdate(entityid_list, field_api_name, field_value)
|
716
|
-
input_json_arr = []
|
717
|
-
entityid_list.each do |entity_id|
|
718
|
-
each_json = {}
|
719
|
-
each_json['id'] = entity_id.to_s
|
720
|
-
each_json[field_api_name] = field_value
|
721
|
-
input_json_arr.push(each_json)
|
722
|
-
end
|
723
|
-
data_json = {}
|
724
|
-
data_json[Utility::APIConstants::DATA] = input_json_arr
|
725
|
-
data_json
|
726
|
-
end
|
727
|
-
end
|
728
|
-
# THIS CLASS SERVES THE EntityAPIHandler CLASS CONSTRUCTING JSON BODY AND INSTANCES
|
729
|
-
class EntityAPIHandlerHelper
|
730
|
-
def initialize; end
|
731
|
-
|
732
|
-
def self.get_instance
|
733
|
-
EntityAPIHandlerHelper.new
|
734
|
-
end
|
735
|
-
|
736
|
-
def get_zcrmrecord_as_json(zcrmrecord)
|
737
|
-
record_json = {}
|
738
|
-
apiname_vs_values = zcrmrecord.field_data
|
739
|
-
record_json['Owner'] = zcrmrecord.owner.id unless zcrmrecord.owner.nil?
|
740
|
-
unless zcrmrecord.layout.nil?
|
741
|
-
record_json['Layout'] = zcrmrecord.layout.id
|
742
|
-
end
|
743
|
-
unless zcrmrecord.line_items.empty?
|
744
|
-
record_json['Product_Details'] = get_line_item_json(zcrmrecord.line_items)
|
745
|
-
end
|
746
|
-
unless zcrmrecord.participants.empty?
|
747
|
-
record_json['Participants'] = get_participants_as_jsonarray(zcrmrecord)
|
748
|
-
end
|
749
|
-
unless zcrmrecord.price_details.empty?
|
750
|
-
record_json['Pricing_Details'] = get_price_details_as_jsonarray(zcrmrecord)
|
751
|
-
end
|
752
|
-
unless zcrmrecord.tax_list.empty?
|
753
|
-
record_json['Tax'] = get_tax_list_as_json(zcrmrecord)
|
754
|
-
end
|
755
|
-
unless zcrmrecord.tag_list.empty?
|
756
|
-
record_json['Tag'] = get_tag_list_as_json(zcrmrecord)
|
757
|
-
end
|
758
|
-
unless apiname_vs_values.empty?
|
759
|
-
apiname_vs_values.each do |key, value|
|
760
|
-
if value.is_a?(Operations::ZCRMRecord)
|
761
|
-
value = value.entity_id
|
762
|
-
elsif value.is_a?(Operations::ZCRMUser)
|
763
|
-
value = value.id
|
764
|
-
end
|
765
|
-
record_json.store(key, value)
|
766
|
-
end
|
767
|
-
end
|
768
|
-
record_json
|
769
|
-
end
|
770
|
-
|
771
|
-
def get_tag_list_as_json(zcrmrecord)
|
772
|
-
tag_list_json_arr = []
|
773
|
-
tag_list = zcrmrecord.tag_list
|
774
|
-
tag_list.each do |tag_ins|
|
775
|
-
tag = {}
|
776
|
-
tag['name'] = tag_ins.name unless tag_ins.name.nil?
|
777
|
-
tag['id'] = tag_ins.id unless tag_ins.id.nil?
|
778
|
-
tag_list_json_arr.push(tag)
|
779
|
-
end
|
780
|
-
tag_list_json_arr
|
781
|
-
end
|
782
|
-
|
783
|
-
def get_tax_list_as_json(zcrmrecord)
|
784
|
-
tax_list_json_arr = []
|
785
|
-
tax_list = zcrmrecord.tax_list
|
786
|
-
tax_list.each do |tax_ins|
|
787
|
-
tax_list_json_arr.push(tax_ins.name)
|
788
|
-
end
|
789
|
-
tax_list_json_arr
|
790
|
-
end
|
791
|
-
|
792
|
-
def get_price_details_as_jsonarray(zcrmrecord)
|
793
|
-
price_details_arr = []
|
794
|
-
price_details_list = zcrmrecord.price_details
|
795
|
-
price_details_list.each do |price_book_pricing_ins|
|
796
|
-
price_details_arr.push(get_zcrmprice_detail_as_json(price_book_pricing_ins))
|
797
|
-
end
|
798
|
-
price_details_arr
|
799
|
-
end
|
800
|
-
|
801
|
-
def get_zcrmprice_detail_as_json(price_book_pricing_ins)
|
802
|
-
price_detail_json = {}
|
803
|
-
unless price_book_pricing_ins.id.nil?
|
804
|
-
price_detail_json['id'] = price_book_pricing_ins.id
|
805
|
-
end
|
806
|
-
price_detail_json['discount'] = price_book_pricing_ins.discount
|
807
|
-
price_detail_json['to_range'] = price_book_pricing_ins.to_range
|
808
|
-
price_detail_json['from_range'] = price_book_pricing_ins.from_range
|
809
|
-
price_detail_json
|
810
|
-
end
|
811
|
-
|
812
|
-
def get_participants_as_jsonarray(zcrmrecord)
|
813
|
-
participants_arr = []
|
814
|
-
participants_list = zcrmrecord.participants
|
815
|
-
participants_list.each do |participant_ins|
|
816
|
-
participants_arr.push(get_zcrmparticipant_as_json(participant_ins))
|
817
|
-
end
|
818
|
-
participants_arr
|
819
|
-
end
|
820
|
-
|
821
|
-
def get_zcrmparticipant_as_json(participant_ins)
|
822
|
-
participant_json = {}
|
823
|
-
participant_json['participant'] = participant_ins.id
|
824
|
-
participant_json['type'] = participant_ins.type
|
825
|
-
participant_json['name'] = participant_ins.name
|
826
|
-
participant_json['Email'] = participant_ins.email
|
827
|
-
participant_json['invited'] = participant_ins.is_invited == true
|
828
|
-
participant_json['status'] = participant_ins.status
|
829
|
-
participant_json
|
830
|
-
end
|
831
|
-
|
832
|
-
def get_line_item_json(line_items_array)
|
833
|
-
line_items_as_json_array = []
|
834
|
-
line_items_array.each do |line_item|
|
835
|
-
line_item_data = {}
|
836
|
-
if line_item.quantity.nil?
|
837
|
-
raise Utility::ZCRMException.get_instance(@request_url_path, Utility::APIConstants::RESPONSECODE_BAD_REQUEST, "Mandatory Field 'quantity' is missing.", nil)
|
838
|
-
end
|
839
|
-
|
840
|
-
line_item_data['id'] = line_item.id unless line_item.id.nil?
|
841
|
-
unless line_item.product.nil?
|
842
|
-
line_item_data['product'] = line_item.product.entity_id
|
843
|
-
end
|
844
|
-
unless line_item.description.nil?
|
845
|
-
line_item_data['product_description'] = line_item.description
|
846
|
-
end
|
847
|
-
unless line_item.list_price.nil?
|
848
|
-
line_item_data['list_price'] = line_item.list_price
|
849
|
-
end
|
850
|
-
line_item_data['quantity'] = line_item.quantity
|
851
|
-
line_item_data['Discount'] = if line_item.discount_percentage.nil?
|
852
|
-
line_item.discount
|
853
|
-
else
|
854
|
-
line_item.discount_percentage + '%'
|
855
|
-
end
|
856
|
-
|
857
|
-
unless line_item.line_tax.nil?
|
858
|
-
line_taxes = line_item.line_tax
|
859
|
-
line_tax_array = []
|
860
|
-
line_taxes.each do |line_tax_instance|
|
861
|
-
tax = {}
|
862
|
-
tax['name'] = line_tax_instance.name
|
863
|
-
tax['value'] = line_tax_instance.value
|
864
|
-
tax['percentage'] = line_tax_instance.percentage
|
865
|
-
line_tax_array.push(tax)
|
866
|
-
line_item_data['line_tax'] = line_tax_array
|
867
|
-
end
|
868
|
-
end
|
869
|
-
line_items_as_json_array.push(line_item_data)
|
870
|
-
end
|
871
|
-
line_items_as_json_array
|
872
|
-
end
|
873
|
-
|
874
|
-
def get_zcrm_pricebook_pricing(price_details)
|
875
|
-
price_detail_ins = Operations::ZCRMPriceBookPricing.get_instance(price_details['id'])
|
876
|
-
price_detail_ins.discount = price_details['discount'].to_f
|
877
|
-
price_detail_ins.to_range = price_details['to_range'].to_f
|
878
|
-
price_detail_ins.from_range = price_details['from_range'].to_f
|
879
|
-
price_detail_ins
|
880
|
-
end
|
881
|
-
|
882
|
-
def get_zcrmparticipant(participant_details)
|
883
|
-
type = participant_details['type']
|
884
|
-
id = nil
|
885
|
-
email = nil
|
886
|
-
if participant_details.key?('Email')
|
887
|
-
id = participant_details['participant']
|
888
|
-
email = participant_details['Email']
|
889
|
-
else
|
890
|
-
email = participant_details['participant']
|
891
|
-
end
|
892
|
-
participant = Operations::ZCRMEventParticipant.get_instance(participant_details['type'], id)
|
893
|
-
participant.name = participant_details['name']
|
894
|
-
participant.email = email
|
895
|
-
participant.is_invited = participant_details['invited'] == true
|
896
|
-
participant.status = participant_details['status']
|
897
|
-
participant
|
898
|
-
end
|
899
|
-
|
900
|
-
def get_zcrminventory_line_item(line_item_details)
|
901
|
-
product_details = line_item_details['product']
|
902
|
-
line_item_instance = Operations::ZCRMInventoryLineItem.get_instance(line_item_details['id'])
|
903
|
-
product = Operations::ZCRMRecord.get_instance('Products', product_details['id'])
|
904
|
-
product.lookup_label = product_details['name']
|
905
|
-
if product_details.key?('Product_Code')
|
906
|
-
product.field_data['Product_Code'] = product_details['Product_Code']
|
907
|
-
end
|
908
|
-
line_item_instance.product = product
|
909
|
-
line_item_instance.description = line_item_details['product_description']
|
910
|
-
line_item_instance.quantity = line_item_details['quantity'].to_i
|
911
|
-
line_item_instance.list_price = line_item_details['list_price'].to_f
|
912
|
-
line_item_instance.total = line_item_details['total'].to_f
|
913
|
-
line_item_instance.discount = line_item_details['Discount'].to_f
|
914
|
-
line_item_instance.total_after_discount = line_item_details['total_after_discount'].to_f
|
915
|
-
line_item_instance.tax_amount = line_item_details['Tax'].to_f
|
916
|
-
line_taxes = line_item_details['line_tax']
|
917
|
-
unless line_taxes.nil?
|
918
|
-
line_taxes.each do |line_tax|
|
919
|
-
tax_instance = Operations::ZCRMTax.get_instance(line_tax['name'])
|
920
|
-
tax_instance.percentage = line_tax['percentage']
|
921
|
-
tax_instance.value = line_tax['value'].to_f
|
922
|
-
line_item_instance.line_tax.push(tax_instance)
|
923
|
-
end
|
924
|
-
end
|
925
|
-
line_item_instance.net_total = line_item_details['net_total'].to_f
|
926
|
-
line_item_instance
|
927
|
-
end
|
928
|
-
|
929
|
-
def get_zcrmsubform(sub_form_details)
|
930
|
-
sub_form_instance = Operations::ZCRMSubForm.get_instance(sub_form_details['id'])
|
931
|
-
sub_form_details.each do |key, value|
|
932
|
-
if key == 'Created_Time'
|
933
|
-
sub_form_instance.created_time = value
|
934
|
-
elsif key == 'Modified_Time'
|
935
|
-
sub_form_instance.modified_time = value
|
936
|
-
elsif key == 'Owner'
|
937
|
-
owner = Operations::ZCRMUser.get_instance(value['id'], value['name'])
|
938
|
-
sub_form_instance.owner = owner
|
939
|
-
elsif key == 'Layout'
|
940
|
-
layout = nil
|
941
|
-
unless value.nil?
|
942
|
-
layout = Operations::ZCRMLayout.get_instance(value['id'])
|
943
|
-
layout.name = value['name']
|
944
|
-
end
|
945
|
-
sub_form_instance.layout = layout
|
946
|
-
elsif key.start_with?('$')
|
947
|
-
sub_form_instance.properties.store(key.gsub('$', ''), value)
|
948
|
-
elsif value.is_a?(Hash) && !value.empty?
|
949
|
-
lookup_record = Operations::ZCRMRecord.get_instance(key, value.dig('id'))
|
950
|
-
lookup_record.name = value.key?('name') ? value.dig('name') : nil
|
951
|
-
sub_form_instance.field_data.store(key, lookup_record)
|
952
|
-
elsif value.is_a?(Array) && !value.empty?
|
953
|
-
arrayinstances = value
|
954
|
-
fieldarray = []
|
955
|
-
arrayinstances.each do |arrayinstance|
|
956
|
-
if arrayinstance.is_a?(Hash) && !arrayinstance.empty?
|
957
|
-
fieldarray.push(entity_api_handler_helper.get_zcrmsubform(arrayinstance))
|
958
|
-
else
|
959
|
-
fieldarray.push(arrayinstance)
|
960
|
-
end
|
961
|
-
end
|
962
|
-
sub_form_instance.field_data.store(key, fieldarray)
|
963
|
-
else
|
964
|
-
sub_form_instance.field_data.store(key, value)
|
965
|
-
end
|
966
|
-
end
|
967
|
-
sub_form_instance
|
968
|
-
end
|
969
|
-
|
970
|
-
def set_record_properties(zcrmrecord, response_hash)
|
971
|
-
entity_api_handler_helper = EntityAPIHandlerHelper.get_instance
|
972
|
-
response_hash.each do |key, value|
|
973
|
-
next if value.nil?
|
974
|
-
|
975
|
-
if key == 'id'
|
976
|
-
zcrmrecord.entity_id = value
|
977
|
-
elsif key == 'Product_Details' && Utility::APIConstants::INVENTORY_MODULES.include?(zcrmrecord.module_api_name)
|
978
|
-
line_items = value
|
979
|
-
line_items.each do |line_item|
|
980
|
-
zcrmrecord.line_items.push(entity_api_handler_helper.get_zcrminventory_line_item(line_item))
|
981
|
-
end
|
982
|
-
elsif key == 'Participants' && zcrmrecord.module_api_name == "Events"
|
983
|
-
participants = value
|
984
|
-
participants.each do |participant|
|
985
|
-
zcrmrecord.participants.push(entity_api_handler_helper.get_zcrmparticipant(participant))
|
986
|
-
end
|
987
|
-
elsif key == 'Pricing_Details' && zcrmrecord.module_api_name == "Price_Books"
|
988
|
-
price_details = value
|
989
|
-
price_details.each do |price_detail|
|
990
|
-
zcrmrecord.price_details.push(entity_api_handler_helper.get_zcrm_pricebook_pricing(price_detail))
|
991
|
-
end
|
992
|
-
elsif key == 'Created_By'
|
993
|
-
created_by = Operations::ZCRMUser.get_instance(value['id'], value['name'])
|
994
|
-
zcrmrecord.created_by = created_by
|
995
|
-
elsif key == 'Modified_By'
|
996
|
-
modified_by = Operations::ZCRMUser.get_instance(value['id'], value['name'])
|
997
|
-
zcrmrecord.modified_by = modified_by
|
998
|
-
elsif key == 'Created_Time'
|
999
|
-
zcrmrecord.created_time = value
|
1000
|
-
elsif key == 'Modified_Time'
|
1001
|
-
zcrmrecord.modified_time = value
|
1002
|
-
elsif key == 'Owner'
|
1003
|
-
owner = Operations::ZCRMUser.get_instance(value['id'], value['name'])
|
1004
|
-
zcrmrecord.owner = owner
|
1005
|
-
elsif key == 'Layout'
|
1006
|
-
layout = nil
|
1007
|
-
unless value.nil?
|
1008
|
-
layout = Operations::ZCRMLayout.get_instance(value['id'])
|
1009
|
-
layout.name = value['name']
|
1010
|
-
end
|
1011
|
-
zcrmrecord.layout = layout
|
1012
|
-
elsif (key == 'Handler') && !value.nil?
|
1013
|
-
handler = Operations::ZCRMUser.get_instance(value['id'], value['name'])
|
1014
|
-
zcrmrecord.field_data.store(key, handler)
|
1015
|
-
elsif (key == 'Tax') && value.is_a?(Array) && !value.empty?
|
1016
|
-
if value.is_a?(Array) && !value.empty?
|
1017
|
-
value.each do |tax_name|
|
1018
|
-
tax_ins = Operations::ZCRMTax.get_instance(tax_name)
|
1019
|
-
zcrmrecord.tax_list.push(tax_ins)
|
1020
|
-
end
|
1021
|
-
end
|
1022
|
-
elsif key == 'Tag'
|
1023
|
-
if value.is_a?(Array) && !value.empty?
|
1024
|
-
value.each do |tag|
|
1025
|
-
tag_ins = Operations::ZCRMTag.get_instance(tag['id'], tag['name'])
|
1026
|
-
zcrmrecord.tag_list.push(tag_ins)
|
1027
|
-
end
|
1028
|
-
end
|
1029
|
-
elsif (key == '$line_tax') && value.is_a?(Array) && !value.empty?
|
1030
|
-
value.each do |line_tax|
|
1031
|
-
tax_ins = Operations::ZCRMTax.get_instance(line_tax['name'])
|
1032
|
-
tax_ins.percentage = line_tax['percentage']
|
1033
|
-
tax_ins.value = line_tax['value']
|
1034
|
-
zcrmrecord.tax_list.push(tax_ins)
|
1035
|
-
end
|
1036
|
-
elsif key.start_with?('$')
|
1037
|
-
zcrmrecord.properties.store(key.gsub('$', ''), value)
|
1038
|
-
elsif key == 'Remind_At'
|
1039
|
-
zcrmrecord.field_data.store(key, value)
|
1040
|
-
elsif key == 'Recurring_Activity'
|
1041
|
-
zcrmrecord.field_data.store(key, value)
|
1042
|
-
elsif value.is_a?(Hash) && !value.empty?
|
1043
|
-
lookup_record = Operations::ZCRMRecord.get_instance(key, value.dig('id'))
|
1044
|
-
lookup_record.name = value.key?('name') ? value.dig('name') : nil
|
1045
|
-
zcrmrecord.field_data.store(key, lookup_record)
|
1046
|
-
elsif value.is_a?(Array) && !value.empty?
|
1047
|
-
arrayinstances = value
|
1048
|
-
fieldarray = []
|
1049
|
-
arrayinstances.each do |arrayinstance|
|
1050
|
-
if arrayinstance.is_a?(Hash) && !arrayinstance.empty?
|
1051
|
-
fieldarray.push(entity_api_handler_helper.get_zcrmsubform(arrayinstance))
|
1052
|
-
else
|
1053
|
-
fieldarray.push(arrayinstance)
|
1054
|
-
end
|
1055
|
-
end
|
1056
|
-
zcrmrecord.field_data.store(key, fieldarray)
|
1057
|
-
else
|
1058
|
-
zcrmrecord.field_data.store(key, value)
|
1059
|
-
end
|
1060
|
-
end
|
1061
|
-
end
|
1062
|
-
end
|
1063
|
-
# THIS CLASS SERVES THE ModuleAPIHandler CLASS CONSTRUCTING JSON BODY AND INSTANCES
|
1064
|
-
class ModuleAPIHandlerHelper
|
1065
|
-
def initialize; end
|
1066
|
-
|
1067
|
-
def self.get_instance
|
1068
|
-
ModuleAPIHandlerHelper.new
|
1069
|
-
end
|
1070
|
-
|
1071
|
-
def construct_json_for_cv_update(customview_instance)
|
1072
|
-
cv_settings = {}
|
1073
|
-
unless customview_instance.sort_by.nil?
|
1074
|
-
field_ins = customview_instance.sort_by
|
1075
|
-
field_details={}
|
1076
|
-
unless field_ins.id.nil?
|
1077
|
-
field_details['id']=field_ins.id
|
1078
|
-
end
|
1079
|
-
|
1080
|
-
unless field_ins.api_name.nil?
|
1081
|
-
field_details['api_name']=field_ins.api_name
|
1082
|
-
end
|
1083
|
-
cv_settings['sort_by'] = field_details
|
1084
|
-
end
|
1085
|
-
unless customview_instance.sort_order.nil?
|
1086
|
-
cv_settings['sort_order'] = customview_instance.sort_order
|
1087
|
-
end
|
1088
|
-
input_json = {}
|
1089
|
-
input_json[Utility::APIConstants::CUSTOM_VIEWS] = [cv_settings]
|
1090
|
-
input_json
|
1091
|
-
end
|
1092
|
-
|
1093
|
-
def get_zcrm_module_related_list(relatedlist_prop)
|
1094
|
-
relatedlist_ins = Operations::ZCRMModuleRelatedList.get_instance(relatedlist_prop['api_name'])
|
1095
|
-
relatedlist_ins.id = relatedlist_prop['id']
|
1096
|
-
relatedlist_ins.module_apiname = relatedlist_prop['module']
|
1097
|
-
relatedlist_ins.display_label = relatedlist_prop['display_label']
|
1098
|
-
relatedlist_ins.name = relatedlist_prop['name']
|
1099
|
-
relatedlist_ins.type = relatedlist_prop['type']
|
1100
|
-
relatedlist_ins.href = relatedlist_prop['href']
|
1101
|
-
relatedlist_ins.is_visible = relatedlist_prop.key?('visible') ? relatedlist_prop['visible'] == true : nil
|
1102
|
-
relatedlist_ins.action = relatedlist_prop['action']
|
1103
|
-
relatedlist_ins.sequence_number = relatedlist_prop['sequence_number']
|
1104
|
-
relatedlist_ins
|
1105
|
-
end
|
1106
|
-
|
1107
|
-
def get_picklist_value_instance(picklist)
|
1108
|
-
picklist_ins = Operations::ZCRMPickListValue.get_instance
|
1109
|
-
picklist_ins.display_value = picklist['display_value']
|
1110
|
-
picklist_ins.actual_value = picklist['actual_value']
|
1111
|
-
if picklist.key?('sequence_number') && !picklist['sequence_number'].nil?
|
1112
|
-
picklist_ins.sequence_number = picklist['sequence_number']
|
1113
|
-
end
|
1114
|
-
picklist_ins.maps = picklist['maps'] if picklist.key?('maps')
|
1115
|
-
picklist_ins
|
1116
|
-
end
|
1117
|
-
|
1118
|
-
def get_multiselect_lookup_field_instance(multi_select_lookup)
|
1119
|
-
multiselect_lookup_field_instance = Operations::ZCRMMultiSelectLookupField.get_instance(multi_select_lookup['api_name'])
|
1120
|
-
multiselect_lookup_field_instance.id = multi_select_lookup['id']
|
1121
|
-
multiselect_lookup_field_instance.connected_module = multi_select_lookup['connected_module']
|
1122
|
-
multiselect_lookup_field_instance.linking_module = multi_select_lookup['linking_module']
|
1123
|
-
multiselect_lookup_field_instance.display_label = multi_select_lookup['display_label']
|
1124
|
-
multiselect_lookup_field_instance
|
1125
|
-
end
|
1126
|
-
|
1127
|
-
def get_lookup_field_instance(lookup_field_details)
|
1128
|
-
lookup_field_instance = Operations::ZCRMLookupField.get_instance(lookup_field_details['api_name'])
|
1129
|
-
lookup_field_instance.display_label = lookup_field_details['display_label']
|
1130
|
-
lookup_field_instance.id = lookup_field_details['id']
|
1131
|
-
lookup_field_instance.module_apiname = lookup_field_details['module']
|
1132
|
-
lookup_field_instance
|
1133
|
-
end
|
1134
|
-
|
1135
|
-
def get_zcrmlayout(layout_details)
|
1136
|
-
layout_instance = Operations::ZCRMLayout.get_instance(layout_details['id'])
|
1137
|
-
layout_instance.created_time = layout_details['created_time']
|
1138
|
-
layout_instance.modified_time = layout_details['modified_time']
|
1139
|
-
layout_instance.name = layout_details['name']
|
1140
|
-
layout_instance.is_visible = layout_details['visible'] == true
|
1141
|
-
layout_instance.created_for = layout_details['created_for']
|
1142
|
-
unless layout_details['created_by'].nil?
|
1143
|
-
layout_instance.created_by = Operations::ZCRMUser.get_instance(layout_details['created_by']['id'], layout_details['created_by']['name'])
|
1144
|
-
end
|
1145
|
-
unless layout_details['modified_by'].nil?
|
1146
|
-
layout_instance.modified_by = Operations::ZCRMUser.get_instance(layout_details['modified_by']['id'], layout_details['modified_by']['name'])
|
1147
|
-
end
|
1148
|
-
accessible_profile_arr = layout_details['profiles']
|
1149
|
-
accessible_profile_instances = []
|
1150
|
-
unless accessible_profile_arr.nil?
|
1151
|
-
accessible_profile_arr.each do |profile|
|
1152
|
-
profile_ins = Operations::ZCRMProfile.get_instance(profile['id'], profile['name'])
|
1153
|
-
profile_ins.is_default = profile['default'] == true
|
1154
|
-
accessible_profile_instances.push(profile_ins)
|
1155
|
-
end
|
1156
|
-
end
|
1157
|
-
layout_instance.accessible_profiles = accessible_profile_instances
|
1158
|
-
layout_instance.sections = get_all_sections_of_layout(layout_details['sections'])
|
1159
|
-
layout_instance.status = layout_details['status']
|
1160
|
-
if layout_details.key?('convert_mapping')
|
1161
|
-
convert_modules = %w[Contacts Deals Accounts]
|
1162
|
-
|
1163
|
-
convert_modules.each do |convert_module|
|
1164
|
-
next unless layout_details['convert_mapping'].key?(convert_module)
|
1165
|
-
|
1166
|
-
convert_map = layout_details['convert_mapping'][convert_module]
|
1167
|
-
convert_map_ins = Operations::ZCRMLeadConvertMapping.get_instance(convert_map['name'], convert_map['id'])
|
1168
|
-
if convert_map.key?('fields')
|
1169
|
-
field_data = convert_map['fields']
|
1170
|
-
unless field_data.nil?
|
1171
|
-
field_data.each do |each_field_data|
|
1172
|
-
convert_mapping_field_ins = Operations::ZCRMLeadConvertMappingField.get_instance(each_field_data['api_name'], each_field_data['id'])
|
1173
|
-
convert_mapping_field_ins.field_label = each_field_data['field_label']
|
1174
|
-
convert_mapping_field_ins.is_required = each_field_data['required'] == true
|
1175
|
-
convert_map_ins.fields.push(convert_mapping_field_ins)
|
1176
|
-
end
|
1177
|
-
end
|
1178
|
-
end
|
1179
|
-
layout_instance.convert_mapping[convert_module] = convert_map_ins
|
1180
|
-
end
|
1181
|
-
end
|
1182
|
-
layout_instance
|
1183
|
-
end
|
1184
|
-
|
1185
|
-
def get_all_sections_of_layout(all_section_details)
|
1186
|
-
section_instances = []
|
1187
|
-
unless all_section_details.nil?
|
1188
|
-
all_section_details.each do |section|
|
1189
|
-
section_ins = Operations::ZCRMSection.get_instance(section['name'])
|
1190
|
-
section_ins.display_label = section['display_label']
|
1191
|
-
section_ins.column_count = section['column_count']
|
1192
|
-
section_ins.sequence_number = section['sequence_number']
|
1193
|
-
section_ins.fields = get_section_fields(section['fields'])
|
1194
|
-
section_ins.tab_traversal = section['tab_traversal']
|
1195
|
-
section_ins.is_subform_section = section['isSubformSection']
|
1196
|
-
section_ins.api_name = section['api_name']
|
1197
|
-
section_ins.properties = get_section_properties(section['properties'])
|
1198
|
-
section_instances.push(section_ins)
|
1199
|
-
end
|
1200
|
-
end
|
1201
|
-
section_instances
|
1202
|
-
end
|
1203
|
-
|
1204
|
-
def get_section_fields(fields)
|
1205
|
-
section_fields = []
|
1206
|
-
unless fields.nil?
|
1207
|
-
fields.each do |field|
|
1208
|
-
section_fields.push(get_zcrmfield(field))
|
1209
|
-
end
|
1210
|
-
end
|
1211
|
-
section_fields
|
1212
|
-
end
|
1213
|
-
|
1214
|
-
def get_section_properties(properties)
|
1215
|
-
section_properties = Operations::ZCRMSectionProperties.get_instance
|
1216
|
-
unless properties.nil?
|
1217
|
-
section_properties.reorder_rows = properties['reorder_rows']
|
1218
|
-
section_properties.tooltip = properties['tooltip']
|
1219
|
-
section_properties.maximum_rows = properties['maximum_rows']
|
1220
|
-
end
|
1221
|
-
section_properties
|
1222
|
-
end
|
1223
|
-
|
1224
|
-
def get_zcrmfield(field_details)
|
1225
|
-
field_instance = Operations::ZCRMField.get_instance(field_details['api_name'])
|
1226
|
-
field_instance.sequence_number = field_details.key?('sequence_number') ? field_details['sequence_number'].to_i : nil
|
1227
|
-
field_instance.id = field_details['id']
|
1228
|
-
field_instance.is_mandatory = field_details.key?('system_mandatory') ? field_details['system_mandatory'] == true : nil
|
1229
|
-
field_instance.default_value = field_details.key?('default_value') ? field_details['default_value'] : nil
|
1230
|
-
field_instance.is_custom_field = field_details.key?('custom_field') ? field_details['custom_field'] == true : nil
|
1231
|
-
field_instance.is_visible = field_details.key?('visible') ? field_details['visible'] == true : nil
|
1232
|
-
field_instance.field_label = field_details.key?('field_label') ? field_details['field_label'] : nil
|
1233
|
-
field_instance.length = field_details.key?('length') ? field_details['length'].to_i : nil
|
1234
|
-
field_instance.created_source = field_details.key?('created_source') ? field_details['created_source'] : nil
|
1235
|
-
field_instance.is_read_only = field_details.key?('read_only') ? field_details['read_only'] == true : nil
|
1236
|
-
field_instance.is_business_card_supported = field_details.key?('businesscard_supported') ? field_details['businesscard_supported'] == true : nil
|
1237
|
-
field_instance.data_type = field_details.key?('data_type') ? field_details['data_type'] : nil
|
1238
|
-
field_instance.convert_mapping = field_details.key?('convert_mapping') ? field_details['convert_mapping'] : nil
|
1239
|
-
field_instance.is_webhook = field_details.key?('webhook') ? field_details['webhook'] : nil
|
1240
|
-
field_instance.crypt = field_details.key?('crypt') ? field_details['crypt'] : nil
|
1241
|
-
field_instance.tooltip = field_details.key?('tooltip') ? field_details['tooltip'] : nil
|
1242
|
-
field_instance.is_field_read_only = field_details.key?('field_read_only') ? field_details['field_read_only'] : nil
|
1243
|
-
field_instance.association_details = field_details.key?('association_details') ? field_details['association_details'] : nil
|
1244
|
-
field_instance.subform = field_details.key?('subform') ? field_details['subform'] : nil
|
1245
|
-
field_instance.is_mass_update = field_details.key?('mass_update') ? field_details['mass_update'] : nil
|
1246
|
-
if field_details.key?('multiselectlookup') && !field_details['multiselectlookup'].empty?
|
1247
|
-
field_instance.multiselectlookup = get_multiselect_lookup_field_instance(field_details['multiselectlookup'])
|
1248
|
-
end
|
1249
|
-
if field_details.key?('view_type')
|
1250
|
-
viewtype_dict = field_details['view_type']
|
1251
|
-
field_layout_permissions = []
|
1252
|
-
field_layout_permissions.push('VIEW') if viewtype_dict['view']
|
1253
|
-
if viewtype_dict['quick_create']
|
1254
|
-
field_layout_permissions.push('QUICK_CREATE')
|
1255
|
-
end
|
1256
|
-
field_layout_permissions.push('CREATE') if viewtype_dict['create']
|
1257
|
-
field_layout_permissions.push('EDIT') if viewtype_dict['edit']
|
1258
|
-
field_instance.field_layout_permissions = field_layout_permissions
|
1259
|
-
end
|
1260
|
-
picklist_arr = field_details['pick_list_values']
|
1261
|
-
unless picklist_arr.empty?
|
1262
|
-
picklist_instance_arr = []
|
1263
|
-
picklist_arr.each do |picklist|
|
1264
|
-
picklist_instance_arr.push(get_picklist_value_instance(picklist))
|
1265
|
-
end
|
1266
|
-
field_instance.picklist_values = picklist_instance_arr
|
1267
|
-
end
|
1268
|
-
if field_details.key?('lookup') && !field_details['lookup'].empty?
|
1269
|
-
field_instance.lookup_field = get_lookup_field_instance(field_details['lookup'])
|
1270
|
-
end
|
1271
|
-
field_instance.is_unique_field = false
|
1272
|
-
field_instance.is_case_sensitive = false
|
1273
|
-
if field_details.key?('unique') && !field_details['unique'].empty?
|
1274
|
-
field_instance.is_unique_field = true
|
1275
|
-
field_instance.is_case_sensitive = field_details['unique']['casesensitive'] == true
|
1276
|
-
end
|
1277
|
-
if field_details.key?('decimal_place') && !field_details['decimal_place'].nil?
|
1278
|
-
field_instance.decimal_place = field_details['decimal_place']
|
1279
|
-
end
|
1280
|
-
if field_details.key?('json_type') && !field_details['json_type'].nil?
|
1281
|
-
field_instance.json_type = field_details['json_type']
|
1282
|
-
end
|
1283
|
-
field_instance.is_formula_field = false
|
1284
|
-
if field_details.key?('formula') && !field_details['formula'].empty?
|
1285
|
-
field_instance.is_formula_field = true
|
1286
|
-
field_instance.formula_return_type = field_details['formula']['return_type']
|
1287
|
-
field_instance.formula_expression = field_details['formula'].key?('expression') ? field_details['formula']['expression'] : nil
|
1288
|
-
end
|
1289
|
-
field_instance.is_currency_field = false
|
1290
|
-
if field_details.key?('currency') && !field_details['currency'].empty?
|
1291
|
-
field_instance.is_currency_field = true
|
1292
|
-
field_instance.precision = field_details['currency'].key?('precision') ? field_details['currency']['precision'].to_i : nil
|
1293
|
-
field_instance.rounding_option = field_details['currency'].key?('rounding_option') ? field_details['currency']['rounding_option'] : nil
|
1294
|
-
end
|
1295
|
-
field_instance.is_auto_number = false
|
1296
|
-
if field_details.key?('auto_number') && !field_details['auto_number'].empty?
|
1297
|
-
field_instance.is_auto_number = true
|
1298
|
-
field_instance.prefix = field_details['auto_number'].key?('prefix') ? field_details['auto_number']['prefix'] : nil
|
1299
|
-
field_instance.suffix = field_details['auto_number'].key?('suffix') ? field_details['auto_number']['suffix'] : nil
|
1300
|
-
field_instance.start_number = field_details['auto_number'].key?('start_number') ? field_details['auto_number']['start_number'] : nil
|
1301
|
-
end
|
1302
|
-
field_instance
|
1303
|
-
end
|
1304
|
-
end
|
1305
|
-
# THIS CLASS IS USED TO HANDLE META DATA RELATED FUNCTIONALITY
|
1306
|
-
class MetaDataAPIHandler < APIHandler
|
1307
|
-
def initialize; end
|
1308
|
-
|
1309
|
-
def self.get_instance
|
1310
|
-
MetaDataAPIHandler.new
|
1311
|
-
end
|
1312
|
-
|
1313
|
-
def get_all_modules
|
1314
|
-
handler_ins = APIHandler.get_instance
|
1315
|
-
handler_ins.request_url_path = 'settings/modules'
|
1316
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_GET
|
1317
|
-
handler_ins.request_api_key = ZCRMSDK::Utility::APIConstants::MODULES
|
1318
|
-
bulk_api_response = ZCRMSDK::Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
1319
|
-
modules_json = bulk_api_response.response_json.dig(ZCRMSDK::Utility::APIConstants::MODULES)
|
1320
|
-
module_ins_list = []
|
1321
|
-
module_helper = MetaDataAPIHandlerHelper.get_instance
|
1322
|
-
modules_json.each do |module_json|
|
1323
|
-
module_ins_list.push(module_helper.get_zcrmmodule(module_json))
|
1324
|
-
end
|
1325
|
-
bulk_api_response.data = module_ins_list
|
1326
|
-
bulk_api_response
|
1327
|
-
end
|
1328
|
-
|
1329
|
-
def get_module(module_api_name)
|
1330
|
-
if module_api_name.nil?
|
1331
|
-
raise Utility::ZCRMException.get_instance('get_module', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'module api name must be provided', 'NO MODULE API NAME PROVIDED')
|
1332
|
-
end
|
1333
|
-
|
1334
|
-
handler_ins = APIHandler.get_instance
|
1335
|
-
handler_ins.request_url_path = 'settings/modules/' + module_api_name
|
1336
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_GET
|
1337
|
-
handler_ins.request_api_key = ZCRMSDK::Utility::APIConstants::MODULES
|
1338
|
-
api_response = ZCRMSDK::Request::APIRequest.get_instance(handler_ins).get_api_response
|
1339
|
-
module_helper = MetaDataAPIHandlerHelper.get_instance
|
1340
|
-
module_json = api_response.response_json.dig(ZCRMSDK::Utility::APIConstants::MODULES)[0]
|
1341
|
-
api_response.data = module_helper.get_zcrmmodule(module_json)
|
1342
|
-
api_response
|
1343
|
-
end
|
1344
|
-
end
|
1345
|
-
# THIS CLASS SERVES THE MetaDataAPIHandler CLASS CONSTRUCTING JSON BODY AND INSTANCES
|
1346
|
-
class MetaDataAPIHandlerHelper
|
1347
|
-
def initialize; end
|
1348
|
-
|
1349
|
-
def self.get_instance
|
1350
|
-
MetaDataAPIHandlerHelper.new
|
1351
|
-
end
|
1352
|
-
|
1353
|
-
def get_relatedlist_property_instance(relatedlist_property)
|
1354
|
-
reltedlist_property_instance = Operations::ZCRMRelatedListProperties.get_instance
|
1355
|
-
reltedlist_property_instance.sort_by = relatedlist_property.key?('sort_by') ? relatedlist_property['sort_by'] : nil
|
1356
|
-
reltedlist_property_instance.sort_order = relatedlist_property.key?('sort_order') ? relatedlist_property['sort_order'] : nil
|
1357
|
-
reltedlist_property_instance.fields = relatedlist_property.key?('fields') ? relatedlist_property['fields'] : nil
|
1358
|
-
reltedlist_property_instance
|
1359
|
-
end
|
1360
|
-
|
1361
|
-
def get_zcrmmodule(module_details)
|
1362
|
-
crmmodule_instance = Operations::ZCRMModule.get_instance(module_details.dig(Utility::APIConstants::API_NAME))
|
1363
|
-
crmmodule_instance.is_viewable = module_details['viewable'] == true
|
1364
|
-
crmmodule_instance.is_creatable = module_details['creatable'] == true
|
1365
|
-
crmmodule_instance.is_convertable = module_details['convertable'] == true
|
1366
|
-
crmmodule_instance.is_editable = module_details['editable'] == true
|
1367
|
-
crmmodule_instance.is_deletable = module_details['deletable'] == true
|
1368
|
-
crmmodule_instance.web_link = module_details.key?('web_link') ? module_details['web_link'] : nil
|
1369
|
-
crmmodule_instance.singular_label = module_details['singular_label']
|
1370
|
-
crmmodule_instance.plural_label = module_details['plural_label']
|
1371
|
-
crmmodule_instance.id = module_details['id']
|
1372
|
-
crmmodule_instance.modified_time = module_details['modified_time']
|
1373
|
-
crmmodule_instance.is_inventory_template_supported = module_details['inventory_template_supported'] == true
|
1374
|
-
crmmodule_instance.is_api_supported = module_details['api_supported'] == true
|
1375
|
-
crmmodule_instance.is_scoring_supported = module_details['scoring_supported'] == true
|
1376
|
-
crmmodule_instance.module_name = module_details['module_name']
|
1377
|
-
crmmodule_instance.business_card_field_limit = module_details.key?('business_card_field_limit') ? module_details['business_card_field_limit'].to_i : nil
|
1378
|
-
crmmodule_instance.sequence_number = module_details.key?('sequence_number') ? module_details['sequence_number'] : nil
|
1379
|
-
crmmodule_instance.is_global_search_supported = module_details.key?('global_search_supported') ? module_details['global_search_supported'] == true : nil
|
1380
|
-
unless module_details['modified_by'].nil?
|
1381
|
-
crmmodule_instance.modified_by = Operations::ZCRMUser.get_instance(module_details['modified_by']['id'], module_details['modified_by']['name'])
|
1382
|
-
end
|
1383
|
-
|
1384
|
-
crmmodule_instance.is_custom_module = module_details['generated_type'] == 'custom'
|
1385
|
-
|
1386
|
-
if module_details.key?('business_card_fields')
|
1387
|
-
crmmodule_instance.business_card_fields = module_details['business_card_fields']
|
1388
|
-
end
|
1389
|
-
|
1390
|
-
profiles = module_details['profiles']
|
1391
|
-
unless profiles.nil?
|
1392
|
-
profiles.each do |profile|
|
1393
|
-
crmmodule_instance.profiles.push(Operations::ZCRMProfile.get_instance(profile['id'], profile['name']))
|
1394
|
-
end
|
1395
|
-
end
|
1396
|
-
|
1397
|
-
if module_details.key?('display_field') && !module_details['display_field'].nil?
|
1398
|
-
crmmodule_instance.display_field_name = module_details['display_field']
|
1399
|
-
end
|
1400
|
-
if module_details.key?('related_lists') && !module_details['related_lists'].nil?
|
1401
|
-
relatedlists = module_details['related_lists']
|
1402
|
-
relatedlist_instances = []
|
1403
|
-
unless relatedlists.nil?
|
1404
|
-
relatedlists.each do |relatedlist|
|
1405
|
-
module_relatedlist_ins = Operations::ZCRMModuleRelatedList.get_instance(relatedlist['api_name'])
|
1406
|
-
relatedlist_instances.push(module_relatedlist_ins.set_relatedlist_properties(relatedlist))
|
1407
|
-
end
|
1408
|
-
end
|
1409
|
-
crmmodule_instance.related_lists = relatedlist_instances
|
1410
|
-
end
|
1411
|
-
if module_details.key?('related_list_properties') && !module_details['related_list_properties'].nil?
|
1412
|
-
crmmodule_instance.related_list_properties = get_relatedlist_property_instance(module_details['related_list_properties'])
|
1413
|
-
end
|
1414
|
-
if module_details.key?('$properties') && !module_details['$properties'].nil?
|
1415
|
-
crmmodule_instance.properties = module_details['$properties']
|
1416
|
-
end
|
1417
|
-
if module_details.key?('per_page') && !module_details['per_page'].nil?
|
1418
|
-
crmmodule_instance.per_page = module_details['per_page'].to_i
|
1419
|
-
end
|
1420
|
-
if module_details.key?('search_layout_fields') && !module_details['search_layout_fields'].nil?
|
1421
|
-
crmmodule_instance.search_layout_fields = module_details['search_layout_fields']
|
1422
|
-
end
|
1423
|
-
if module_details.key?('custom_view') && !module_details['custom_view'].nil?
|
1424
|
-
meta_data_api_helper = MetaDataAPIHandlerHelper.get_instance
|
1425
|
-
crmmodule_instance.default_custom_view = meta_data_api_helper.get_zcrm_customview(module_details.dig('custom_view'), crmmodule_instance.api_name, nil)
|
1426
|
-
crmmodule_instance.default_custom_view_id = module_details['custom_view']['id']
|
1427
|
-
end
|
1428
|
-
if module_details.key?('territory') && !module_details['territory'].nil?
|
1429
|
-
crmmodule_instance.default_territory_id = module_details['territory']['id']
|
1430
|
-
crmmodule_instance.default_territory_name = module_details['territory']['name']
|
1431
|
-
end
|
1432
|
-
crmmodule_instance.is_kanban_view = module_details.key?('kanban_view') ? module_details['kanban_view'] == true : nil
|
1433
|
-
crmmodule_instance.is_filter_status = module_details.key?('filter_status') ? module_details['filter_status'] == true : nil
|
1434
|
-
crmmodule_instance.is_presence_sub_menu = module_details.key?('presence_sub_menu') ? module_details['presence_sub_menu_status'] == true : nil
|
1435
|
-
crmmodule_instance.arguments = module_details['arguments']
|
1436
|
-
crmmodule_instance.generated_type = module_details['generated_type']
|
1437
|
-
crmmodule_instance.is_quick_create = module_details['quick_create'] == true
|
1438
|
-
crmmodule_instance.is_kanban_view_supported = module_details.key?('kanban_view_supported') ? module_details['kanban_view_supported'] == true : nil
|
1439
|
-
crmmodule_instance.is_filter_supported = module_details.key?('filter_supported') ? module_details['filter_supported'] == true : nil
|
1440
|
-
unless module_details['parent_module'].nil?
|
1441
|
-
parent_module_instance = Operations::ZCRMModule.get_instance(module_details['parent_module']['api_name'])
|
1442
|
-
parent_module_instance.id = module_details['parent_module']['id']
|
1443
|
-
unless parent_module_instance.id.nil?
|
1444
|
-
crmmodule_instance.parent_module = parent_module_instance
|
1445
|
-
end
|
1446
|
-
end
|
1447
|
-
crmmodule_instance.is_feeds_required = module_details['feeds_required'] == true
|
1448
|
-
crmmodule_instance.is_email_template_support = module_details['emailTemplate_support'] == true
|
1449
|
-
crmmodule_instance.is_webform_supported = module_details['webform_supported'] == true
|
1450
|
-
crmmodule_instance.visibility = module_details['visibility']
|
1451
|
-
crmmodule_instance
|
1452
|
-
end
|
1453
|
-
|
1454
|
-
def construct_criteria(criteria)
|
1455
|
-
criteria_instance = Operations::ZCRMCustomViewCriteria.get_instance
|
1456
|
-
criteria_instance.field = criteria.key?('field') ? criteria['field'] : nil
|
1457
|
-
criteria_instance.comparator = criteria.key?('comparator') ? criteria['comparator'] : nil
|
1458
|
-
unless criteria['value'].nil?
|
1459
|
-
criteria_instance.index = $index
|
1460
|
-
criteria_instance.value = criteria['value']
|
1461
|
-
criteria_instance.pattern = $index.to_s
|
1462
|
-
$index = $index + 1
|
1463
|
-
criteria_instance.criteria = ' (' + criteria_instance.field .to_s + ':' + criteria_instance.comparator.to_s + ':' + criteria_instance.value.to_s + ') '
|
1464
|
-
end
|
1465
|
-
group_criteria = []
|
1466
|
-
unless criteria['group'].nil?
|
1467
|
-
i = 0
|
1468
|
-
while i < criteria['group'].count
|
1469
|
-
group_criteria.push(construct_criteria(criteria['group'][i]))
|
1470
|
-
i += 1
|
1471
|
-
end
|
1472
|
-
end
|
1473
|
-
criteria_instance.group = group_criteria unless group_criteria.nil?
|
1474
|
-
unless criteria['group_operator'].nil?
|
1475
|
-
criteria_instance.group_operator = criteria['group_operator']
|
1476
|
-
criteria_instance.criteria = '(' + group_criteria[0].criteria + criteria_instance.group_operator + group_criteria[1].criteria + ')'
|
1477
|
-
criteria_instance.pattern = '{' + group_criteria[0].pattern + criteria_instance.group_operator + group_criteria[1].pattern + '}'
|
1478
|
-
end
|
1479
|
-
criteria_instance
|
1480
|
-
end
|
1481
|
-
|
1482
|
-
def get_zcrm_customview(customview_details, module_api_name, categories = nil)
|
1483
|
-
customview_instance = Operations::ZCRMCustomView.get_instance(customview_details['id'], module_api_name)
|
1484
|
-
customview_instance.display_value = customview_details['display_value']
|
1485
|
-
customview_instance.is_default = customview_details['default'] == true
|
1486
|
-
customview_instance.name = customview_details['name']
|
1487
|
-
customview_instance.is_system_defined = customview_details['system_defined'] == true
|
1488
|
-
customview_instance.shared_details = customview_details['shared_details']
|
1489
|
-
customview_instance.system_name = customview_details['system_name']
|
1490
|
-
customview_instance.sort_by = customview_details.key?('sort_by') ? customview_details['sort_by'] : nil
|
1491
|
-
customview_instance.category = customview_details.key?('category') ? customview_details['category'] : nil
|
1492
|
-
customview_instance.fields = customview_details.key?('fields') ? customview_details['fields'] : nil
|
1493
|
-
customview_instance.favorite = customview_details.key?('favorite') ? customview_details['favorite'] : nil
|
1494
|
-
customview_instance.sort_order = customview_details.key?('sort_order') ? customview_details['sort_order'] : nil
|
1495
|
-
if customview_details.key?('criteria') && !customview_details['criteria'].nil?
|
1496
|
-
criteria = customview_details['criteria'] # entire criteria
|
1497
|
-
$index = 0
|
1498
|
-
customview_instance.criteria = construct_criteria(criteria)
|
1499
|
-
customview_instance.criteria_condition = customview_instance.criteria.criteria
|
1500
|
-
customview_instance.criteria_pattern = customview_instance.criteria.pattern
|
1501
|
-
end
|
1502
|
-
unless categories.nil?
|
1503
|
-
category_instances = []
|
1504
|
-
categories.each do |category|
|
1505
|
-
cv_category_instance = Operations::ZCRMCustomViewCategory.get_instance
|
1506
|
-
cv_category_instance.display_value = categories[category]
|
1507
|
-
cv_category_instance.actual_value = category
|
1508
|
-
category_instances.push(cv_category_instance)
|
1509
|
-
end
|
1510
|
-
customview_instance.categories = category_instances
|
1511
|
-
end
|
1512
|
-
if customview_details.key?('offline')
|
1513
|
-
customview_instance.is_off_line = customview_details['offline']
|
1514
|
-
end
|
1515
|
-
customview_instance
|
1516
|
-
end
|
1517
|
-
end
|
1518
|
-
# THIS CLASS IS USED TO HANDLE ORGANIZATION RELATED FUNCTIONALITY
|
1519
|
-
class OrganizationAPIHandler
|
1520
|
-
def initialize; end
|
1521
|
-
|
1522
|
-
def self.get_instance
|
1523
|
-
OrganizationAPIHandler.new
|
1524
|
-
end
|
1525
|
-
|
1526
|
-
def get_organization_details
|
1527
|
-
handler_ins = APIHandler.get_instance
|
1528
|
-
handler_ins.request_url_path = 'org'
|
1529
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
1530
|
-
handler_ins.request_api_key = Utility::APIConstants::ORG
|
1531
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
1532
|
-
org_json = api_response.response_json[Utility::APIConstants::ORG][0]
|
1533
|
-
org_api_helper = OrganizationAPIHandlerHelper.get_instance
|
1534
|
-
api_response.data = org_api_helper.get_zcrm_organization(org_json)
|
1535
|
-
api_response
|
1536
|
-
end
|
1537
|
-
|
1538
|
-
def get_all_roles
|
1539
|
-
handler_ins = APIHandler.get_instance
|
1540
|
-
handler_ins.request_url_path = 'settings/roles'
|
1541
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
1542
|
-
handler_ins.request_api_key = Utility::APIConstants::ROLES
|
1543
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
1544
|
-
roles = bulk_api_response.response_json[Utility::APIConstants::ROLES]
|
1545
|
-
role_instances = []
|
1546
|
-
org_api_helper = OrganizationAPIHandlerHelper.get_instance
|
1547
|
-
roles.each do |role|
|
1548
|
-
role_instances.push(org_api_helper.get_zcrm_role(role))
|
1549
|
-
end
|
1550
|
-
bulk_api_response.data = role_instances
|
1551
|
-
bulk_api_response
|
1552
|
-
end
|
1553
|
-
|
1554
|
-
def get_role(role_id)
|
1555
|
-
if role_id.nil?
|
1556
|
-
raise Utility::ZCRMException.get_instance('get_role', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'role id must be given', 'ROLE ID IS NOT PROVIDED')
|
1557
|
-
end
|
1558
|
-
|
1559
|
-
handler_ins = APIHandler.get_instance
|
1560
|
-
handler_ins.request_url_path = 'settings/roles/' + role_id.to_s
|
1561
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
1562
|
-
handler_ins.request_api_key = Utility::APIConstants::ROLES
|
1563
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
1564
|
-
role = api_response.response_json[Utility::APIConstants::ROLES][0]
|
1565
|
-
org_api_helper = OrganizationAPIHandlerHelper.get_instance
|
1566
|
-
api_response.data = org_api_helper.get_zcrm_role(role)
|
1567
|
-
api_response
|
1568
|
-
end
|
1569
|
-
|
1570
|
-
def get_all_profiles
|
1571
|
-
handler_ins = APIHandler.get_instance
|
1572
|
-
handler_ins.request_url_path = 'settings/profiles'
|
1573
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
1574
|
-
handler_ins.request_api_key = Utility::APIConstants::PROFILES
|
1575
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
1576
|
-
profiles = bulk_api_response.response_json[handler_ins.request_api_key]
|
1577
|
-
profile_instances = []
|
1578
|
-
org_api_helper = OrganizationAPIHandlerHelper.get_instance
|
1579
|
-
profiles.each do |profile|
|
1580
|
-
profile_instances.push(org_api_helper.get_zcrm_profile(profile))
|
1581
|
-
end
|
1582
|
-
bulk_api_response.data = profile_instances
|
1583
|
-
bulk_api_response
|
1584
|
-
end
|
1585
|
-
|
1586
|
-
def get_profile(profile_id)
|
1587
|
-
if profile_id.nil?
|
1588
|
-
raise Utility::ZCRMException.get_instance('get_profile', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'profile id must be given', 'PROFILE ID IS NOT PROVIDED')
|
1589
|
-
end
|
1590
|
-
|
1591
|
-
handler_ins = APIHandler.get_instance
|
1592
|
-
handler_ins.request_url_path = 'settings/profiles/' + profile_id.to_s
|
1593
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
1594
|
-
handler_ins.request_api_key = Utility::APIConstants::PROFILES
|
1595
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
1596
|
-
profile = api_response.response_json[handler_ins.request_api_key][0]
|
1597
|
-
org_api_helper = OrganizationAPIHandlerHelper.get_instance
|
1598
|
-
api_response.data = org_api_helper.get_zcrm_profile(profile)
|
1599
|
-
api_response
|
1600
|
-
end
|
1601
|
-
|
1602
|
-
def create_user(user_instance)
|
1603
|
-
if user_instance.nil?
|
1604
|
-
raise Utility::ZCRMException.get_instance('create_user', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'user instance must be given', 'USER INSTANCE IS NOT PROVIDED')
|
1605
|
-
end
|
1606
|
-
|
1607
|
-
handler_ins = APIHandler.get_instance
|
1608
|
-
handler_ins.request_url_path = 'users'
|
1609
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_POST
|
1610
|
-
handler_ins.request_api_key = Utility::APIConstants::USERS
|
1611
|
-
org_api_helper = OrganizationAPIHandlerHelper.get_instance
|
1612
|
-
handler_ins.request_body = org_api_helper.construct_json_from_user_instance(user_instance)
|
1613
|
-
Request::APIRequest.get_instance(handler_ins).get_api_response
|
1614
|
-
end
|
1615
|
-
|
1616
|
-
def update_user(user_instance)
|
1617
|
-
if user_instance.nil? || user_instance.id.nil?
|
1618
|
-
raise Utility::ZCRMException.get_instance('update_user', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'user instance and id must be given', 'USER INSTANCE OR ID IS NOT PROVIDED')
|
1619
|
-
end
|
1620
|
-
|
1621
|
-
handler_ins = APIHandler.get_instance
|
1622
|
-
handler_ins.request_url_path = 'users/' + user_instance.id.to_s
|
1623
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_PUT
|
1624
|
-
handler_ins.request_api_key = Utility::APIConstants::USERS
|
1625
|
-
org_api_helper = OrganizationAPIHandlerHelper.get_instance
|
1626
|
-
handler_ins.request_body = org_api_helper.construct_json_from_user_instance(user_instance)
|
1627
|
-
Request::APIRequest.get_instance(handler_ins).get_api_response
|
1628
|
-
end
|
1629
|
-
|
1630
|
-
def delete_user(user_id)
|
1631
|
-
if user_id.nil?
|
1632
|
-
raise Utility::ZCRMException.get_instance('delete_user', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'user id must be given', 'USER ID IS NOT PROVIDED')
|
1633
|
-
end
|
1634
|
-
|
1635
|
-
handler_ins = APIHandler.get_instance
|
1636
|
-
handler_ins.request_url_path = 'users/' + user_id.to_s
|
1637
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_DELETE
|
1638
|
-
handler_ins.request_api_key = Utility::APIConstants::USERS
|
1639
|
-
Request::APIRequest.get_instance(handler_ins).get_api_response
|
1640
|
-
end
|
1641
|
-
|
1642
|
-
def get_user(user_id)
|
1643
|
-
if user_id.nil?
|
1644
|
-
raise Utility::ZCRMException.get_instance('get_user', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'user id must be given', 'USER ID IS NOT PROVIDED')
|
1645
|
-
end
|
1646
|
-
|
1647
|
-
handler_ins = APIHandler.get_instance
|
1648
|
-
handler_ins.request_url_path = 'users/' + user_id.to_s
|
1649
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
1650
|
-
handler_ins.request_api_key = Utility::APIConstants::USERS
|
1651
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
1652
|
-
org_api_helper = OrganizationAPIHandlerHelper.get_instance
|
1653
|
-
api_response.data = org_api_helper.get_zcrm_user(api_response.response_json[Utility::APIConstants::USERS][0])
|
1654
|
-
api_response
|
1655
|
-
end
|
1656
|
-
|
1657
|
-
def get_all_users(page,per_page)
|
1658
|
-
get_users('AllUsers',page,per_page)
|
1659
|
-
end
|
1660
|
-
|
1661
|
-
def get_all_deactive_users(page,per_page)
|
1662
|
-
get_users('DeactiveUsers',page,per_page)
|
1663
|
-
end
|
1664
|
-
|
1665
|
-
def get_all_active_users(page,per_page)
|
1666
|
-
get_users('ActiveUsers',page,per_page)
|
1667
|
-
end
|
1668
|
-
|
1669
|
-
def get_all_confirmed_users(page,per_page)
|
1670
|
-
get_users('ConfirmedUsers',page,per_page)
|
1671
|
-
end
|
1672
|
-
|
1673
|
-
def get_all_not_confirmed_users(page,per_page)
|
1674
|
-
get_users('NotConfirmedUsers',page,per_page)
|
1675
|
-
end
|
1676
|
-
|
1677
|
-
def get_all_deleted_users(page,per_page)
|
1678
|
-
get_users('DeletedUsers',page,per_page)
|
1679
|
-
end
|
1680
|
-
|
1681
|
-
def get_all_active_confirmed_users(page,per_page)
|
1682
|
-
get_users('ActiveConfirmedUsers',page,per_page)
|
1683
|
-
end
|
1684
|
-
|
1685
|
-
def get_all_admin_users(page,per_page)
|
1686
|
-
get_users('AdminUsers',page,per_page)
|
1687
|
-
end
|
1688
|
-
|
1689
|
-
def get_all_active_confirmed_admin_users(page,per_page)
|
1690
|
-
get_users('ActiveConfirmedAdmins',page,per_page)
|
1691
|
-
end
|
1692
|
-
|
1693
|
-
def get_current_user(page = nil, per_page = nil)
|
1694
|
-
get_users('CurrentUser',page,per_page)
|
1695
|
-
end
|
1696
|
-
|
1697
|
-
def get_users(user_type = nil,page=1,per_page=200)
|
1698
|
-
handler_ins = APIHandler.get_instance
|
1699
|
-
handler_ins.add_param('type', user_type) unless user_type.nil?
|
1700
|
-
handler_ins.add_param('page', page)
|
1701
|
-
handler_ins.add_param('per_page', per_page)
|
1702
|
-
handler_ins.request_url_path = 'users'
|
1703
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
1704
|
-
handler_ins.request_api_key = Utility::APIConstants::USERS
|
1705
|
-
bulk_api_response = ZCRMSDK::Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
1706
|
-
users_json = bulk_api_response.response_json[Utility::APIConstants::USERS]
|
1707
|
-
user_instances = []
|
1708
|
-
org_api_helper = OrganizationAPIHandlerHelper.get_instance
|
1709
|
-
users_json.each do |user_details|
|
1710
|
-
user_instances.push(org_api_helper.get_zcrm_user(user_details))
|
1711
|
-
end
|
1712
|
-
bulk_api_response.data = user_instances
|
1713
|
-
bulk_api_response
|
1714
|
-
end
|
1715
|
-
|
1716
|
-
def search_users_by_criteria(criteria, type,page,per_page)
|
1717
|
-
if criteria.nil?
|
1718
|
-
raise Utility::ZCRMException.get_instance('search_users_by_criteria', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'criteria must be provided', 'NO CRITERIA PROVIDED')
|
1719
|
-
end
|
1720
|
-
|
1721
|
-
handler_ins = APIHandler.get_instance
|
1722
|
-
handler_ins.request_url_path = 'users/search'
|
1723
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
1724
|
-
handler_ins.request_api_key = Utility::APIConstants::USERS
|
1725
|
-
handler_ins.add_param('criteria', criteria)
|
1726
|
-
handler_ins.add_param('type', type) unless type.nil?
|
1727
|
-
handler_ins.add_param('page', page)
|
1728
|
-
handler_ins.add_param('per_page', per_page)
|
1729
|
-
bulk_api_response = ZCRMSDK::Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
1730
|
-
users_json = bulk_api_response.response_json[Utility::APIConstants::USERS]
|
1731
|
-
user_instances = []
|
1732
|
-
org_api_helper = OrganizationAPIHandlerHelper.get_instance
|
1733
|
-
users_json.each do |user_details|
|
1734
|
-
user_instances.push(org_api_helper.get_zcrm_user(user_details))
|
1735
|
-
end
|
1736
|
-
bulk_api_response.data = user_instances
|
1737
|
-
bulk_api_response
|
1738
|
-
end
|
1739
|
-
|
1740
|
-
def create_organization_taxes(org_tax_instances)
|
1741
|
-
if org_tax_instances.length > 100
|
1742
|
-
raise Utility::ZCRMException.get_instance('create_organization_taxes', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'org tax count must be less than or equals to 100', 'MORE ORG TAXES PROVIDED')
|
1743
|
-
end
|
1744
|
-
|
1745
|
-
if org_tax_instances.length < 1
|
1746
|
-
raise Utility::ZCRMException.get_instance('create_organization_taxes', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'org tax count must be at least 1', 'NO ORG TAX PROVIDED')
|
1747
|
-
end
|
1748
|
-
|
1749
|
-
handler_ins = APIHandler.get_instance
|
1750
|
-
handler_ins.request_url_path = 'org/taxes'
|
1751
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_POST
|
1752
|
-
handler_ins.request_api_key = Utility::APIConstants::TAXES
|
1753
|
-
org_api_helper = OrganizationAPIHandlerHelper.get_instance
|
1754
|
-
data_array = []
|
1755
|
-
org_tax_instances.each do |org_tax_instance|
|
1756
|
-
if org_tax_instance.id.nil?
|
1757
|
-
data_array.push(org_api_helper.get_zcrmorgtax_as_json(org_tax_instance))
|
1758
|
-
else
|
1759
|
-
raise Utility::ZCRMException.get_instance('Org_tax_Create', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'org tax id must be nil', 'ORG TAX ID PROVIDED')
|
1760
|
-
end
|
1761
|
-
end
|
1762
|
-
request_json = {}
|
1763
|
-
request_json[Utility::APIConstants::TAXES] = data_array
|
1764
|
-
handler_ins.request_body = request_json
|
1765
|
-
bulk_api_response = ZCRMSDK::Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
1766
|
-
bulk_api_response
|
1767
|
-
end
|
1768
|
-
|
1769
|
-
def update_organization_taxes(org_tax_instances)
|
1770
|
-
if org_tax_instances.length > 100
|
1771
|
-
raise Utility::ZCRMException.get_instance('update_organization_taxes', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'org tax count must be less than or equals to 100', 'MORE ORG TAXES PROVIDED')
|
1772
|
-
end
|
1773
|
-
|
1774
|
-
if org_tax_instances.length < 1
|
1775
|
-
raise Utility::ZCRMException.get_instance('update_organization_taxes', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'org tax count must be at least 1', 'NO ORG TAX PROVIDED')
|
1776
|
-
end
|
1777
|
-
|
1778
|
-
handler_ins = APIHandler.get_instance
|
1779
|
-
handler_ins.request_url_path = 'org/taxes'
|
1780
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_PUT
|
1781
|
-
handler_ins.request_api_key = Utility::APIConstants::TAXES
|
1782
|
-
org_api_helper = OrganizationAPIHandlerHelper.get_instance
|
1783
|
-
data_array = []
|
1784
|
-
org_tax_instances.each do |org_tax_instance|
|
1785
|
-
if org_tax_instance.id.nil?
|
1786
|
-
raise Utility::ZCRMException.get_instance('Org_tax_update', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'org tax id must not be nil', 'ORG TAX ID NOT PROVIDED')
|
1787
|
-
else
|
1788
|
-
data_array.push(org_api_helper.get_zcrmorgtax_as_json(org_tax_instance))
|
1789
|
-
end
|
1790
|
-
end
|
1791
|
-
|
1792
|
-
request_json = {}
|
1793
|
-
request_json[Utility::APIConstants::TAXES] = data_array
|
1794
|
-
handler_ins.request_body = request_json
|
1795
|
-
bulk_api_response = ZCRMSDK::Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
1796
|
-
bulk_api_response
|
1797
|
-
end
|
1798
|
-
|
1799
|
-
def delete_organization_taxes(org_tax_ids)
|
1800
|
-
if org_tax_ids.length > 100
|
1801
|
-
raise Utility::ZCRMException.get_instance('delete_organization_taxes', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'org tax count must be less than or equals to 100', 'MORE ORG TAX PROVIDED')
|
1802
|
-
end
|
1803
|
-
|
1804
|
-
if org_tax_ids.length < 1
|
1805
|
-
raise Utility::ZCRMException.get_instance('delete_organization_taxes', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'org tax count must be at least 1', 'NO ORG TAX PROVIDED')
|
1806
|
-
end
|
1807
|
-
|
1808
|
-
handler_ins = APIHandler.get_instance
|
1809
|
-
handler_ins.request_url_path = 'org/taxes'
|
1810
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_DELETE
|
1811
|
-
handler_ins.request_api_key = Utility::APIConstants::TAXES
|
1812
|
-
ids_as_string = ''
|
1813
|
-
org_tax_ids.each do |org_tax_id|
|
1814
|
-
ids_as_string += org_tax_id.to_s + ','
|
1815
|
-
end
|
1816
|
-
|
1817
|
-
handler_ins.add_param('ids', ids_as_string)
|
1818
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
1819
|
-
bulk_api_response
|
1820
|
-
end
|
1821
|
-
|
1822
|
-
def delete_organization_tax(orgtax_id)
|
1823
|
-
if orgtax_id.nil?
|
1824
|
-
raise Utility::ZCRMException.get_instance('delete_organization_tax', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'org tax id must be given', 'NO ORG TAX ID PROVIDED')
|
1825
|
-
end
|
1826
|
-
|
1827
|
-
handler_ins = APIHandler.get_instance
|
1828
|
-
handler_ins.request_url_path = 'org/taxes/' + orgtax_id.to_s
|
1829
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_DELETE
|
1830
|
-
handler_ins.request_api_key = Utility::APIConstants::TAXES
|
1831
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
1832
|
-
api_response
|
1833
|
-
end
|
1834
|
-
|
1835
|
-
def get_organization_taxes
|
1836
|
-
handler_ins = APIHandler.get_instance
|
1837
|
-
handler_ins.request_url_path = 'org/taxes'
|
1838
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
1839
|
-
handler_ins.request_api_key = Utility::APIConstants::TAXES
|
1840
|
-
bulk_api_response = ZCRMSDK::Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
1841
|
-
org_taxes_json = bulk_api_response.response_json[Utility::APIConstants::TAXES]
|
1842
|
-
org_taxes_instances = []
|
1843
|
-
org_api_helper = OrganizationAPIHandlerHelper.get_instance
|
1844
|
-
org_taxes_json.each do |org_tax|
|
1845
|
-
org_taxes_instances.push(org_api_helper.get_zcrm_org_tax_instance(org_tax))
|
1846
|
-
end
|
1847
|
-
bulk_api_response.data = org_taxes_instances
|
1848
|
-
bulk_api_response
|
1849
|
-
end
|
1850
|
-
|
1851
|
-
def get_organization_tax(org_tax_id)
|
1852
|
-
if org_tax_id.nil?
|
1853
|
-
raise Utility::ZCRMException.get_instance('get_organization_tax', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'org tax id must be given', 'NO ORG TAX ID PROVIDED')
|
1854
|
-
end
|
1855
|
-
|
1856
|
-
handler_ins = APIHandler.get_instance
|
1857
|
-
handler_ins.request_url_path = 'org/taxes/' + org_tax_id.to_s
|
1858
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
1859
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
1860
|
-
org_api_helper = OrganizationAPIHandlerHelper.get_instance
|
1861
|
-
api_response.data = org_api_helper.get_zcrm_org_tax_instance(api_response.response_json[Utility::APIConstants::TAXES][0])
|
1862
|
-
api_response
|
1863
|
-
end
|
1864
|
-
def get_notes(sort_by, sort_order, page, per_page)
|
1865
|
-
handler_ins = APIHandler.get_instance
|
1866
|
-
handler_ins.request_url_path = 'Notes'
|
1867
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_GET
|
1868
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
1869
|
-
handler_ins.add_param('page', page)
|
1870
|
-
handler_ins.add_param('per_page', per_page)
|
1871
|
-
handler_ins.add_param('sort_by', sort_by)unless sort_by.nil?
|
1872
|
-
handler_ins.add_param('sort_order', sort_order)unless sort_order.nil?
|
1873
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
1874
|
-
notes_json = bulk_api_response.response_json.dig(ZCRMSDK::Utility::APIConstants::DATA)
|
1875
|
-
notes_list = []
|
1876
|
-
notes_helper = RelatedListAPIHandlerHelper.get_instance
|
1877
|
-
notes_json.each do |note_json|
|
1878
|
-
record_ins=Operations::ZCRMRecord.get_instance(note_json['$se_module'], note_json['Parent_Id']['id'])
|
1879
|
-
note_ins = Operations::ZCRMNote.get_instance(record_ins,note_json['id'])
|
1880
|
-
notes_list.push(notes_helper.get_zcrm_note(note_json,note_ins))
|
1881
|
-
end
|
1882
|
-
bulk_api_response.data = notes_list
|
1883
|
-
bulk_api_response
|
1884
|
-
end
|
1885
|
-
def create_notes(note_instances)
|
1886
|
-
if note_instances.length > 100
|
1887
|
-
raise Utility::ZCRMException.get_instance('create_notes', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'note count must be less than or equals to 100', 'MORE NOTES PROVIDED')
|
1888
|
-
end
|
1889
|
-
|
1890
|
-
if note_instances.length < 1
|
1891
|
-
raise Utility::ZCRMException.get_instance('create_notes', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'note count must be at least 1', 'NO NOTES PROVIDED')
|
1892
|
-
end
|
1893
|
-
|
1894
|
-
handler_ins = APIHandler.get_instance
|
1895
|
-
handler_ins.request_url_path = 'Notes'
|
1896
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_POST
|
1897
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
1898
|
-
notes_api_helper = RelatedListAPIHandlerHelper.get_instance
|
1899
|
-
data_array = []
|
1900
|
-
note_instances.each do |note_instance|
|
1901
|
-
if note_instance.id.nil?
|
1902
|
-
data_array.push(notes_api_helper.get_zcrmnote_as_json(note_instance))
|
1903
|
-
else
|
1904
|
-
raise Utility::ZCRMException.get_instance('notes_Create', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'note id must be nil', 'NOTE ID PROVIDED')
|
1905
|
-
end
|
1906
|
-
end
|
1907
|
-
request_json = {}
|
1908
|
-
request_json[Utility::APIConstants::DATA] = data_array
|
1909
|
-
handler_ins.request_body = request_json
|
1910
|
-
bulk_api_response = ZCRMSDK::Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
1911
|
-
bulk_api_response
|
1912
|
-
end
|
1913
|
-
def delete_notes(note_ids)
|
1914
|
-
if note_ids.length > 100
|
1915
|
-
raise Utility::ZCRMException.get_instance('delete_notes', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'notes count must be less than or equals to 100', 'MORE NOTES PROVIDED')
|
1916
|
-
end
|
1917
|
-
|
1918
|
-
if note_ids.length < 1
|
1919
|
-
raise Utility::ZCRMException.get_instance('delete_notes', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'notes count must be at least 1', 'NO NOTES PROVIDED')
|
1920
|
-
end
|
1921
|
-
|
1922
|
-
handler_ins = APIHandler.get_instance
|
1923
|
-
handler_ins.request_url_path = 'Notes'
|
1924
|
-
handler_ins.request_method = Utility::APIConstants::REQUEST_METHOD_DELETE
|
1925
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
1926
|
-
ids_as_string = ''
|
1927
|
-
note_ids.each do |note_id|
|
1928
|
-
ids_as_string += note_id.to_s + ','
|
1929
|
-
end
|
1930
|
-
|
1931
|
-
handler_ins.add_param('ids', ids_as_string)
|
1932
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
1933
|
-
bulk_api_response
|
1934
|
-
end
|
1935
|
-
end
|
1936
|
-
# THIS CLASS SERVES THE OrganizationAPIHandler CLASS CONSTRUCTING JSON BODY AND INSTANCES
|
1937
|
-
class OrganizationAPIHandlerHelper
|
1938
|
-
def initialize; end
|
1939
|
-
|
1940
|
-
def self.get_instance
|
1941
|
-
OrganizationAPIHandlerHelper.new
|
1942
|
-
end
|
1943
|
-
|
1944
|
-
def get_zcrm_user_customizeinfo(customize_info)
|
1945
|
-
customize_info_instance = Operations::ZCRMUserCustomizeInfo.get_instance
|
1946
|
-
customize_info_instance.notes_desc = customize_info['notes_desc']
|
1947
|
-
customize_info_instance.is_to_show_right_panel = customize_info.key?('show_right_panel') ? customize_info['show_right_panel'] == true : nil
|
1948
|
-
customize_info_instance.is_bc_view = customize_info['bc_view']
|
1949
|
-
customize_info_instance.is_to_show_home = customize_info.key?('show_home') ? customize_info['show_home'] == true : nil
|
1950
|
-
customize_info_instance.is_to_show_detail_view = customize_info.key?('show_detail_view') ? customize_info['show_detail_view'] == true : nil
|
1951
|
-
customize_info_instance.unpin_recent_item = customize_info['unpin_recent_item']
|
1952
|
-
customize_info_instance
|
1953
|
-
end
|
1954
|
-
|
1955
|
-
def get_zcrm_org_tax_instance(org_tax)
|
1956
|
-
org_tax_instance = Operations::ZCRMOrgTax.get_instance(org_tax['id'], org_tax['name'])
|
1957
|
-
org_tax_instance.display_label = org_tax['display_label']
|
1958
|
-
org_tax_instance.value = org_tax['value']
|
1959
|
-
org_tax_instance
|
1960
|
-
end
|
1961
|
-
|
1962
|
-
def get_zcrm_user_theme(user_theme_info)
|
1963
|
-
user_theme_instance = Operations::ZCRMUserTheme.get_instance
|
1964
|
-
user_theme_instance.normal_tab_font_color = user_theme_info['normal_tab']['font_color']
|
1965
|
-
user_theme_instance.normal_tab_background = user_theme_info['normal_tab']['background']
|
1966
|
-
user_theme_instance.selected_tab_font_color = user_theme_info['selected_tab']['font_color']
|
1967
|
-
user_theme_instance.selected_tab_background = user_theme_info['selected_tab']['background']
|
1968
|
-
user_theme_instance.new_background = user_theme_info['new_background']
|
1969
|
-
user_theme_instance.background = user_theme_info['background']
|
1970
|
-
user_theme_instance.screen = user_theme_info['screen']
|
1971
|
-
user_theme_instance.type = user_theme_info['type']
|
1972
|
-
user_theme_instance
|
1973
|
-
end
|
1974
|
-
|
1975
|
-
def get_zcrmorgtax_as_json(zcrmorgtax_instance)
|
1976
|
-
orgtax_as_json = {}
|
1977
|
-
unless zcrmorgtax_instance.id.nil?
|
1978
|
-
orgtax_as_json['id'] = zcrmorgtax_instance.id.to_s
|
1979
|
-
end
|
1980
|
-
unless zcrmorgtax_instance.name.nil?
|
1981
|
-
orgtax_as_json['name'] = zcrmorgtax_instance.name
|
1982
|
-
end
|
1983
|
-
unless zcrmorgtax_instance.display_label.nil?
|
1984
|
-
orgtax_as_json['display_label'] = zcrmorgtax_instance.display_label
|
1985
|
-
end
|
1986
|
-
unless zcrmorgtax_instance.value.nil?
|
1987
|
-
orgtax_as_json['value'] = zcrmorgtax_instance.value
|
1988
|
-
end
|
1989
|
-
unless zcrmorgtax_instance.sequence_number.nil?
|
1990
|
-
orgtax_as_json['sequence_number'] = zcrmorgtax_instance.sequence_number
|
1991
|
-
end
|
1992
|
-
orgtax_as_json
|
1993
|
-
end
|
1994
|
-
|
1995
|
-
def construct_json_from_user_instance(user_instance)
|
1996
|
-
user_info_json = {}
|
1997
|
-
unless user_instance.role.nil?
|
1998
|
-
user_info_json['role'] = user_instance.role.id.to_s
|
1999
|
-
end
|
2000
|
-
unless user_instance.profile.nil?
|
2001
|
-
user_info_json['profile'] = user_instance.profile.id.to_s
|
2002
|
-
end
|
2003
|
-
unless user_instance.country.nil?
|
2004
|
-
user_info_json['country'] = user_instance.country
|
2005
|
-
end
|
2006
|
-
user_info_json['name'] = user_instance.name unless user_instance.name.nil?
|
2007
|
-
user_info_json['city'] = user_instance.city unless user_instance.city.nil?
|
2008
|
-
unless user_instance.signature.nil?
|
2009
|
-
user_info_json['signature'] = user_instance.signature
|
2010
|
-
end
|
2011
|
-
unless user_instance.name_format.nil?
|
2012
|
-
user_info_json['name_format'] = user_instance.name_format
|
2013
|
-
end
|
2014
|
-
unless user_instance.language.nil?
|
2015
|
-
user_info_json['language'] = user_instance.language
|
2016
|
-
end
|
2017
|
-
unless user_instance.locale.nil?
|
2018
|
-
user_info_json['locale'] = user_instance.locale
|
2019
|
-
end
|
2020
|
-
unless user_instance.is_personal_account.nil?
|
2021
|
-
user_info_json['personal_account'] = user_instance.is_personal_account == true
|
2022
|
-
end
|
2023
|
-
unless user_instance.default_tab_group.nil?
|
2024
|
-
user_info_json['default_tab_group'] = user_instance.default_tab_group
|
2025
|
-
end
|
2026
|
-
unless user_instance.street.nil?
|
2027
|
-
user_info_json['street'] = user_instance.street
|
2028
|
-
end
|
2029
|
-
unless user_instance.alias_aka.nil?
|
2030
|
-
user_info_json['alias'] = user_instance.alias_aka
|
2031
|
-
end
|
2032
|
-
unless user_instance.state.nil?
|
2033
|
-
user_info_json['state'] = user_instance.state
|
2034
|
-
end
|
2035
|
-
unless user_instance.country_locale.nil?
|
2036
|
-
user_info_json['country_locale'] = user_instance.country_locale
|
2037
|
-
end
|
2038
|
-
user_info_json['fax'] = user_instance.fax unless user_instance.fax.nil?
|
2039
|
-
unless user_instance.first_name.nil?
|
2040
|
-
user_info_json['first_name'] = user_instance.first_name
|
2041
|
-
end
|
2042
|
-
unless user_instance.email.nil?
|
2043
|
-
user_info_json['email'] = user_instance.email
|
2044
|
-
end
|
2045
|
-
user_info_json['zip'] = user_instance.zip unless user_instance.zip.nil?
|
2046
|
-
unless user_instance.decimal_separator.nil?
|
2047
|
-
user_info_json['decimal_separator'] = user_instance.decimal_separator
|
2048
|
-
end
|
2049
|
-
unless user_instance.reporting_to.nil?
|
2050
|
-
user_info_json['Reporting_To'] = get_reporting_to_as_json(user_instance.reporting_to)
|
2051
|
-
end
|
2052
|
-
unless user_instance.website.nil?
|
2053
|
-
user_info_json['website'] = user_instance.website
|
2054
|
-
end
|
2055
|
-
unless user_instance.time_format.nil?
|
2056
|
-
user_info_json['time_format'] = user_instance.time_format
|
2057
|
-
end
|
2058
|
-
unless user_instance.mobile.nil?
|
2059
|
-
user_info_json['mobile'] = user_instance.mobile
|
2060
|
-
end
|
2061
|
-
unless user_instance.last_name.nil?
|
2062
|
-
user_info_json['last_name'] = user_instance.last_name
|
2063
|
-
end
|
2064
|
-
unless user_instance.time_zone.nil?
|
2065
|
-
user_info_json['time_zone'] = user_instance.time_zone
|
2066
|
-
end
|
2067
|
-
unless user_instance.phone.nil?
|
2068
|
-
user_info_json['phone'] = user_instance.phone
|
2069
|
-
end
|
2070
|
-
user_info_json['dob'] = user_instance.dob unless user_instance.dob.nil?
|
2071
|
-
unless user_instance.date_format.nil?
|
2072
|
-
user_info_json['date_format'] = user_instance.date_format
|
2073
|
-
end
|
2074
|
-
unless user_instance.status.nil?
|
2075
|
-
user_info_json['status'] = user_instance.status
|
2076
|
-
end
|
2077
|
-
custom_fields_data = user_instance.field_apiname_vs_value
|
2078
|
-
unless custom_fields_data.nil?
|
2079
|
-
custom_fields_data.each do |key|
|
2080
|
-
user_info_json[key] = custom_fields_data[key]
|
2081
|
-
end
|
2082
|
-
end
|
2083
|
-
Utility::CommonUtil.create_api_supported_input_json(user_info_json, Utility::APIConstants::USERS)
|
2084
|
-
end
|
2085
|
-
|
2086
|
-
def get_reporting_to_as_json(reporting_to_details)
|
2087
|
-
reporting_to = {}
|
2088
|
-
reporting_to['id'] = reporting_to_details.id
|
2089
|
-
reporting_to
|
2090
|
-
end
|
2091
|
-
|
2092
|
-
def get_zcrm_role(role_details)
|
2093
|
-
role_instance = Operations::ZCRMRole.get_instance(role_details['id'], role_details['name'])
|
2094
|
-
role_instance.display_label = role_details['display_label']
|
2095
|
-
role_instance.description = role_details['description']
|
2096
|
-
unless role_details['forecast_manager'].nil?
|
2097
|
-
role_instance.forecast_manager = Operations::ZCRMUser.get_instance(role_details['forecast_manager']['id'], role_details['forecast_manager']['name'])
|
2098
|
-
end
|
2099
|
-
role_instance.is_admin = role_details['admin_user'] == true
|
2100
|
-
role_instance.is_share_with_peers = role_details['share_with_peers'] == true
|
2101
|
-
if role_details.key?('reporting_to') && !role_details['reporting_to'].nil?
|
2102
|
-
role_instance.reporting_to = Operations::ZCRMUser.get_instance(role_details['reporting_to']['id'], role_details['reporting_to']['name'])
|
2103
|
-
end
|
2104
|
-
role_instance
|
2105
|
-
end
|
2106
|
-
|
2107
|
-
def get_zcrm_profile(profile_details)
|
2108
|
-
profile_instance = Operations::ZCRMProfile.get_instance(profile_details['id'], profile_details['name'])
|
2109
|
-
profile_instance.created_time = profile_details['created_time']
|
2110
|
-
profile_instance.modified_time = profile_details['modified_time']
|
2111
|
-
profile_instance.description = profile_details['description']
|
2112
|
-
profile_instance.category = profile_details['category']
|
2113
|
-
unless profile_details['modified_by'].nil?
|
2114
|
-
profile_instance.modified_by = Operations::ZCRMUser.get_instance(profile_details['modified_by']['id'], profile_details['modified_by']['name'])
|
2115
|
-
end
|
2116
|
-
unless profile_details['created_by'].nil?
|
2117
|
-
profile_instance.created_by = Operations::ZCRMUser.get_instance(profile_details['created_by']['id'], profile_details['created_by']['name'])
|
2118
|
-
end
|
2119
|
-
if profile_details.key?('permissions_details')
|
2120
|
-
permissions = profile_details['permissions_details']
|
2121
|
-
unless permissions.nil?
|
2122
|
-
permissions.each do |permission|
|
2123
|
-
permission_ins = Operations::ZCRMPermission.get_instance(permission['name'], permission['id'])
|
2124
|
-
permission_ins.display_label = permission['display_label']
|
2125
|
-
permission_ins.module_api_name = permission['module']
|
2126
|
-
permission_ins.is_enabled = permission['enabled'] == true
|
2127
|
-
profile_instance.permissions.push(permission_ins)
|
2128
|
-
end
|
2129
|
-
end
|
2130
|
-
end
|
2131
|
-
if profile_details.key?('sections')
|
2132
|
-
sections = profile_details['sections']
|
2133
|
-
unless sections.nil?
|
2134
|
-
sections.each do |section|
|
2135
|
-
profile_section_instance = Operations::ZCRMProfileSection.get_instance(section['name'])
|
2136
|
-
if section.key?('categories')
|
2137
|
-
categories = section['categories']
|
2138
|
-
unless categories.nil?
|
2139
|
-
categories.each do |category|
|
2140
|
-
category_ins = Operations::ZCRMProfileCategory.get_instance(category['name'])
|
2141
|
-
category_ins.display_label = category['display_label']
|
2142
|
-
category_ins.permission_ids = category['permissions_details']
|
2143
|
-
category_ins.module_api_name = category.key?('module') ? category['module'] : nil
|
2144
|
-
profile_section_instance.categories.push(category_ins)
|
2145
|
-
end
|
2146
|
-
end
|
2147
|
-
end
|
2148
|
-
profile_instance.sections.push(profile_section_instance)
|
2149
|
-
end
|
2150
|
-
end
|
2151
|
-
end
|
2152
|
-
profile_instance
|
2153
|
-
end
|
2154
|
-
|
2155
|
-
def get_zcrm_organization(org_details)
|
2156
|
-
org_instance = Org::ZCRMOrganization.get_instance(org_details['company_name'], org_details['id'])
|
2157
|
-
org_instance.alias_aka = org_details['alias']
|
2158
|
-
org_instance.city = org_details['city']
|
2159
|
-
org_instance.country = org_details['country']
|
2160
|
-
org_instance.country_code = org_details['country_code']
|
2161
|
-
org_instance.currency_locale = org_details['currency_locale']
|
2162
|
-
org_instance.currency_symbol = org_details['currency_symbol']
|
2163
|
-
org_instance.currency = org_details['currency']
|
2164
|
-
org_instance.description = org_details['description']
|
2165
|
-
org_instance.employee_count = org_details['employee_count']
|
2166
|
-
org_instance.zia_portal_id = org_details['zia_portal_id']
|
2167
|
-
org_instance.photo_id = org_details['photo_id']
|
2168
|
-
org_instance.fax = org_details['fax']
|
2169
|
-
org_instance.privacy_settings = org_details['privacy_settings']
|
2170
|
-
org_instance.is_gapps_enabled = org_details['gapps_enabled'] == true
|
2171
|
-
org_instance.iso_code = org_details['iso_code']
|
2172
|
-
org_instance.mc_status = org_details['mc_status']
|
2173
|
-
org_instance.mobile = org_details['mobile']
|
2174
|
-
org_instance.phone = org_details['phone']
|
2175
|
-
org_instance.primary_email = org_details['primary_email']
|
2176
|
-
org_instance.primary_zuid = org_details['primary_zuid']
|
2177
|
-
org_instance.state = org_details['state']
|
2178
|
-
org_instance.street = org_details['street']
|
2179
|
-
org_instance.time_zone = org_details['time_zone']
|
2180
|
-
org_instance.website = org_details['website']
|
2181
|
-
org_instance.zgid = org_details['zgid']
|
2182
|
-
org_instance.zip_code = org_details['zip']
|
2183
|
-
unless org_details['license_details'].nil?
|
2184
|
-
license_details = org_details['license_details']
|
2185
|
-
org_instance.is_paid_account = license_details['paid'] == true
|
2186
|
-
org_instance.paid_type = license_details['paid_type']
|
2187
|
-
org_instance.paid_expiry = license_details['paid_expiry']
|
2188
|
-
org_instance.trial_type = license_details['trial_type']
|
2189
|
-
org_instance.trial_expiry = license_details['trial_expiry']
|
2190
|
-
org_instance.users_license_purchased = license_details['users_license_purchased']
|
2191
|
-
end
|
2192
|
-
org_instance
|
2193
|
-
end
|
2194
|
-
|
2195
|
-
def get_zcrm_user(user_details)
|
2196
|
-
user_instance = Operations::ZCRMUser.get_instance(user_details['id'], user_details.key?('name') ? user_details['name'] : nil)
|
2197
|
-
user_instance.is_microsoft = user_details['microsoft'] == true
|
2198
|
-
user_instance.country = user_details.key?('country') ? user_details['country'] : nil
|
2199
|
-
user_instance.role = Operations::ZCRMRole.get_instance(user_details['role']['id'], user_details['role']['name'])
|
2200
|
-
if user_details.key?('customize_info')
|
2201
|
-
user_instance.customize_info = get_zcrm_user_customizeinfo(user_details['customize_info'])
|
2202
|
-
end
|
2203
|
-
user_instance.city = user_details['city']
|
2204
|
-
user_instance.signature = user_details.key?('signature') ? user_details['signature'] : nil
|
2205
|
-
user_instance.name_format = user_details.key?('name_format') ? user_details['name_format'] : nil
|
2206
|
-
user_instance.language = user_details['language']
|
2207
|
-
user_instance.locale = user_details['locale']
|
2208
|
-
user_instance.is_personal_account = user_details.key?('personal_account') ? user_details['personal_account'] == true : nil
|
2209
|
-
user_instance.default_tab_group = user_details.key?('default_tab_group') ? user_details['default_tab_group'] : nil
|
2210
|
-
user_instance.alias_aka = user_details['alias']
|
2211
|
-
user_instance.street = user_details['street']
|
2212
|
-
user_instance.city = user_details['city']
|
2213
|
-
if user_details.key?('theme')
|
2214
|
-
user_instance.theme = get_zcrm_user_theme(user_details['theme'])
|
2215
|
-
end
|
2216
|
-
user_instance.state = user_details['state']
|
2217
|
-
user_instance.country_locale = user_details['country_locale']
|
2218
|
-
user_instance.fax = user_details['fax']
|
2219
|
-
user_instance.first_name = user_details['first_name']
|
2220
|
-
user_instance.email = user_details['email']
|
2221
|
-
user_instance.zip = user_details['zip']
|
2222
|
-
user_instance.decimal_separator = user_details.key?('decimal_separator') ? user_details['decimal_separator'] : nil
|
2223
|
-
user_instance.website = user_details['website']
|
2224
|
-
user_instance.time_format = user_details['time_format']
|
2225
|
-
user_instance.profile = Operations::ZCRMProfile.get_instance(user_details['profile']['id'], user_details['profile']['name'])
|
2226
|
-
user_instance.mobile = user_details['mobile']
|
2227
|
-
user_instance.last_name = user_details['last_name']
|
2228
|
-
user_instance.time_zone = user_details['time_zone']
|
2229
|
-
user_instance.zuid = user_details['zuid']
|
2230
|
-
user_instance.is_confirm = user_details['confirm'] == true
|
2231
|
-
user_instance.full_name = user_details['full_name']
|
2232
|
-
user_instance.phone = user_details['phone']
|
2233
|
-
user_instance.dob = user_details['dob']
|
2234
|
-
user_instance.offset = user_details['offset']
|
2235
|
-
user_instance.date_format = user_details['date_format']
|
2236
|
-
user_instance.status = user_details['status']
|
2237
|
-
if user_details.key?('territories')
|
2238
|
-
user_instance.territories = user_details['territories']
|
2239
|
-
end
|
2240
|
-
if user_details.key?('Reporting_To')
|
2241
|
-
unless user_details['Reporting_To'].nil?
|
2242
|
-
reporting_to = user_details['Reporting_To']
|
2243
|
-
user_instance.reporting_to = Operations::ZCRMUser.get_instance(reporting_to['id'], reporting_to['name'])
|
2244
|
-
end
|
2245
|
-
end
|
2246
|
-
if user_details.key?('Currency')
|
2247
|
-
user_instance.currency = user_details['Currency']
|
2248
|
-
end
|
2249
|
-
created_by = user_details['created_by']
|
2250
|
-
modified_by = user_details['Modified_By']
|
2251
|
-
user_instance.created_by = Operations::ZCRMUser.get_instance(created_by['id'], created_by['name'])
|
2252
|
-
user_instance.modified_by = Operations::ZCRMUser.get_instance(modified_by['id'], modified_by['name'])
|
2253
|
-
user_instance.is_online = user_details['Isonline']
|
2254
|
-
user_instance.created_time = user_details['created_time']
|
2255
|
-
user_instance.modified_time = user_details['Modified_Time']
|
2256
|
-
user_instance
|
2257
|
-
end
|
2258
|
-
end
|
2259
|
-
# THIS CLASS IS USED TO HANDLE TAG RELATED FUNCTIONALITY
|
2260
|
-
class TagAPIHandler < APIHandler
|
2261
|
-
def initialize(module_instance = nil)
|
2262
|
-
@module_instance = module_instance
|
2263
|
-
end
|
2264
|
-
|
2265
|
-
def self.get_instance(module_ins = nil)
|
2266
|
-
TagAPIHandler.new(module_ins)
|
2267
|
-
end
|
2268
|
-
|
2269
|
-
def get_tags
|
2270
|
-
handler_ins = APIHandler.get_instance
|
2271
|
-
handler_ins.request_url_path = 'settings/tags'
|
2272
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_GET
|
2273
|
-
handler_ins.request_api_key = ZCRMSDK::Utility::APIConstants::TAG
|
2274
|
-
handler_ins.add_param('module', @module_instance.api_name)
|
2275
|
-
bulk_api_response = ZCRMSDK::Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
2276
|
-
tags_json = bulk_api_response.response_json.dig(ZCRMSDK::Utility::APIConstants::TAG)
|
2277
|
-
tag_list = []
|
2278
|
-
tag_helper = TagAPIHandlerHelper.get_instance
|
2279
|
-
tags_json.each do |tag_json|
|
2280
|
-
tag_ins = Operations::ZCRMTag.get_instance(tag_json['id'], tag_json['name'])
|
2281
|
-
tag_list.push(tag_helper.get_zcrmtag(tag_ins, tag_json))
|
2282
|
-
end
|
2283
|
-
bulk_api_response.data = tag_list
|
2284
|
-
bulk_api_response
|
2285
|
-
end
|
2286
|
-
|
2287
|
-
def get_tag_count(tag_id)
|
2288
|
-
if tag_id.nil?
|
2289
|
-
raise Utility::ZCRMException.get_instance('get_tag_count', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'Tag id must be given', 'NO TAG ID PROVIDED')
|
2290
|
-
end
|
2291
|
-
|
2292
|
-
handler_ins = APIHandler.get_instance
|
2293
|
-
tag_id = tag_id.to_s
|
2294
|
-
handler_ins.request_url_path = 'settings/tags/' + tag_id + '/actions/records_count'
|
2295
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_GET
|
2296
|
-
handler_ins.request_api_key = ZCRMSDK::Utility::APIConstants::TAG
|
2297
|
-
handler_ins.add_param('module', @module_instance.api_name)
|
2298
|
-
api_response = ZCRMSDK::Request::APIRequest.get_instance(handler_ins).get_api_response
|
2299
|
-
tag_json = api_response.response_json
|
2300
|
-
tag_ins = Operations::ZCRMTag.get_instance(tag_id)
|
2301
|
-
tag_helper = TagAPIHandlerHelper.get_instance
|
2302
|
-
api_response.data = tag_helper.get_zcrmtag(tag_ins, tag_json)
|
2303
|
-
api_response
|
2304
|
-
end
|
2305
|
-
|
2306
|
-
def create_tags(tag_list)
|
2307
|
-
if tag_list.length > 50
|
2308
|
-
raise Utility::ZCRMException.get_instance('create_tags', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'Tag count must be less than or equals to 50', 'MORE TAGS PROVIDED')
|
2309
|
-
end
|
2310
|
-
|
2311
|
-
if tag_list.length < 1
|
2312
|
-
raise Utility::ZCRMException.get_instance('create_tags', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'Tag count must at least be 1', 'NO TAGS PROVIDED')
|
2313
|
-
end
|
2314
|
-
|
2315
|
-
handler_ins = APIHandler.get_instance
|
2316
|
-
handler_ins.request_url_path = 'settings/tags'
|
2317
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_POST
|
2318
|
-
handler_ins.request_api_key = ZCRMSDK::Utility::APIConstants::TAG
|
2319
|
-
handler_ins.add_param('module', @module_instance.api_name)
|
2320
|
-
data_array = []
|
2321
|
-
tag_helper = TagAPIHandlerHelper.get_instance
|
2322
|
-
tag_list.each do |tag|
|
2323
|
-
if tag.id.nil?
|
2324
|
-
data_array.push(tag_helper.construct_json_for_tag(tag))
|
2325
|
-
else
|
2326
|
-
raise Utility::ZCRMException.get_instance('Tags_Create', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'tag id must be nil', 'TAG ID PROVIDED')
|
2327
|
-
end
|
2328
|
-
end
|
2329
|
-
request_json = {}
|
2330
|
-
request_json[Utility::APIConstants::TAG] = data_array
|
2331
|
-
handler_ins.request_body = request_json
|
2332
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
2333
|
-
created_tags = []
|
2334
|
-
entity_responses = bulk_api_response.bulk_entity_response
|
2335
|
-
length = entity_responses.length
|
2336
|
-
length -= 1
|
2337
|
-
(0..length).each do |i|
|
2338
|
-
entity_response_ins = entity_responses[i]
|
2339
|
-
next unless entity_response_ins.status == Utility::APIConstants::STATUS_SUCCESS
|
2340
|
-
|
2341
|
-
tag_create_details = entity_response_ins.details
|
2342
|
-
new_tag = tag_list[i]
|
2343
|
-
tag_helper = TagAPIHandlerHelper.get_instance
|
2344
|
-
tag_helper.get_zcrmtag(new_tag, tag_create_details)
|
2345
|
-
created_tags.push(new_tag)
|
2346
|
-
entity_response_ins.data = new_tag
|
2347
|
-
end
|
2348
|
-
bulk_api_response.data = created_tags
|
2349
|
-
bulk_api_response
|
2350
|
-
end
|
2351
|
-
|
2352
|
-
def update_tags(tag_list)
|
2353
|
-
if tag_list.length > 50
|
2354
|
-
raise Utility::ZCRMException.get_instance('update_tags', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'Tag count must be less than or equals to 50', 'MORE TAGS PROVIDED')
|
2355
|
-
end
|
2356
|
-
|
2357
|
-
if tag_list.length < 1
|
2358
|
-
raise Utility::ZCRMException.get_instance('update_tags', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'Tag count must at least be 1', 'NO TAGS PROVIDED')
|
2359
|
-
end
|
2360
|
-
|
2361
|
-
handler_ins = APIHandler.get_instance
|
2362
|
-
handler_ins.request_url_path = 'settings/tags'
|
2363
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_PUT
|
2364
|
-
handler_ins.request_api_key = ZCRMSDK::Utility::APIConstants::TAG
|
2365
|
-
handler_ins.add_param('module', @module_instance.api_name)
|
2366
|
-
data_array = []
|
2367
|
-
tag_helper = TagAPIHandlerHelper.get_instance
|
2368
|
-
tag_list.each do |tag|
|
2369
|
-
if !tag.id.nil?
|
2370
|
-
data_array.push(tag_helper.construct_json_for_tag(tag))
|
2371
|
-
else
|
2372
|
-
raise Utility::ZCRMException.get_instance('Tags_update', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'tag id must not be nil', 'TAG ID NOT PROVIDED')
|
2373
|
-
end
|
2374
|
-
end
|
2375
|
-
request_json = {}
|
2376
|
-
request_json[Utility::APIConstants::TAG] = data_array
|
2377
|
-
handler_ins.request_body = request_json
|
2378
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
2379
|
-
updated_tags = []
|
2380
|
-
entity_responses = bulk_api_response.bulk_entity_response
|
2381
|
-
length = entity_responses.length
|
2382
|
-
length -= 1
|
2383
|
-
(0..length).each do |i|
|
2384
|
-
entity_response_ins = entity_responses[i]
|
2385
|
-
next unless entity_response_ins.status == Utility::APIConstants::STATUS_SUCCESS
|
2386
|
-
|
2387
|
-
tag_update_details = entity_response_ins.details
|
2388
|
-
new_tag = tag_list[i]
|
2389
|
-
tag_helper = TagAPIHandlerHelper.get_instance
|
2390
|
-
tag_helper.get_zcrmtag(new_tag, tag_update_details)
|
2391
|
-
updated_tags.push(new_tag)
|
2392
|
-
entity_response_ins.data = new_tag
|
2393
|
-
end
|
2394
|
-
bulk_api_response.data = updated_tags
|
2395
|
-
bulk_api_response
|
2396
|
-
end
|
2397
|
-
|
2398
|
-
def add_tags_to_multiple_records(tag_list, record_list)
|
2399
|
-
if tag_list.length > 50
|
2400
|
-
raise Utility::ZCRMException.get_instance('add_tags_to_multiple_records', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'Tag count must be less than or equals to 50', 'MORE TAGS PROVIDED')
|
2401
|
-
end
|
2402
|
-
|
2403
|
-
if tag_list.length < 1
|
2404
|
-
raise Utility::ZCRMException.get_instance('add_tags_to_multiple_records', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'Tag count must at least be 1', 'NO TAGS PROVIDED')
|
2405
|
-
end
|
2406
|
-
|
2407
|
-
if record_list.length > 100
|
2408
|
-
raise Utility::ZCRMException.get_instance('add_tags_to_multiple_records', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'records count must be less than or equals to 100', 'MORE RECORDS PROVIDED')
|
2409
|
-
end
|
2410
|
-
|
2411
|
-
if record_list.length < 1
|
2412
|
-
raise Utility::ZCRMException.get_instance('add_tags_to_multiple_records', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'records must at least be 1', 'NO RECORDS PROVIDED')
|
2413
|
-
end
|
2414
|
-
|
2415
|
-
record_ids_as_string = ''
|
2416
|
-
record_list.each do |record_id|
|
2417
|
-
record_ids_as_string += record_id.to_s + ','
|
2418
|
-
end
|
2419
|
-
handler_ins = APIHandler.get_instance
|
2420
|
-
handler_ins.request_url_path = @module_instance.api_name + '/actions/add_tags'
|
2421
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_POST
|
2422
|
-
handler_ins.request_api_key = ZCRMSDK::Utility::APIConstants::DATA
|
2423
|
-
handler_ins.add_param('ids', record_ids_as_string)
|
2424
|
-
tag_names_as_string = ''
|
2425
|
-
tag_list.each do |tag_name|
|
2426
|
-
tag_names_as_string += tag_name.to_s + ','
|
2427
|
-
end
|
2428
|
-
handler_ins.add_param('tag_names', tag_names_as_string)
|
2429
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
2430
|
-
entity_responses = bulk_api_response.bulk_entity_response
|
2431
|
-
length = entity_responses.length
|
2432
|
-
length -= 1
|
2433
|
-
records = []
|
2434
|
-
(0..length).each do |i|
|
2435
|
-
entity_response_ins = entity_responses[i]
|
2436
|
-
next unless entity_response_ins.status == Utility::APIConstants::STATUS_SUCCESS
|
2437
|
-
tag_added_details = entity_response_ins.details
|
2438
|
-
record = Operations::ZCRMRecord.get_instance(@module_instance.api_name, tag_added_details['id'])
|
2439
|
-
tag_added_details['tags'].each do |tag_name|
|
2440
|
-
record.tag_list.push(Operations::ZCRMTag.get_instance(nil, tag_name))
|
2441
|
-
end
|
2442
|
-
records.push(record)
|
2443
|
-
entity_response_ins.data = record
|
2444
|
-
end
|
2445
|
-
bulk_api_response.data = records
|
2446
|
-
bulk_api_response
|
2447
|
-
end
|
2448
|
-
|
2449
|
-
def remove_tags_from_multiple_records(tag_list, record_list)
|
2450
|
-
if tag_list.length > 50
|
2451
|
-
raise Utility::ZCRMException.get_instance('remove_tags_from_multiple_records', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'Tag count must be less than or equals to 50', 'MORE TAGS PROVIDED')
|
2452
|
-
end
|
2453
|
-
|
2454
|
-
if tag_list.length < 1
|
2455
|
-
raise Utility::ZCRMException.get_instance('remove_tags_from_multiple_records', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'Tag count must at least be 1', 'NO TAGS PROVIDED')
|
2456
|
-
end
|
2457
|
-
|
2458
|
-
if record_list.length > 100
|
2459
|
-
raise Utility::ZCRMException.get_instance('remove_tags_from_multiple_records', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'records count must be less than or equals to 100', 'MORE RECORDS PROVIDED')
|
2460
|
-
end
|
2461
|
-
|
2462
|
-
if record_list.length < 1
|
2463
|
-
raise Utility::ZCRMException.get_instance('remove_tags_from_multiple_records', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'records must at least be 1', 'NO RECORDS PROVIDED')
|
2464
|
-
end
|
2465
|
-
|
2466
|
-
record_ids_as_string = ''
|
2467
|
-
record_list.each do |record_id|
|
2468
|
-
record_ids_as_string += record_id.to_s + ','
|
2469
|
-
end
|
2470
|
-
|
2471
|
-
handler_ins = APIHandler.get_instance
|
2472
|
-
handler_ins.request_url_path = @module_instance.api_name + '/actions/remove_tags'
|
2473
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_POST
|
2474
|
-
handler_ins.request_api_key = ZCRMSDK::Utility::APIConstants::DATA
|
2475
|
-
handler_ins.add_param('ids', record_ids_as_string)
|
2476
|
-
tag_names_as_string = ''
|
2477
|
-
tag_list.each do |tag_name|
|
2478
|
-
tag_names_as_string += tag_name.to_s + ','
|
2479
|
-
end
|
2480
|
-
|
2481
|
-
handler_ins.add_param('tag_names', tag_names_as_string)
|
2482
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
2483
|
-
entity_responses = bulk_api_response.bulk_entity_response
|
2484
|
-
length = entity_responses.length
|
2485
|
-
length -= 1
|
2486
|
-
records = []
|
2487
|
-
(0..length).each do |i|
|
2488
|
-
entity_response_ins = entity_responses[i]
|
2489
|
-
next unless entity_response_ins.status == Utility::APIConstants::STATUS_SUCCESS
|
2490
|
-
|
2491
|
-
tag_added_details = entity_response_ins.details
|
2492
|
-
record = Operations::ZCRMRecord.get_instance(@module_instance.api_name, tag_added_details['id'])
|
2493
|
-
tag_added_details['tags'].each do |tag_name|
|
2494
|
-
record.tag_list.push(Operations::ZCRMTag.get_instance(nil, tag_name))
|
2495
|
-
end
|
2496
|
-
records.push(record)
|
2497
|
-
entity_response_ins.data = record
|
2498
|
-
end
|
2499
|
-
bulk_api_response.data = records
|
2500
|
-
bulk_api_response
|
2501
|
-
end
|
2502
|
-
|
2503
|
-
def add_tags(record, tag_list)
|
2504
|
-
if tag_list.length > 10
|
2505
|
-
raise Utility::ZCRMException.get_instance('add_tags', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'Tag count must be less than or equals to 10', 'MORE TAGS PROVIDED')
|
2506
|
-
end
|
2507
|
-
|
2508
|
-
if tag_list.length < 1
|
2509
|
-
raise Utility::ZCRMException.get_instance('add_tags', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'Tag count must at least be 1', 'NO TAGS PROVIDED')
|
2510
|
-
end
|
2511
|
-
|
2512
|
-
if record.nil? || record.entity_id.nil?
|
2513
|
-
raise Utility::ZCRMException.get_instance('add_tags', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, ' record instance and record id must be given', 'RECORD or RECORD ID NOT PROVIDED')
|
2514
|
-
end
|
2515
|
-
|
2516
|
-
handler_ins = APIHandler.get_instance
|
2517
|
-
handler_ins.request_url_path = record.module_api_name + '/' + record.entity_id + '/actions/add_tags'
|
2518
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_POST
|
2519
|
-
handler_ins.request_api_key = ZCRMSDK::Utility::APIConstants::DATA
|
2520
|
-
tag_names_as_string = ''
|
2521
|
-
tag_list.each do |tag_name|
|
2522
|
-
tag_names_as_string += tag_name.to_s + ','
|
2523
|
-
end
|
2524
|
-
handler_ins.add_param('tag_names', tag_names_as_string)
|
2525
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
2526
|
-
response_details = api_response.response_json.dig(Utility::APIConstants::DATA, 0, 'details')
|
2527
|
-
response_details['tags'].each do |tag_name|
|
2528
|
-
record.tag_list.push(Operations::ZCRMTag.get_instance(nil, tag_name))
|
2529
|
-
end
|
2530
|
-
api_response.data = record
|
2531
|
-
api_response
|
2532
|
-
end
|
2533
|
-
|
2534
|
-
def remove_tags(record, tag_list)
|
2535
|
-
if tag_list.length > 10
|
2536
|
-
raise Utility::ZCRMException.get_instance('remove_tags', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'Tag count must be less than or equals to 10', 'MORE TAGS PROVIDED')
|
2537
|
-
end
|
2538
|
-
|
2539
|
-
if tag_list.length < 1
|
2540
|
-
raise Utility::ZCRMException.get_instance('remove_tags', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'Tag count must be at least 1', 'NO TAGS PROVIDED')
|
2541
|
-
end
|
2542
|
-
|
2543
|
-
if record.nil? || record.entity_id.nil?
|
2544
|
-
raise Utility::ZCRMException.get_instance('remove_tags', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, ' record instance and record id must be given', 'RECORD or RECORD ID NOT PROVIDED')
|
2545
|
-
end
|
2546
|
-
|
2547
|
-
handler_ins = APIHandler.get_instance
|
2548
|
-
handler_ins.request_url_path = record.module_api_name + '/' + record.entity_id + '/actions/remove_tags'
|
2549
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_POST
|
2550
|
-
handler_ins.request_api_key = ZCRMSDK::Utility::APIConstants::DATA
|
2551
|
-
tag_names_as_string = ''
|
2552
|
-
tag_list.each do |tag_name|
|
2553
|
-
tag_names_as_string += tag_name.to_s + ','
|
2554
|
-
end
|
2555
|
-
handler_ins.add_param('tag_names', tag_names_as_string)
|
2556
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
2557
|
-
response_details = api_response.response_json.dig(Utility::APIConstants::DATA, 0, 'details')
|
2558
|
-
response_details['tags'].each do |tag_name|
|
2559
|
-
record.tag_list.push(Operations::ZCRMTag.get_instance(nil, tag_name))
|
2560
|
-
end
|
2561
|
-
api_response.data = record
|
2562
|
-
api_response
|
2563
|
-
end
|
2564
|
-
|
2565
|
-
def delete(tag_id)
|
2566
|
-
if tag_id.nil?
|
2567
|
-
raise Utility::ZCRMException.get_instance('delete', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, ' tag id must be given', 'TAG ID NOT PROVIDED')
|
2568
|
-
end
|
2569
|
-
|
2570
|
-
handler_ins = APIHandler.get_instance
|
2571
|
-
handler_ins.request_url_path = 'settings/tags/' + tag_id.to_s
|
2572
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_DELETE
|
2573
|
-
handler_ins.request_api_key = ZCRMSDK::Utility::APIConstants::TAG
|
2574
|
-
api_response = ZCRMSDK::Request::APIRequest.get_instance(handler_ins).get_api_response
|
2575
|
-
api_response
|
2576
|
-
end
|
2577
|
-
|
2578
|
-
def merge(tag_id, merge_tag_id)
|
2579
|
-
if tag_id.nil? || merge_tag_id.nil?
|
2580
|
-
raise Utility::ZCRMException.get_instance('merge', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, ' tag id and merge tag id must be given', 'TAG ID OR MERGE TAG ID NOT PROVIDED')
|
2581
|
-
end
|
2582
|
-
|
2583
|
-
handler_ins = APIHandler.get_instance
|
2584
|
-
handler_ins.request_url_path = 'settings/tags/' + merge_tag_id.to_s + '/actions/merge'
|
2585
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_POST
|
2586
|
-
handler_ins.request_api_key = ZCRMSDK::Utility::APIConstants::TAG
|
2587
|
-
tag_json = {}
|
2588
|
-
tag_json['conflict_id'] = tag_id.to_s
|
2589
|
-
handler_ins.request_body = handler_ins.request_body = Utility::CommonUtil.create_api_supported_input_json(tag_json, Utility::APIConstants::TAG)
|
2590
|
-
api_response = ZCRMSDK::Request::APIRequest.get_instance(handler_ins).get_api_response
|
2591
|
-
response_details = api_response.response_json.dig(Utility::APIConstants::TAG, 0, 'details')
|
2592
|
-
tag = Operations::ZCRMTag.get_instance(response_details['id'])
|
2593
|
-
tag_helper = TagAPIHandlerHelper.get_instance
|
2594
|
-
tag_helper.get_zcrmtag(tag, response_details)
|
2595
|
-
api_response.data = tag
|
2596
|
-
api_response
|
2597
|
-
end
|
2598
|
-
|
2599
|
-
def update(tag)
|
2600
|
-
if tag.nil? || tag.id.nil?
|
2601
|
-
raise Utility::ZCRMException.get_instance('update', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'tag instance and tag id must be given', 'TAG INSTANCE OR TAG ID NOT PROVIDED')
|
2602
|
-
end
|
2603
|
-
|
2604
|
-
handler_ins = APIHandler.get_instance
|
2605
|
-
handler_ins.request_url_path = 'settings/tags/' + tag.id.to_s
|
2606
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_PUT
|
2607
|
-
handler_ins.request_api_key = ZCRMSDK::Utility::APIConstants::TAG
|
2608
|
-
handler_ins.add_param('module', tag.module_apiname)
|
2609
|
-
tag_json = {}
|
2610
|
-
tag_json['name'] = tag.name
|
2611
|
-
handler_ins.request_body = handler_ins.request_body = Utility::CommonUtil.create_api_supported_input_json(tag_json, Utility::APIConstants::TAG)
|
2612
|
-
api_response = ZCRMSDK::Request::APIRequest.get_instance(handler_ins).get_api_response
|
2613
|
-
response_details = api_response.response_json.dig(Utility::APIConstants::TAG, 0, 'details')
|
2614
|
-
tag_helper = TagAPIHandlerHelper.get_instance
|
2615
|
-
tag_helper.get_zcrmtag(tag, response_details)
|
2616
|
-
api_response.data = tag
|
2617
|
-
api_response
|
2618
|
-
end
|
2619
|
-
end
|
2620
|
-
# THIS CLASS SERVES THE TagAPIHandler CLASS CONSTRUCTING JSON BODY AND INSTANCES
|
2621
|
-
class TagAPIHandlerHelper
|
2622
|
-
def initialize; end
|
2623
|
-
|
2624
|
-
def self.get_instance
|
2625
|
-
TagAPIHandlerHelper.new
|
2626
|
-
end
|
2627
|
-
|
2628
|
-
def get_zcrmtag(tag_ins, tag_details)
|
2629
|
-
tag_details.each do |key, value|
|
2630
|
-
tag_ins.id = value if (key == 'id') && !value.nil?
|
2631
|
-
if (key == 'created_by') && !value.nil?
|
2632
|
-
tag_ins.created_by = Operations::ZCRMUser.get_instance(tag_details['created_by']['id'], tag_details['created_by']['name'])
|
2633
|
-
end
|
2634
|
-
if (key == 'modified_by') && !value.nil?
|
2635
|
-
tag_ins.created_by = Operations::ZCRMUser.get_instance(tag_details['modified_by']['id'], tag_details['modified_by']['name'])
|
2636
|
-
end
|
2637
|
-
if (key == 'created_time') && !value.nil?
|
2638
|
-
tag_ins.created_time = tag_details['created_time']
|
2639
|
-
end
|
2640
|
-
if (key == 'modified_time') && !value.nil?
|
2641
|
-
tag_ins.modified_time = tag_details['modified_time']
|
2642
|
-
end
|
2643
|
-
if (key == 'count') && !value.nil?
|
2644
|
-
tag_ins.count = tag_details['count']
|
2645
|
-
end
|
2646
|
-
end
|
2647
|
-
tag_ins
|
2648
|
-
end
|
2649
|
-
|
2650
|
-
def construct_json_for_tag(zcrmtag)
|
2651
|
-
tag_json = {}
|
2652
|
-
tag_json['id'] = zcrmtag.id unless zcrmtag.id.nil?
|
2653
|
-
tag_json['name'] = zcrmtag.name unless zcrmtag.name.nil?
|
2654
|
-
tag_json
|
2655
|
-
end
|
2656
|
-
end
|
2657
|
-
# THIS CLASS IS USED TO HANDLE RELATED LIST RELATED FUNCTIONALITY
|
2658
|
-
class RelatedListAPIHandler < APIHandler
|
2659
|
-
def initialize(parentrecord, related_list)
|
2660
|
-
@parentrecord = parentrecord
|
2661
|
-
if related_list.instance_of?(Operations::ZCRMModuleRelation)
|
2662
|
-
@related_list = related_list
|
2663
|
-
else
|
2664
|
-
@junction_record = related_list
|
2665
|
-
end
|
2666
|
-
end
|
2667
|
-
|
2668
|
-
def self.get_instance(parentrecord, related_list)
|
2669
|
-
RelatedListAPIHandler.new(parentrecord, related_list)
|
2670
|
-
end
|
2671
|
-
|
2672
|
-
def get_records(sort_by_field, sort_order, page, per_page)
|
2673
|
-
handler_ins = APIHandler.get_instance
|
2674
|
-
handler_ins.request_url_path = ''
|
2675
|
-
handler_ins.request_url_path = @parentrecord.module_api_name + '/' + @parentrecord.entity_id + '/' + @related_list.api_name
|
2676
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_GET
|
2677
|
-
unless sort_by_field.nil?
|
2678
|
-
handler_ins.add_param('sort_by_field', sort_by_field)
|
2679
|
-
end
|
2680
|
-
|
2681
|
-
handler_ins.add_param('sort_order', sort_order) unless sort_order.nil?
|
2682
|
-
handler_ins.add_param('page', page)
|
2683
|
-
handler_ins.add_param('per_page', per_page)
|
2684
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
2685
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
2686
|
-
data_arr = bulk_api_response.response_json[Utility::APIConstants::DATA]
|
2687
|
-
entity_helper = EntityAPIHandlerHelper.get_instance
|
2688
|
-
record_ins_list = []
|
2689
|
-
data_arr.each do |record_data|
|
2690
|
-
zcrm_record = Operations::ZCRMRecord.get_instance(@related_list.api_name, record_data['id'])
|
2691
|
-
entity_helper.set_record_properties(zcrm_record, record_data)
|
2692
|
-
record_ins_list.push(zcrm_record)
|
2693
|
-
end
|
2694
|
-
bulk_api_response.data = record_ins_list
|
2695
|
-
bulk_api_response
|
2696
|
-
end
|
2697
|
-
|
2698
|
-
def upload_attachment(file_path)
|
2699
|
-
if file_path.nil?
|
2700
|
-
raise Utility::ZCRMException.get_instance('upload_attachment', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'file path must be given', 'FILEPATH NOT PROVIDED')
|
2701
|
-
end
|
2702
|
-
|
2703
|
-
handler_ins = APIHandler.get_instance
|
2704
|
-
handler_ins.request_url_path = ''
|
2705
|
-
handler_ins.request_url_path = @parentrecord.module_api_name + '/' + @parentrecord.entity_id + '/' + @related_list.api_name
|
2706
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_POST
|
2707
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
2708
|
-
api_response = Request::APIRequest.get_instance(handler_ins).upload_file(file_path)
|
2709
|
-
response_details = api_response.response_json.dig(Utility::APIConstants::DATA, 0, 'details')
|
2710
|
-
api_response.data = Operations::ZCRMAttachment.get_instance(@parent_record, response_details['id'])
|
2711
|
-
api_response
|
2712
|
-
end
|
2713
|
-
|
2714
|
-
def upload_link_as_attachment(link_url)
|
2715
|
-
if link_url.nil?
|
2716
|
-
raise Utility::ZCRMException.get_instance('upload_link_as_attachment', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'link URL must be given', 'URL_LINK NOT PROVIDED')
|
2717
|
-
end
|
2718
|
-
|
2719
|
-
handler_ins = APIHandler.get_instance
|
2720
|
-
handler_ins.request_url_path = ''
|
2721
|
-
handler_ins.request_url_path = @parentrecord.module_api_name + '/' + @parentrecord.entity_id + '/' + @related_list.api_name
|
2722
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_POST
|
2723
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
2724
|
-
api_response = Request::APIRequest.get_instance(handler_ins).upload_link_as_attachment(link_url)
|
2725
|
-
response_details = api_response.response_json.dig(Utility::APIConstants::DATA, 0, 'details')
|
2726
|
-
api_response.data = Operations::ZCRMAttachment.get_instance(@parent_record, response_details['id'])
|
2727
|
-
api_response
|
2728
|
-
end
|
2729
|
-
|
2730
|
-
def add_relation
|
2731
|
-
if @junction_record.nil?
|
2732
|
-
raise Utility::ZCRMException.get_instance('add_relation', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'junction_record must be given', 'JUNCTION RECORD NOT PROVIDED')
|
2733
|
-
end
|
2734
|
-
|
2735
|
-
handler_ins = APIHandler.get_instance
|
2736
|
-
handler_ins.request_url_path = ''
|
2737
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_PUT
|
2738
|
-
handler_ins.request_url_path = @parentrecord.module_api_name + '/' + @parentrecord.entity_id + '/' + @junction_record.api_name + '/' + @junction_record.id
|
2739
|
-
data_array = @junction_record.related_data
|
2740
|
-
handler_ins.request_body = Utility::CommonUtil.create_api_supported_input_json(data_array, Utility::APIConstants::DATA)
|
2741
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
2742
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
2743
|
-
api_response
|
2744
|
-
end
|
2745
|
-
|
2746
|
-
def remove_relation
|
2747
|
-
if @junction_record.nil?
|
2748
|
-
raise Utility::ZCRMException.get_instance('remove_relation', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'junction_record must be given', 'JUNCTION RECORD NOT PROVIDED')
|
2749
|
-
end
|
2750
|
-
|
2751
|
-
handler_ins = APIHandler.get_instance
|
2752
|
-
handler_ins.request_url_path = ''
|
2753
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_DELETE
|
2754
|
-
handler_ins.request_url_path = @parentrecord.module_api_name + '/' + @parentrecord.entity_id + '/' + @junction_record.api_name + '/' + @junction_record.id
|
2755
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
2756
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
2757
|
-
api_response
|
2758
|
-
end
|
2759
|
-
|
2760
|
-
def delete_attachment(attachment_id)
|
2761
|
-
if attachment_id.nil?
|
2762
|
-
raise Utility::ZCRMException.get_instance('delete_attachment', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'attachment id must be given', 'ID IS NOT PROVIDED')
|
2763
|
-
end
|
2764
|
-
|
2765
|
-
handler_ins = APIHandler.get_instance
|
2766
|
-
handler_ins.request_url_path = ''
|
2767
|
-
handler_ins.request_url_path = @parentrecord.module_api_name + '/' + @parentrecord.entity_id + '/' + @related_list.api_name + '/' + attachment_id
|
2768
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_DELETE
|
2769
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
2770
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
2771
|
-
api_response
|
2772
|
-
end
|
2773
|
-
|
2774
|
-
def download_attachment(attachment_id)
|
2775
|
-
if attachment_id.nil?
|
2776
|
-
raise Utility::ZCRMException.get_instance('download_attachment', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'attachment id must be given', 'ID IS NOT PROVIDED')
|
2777
|
-
end
|
2778
|
-
|
2779
|
-
handler_ins = APIHandler.get_instance
|
2780
|
-
handler_ins.request_url_path = ''
|
2781
|
-
handler_ins.request_url_path = @parentrecord.module_api_name + '/' + @parentrecord.entity_id + '/' + @related_list.api_name + '/' + attachment_id
|
2782
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_GET
|
2783
|
-
api_response = Request::APIRequest.get_instance(handler_ins).download_file
|
2784
|
-
api_response
|
2785
|
-
end
|
2786
|
-
|
2787
|
-
def add_notes(note_instances)
|
2788
|
-
if note_instances.length > 100
|
2789
|
-
raise Utility::ZCRMException.get_instance('create_notes', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'note count must be less than or equals to 100', 'MORE NOTES PROVIDED')
|
2790
|
-
end
|
2791
|
-
|
2792
|
-
if note_instances.length < 1
|
2793
|
-
raise Utility::ZCRMException.get_instance('create_notes', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'note count must be at least 1', 'NO NOTES PROVIDED')
|
2794
|
-
end
|
2795
|
-
|
2796
|
-
handler_ins = APIHandler.get_instance
|
2797
|
-
handler_ins.request_url_path = ''
|
2798
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_POST
|
2799
|
-
handler_ins.request_url_path = @parentrecord.module_api_name + '/' + @parentrecord.entity_id + '/' + @related_list.api_name
|
2800
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
2801
|
-
notes_api_helper = RelatedListAPIHandlerHelper.get_instance
|
2802
|
-
data_array = []
|
2803
|
-
note_instances.each do |note_instance|
|
2804
|
-
if note_instance.id.nil?
|
2805
|
-
data_array.push(notes_api_helper.get_zcrmnote_as_json(note_instance))
|
2806
|
-
else
|
2807
|
-
raise Utility::ZCRMException.get_instance('notes_Create', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'note id must be nil', 'NOTE ID PROVIDED')
|
2808
|
-
end
|
2809
|
-
end
|
2810
|
-
request_json = {}
|
2811
|
-
request_json[Utility::APIConstants::DATA] = data_array
|
2812
|
-
handler_ins.request_body = request_json
|
2813
|
-
bulk_api_response = ZCRMSDK::Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
2814
|
-
bulk_api_response
|
2815
|
-
end
|
2816
|
-
|
2817
|
-
def update_note(note_ins)
|
2818
|
-
if note_ins.nil? || note_ins.id.nil?
|
2819
|
-
raise Utility::ZCRMException.get_instance('update_note', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'note instance and note id must be given', 'NOTE INSTANCE OR NOTE ID NOT PROVIDED')
|
2820
|
-
end
|
2821
|
-
|
2822
|
-
handler_ins = APIHandler.get_instance
|
2823
|
-
handler_ins.request_url_path = ''
|
2824
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_PUT
|
2825
|
-
handler_ins.request_url_path = @parentrecord.module_api_name + '/' + @parentrecord.entity_id + '/' + @related_list.api_name + '/' + note_ins.id
|
2826
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
2827
|
-
helper_obj = RelatedListAPIHandlerHelper.get_instance
|
2828
|
-
input_json = helper_obj.get_zcrmnote_as_json(note_ins)
|
2829
|
-
handler_ins.request_body = Utility::CommonUtil.create_api_supported_input_json(input_json, Utility::APIConstants::DATA)
|
2830
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
2831
|
-
response_details = api_response.response_json.dig(Utility::APIConstants::DATA, 0, 'details')
|
2832
|
-
api_response.data = helper_obj.get_zcrm_note(response_details, note_ins, @parentrecord)
|
2833
|
-
api_response
|
2834
|
-
end
|
2835
|
-
|
2836
|
-
def delete_note(note_ins)
|
2837
|
-
if note_ins.nil? || note_ins.id.nil?
|
2838
|
-
raise Utility::ZCRMException.get_instance('delete_note', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'note instance and note id must be given', 'NOTE INSTANCE OR NOTE ID NOT PROVIDED')
|
2839
|
-
end
|
2840
|
-
|
2841
|
-
handler_ins = APIHandler.get_instance
|
2842
|
-
handler_ins.request_url_path = ''
|
2843
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_DELETE
|
2844
|
-
handler_ins.request_url_path = @parentrecord.module_api_name + '/' + @parentrecord.entity_id + '/' + @related_list.api_name + '/' + note_ins.id
|
2845
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
2846
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
2847
|
-
api_response
|
2848
|
-
end
|
2849
|
-
|
2850
|
-
def get_attachments(page, per_page)
|
2851
|
-
handler_ins = APIHandler.get_instance
|
2852
|
-
handler_ins.request_url_path = ''
|
2853
|
-
handler_ins.request_url_path = @parentrecord.module_api_name + '/' + @parentrecord.entity_id + '/' + @related_list.api_name
|
2854
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_GET
|
2855
|
-
handler_ins.add_param('page', page)
|
2856
|
-
handler_ins.add_param('per_page', per_page)
|
2857
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
2858
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
2859
|
-
data_arr = bulk_api_response.response_json[Utility::APIConstants::DATA]
|
2860
|
-
helper_obj = RelatedListAPIHandlerHelper.get_instance
|
2861
|
-
attachment_ins_list = []
|
2862
|
-
data_arr.each do |attachmentdetails|
|
2863
|
-
zcrm_attachment = helper_obj.get_zcrm_attachment(attachmentdetails, @parentrecord)
|
2864
|
-
attachment_ins_list.push(zcrm_attachment)
|
2865
|
-
end
|
2866
|
-
bulk_api_response.data = attachment_ins_list
|
2867
|
-
bulk_api_response
|
2868
|
-
end
|
2869
|
-
|
2870
|
-
def get_notes(sort_by, sort_order, page, per_page)
|
2871
|
-
handler_ins = APIHandler.get_instance
|
2872
|
-
handler_ins.request_url_path = ''
|
2873
|
-
handler_ins.request_url_path = @parentrecord.module_api_name + '/' + @parentrecord.entity_id + '/' + @related_list.api_name
|
2874
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_GET
|
2875
|
-
handler_ins.add_param('sort_by', sort_by) unless sort_by.nil?
|
2876
|
-
handler_ins.add_param('sort_order', sort_order) unless sort_order.nil?
|
2877
|
-
handler_ins.add_param('page', page)
|
2878
|
-
handler_ins.add_param('per_page', per_page)
|
2879
|
-
handler_ins.request_api_key = Utility::APIConstants::DATA
|
2880
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
2881
|
-
data_arr = bulk_api_response.response_json[Utility::APIConstants::DATA]
|
2882
|
-
helper_obj = RelatedListAPIHandlerHelper.get_instance
|
2883
|
-
note_ins_list = []
|
2884
|
-
data_arr.each do |notedetails|
|
2885
|
-
zcrm_note = helper_obj.get_zcrm_note(notedetails, nil, @parentrecord)
|
2886
|
-
note_ins_list.push(zcrm_note)
|
2887
|
-
end
|
2888
|
-
bulk_api_response.data = note_ins_list
|
2889
|
-
bulk_api_response
|
2890
|
-
end
|
2891
|
-
end
|
2892
|
-
# THIS CLASS SERVES THE RelatedListAPIHandler CLASS CONSTRUCTING JSON BODY AND INSTANCES
|
2893
|
-
class RelatedListAPIHandlerHelper
|
2894
|
-
def initialize; end
|
2895
|
-
|
2896
|
-
def self.get_instance
|
2897
|
-
RelatedListAPIHandlerHelper.new
|
2898
|
-
end
|
2899
|
-
|
2900
|
-
def get_zcrmnote_as_json(note_ins)
|
2901
|
-
note = {}
|
2902
|
-
note['Note_Title'] = note_ins.title unless note_ins.title.nil?
|
2903
|
-
note['Note_Content'] = note_ins.content
|
2904
|
-
note['Parent_Id'] = note_ins.parent_id unless note_ins.parent_id.nil?
|
2905
|
-
note['se_module'] = note_ins.parent_module unless note_ins.parent_module.nil?
|
2906
|
-
note
|
2907
|
-
end
|
2908
|
-
|
2909
|
-
def get_zcrm_note(note_details, zcrmnote_ins = nil, parentrecord = nil)
|
2910
|
-
if zcrmnote_ins.nil?
|
2911
|
-
zcrmnote_ins = ZCRMSDK::Operations::ZCRMNote.get_instance(parentrecord, note_details['id'])
|
2912
|
-
end
|
2913
|
-
zcrmnote_ins.id = note_details['id']
|
2914
|
-
if note_details.key?('Note_Title')
|
2915
|
-
zcrmnote_ins.title = note_details['Note_Title']
|
2916
|
-
end
|
2917
|
-
if note_details.key?('Note_Content')
|
2918
|
-
zcrmnote_ins.content = note_details['Note_Content']
|
2919
|
-
end
|
2920
|
-
if note_details.key?('Owner')
|
2921
|
-
unless note_details['Owner'].nil?
|
2922
|
-
owner = note_details['Owner']
|
2923
|
-
zcrmnote_ins.owner = ZCRMSDK::Operations::ZCRMUser.get_instance(owner['id'], owner['name'])
|
2924
|
-
end
|
2925
|
-
end
|
2926
|
-
if note_details.key?('Created_By')
|
2927
|
-
unless note_details['Created_By'].nil?
|
2928
|
-
created_by = note_details['Created_By']
|
2929
|
-
zcrmnote_ins.created_by = ZCRMSDK::Operations::ZCRMUser.get_instance(created_by['id'], created_by['name'])
|
2930
|
-
end
|
2931
|
-
end
|
2932
|
-
if note_details.key?('Modified_By')
|
2933
|
-
unless note_details['Modified_By'].nil?
|
2934
|
-
modified_by = note_details['Modified_By']
|
2935
|
-
zcrmnote_ins.modified_by = ZCRMSDK::Operations::ZCRMUser.get_instance(modified_by['id'], modified_by['name'])
|
2936
|
-
end
|
2937
|
-
end
|
2938
|
-
zcrmnote_ins.size = note_details['$size'] if note_details.key?('$size')
|
2939
|
-
if note_details.key?('Created_Time')
|
2940
|
-
zcrmnote_ins.created_time = note_details['Created_Time']
|
2941
|
-
end
|
2942
|
-
if note_details.key?('$editable')
|
2943
|
-
zcrmnote_ins.is_editable = note_details['$editable'] == true
|
2944
|
-
end
|
2945
|
-
if note_details.key?('Modified_Time')
|
2946
|
-
zcrmnote_ins.modified_time = note_details['Modified_Time']
|
2947
|
-
end
|
2948
|
-
if note_details.key?('$voice_note')
|
2949
|
-
zcrmnote_ins.is_voice_note = note_details['$voice_note']
|
2950
|
-
end
|
2951
|
-
if note_details.key?('$se_module')
|
2952
|
-
zcrmnote_ins.parent_module = note_details['$se_module']
|
2953
|
-
end
|
2954
|
-
if note_details.key?('Parent_Id')
|
2955
|
-
unless note_details['Parent_Id'].nil?
|
2956
|
-
parent_details = note_details['Parent_Id']
|
2957
|
-
unless parent_details['id'].nil?
|
2958
|
-
zcrmnote_ins.parent_id = parent_details['id']
|
2959
|
-
end
|
2960
|
-
unless parent_details['name'].nil?
|
2961
|
-
zcrmnote_ins.parent_name = parent_details['name']
|
2962
|
-
end
|
2963
|
-
end
|
2964
|
-
end
|
2965
|
-
zcrmnote_ins.size = note_details['$size'] if note_details.key?('$size')
|
2966
|
-
if note_details.key?('$attachments')
|
2967
|
-
unless note_details['$attachments'].nil?
|
2968
|
-
attachments = note_details['$attachments']
|
2969
|
-
attachment_instants = []
|
2970
|
-
attachments.each do |attachment|
|
2971
|
-
attachment_instants.push(get_zcrm_attachment(attachment, parentrecord))
|
2972
|
-
end
|
2973
|
-
zcrmnote_ins.attachments = attachment_instants
|
2974
|
-
end
|
2975
|
-
end
|
2976
|
-
zcrmnote_ins
|
2977
|
-
end
|
2978
|
-
|
2979
|
-
def get_zcrm_attachment(attachment_details, parent_record)
|
2980
|
-
attachment_ins = ZCRMSDK::Operations::ZCRMAttachment.get_instance(parent_record, attachment_details['id'])
|
2981
|
-
if attachment_details.key?('File_Name')
|
2982
|
-
attachment_ins.file_name = attachment_details['File_Name']
|
2983
|
-
end
|
2984
|
-
if attachment_details.key?('$editable')
|
2985
|
-
attachment_ins.is_editable = attachment_details['$editable'] == true
|
2986
|
-
end
|
2987
|
-
if attachment_details.key?('$file_id')
|
2988
|
-
attachment_ins.file_id = attachment_details['$file_id']
|
2989
|
-
end
|
2990
|
-
if attachment_details.key?('Owner')
|
2991
|
-
unless attachment_details['Owner'].nil?
|
2992
|
-
owner = attachment_details['Owner']
|
2993
|
-
attachment_ins.owner = ZCRMSDK::Operations::ZCRMUser.get_instance(owner['id'], owner['name'])
|
2994
|
-
end
|
2995
|
-
end
|
2996
|
-
if attachment_details.key?('Created_By')
|
2997
|
-
unless attachment_details['Created_By'].nil?
|
2998
|
-
created_by = attachment_details['Created_By']
|
2999
|
-
attachment_ins.created_by = ZCRMSDK::Operations::ZCRMUser.get_instance(created_by['id'], created_by['name'])
|
3000
|
-
end
|
3001
|
-
end
|
3002
|
-
if attachment_details.key?('Modified_By')
|
3003
|
-
unless attachment_details['Modified_By'].nil?
|
3004
|
-
modified_by = attachment_details['Modified_By']
|
3005
|
-
attachment_ins.modified_by = ZCRMSDK::Operations::ZCRMUser.get_instance(modified_by['id'], modified_by['name'])
|
3006
|
-
end
|
3007
|
-
end
|
3008
|
-
if attachment_details.key?('Created_Time')
|
3009
|
-
attachment_ins.created_time = attachment_details['Created_Time']
|
3010
|
-
end
|
3011
|
-
if attachment_details.key?('Modified_Time')
|
3012
|
-
attachment_ins.modified_time = attachment_details['Modified_Time']
|
3013
|
-
end
|
3014
|
-
if attachment_details.key?('$type')
|
3015
|
-
attachment_ins.type = attachment_details['$type']
|
3016
|
-
end
|
3017
|
-
if attachment_details.key?('$se_module')
|
3018
|
-
attachment_ins.parent_module = attachment_details['$se_module']
|
3019
|
-
end
|
3020
|
-
if attachment_details.key?('Parent_Id')
|
3021
|
-
unless attachment_details['Parent_Id'].nil?
|
3022
|
-
parent_details = attachment_details['Parent_Id']
|
3023
|
-
unless parent_details['id'].nil?
|
3024
|
-
attachment_ins.parent_id = parent_details['id']
|
3025
|
-
end
|
3026
|
-
unless parent_details['name'].nil?
|
3027
|
-
attachment_ins.parent_name = parent_details['name']
|
3028
|
-
end
|
3029
|
-
end
|
3030
|
-
end
|
3031
|
-
if attachment_details.key?('Size')
|
3032
|
-
attachment_ins.size = attachment_details['Size']
|
3033
|
-
end
|
3034
|
-
if attachment_details.key?('$link_url')
|
3035
|
-
attachment_ins.link_url = attachment_details['$link_url']
|
3036
|
-
end
|
3037
|
-
attachment_ins
|
3038
|
-
end
|
3039
|
-
end
|
3040
|
-
|
3041
|
-
class VariableAPIHandler < APIHandler
|
3042
|
-
def initialize(variable_ins = nil)
|
3043
|
-
@zcrmvariable = variable_ins
|
3044
|
-
end
|
3045
|
-
|
3046
|
-
def self.get_instance(variable_ins = nil)
|
3047
|
-
VariableAPIHandler.new(variable_ins)
|
3048
|
-
end
|
3049
|
-
|
3050
|
-
def create_variables(variables)
|
3051
|
-
if variables.length > 100
|
3052
|
-
raise Utility::ZCRMException.get_instance('create_variables', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'variable count must be less than or equals to 100', 'MORE VARIABLES PROVIDED')
|
3053
|
-
end
|
3054
|
-
|
3055
|
-
if variables.length < 1
|
3056
|
-
raise Utility::ZCRMException.get_instance('create_variables', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'variable count must at least be 1', 'NO VARIABLES PROVIDED')
|
3057
|
-
end
|
3058
|
-
|
3059
|
-
handler_ins = APIHandler.get_instance
|
3060
|
-
handler_ins.request_url_path = 'settings/variables'
|
3061
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_POST
|
3062
|
-
handler_ins.request_api_key = ZCRMSDK::Utility::APIConstants::VARIABLE
|
3063
|
-
variable_array = []
|
3064
|
-
variable_helper = VariableAPIHandlerHelper.get_instance
|
3065
|
-
variables.each do |variable|
|
3066
|
-
if variable.id.nil?
|
3067
|
-
variable_array.push(variable_helper.get_zcrmvariable_as_json(variable))
|
3068
|
-
else
|
3069
|
-
raise Utility::ZCRMException.get_instance('create_variables', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'variable id must be nil', 'VARIABLE ID PROVIDED')
|
3070
|
-
end
|
3071
|
-
end
|
3072
|
-
request_json = {}
|
3073
|
-
request_json[Utility::APIConstants::VARIABLE] = variable_array
|
3074
|
-
handler_ins.request_body = request_json
|
3075
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
3076
|
-
bulk_api_response
|
3077
|
-
end
|
3078
|
-
|
3079
|
-
def update_variables(variables)
|
3080
|
-
if variables.length > 100
|
3081
|
-
raise Utility::ZCRMException.get_instance('update_variables', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'variable count must be less than or equals to 100', 'MORE VARIABLES PROVIDED')
|
3082
|
-
end
|
3083
|
-
|
3084
|
-
if variables.length < 1
|
3085
|
-
raise Utility::ZCRMException.get_instance('update_variables', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'variable count must at least be 1', 'NO VARIABLES PROVIDED')
|
3086
|
-
end
|
3087
|
-
|
3088
|
-
handler_ins = APIHandler.get_instance
|
3089
|
-
handler_ins.request_url_path = 'settings/variables'
|
3090
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_PUT
|
3091
|
-
handler_ins.request_api_key = ZCRMSDK::Utility::APIConstants::VARIABLE
|
3092
|
-
variable_array = []
|
3093
|
-
variable_helper = VariableAPIHandlerHelper.get_instance
|
3094
|
-
variables.each do |variable|
|
3095
|
-
unless variable.id.nil?
|
3096
|
-
variable_array.push(variable_helper.get_zcrmvariable_as_json(variable))
|
3097
|
-
else
|
3098
|
-
raise Utility::ZCRMException.get_instance('update_variables', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'variable id must not be nil', 'VARIABLE ID NOT PROVIDED')
|
3099
|
-
end
|
3100
|
-
end
|
3101
|
-
request_json = {}
|
3102
|
-
request_json[Utility::APIConstants::VARIABLE] = variable_array
|
3103
|
-
handler_ins.request_body = request_json
|
3104
|
-
bulk_api_response = Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
3105
|
-
bulk_api_response
|
3106
|
-
end
|
3107
|
-
|
3108
|
-
def get_variable(group_id)
|
3109
|
-
if @zcrmvariable.id.nil?
|
3110
|
-
raise Utility::ZCRMException.get_instance('get_variable', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'id should be set for the variable', 'ID IS NOT PROVIDED')
|
3111
|
-
end
|
3112
|
-
|
3113
|
-
if group_id.nil?
|
3114
|
-
raise Utility::ZCRMException.get_instance('get_variable', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'group should be set for the variable', 'ID IS NOT PROVIDED')
|
3115
|
-
end
|
3116
|
-
|
3117
|
-
handler_ins = APIHandler.get_instance
|
3118
|
-
handler_ins.request_url_path = ''
|
3119
|
-
handler_ins.request_url_path = 'settings/variables/' + @zcrmvariable.id.to_s
|
3120
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_GET
|
3121
|
-
handler_ins.request_api_key = Utility::APIConstants::VARIABLE
|
3122
|
-
handler_ins.add_param('group',group_id)
|
3123
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
3124
|
-
obj = VariableAPIHandlerHelper.get_instance
|
3125
|
-
obj.get_zcrmvariable(@zcrmvariable, api_response.response_json.dig(Utility::APIConstants::VARIABLE, 0))
|
3126
|
-
api_response.data = @zcrmvariable
|
3127
|
-
api_response
|
3128
|
-
end
|
3129
|
-
|
3130
|
-
def update_variable
|
3131
|
-
if @zcrmvariable.id.nil?
|
3132
|
-
raise Utility::ZCRMException.get_instance('update_variable', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'id should be set for the variable', 'ID IS NOT PROVIDED')
|
3133
|
-
end
|
3134
|
-
|
3135
|
-
handler_ins = APIHandler.get_instance
|
3136
|
-
handler_ins.request_url_path = ''
|
3137
|
-
handler_ins.request_url_path = 'settings/variables/' + @zcrmvariable.id.to_s
|
3138
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_PUT
|
3139
|
-
handler_ins.request_api_key = Utility::APIConstants::VARIABLE
|
3140
|
-
helper_obj = VariableAPIHandlerHelper.get_instance
|
3141
|
-
input_json = helper_obj.get_zcrmvariable_as_json(@zcrmvariable)
|
3142
|
-
handler_ins.request_body = Utility::CommonUtil.create_api_supported_input_json(input_json, Utility::APIConstants::VARIABLE)
|
3143
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
3144
|
-
response_details = api_response.response_json.dig(Utility::APIConstants::VARIABLE, 0, 'details')
|
3145
|
-
@zcrmvariable.id = response_details['id']
|
3146
|
-
api_response.data = @zcrmvariable
|
3147
|
-
api_response
|
3148
|
-
end
|
3149
|
-
|
3150
|
-
def delete_variable
|
3151
|
-
if @zcrmvariable.id.nil?
|
3152
|
-
raise Utility::ZCRMException.get_instance('delete_variable', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'id should be set for the variable', 'ID IS NOT PROVIDED')
|
3153
|
-
end
|
3154
|
-
|
3155
|
-
handler_ins = APIHandler.get_instance
|
3156
|
-
handler_ins.request_url_path = ''
|
3157
|
-
handler_ins.request_url_path = 'settings/variables/' + @zcrmvariable.id.to_s
|
3158
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_DELETE
|
3159
|
-
handler_ins.request_api_key = Utility::APIConstants::VARIABLE
|
3160
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
3161
|
-
api_response
|
3162
|
-
end
|
3163
|
-
|
3164
|
-
def get_variables
|
3165
|
-
handler_ins = APIHandler.get_instance
|
3166
|
-
handler_ins.request_url_path = 'settings/variables'
|
3167
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_GET
|
3168
|
-
handler_ins.request_api_key = ZCRMSDK::Utility::APIConstants::VARIABLE
|
3169
|
-
bulk_api_response = ZCRMSDK::Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
3170
|
-
variables_json = bulk_api_response.response_json.dig(ZCRMSDK::Utility::APIConstants::VARIABLE)
|
3171
|
-
variable_list = []
|
3172
|
-
variable_helper = VariableAPIHandlerHelper.get_instance
|
3173
|
-
variables_json.each do |variable_json|
|
3174
|
-
variable_ins = Operations::ZCRMVariable.get_instance(variable_json['api_name'], variable_json['id'])
|
3175
|
-
variable_list.push(variable_helper.get_zcrmvariable(variable_ins, variable_json))
|
3176
|
-
end
|
3177
|
-
bulk_api_response.data = variable_list
|
3178
|
-
bulk_api_response
|
3179
|
-
end
|
3180
|
-
end
|
3181
|
-
|
3182
|
-
class VariableAPIHandlerHelper
|
3183
|
-
def initialize; end
|
3184
|
-
|
3185
|
-
def self.get_instance
|
3186
|
-
VariableAPIHandlerHelper.new
|
3187
|
-
end
|
3188
|
-
|
3189
|
-
def get_zcrmvariable(zcrm_variable_ins, variable_details)
|
3190
|
-
variable_details.each do |key, value|
|
3191
|
-
zcrm_variable_ins.id = value if (key == 'id') && !value.nil?
|
3192
|
-
if (key == 'variable_group') && !value.nil?
|
3193
|
-
zcrm_variable_ins.variable_group = Operations::ZCRMVariableGroup.get_instance(variable_details['variable_group']['api_name'], variable_details['variable_group']['id'])
|
3194
|
-
elsif (key == 'api_name') && !value.nil?
|
3195
|
-
zcrm_variable_ins.api_name = variable_details['api_name']
|
3196
|
-
elsif (key == 'name') && !value.nil?
|
3197
|
-
zcrm_variable_ins.name = variable_details['name']
|
3198
|
-
elsif (key == 'id') && !value.nil?
|
3199
|
-
zcrm_variable_ins.id = variable_details['id']
|
3200
|
-
elsif (key == 'type') && !value.nil?
|
3201
|
-
zcrm_variable_ins.type = variable_details['type']
|
3202
|
-
elsif (key == 'value') && !value.nil?
|
3203
|
-
zcrm_variable_ins.value = variable_details['value']
|
3204
|
-
elsif (key == 'description') && !value.nil?
|
3205
|
-
zcrm_variable_ins.description = variable_details['description']
|
3206
|
-
end
|
3207
|
-
end
|
3208
|
-
zcrm_variable_ins
|
3209
|
-
end
|
3210
|
-
|
3211
|
-
def get_zcrmvariable_as_json(zcrm_variable_ins)
|
3212
|
-
variable_json = {}
|
3213
|
-
variable_json['id'] = zcrm_variable_ins.id unless zcrm_variable_ins.id.nil?
|
3214
|
-
variable_json['name'] = zcrm_variable_ins.name unless zcrm_variable_ins.name.nil?
|
3215
|
-
variable_json['api_name'] = zcrm_variable_ins.api_name unless zcrm_variable_ins.api_name.nil?
|
3216
|
-
variable_json['type'] = zcrm_variable_ins.type unless zcrm_variable_ins.type.nil?
|
3217
|
-
variable_json['value'] = zcrm_variable_ins.value unless zcrm_variable_ins.value.nil?
|
3218
|
-
variable_json['description'] = zcrm_variable_ins.description unless zcrm_variable_ins.description.nil?
|
3219
|
-
unless zcrm_variable_ins.variable_group.nil?
|
3220
|
-
variable_group_json = {}
|
3221
|
-
variable_group_json['id'] = zcrm_variable_ins.variable_group.id unless zcrm_variable_ins.variable_group.nil? || zcrm_variable_ins.variable_group.id.nil?
|
3222
|
-
variable_group_json['api_name'] = zcrm_variable_ins.variable_group.id unless zcrm_variable_ins.variable_group.nil? || zcrm_variable_ins.variable_group.id.nil?
|
3223
|
-
variable_json['variable_group']= variable_group_json
|
3224
|
-
end
|
3225
|
-
variable_json
|
3226
|
-
end
|
3227
|
-
end
|
3228
|
-
|
3229
|
-
class VariableGroupAPIHandler < APIHandler
|
3230
|
-
def initialize(variable_group_ins = nil)
|
3231
|
-
@zcrmvariablegroup = variable_group_ins
|
3232
|
-
end
|
3233
|
-
|
3234
|
-
def self.get_instance(variable_group_ins = nil)
|
3235
|
-
VariableGroupAPIHandler.new(variable_group_ins)
|
3236
|
-
end
|
3237
|
-
|
3238
|
-
def get_variable_group
|
3239
|
-
if @zcrmvariablegroup.id.nil?
|
3240
|
-
raise Utility::ZCRMException.get_instance('get_variable', Utility::APIConstants::RESPONSECODE_BAD_REQUEST, 'id should be set for the variable', 'ID IS NOT PROVIDED')
|
3241
|
-
end
|
3242
|
-
|
3243
|
-
handler_ins = APIHandler.get_instance
|
3244
|
-
handler_ins.request_url_path = ''
|
3245
|
-
handler_ins.request_url_path = 'settings/variable_groups/' + @zcrmvariablegroup.id.to_s
|
3246
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_GET
|
3247
|
-
handler_ins.request_api_key = Utility::APIConstants::VARIABLE_GROUP
|
3248
|
-
api_response = Request::APIRequest.get_instance(handler_ins).get_api_response
|
3249
|
-
obj = VariableGroupAPIHandlerHelper.get_instance
|
3250
|
-
obj.get_zcrmvariablegroup(@zcrmvariablegroup, api_response.response_json.dig(Utility::APIConstants::VARIABLE_GROUP, 0))
|
3251
|
-
api_response.data = @zcrmvariablegroup
|
3252
|
-
api_response
|
3253
|
-
end
|
3254
|
-
|
3255
|
-
def get_variable_groups
|
3256
|
-
handler_ins = APIHandler.get_instance
|
3257
|
-
handler_ins.request_url_path = 'settings/variable_groups'
|
3258
|
-
handler_ins.request_method = ZCRMSDK::Utility::APIConstants::REQUEST_METHOD_GET
|
3259
|
-
handler_ins.request_api_key = ZCRMSDK::Utility::APIConstants::VARIABLE_GROUP
|
3260
|
-
bulk_api_response = ZCRMSDK::Request::APIRequest.get_instance(handler_ins).get_bulk_api_response
|
3261
|
-
variable_groups_json = bulk_api_response.response_json.dig(ZCRMSDK::Utility::APIConstants::VARIABLE_GROUP)
|
3262
|
-
variable_group_list = []
|
3263
|
-
variable_group_helper = VariableGroupAPIHandlerHelper.get_instance
|
3264
|
-
variable_groups_json.each do |variable_group_json|
|
3265
|
-
variable_group_ins = Operations::ZCRMVariableGroup.get_instance(variable_group_json['api_name'], variable_group_json['id'])
|
3266
|
-
variable_group_list.push(variable_group_helper.get_zcrmvariablegroup(variable_group_ins, variable_group_json))
|
3267
|
-
end
|
3268
|
-
bulk_api_response.data = variable_group_list
|
3269
|
-
bulk_api_response
|
3270
|
-
end
|
3271
|
-
end
|
3272
|
-
|
3273
|
-
class VariableGroupAPIHandlerHelper
|
3274
|
-
def initialize; end
|
3275
|
-
|
3276
|
-
def self.get_instance
|
3277
|
-
VariableGroupAPIHandlerHelper.new
|
3278
|
-
end
|
3279
|
-
|
3280
|
-
def get_zcrmvariablegroup(zcrm_variablegroup_ins, variable_group_details)
|
3281
|
-
variable_group_details.each do |key, value|
|
3282
|
-
zcrm_variablegroup_ins.id = value if (key == 'id') && !value.nil?
|
3283
|
-
if (key == 'api_name') && !value.nil?
|
3284
|
-
zcrm_variablegroup_ins.api_name = variable_group_details['api_name']
|
3285
|
-
elsif (key == 'name') && !value.nil?
|
3286
|
-
zcrm_variablegroup_ins.name = variable_group_details['name']
|
3287
|
-
elsif (key == 'id') && !value.nil?
|
3288
|
-
zcrm_variablegroup_ins.id = variable_group_details['id']
|
3289
|
-
elsif (key == 'display_label') && !value.nil?
|
3290
|
-
zcrm_variablegroup_ins.display_label = variable_group_details['display_label']
|
3291
|
-
elsif (key == 'description') && !value.nil?
|
3292
|
-
zcrm_variablegroup_ins.description = variable_group_details['description']
|
3293
|
-
end
|
3294
|
-
end
|
3295
|
-
zcrm_variablegroup_ins
|
3296
|
-
end
|
3297
|
-
end
|
3298
|
-
end
|
3299
|
-
end
|