Sha256: c0e7d2271f87a165ad4c6b7af4e8dd3080d3641817d396c31cf3c508fdb1460e

Contents?: true

Size: 897 Bytes

Versions: 6

Compression:

Stored size: 897 Bytes

Contents

# frozen_string_literal: true

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

module ZohoHub
  module Settings
    class Field
      include WithConnection
      include WithAttributes

      REQUEST_PATH = 'settings/fields'

      attributes :custom_field, :lookup, :convert_mapping, :visible, :field_label, :length,
                 :view_type, :read_only, :api_name, :unique, :data_type, :formula, :currency, :id,
                 :decimal_place, :pick_list_values, :auto_number

      def self.all_for(module_name)
        fields = all_json_for(module_name)
        fields.map { |json| new(json) }
      end

      def self.all_json_for(module_name)
        response = get(REQUEST_PATH, module: module_name)
        response[:fields]
      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/field.rb
zoho_hub-0.4.1 lib/zoho_hub/settings/field.rb
zoho_hub-0.4.0 lib/zoho_hub/settings/field.rb
zoho_hub-0.3.0 lib/zoho_hub/settings/field.rb
zoho_hub-0.2.0 lib/zoho_hub/settings/field.rb
zoho_hub-0.1.9 lib/zoho_hub/settings/field.rb