ZCRMSDK 1.0.4 → 3.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 +447 -0
- data/src/com/zoho/api/authenticator/oauth_token.rb +272 -0
- data/src/com/zoho/api/authenticator/store/db_store.rb +191 -0
- data/src/com/zoho/api/authenticator/store/file_store.rb +235 -0
- data/src/com/zoho/api/authenticator/store/token_store.rb +33 -0
- data/src/com/zoho/api/authenticator/token.rb +10 -0
- data/src/com/zoho/api/logger/sdk_logger.rb +78 -0
- data/src/com/zoho/crm/api/assignment_rules/api_exception.rb +121 -0
- data/src/com/zoho/crm/api/assignment_rules/assignment_rule.rb +215 -0
- data/src/com/zoho/crm/api/assignment_rules/assignment_rules_operations.rb +61 -0
- data/src/com/zoho/crm/api/assignment_rules/default_user.rb +80 -0
- data/src/com/zoho/crm/api/assignment_rules/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/assignment_rules/response_wrapper.rb +63 -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 +405 -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/escalation.rb +80 -0
- data/src/com/zoho/crm/api/blue_print/field.rb +1127 -0
- data/src/com/zoho/crm/api/blue_print/next_transition.rb +118 -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 +271 -0
- data/src/com/zoho/crm/api/blue_print/validation_error.rb +137 -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 +155 -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 +138 -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 +215 -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 +136 -0
- data/src/com/zoho/crm/api/custom_views/custom_view.rb +386 -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_to.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 +21 -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/email_templates/api_exception.rb +121 -0
- data/src/com/zoho/crm/api/email_templates/attachment.rb +118 -0
- data/src/com/zoho/crm/api/email_templates/email_template.rb +390 -0
- data/src/com/zoho/crm/api/email_templates/email_templates_operations.rb +61 -0
- data/src/com/zoho/crm/api/email_templates/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/email_templates/response_wrapper.rb +83 -0
- data/src/com/zoho/crm/api/exception/sdk_exception.rb +47 -0
- data/src/com/zoho/crm/api/field_attachments/api_exception.rb +121 -0
- data/src/com/zoho/crm/api/field_attachments/body_wrapper.rb +62 -0
- data/src/com/zoho/crm/api/field_attachments/field_attachments_operations.rb +52 -0
- data/src/com/zoho/crm/api/field_attachments/file_body_wrapper.rb +64 -0
- data/src/com/zoho/crm/api/field_attachments/response_handler.rb +10 -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/external.rb +99 -0
- data/src/com/zoho/crm/api/fields/field.rb +1110 -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/history_tracking.rb +80 -0
- data/src/com/zoho/crm/api/fields/lookup_field.rb +80 -0
- data/src/com/zoho/crm/api/fields/maps.rb +80 -0
- data/src/com/zoho/crm/api/fields/module.rb +157 -0
- data/src/com/zoho/crm/api/fields/multi_module_lookup.rb +99 -0
- data/src/com/zoho/crm/api/fields/multi_select_lookup.rb +175 -0
- data/src/com/zoho/crm/api/fields/multi_user_lookup.rb +175 -0
- data/src/com/zoho/crm/api/fields/pick_list_value.rb +194 -0
- data/src/com/zoho/crm/api/fields/private.rb +99 -0
- data/src/com/zoho/crm/api/fields/related_details.rb +156 -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 +220 -0
- data/src/com/zoho/crm/api/inventory_templates/api_exception.rb +121 -0
- data/src/com/zoho/crm/api/inventory_templates/inventory_template.rb +352 -0
- data/src/com/zoho/crm/api/inventory_templates/inventory_templates_operations.rb +82 -0
- data/src/com/zoho/crm/api/inventory_templates/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/inventory_templates/response_wrapper.rb +83 -0
- data/src/com/zoho/crm/api/layouts/api_exception.rb +121 -0
- data/src/com/zoho/crm/api/layouts/layout.rb +310 -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 +252 -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 +939 -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 +368 -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/hierarchy_preference.rb +61 -0
- data/src/com/zoho/crm/api/org/license_details.rb +156 -0
- data/src/com/zoho/crm/api/org/org.rb +669 -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/pipeline/action_handler.rb +10 -0
- data/src/com/zoho/crm/api/pipeline/action_response.rb +10 -0
- data/src/com/zoho/crm/api/pipeline/action_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/pipeline/api_exception.rb +129 -0
- data/src/com/zoho/crm/api/pipeline/body_wrapper.rb +61 -0
- data/src/com/zoho/crm/api/pipeline/forecast_category.rb +80 -0
- data/src/com/zoho/crm/api/pipeline/pick_list_value.rb +175 -0
- data/src/com/zoho/crm/api/pipeline/pipeline.rb +213 -0
- data/src/com/zoho/crm/api/pipeline/pipeline_operations.rb +165 -0
- data/src/com/zoho/crm/api/pipeline/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/pipeline/response_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/pipeline/stage.rb +80 -0
- data/src/com/zoho/crm/api/pipeline/success_response.rb +123 -0
- data/src/com/zoho/crm/api/pipeline/transfer_action_handler.rb +10 -0
- data/src/com/zoho/crm/api/pipeline/transfer_action_response.rb +10 -0
- data/src/com/zoho/crm/api/pipeline/transfer_action_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/pipeline/transfer_and_delete_wrapper.rb +61 -0
- data/src/com/zoho/crm/api/pipeline/transfer_pipe_line.rb +80 -0
- data/src/com/zoho/crm/api/profiles/api_exception.rb +121 -0
- data/src/com/zoho/crm/api/profiles/category.rb +118 -0
- data/src/com/zoho/crm/api/profiles/default_view.rb +99 -0
- data/src/com/zoho/crm/api/profiles/permission_detail.rb +137 -0
- data/src/com/zoho/crm/api/profiles/profile.rb +328 -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 +145 -0
- data/src/com/zoho/crm/api/record/body_wrapper.rb +137 -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/count_handler.rb +10 -0
- data/src/com/zoho/crm/api/record/count_wrapper.rb +63 -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/image_upload.rb +213 -0
- data/src/com/zoho/crm/api/record/info.rb +118 -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 +137 -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/mass_update_territory.rb +80 -0
- data/src/com/zoho/crm/api/record/multi_select_lookup.rb +99 -0
- data/src/com/zoho/crm/api/record/multi_select_picklist.rb +80 -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/price_book.rb +31 -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 +847 -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/tax.rb +80 -0
- data/src/com/zoho/crm/api/record/territory.rb +138 -0
- data/src/com/zoho/crm/api/record/widget.rb +80 -0
- data/src/com/zoho/crm/api/record/wizard.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 +15 -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 +12 -0
- data/src/com/zoho/crm/api/send_mail/action_handler.rb +10 -0
- data/src/com/zoho/crm/api/send_mail/action_response.rb +10 -0
- data/src/com/zoho/crm/api/send_mail/action_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/send_mail/api_exception.rb +125 -0
- data/src/com/zoho/crm/api/send_mail/body_wrapper.rb +61 -0
- data/src/com/zoho/crm/api/send_mail/data_subject_request.rb +80 -0
- data/src/com/zoho/crm/api/send_mail/inventory_details.rb +100 -0
- data/src/com/zoho/crm/api/send_mail/mail.rb +423 -0
- data/src/com/zoho/crm/api/send_mail/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/send_mail/response_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/send_mail/send_mail_operations.rb +61 -0
- data/src/com/zoho/crm/api/send_mail/success_response.rb +121 -0
- data/src/com/zoho/crm/api/send_mail/template.rb +10 -0
- data/src/com/zoho/crm/api/send_mail/user_address.rb +137 -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 +176 -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 +83 -0
- data/src/com/zoho/crm/api/territories/territories_operations.rb +47 -0
- data/src/com/zoho/crm/api/territories/territory.rb +272 -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 +730 -0
- data/src/com/zoho/crm/api/users/users_operations.rb +181 -0
- data/src/com/zoho/crm/api/util/api_http_connector.rb +112 -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 +237 -0
- data/src/com/zoho/crm/api/util/constants.rb +661 -0
- data/src/com/zoho/crm/api/util/converter.rb +236 -0
- data/src/com/zoho/crm/api/util/data_type_converter.rb +168 -0
- data/src/com/zoho/crm/api/util/downloader.rb +83 -0
- data/src/com/zoho/crm/api/util/form_data_converter.rb +156 -0
- data/src/com/zoho/crm/api/util/header_param_validator.rb +55 -0
- data/src/com/zoho/crm/api/util/json_converter.rb +724 -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 +914 -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/com/zoho/crm/api/wizards/api_exception.rb +121 -0
- data/src/com/zoho/crm/api/wizards/button.rb +252 -0
- data/src/com/zoho/crm/api/wizards/chart_data.rb +118 -0
- data/src/com/zoho/crm/api/wizards/connection.rb +80 -0
- data/src/com/zoho/crm/api/wizards/container.rb +119 -0
- data/src/com/zoho/crm/api/wizards/node.rb +118 -0
- data/src/com/zoho/crm/api/wizards/response_handler.rb +10 -0
- data/src/com/zoho/crm/api/wizards/response_wrapper.rb +63 -0
- data/src/com/zoho/crm/api/wizards/screen.rb +99 -0
- data/src/com/zoho/crm/api/wizards/segment.rb +176 -0
- data/src/com/zoho/crm/api/wizards/transition.rb +80 -0
- data/src/com/zoho/crm/api/wizards/wizard.rb +273 -0
- data/src/com/zoho/crm/api/wizards/wizards_operations.rb +61 -0
- data/src/resources/JSONDetails.json +1 -0
- data/src/version.rb +3 -0
- metadata +476 -41
- data/lib/ZCRMSDK.rb +0 -14
- data/lib/ZCRMSDK/handler.rb +0 -3290
- 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/test.rb +0 -5748
- data/lib/ZCRMSDK/utility.rb +0 -310
- data/lib/ZCRMSDK/version.rb +0 -5
@@ -0,0 +1,272 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
require 'monitor'
|
5
|
+
|
6
|
+
require_relative 'token'
|
7
|
+
require_relative '../../crm/api/util/constants'
|
8
|
+
require_relative '../logger/sdk_logger'
|
9
|
+
require_relative '../../crm/api/exception/sdk_exception'
|
10
|
+
|
11
|
+
module Authenticator
|
12
|
+
# This class gets and refreshes the tokens based on the expiry time.
|
13
|
+
class OAuthToken < Token
|
14
|
+
attr_accessor :client_id , :client_secret ,:redirect_url ,:grant_token,:refresh_token, :access_token ,:user_mail ,:id ,:expires_in
|
15
|
+
@@sync_lock = Monitor.new
|
16
|
+
|
17
|
+
# Creates an OAuthToken class instance with the specified parameters.
|
18
|
+
# @param client_id [string] A String containing the OAuth client id.
|
19
|
+
# @param client_secret [string] A String containing the OAuth client secret.
|
20
|
+
# @param grant_token [string] A String containing the grant token.
|
21
|
+
# @param refresh_token [string] A String containing the refresh token.
|
22
|
+
# @param redirect_url [string] A String containing the OAuth redirect URL.
|
23
|
+
# @param id [string] A String containing ID
|
24
|
+
|
25
|
+
def initialize(client_id:, client_secret:, grant_token: nil, refresh_token: nil, redirect_url: nil,id: nil)
|
26
|
+
error ={}
|
27
|
+
unless client_id.is_a?(String)
|
28
|
+
error[Constants::ERROR_HASH_FIELD] = Constants::CLIENT_ID
|
29
|
+
|
30
|
+
error[Constants::ERROR_HASH_EXPECTED_TYPE] = String
|
31
|
+
|
32
|
+
error[Constants::ERROR_HASH_CLASS] = OAuthToken.class
|
33
|
+
|
34
|
+
raise SDKException.new(Constants::INPUT_ERROR, nil, error, nil)
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
unless client_secret.is_a?(String)
|
39
|
+
error[Constants::ERROR_HASH_FIELD] = Constants::CLIENT_SECRET
|
40
|
+
|
41
|
+
error[Constants::ERROR_HASH_EXPECTED_TYPE] = String
|
42
|
+
|
43
|
+
error[Constants::ERROR_HASH_CLASS] = OAuthToken.class
|
44
|
+
|
45
|
+
raise SDKException.new(Constants::INPUT_ERROR, nil, error, nil)
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
if !grant_token.nil? && !grant_token.is_a?(String)
|
50
|
+
error[Constants::ERROR_HASH_FIELD] = Constants::GRANT_TOKEN
|
51
|
+
|
52
|
+
error[Constants::ERROR_HASH_EXPECTED_TYPE] = String
|
53
|
+
|
54
|
+
error[Constants::ERROR_HASH_CLASS] = OAuthToken.class
|
55
|
+
|
56
|
+
raise SDKException.new(Constants::INPUT_ERROR, nil, error, nil)
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
if !refresh_token.nil? && !refresh_token.is_a?(String)
|
61
|
+
error[Constants::ERROR_HASH_FIELD] = Constants::REFRESH_TOKEN
|
62
|
+
|
63
|
+
error[Constants::ERROR_HASH_EXPECTED_TYPE] = String
|
64
|
+
|
65
|
+
error[Constants::ERROR_HASH_CLASS] = OAuthToken.class
|
66
|
+
|
67
|
+
raise SDKException.new(Constants::INPUT_ERROR, nil, error, nil)
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
if !redirect_url.nil? && !redirect_url.is_a?(String)
|
72
|
+
error[Constants::ERROR_HASH_FIELD] = Constants::REDIRECT_URL
|
73
|
+
|
74
|
+
error[Constants::ERROR_HASH_EXPECTED_TYPE] = String
|
75
|
+
|
76
|
+
error[Constants::ERROR_HASH_CLASS] = OAuthToken.class
|
77
|
+
|
78
|
+
raise SDKException.new(Constants::INPUT_ERROR, nil, error, nil)
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
if !id.nil? && !id.is_a?(String)
|
83
|
+
error[Constants::ERROR_HASH_FIELD] = Constants::ID
|
84
|
+
|
85
|
+
error[Constants::ERROR_HASH_EXPECTED_TYPE] = String
|
86
|
+
|
87
|
+
error[Constants::ERROR_HASH_CLASS] = OAuthToken.class
|
88
|
+
|
89
|
+
raise SDKException.new(Constants::INPUT_ERROR, nil, error, nil)
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
if grant_token.nil? && refresh_token.nil?
|
94
|
+
error[Constants::ERROR_HASH_FIELD] = Constants::TYPE
|
95
|
+
|
96
|
+
error[Constants::ERROR_HASH_EXPECTED_TYPE] = Constants::EXPECTED_TOKEN_TYPES
|
97
|
+
|
98
|
+
error[Constants::ERROR_HASH_CLASS] = OAuthToken.class
|
99
|
+
|
100
|
+
raise SDKException.new(Constants::INPUT_ERROR, nil, error, nil)
|
101
|
+
end
|
102
|
+
@client_id = client_id
|
103
|
+
|
104
|
+
@client_secret = client_secret
|
105
|
+
|
106
|
+
@redirect_url = redirect_url
|
107
|
+
|
108
|
+
@refresh_token = refresh_token
|
109
|
+
|
110
|
+
@grant_token = grant_token
|
111
|
+
|
112
|
+
@access_token = nil
|
113
|
+
|
114
|
+
@expires_in = nil
|
115
|
+
|
116
|
+
@user_mail = nil
|
117
|
+
|
118
|
+
@id = id
|
119
|
+
end
|
120
|
+
|
121
|
+
def authenticate(url_connection)
|
122
|
+
@@sync_lock.synchronize do
|
123
|
+
initializer = Initializer.get_initializer
|
124
|
+
store = initializer.store
|
125
|
+
user = initializer.user
|
126
|
+
|
127
|
+
oauth_token = nil
|
128
|
+
if !@id.nil?
|
129
|
+
oauth_token = initializer.store.get_token_by_id(@id, self)
|
130
|
+
else
|
131
|
+
oauth_token = initializer.store.get_token(user, self)
|
132
|
+
end
|
133
|
+
|
134
|
+
token = ""
|
135
|
+
|
136
|
+
if oauth_token.nil?
|
137
|
+
token = @refresh_token.nil? ? generate_access_token(user, store).access_token : refresh_access_token(user, store).access_token
|
138
|
+
elsif oauth_token.expires_in.to_f - get_current_time_in_millis < 5000
|
139
|
+
SDKLog::SDKLogger.info(Constants::REFRESH_TOKEN_MESSAGE)
|
140
|
+
token = oauth_token.refresh_access_token(user, store).access_token
|
141
|
+
else
|
142
|
+
token = oauth_token.access_token
|
143
|
+
end
|
144
|
+
|
145
|
+
url_connection.headers[Constants::AUTHORIZATION] = Constants::OAUTH_HEADER_PREFIX + token
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def remove
|
150
|
+
Initializer.get_initializer.store.delete_token(self)
|
151
|
+
true
|
152
|
+
rescue StandardError
|
153
|
+
false
|
154
|
+
end
|
155
|
+
|
156
|
+
def generate_access_token(user, store)
|
157
|
+
json_body = {}
|
158
|
+
|
159
|
+
json_body[Constants::CLIENT_ID] = @client_id
|
160
|
+
|
161
|
+
json_body[Constants::CLIENT_SECRET] = @client_secret
|
162
|
+
|
163
|
+
json_body[Constants::REDIRECT_URI] = @redirect_url if !@redirect_url.nil?
|
164
|
+
|
165
|
+
json_body[Constants::GRANT_TYPE] = Constants::GRANT_TYPE_AUTH_CODE
|
166
|
+
|
167
|
+
json_body[Constants::CODE] = @grant_token
|
168
|
+
|
169
|
+
response = get_response_from_server(json_body)
|
170
|
+
|
171
|
+
begin
|
172
|
+
parse_response(response)
|
173
|
+
|
174
|
+
generate_id()
|
175
|
+
|
176
|
+
store.save_token(user,self)
|
177
|
+
rescue SDKException => e
|
178
|
+
raise e
|
179
|
+
rescue StandardError => e
|
180
|
+
raise SDKException.new(nil, Constants::SAVE_TOKEN_ERROR, nil, e)
|
181
|
+
end
|
182
|
+
self
|
183
|
+
end
|
184
|
+
|
185
|
+
def refresh_access_token(user, store)
|
186
|
+
json_body = {}
|
187
|
+
|
188
|
+
json_body[Constants::CLIENT_ID] = @client_id
|
189
|
+
|
190
|
+
json_body[Constants::CLIENT_SECRET] = @client_secret
|
191
|
+
|
192
|
+
json_body[Constants::REDIRECT_URI] = @redirect_url if !@redirect_url.nil?
|
193
|
+
|
194
|
+
json_body[Constants::GRANT_TYPE] = Constants::REFRESH_TOKEN
|
195
|
+
|
196
|
+
json_body[Constants::REFRESH_TOKEN] = @refresh_token
|
197
|
+
|
198
|
+
response = get_response_from_server(json_body)
|
199
|
+
|
200
|
+
begin
|
201
|
+
parse_response(response)
|
202
|
+
|
203
|
+
generate_id()
|
204
|
+
|
205
|
+
store.save_token(user,self)
|
206
|
+
rescue SDKException => e
|
207
|
+
raise e
|
208
|
+
rescue StandardError => e
|
209
|
+
raise SDKException.new(nil, Constants::SAVE_TOKEN_ERROR, nil, e)
|
210
|
+
end
|
211
|
+
self
|
212
|
+
end
|
213
|
+
|
214
|
+
def parse_response(response)
|
215
|
+
response_json = JSON.parse(response)
|
216
|
+
|
217
|
+
unless response_json.key? Constants::ACCESS_TOKEN
|
218
|
+
raise SDKException.new(Constants::INVALID_CLIENT_ERROR, response_json[Constants::ERROR_KEY], nil, nil)
|
219
|
+
end
|
220
|
+
|
221
|
+
@access_token = response_json[Constants::ACCESS_TOKEN]
|
222
|
+
|
223
|
+
@expires_in = get_token_expiry_time(response_json)
|
224
|
+
|
225
|
+
@refresh_token = response_json[Constants::REFRESH_TOKEN] if response_json.key? Constants::REFRESH_TOKEN
|
226
|
+
self
|
227
|
+
end
|
228
|
+
|
229
|
+
def get_response_from_server(json_body)
|
230
|
+
accounts_url = Initializer.get_initializer.environment.accounts_url
|
231
|
+
|
232
|
+
url = URI(accounts_url)
|
233
|
+
|
234
|
+
http = Net::HTTP.new(url.host, url.port)
|
235
|
+
|
236
|
+
http.use_ssl = true
|
237
|
+
|
238
|
+
request = Net::HTTP::Post.new(url.request_uri)
|
239
|
+
request.add_field(Constants::USER_AGENT_KEY, Constants::USER_AGENT)
|
240
|
+
request.set_form(json_body, Constants::APPLICATION_FORM_URLENCODED)
|
241
|
+
|
242
|
+
response = http.request(request)
|
243
|
+
|
244
|
+
response.body
|
245
|
+
rescue StandardError => e
|
246
|
+
raise SDKException.new(nil, nil, nil, e)
|
247
|
+
end
|
248
|
+
|
249
|
+
def get_token_expiry_time(response_json)
|
250
|
+
expires_in = response_json[Constants::EXPIRES_IN]
|
251
|
+
|
252
|
+
expires_in *= 1000 unless response_json.key? Constants::EXPIRES_IN_SEC
|
253
|
+
|
254
|
+
expires_in += get_current_time_in_millis
|
255
|
+
|
256
|
+
expires_in
|
257
|
+
end
|
258
|
+
|
259
|
+
def get_current_time_in_millis
|
260
|
+
(Time.now.to_f * 1000).to_i
|
261
|
+
end
|
262
|
+
|
263
|
+
def generate_id
|
264
|
+
id = ""
|
265
|
+
email = Initializer.get_initializer.user.email
|
266
|
+
environment = Initializer.get_initializer.environment.name
|
267
|
+
id = id + "ruby_" +email[0..email.index(Constants::AT) - 1] + Constants::UNDERSCORE
|
268
|
+
id = id + environment + Constants::UNDERSCORE + @refresh_token[@refresh_token.length-4..@refresh_token.length-1]
|
269
|
+
@id = id
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
@@ -0,0 +1,191 @@
|
|
1
|
+
require 'mysql2'
|
2
|
+
require_relative 'token_store'
|
3
|
+
require_relative '../oauth_token'
|
4
|
+
require_relative '../../../crm/api/util/constants'
|
5
|
+
|
6
|
+
module Store
|
7
|
+
# This class stores the user token details to the MySQL DataBase.
|
8
|
+
class DBStore < TokenStore
|
9
|
+
attr_reader :user_name, :password, :port_number, :host, :database_name, :table_name
|
10
|
+
|
11
|
+
# Creates an DBStore class instance with the specified parameters.
|
12
|
+
# @param host [string] A String containing the DataBase host name.
|
13
|
+
# @param database_name A String containing the DataBase name.
|
14
|
+
# @param table_name A String containing the table name.
|
15
|
+
# @param user_name A String containing the DataBase user name.
|
16
|
+
# @param password A String containing the DataBase password.
|
17
|
+
# @param port_number A String containing the DataBase port number.
|
18
|
+
def initialize(host: Constants::MYSQL_HOST, database_name: Constants::MYSQL_DATABASE_NAME ,table_name: Constants::MYSQL_TABLE_NAME,user_name: Constants::MYSQL_USER_NAME,password: '',port_number: Constants::MYSQL_PORT_NUMBER )
|
19
|
+
@host = host
|
20
|
+
@database_name = database_name
|
21
|
+
@table_name = table_name
|
22
|
+
@user_name = user_name
|
23
|
+
@password = password
|
24
|
+
@port_number = port_number
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_token(user, token)
|
28
|
+
con = Mysql2::Client.new(host: @host, username: @user_name, password: @password, database: @database_name, port: @port_number)
|
29
|
+
|
30
|
+
query = construct_db_query(user.email, token, false)
|
31
|
+
|
32
|
+
rs = con.query(query)
|
33
|
+
|
34
|
+
con.close
|
35
|
+
|
36
|
+
rs.each do |row|
|
37
|
+
oauthtoken = token
|
38
|
+
|
39
|
+
oauthtoken.client_id = row[Constants::CLIENT_ID]
|
40
|
+
|
41
|
+
oauthtoken.client_secret = row[Constants::CLIENT_SECRET]
|
42
|
+
|
43
|
+
oauthtoken.grant_token = row[Constants::GRANT_TOKEN]
|
44
|
+
|
45
|
+
oauthtoken.redirect_url = row[Constants::REDIRECT_URL]
|
46
|
+
|
47
|
+
oauthtoken.refresh_token = row[Constants::REFRESH_TOKEN]
|
48
|
+
|
49
|
+
oauthtoken.id = row[Constants::ID]
|
50
|
+
|
51
|
+
oauthtoken.user_mail = row[Constants::USER_MAIL]
|
52
|
+
|
53
|
+
oauthtoken.access_token = row[Constants::ACCESS_TOKEN]
|
54
|
+
|
55
|
+
oauthtoken.expires_in = row[Constants::EXPIRY_TIME]
|
56
|
+
|
57
|
+
return oauthtoken
|
58
|
+
end
|
59
|
+
nil
|
60
|
+
rescue Mysql2::Error => e
|
61
|
+
raise SDKException.new(Constants::TOKEN_STORE, Constants::GET_TOKEN_DB_ERROR, nil, e)
|
62
|
+
end
|
63
|
+
|
64
|
+
def save_token(user, token)
|
65
|
+
con = Mysql2::Client.new(host: @host, username: @user_name, password: @password, database: @database_name, port: @port_number)
|
66
|
+
if token.is_a? Authenticator::OAuthToken
|
67
|
+
query = "insert into #{token.table_name}(id,user_mail,client_id,client_secret,refresh_token,access_token,grant_token,expiry_time,redirect_url) values ('#{token.id}','#{user.email}','#{token.client_id}','#{token.client_secret}','#{token.refresh_token}','#{token.access_token}','#{token.grant_token}','#{token.expires_in}','#{token.redirect_url}')"
|
68
|
+
token.user_mail = user.email
|
69
|
+
delete_token(token)
|
70
|
+
con.query(query)
|
71
|
+
end
|
72
|
+
|
73
|
+
con.close
|
74
|
+
rescue Mysql2::Error => e
|
75
|
+
raise SDKException.new(Constants::TOKEN_STORE, Constants::SAVE_TOKEN_DB_ERROR, nil, e)
|
76
|
+
end
|
77
|
+
|
78
|
+
def delete_token(token)
|
79
|
+
con = Mysql2::Client.new(host: @host, username: @user_name, password: @password, database: @database_name, port: @port_number)
|
80
|
+
if token.is_a? Authenticator::OAuthToken
|
81
|
+
query = construct_db_query(token.user_mail, token, true)
|
82
|
+
|
83
|
+
con.query(query)
|
84
|
+
end
|
85
|
+
|
86
|
+
con.close
|
87
|
+
rescue Mysql2::Error => e
|
88
|
+
raise SDKException.new(Constants::TOKEN_STORE, Constants::DELETE_TOKEN_DB_ERROR, nil, e)
|
89
|
+
end
|
90
|
+
|
91
|
+
def delete_tokens
|
92
|
+
con = Mysql2::Client.new(host: @host, username: @user_name, password: @password, database: @database_name, port: @port_number)
|
93
|
+
|
94
|
+
query = "delete * from #{@table_name}"
|
95
|
+
|
96
|
+
con.query(query)
|
97
|
+
|
98
|
+
con.close
|
99
|
+
rescue Mysql2::Error => e
|
100
|
+
raise SDKException.new(Constants::TOKEN_STORE, Constants::DELETE_TOKENS_DB_ERROR, nil, e)
|
101
|
+
end
|
102
|
+
|
103
|
+
def get_tokens
|
104
|
+
tokens = []
|
105
|
+
con = Mysql2::Client.new(host: @host, username: @user_name, password: @password, database: @database_name, port: @port_number)
|
106
|
+
|
107
|
+
query = "select * from #{@table_name}"
|
108
|
+
|
109
|
+
rs = con.query(query)
|
110
|
+
|
111
|
+
con.close
|
112
|
+
|
113
|
+
rs.each do |row|
|
114
|
+
|
115
|
+
|
116
|
+
oauthtoken = Authenticator::OAuthToken.new(client_id: row[Constants::CLIENT_ID],client_secret: row[Constants::CLIENT_SECRET],grant_token: grant_token,refresh_token: row[Constants::REFRESH_TOKEN])
|
117
|
+
|
118
|
+
oauthtoken.id = row[Constants::ID]
|
119
|
+
|
120
|
+
oauthtoken.user_mail = row[Constants::USER_MAIL]
|
121
|
+
|
122
|
+
oauthtoken.access_token = row[Constants::ACCESS_TOKEN]
|
123
|
+
|
124
|
+
oauthtoken.redirect_url = row[Constants::REDIRECT_URL]
|
125
|
+
|
126
|
+
oauthtoken.expires_in = row[Constants::EXPIRY_TIME]
|
127
|
+
|
128
|
+
tokens.push(oauthtoken)
|
129
|
+
end
|
130
|
+
tokens
|
131
|
+
rescue Mysql2::Error => e
|
132
|
+
raise SDKException.new(Constants::TOKEN_STORE, Constants::GET_TOKENS_DB_ERROR, nil, e)
|
133
|
+
end
|
134
|
+
|
135
|
+
def construct_db_query(email, token, is_delete)
|
136
|
+
raise SDKException.new(Constants::USER_MAIL_NULL_ERROR, Constants::USER_MAIL_NULL_ERROR_MESSAGE) if email.nil?
|
137
|
+
|
138
|
+
query = is_delete ? 'delete from ' : 'select * from '
|
139
|
+
|
140
|
+
query += "#{@table_name} where user_mail='#{email}' and client_id='#{token.client_id}' and "
|
141
|
+
|
142
|
+
query += if token.grant_token.nil?
|
143
|
+
"refresh_token='#{token.refresh_token}'"
|
144
|
+
else
|
145
|
+
"grant_token='#{token.grant_token}'"
|
146
|
+
end
|
147
|
+
|
148
|
+
query
|
149
|
+
end
|
150
|
+
def get_token_by_id(id,token)
|
151
|
+
con = Mysql2::Client.new(host: @host, username: @user_name, password: @password, database: @database_name, port: @port_number)
|
152
|
+
|
153
|
+
if token.is_a? Authenticator::OAuthToken
|
154
|
+
query = "select * from #{@table_name} where id='#{id}'"
|
155
|
+
|
156
|
+
rs = con.query(query)
|
157
|
+
|
158
|
+
con.close
|
159
|
+
|
160
|
+
rs.each do |row|
|
161
|
+
if id == row[Constants::ID]
|
162
|
+
oauthtoken = token
|
163
|
+
|
164
|
+
oauthtoken.client_id = row[Constants::CLIENT_ID]
|
165
|
+
|
166
|
+
oauthtoken.client_secret = row[Constants::CLIENT_SECRET]
|
167
|
+
|
168
|
+
oauthtoken.grant_token = row[Constants::GRANT_TOKEN]
|
169
|
+
|
170
|
+
oauthtoken.redirect_url = row[Constants::REDIRECT_URL]
|
171
|
+
|
172
|
+
oauthtoken.refresh_token = row[Constants::REFRESH_TOKEN]
|
173
|
+
|
174
|
+
oauthtoken.id = row[Constants::ID]
|
175
|
+
|
176
|
+
oauthtoken.user_mail = row[Constants::USER_MAIL]
|
177
|
+
|
178
|
+
oauthtoken.access_token = row[Constants::ACCESS_TOKEN]
|
179
|
+
|
180
|
+
oauthtoken.expires_in = row[Constants::EXPIRY_TIME]
|
181
|
+
|
182
|
+
return oauthtoken
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
nil
|
187
|
+
rescue Mysql2::Error => e
|
188
|
+
raise SDKException.new(Constants::TOKEN_STORE, Constants::GET_TOKEN_BY_ID_DB_ERROR, nil, e)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|