Sha256: cdc1d494923903de1e69d4f8915c46fdb6b732859073fdfb2c2eeb256b3cc9a2

Contents?: true

Size: 1.78 KB

Versions: 6

Compression:

Stored size: 1.78 KB

Contents

# frozen_string_literal: true

require 'zoho_hub/with_connection'
require 'zoho_hub/with_attributes'

require 'zoho_hub/settings/field'

module ZohoHub
  module Settings
    # Zoho CRM has standard modules such as, Leads, Accounts, Contacts, Deals, Forecasts,
    # Activities, etc,. Using Zoho CRM REST API, you can retrieve the list of available modules.
    #
    # convertable: Describes if the user can convert the record into another type of record.
    #              For example: Convert Leads in to Deals.
    # creatable: Checks if the user can create a record in the current module.
    # generated_type: Describes the type of module which would be generated by the user. There are
    #                 4 types: default, web, custom, linking.
    # api_supported: The modules which are currently not accessible by APIs have value as "false".
    #                If the modules are supported in the future, the value automatically changes
    #                to "true".
    # modified_time: The date and time of changes made by the user.
    #
    # More details: https://www.zoho.com/crm/help/api/v2/#Modules-APIs
    class Module
      include WithConnection
      include WithAttributes

      REQUEST_PATH = 'settings/modules'

      attributes :convertable, :editable, :deletable, :web_link, :singular_label, :modified_time,
                 :viewable, :api_supported, :creatable, :plural_label, :api_name, :modified_by,
                 :generated_type, :id, :module_name, :fields

      def self.all
        modules = all_json
        modules.map { |json| new(json) }
      end

      def self.all_json
        response = get(REQUEST_PATH)
        response[:modules]
      end

      def initialize(json = {})
        attributes.each { |attr| send("#{attr}=", json[attr]) }
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
zoho_hub-0.4.2 lib/zoho_hub/settings/module.rb
zoho_hub-0.4.1 lib/zoho_hub/settings/module.rb
zoho_hub-0.4.0 lib/zoho_hub/settings/module.rb
zoho_hub-0.3.0 lib/zoho_hub/settings/module.rb
zoho_hub-0.2.0 lib/zoho_hub/settings/module.rb
zoho_hub-0.1.9 lib/zoho_hub/settings/module.rb