lib/pipe_rocket/service.rb
def transform_custom_fields(params)
      return params unless @has_custom_fields

      @@name_key_hash = Pipedrive.send("#{@resource_name}_fields").name_key_hash
      @@name_key_hash.transform_keys!{|key|clear_key(key)}

      hash = ::CUSTOM_FIELD_NAMES
      if hash && hash[@resource_name.to_sym]
        @@name_key_hash = @@name_key_hash.merge(hash[@resource_name.to_sym].invert)
      end

      keys = @@name_key_hash.keys
      res = {}

      params.each do |name, value|
        if keys.include?(name.to_s) #Custom Field
          res[@@name_key_hash[name.to_s]] = value
        else
          res[name] = value
        end
      end
      res
    end
# Trasform custom fields from their names to keys
Trasform custom fields from their names to keys
Trasform custom fields from their names to keys
def transform_custom_fields(params)
      return params unless @has_custom_fields
      @@name_key_hash = Pipedrive.send("#{@resource_name}_fields").name_key_hash
      @@name_key_hash.transform_keys!{|key|clear_key(key)}
      hash = ::CUSTOM_FIELD_NAMES
      if hash && hash[@resource_name.to_sym]
        @@name_key_hash = @@name_key_hash.merge(hash[@resource_name.to_sym].invert)
      end
      keys = @@name_key_hash.keys
      res = {}
      params.each do |name, value|
        if keys.include?(name.to_s) 
          res[@@name_key_hash[name.to_s]] = value
        else
          res[name] = value
        end
      end
      res
    end
def transform_custom_fields ( params ) return params unless @has_custom_fields @@name_key_hash = Pipedrive . send ( "#{@resource_name}_fields" ) . name_key_hash @@name_key_hash . transform_keys! { | key | clear_key ( key ) } hash = :: CUSTOM_FIELD_NAMES if hash && hash [ @resource_name . to_sym ] @@name_key_hash = @@name_key_hash . merge ( hash [ @resource_name . to_sym ] . invert ) end keys = @@name_key_hash . keys res = { } params . each do | name , value | if keys . include? ( name . to_s ) res [ @@name_key_hash [ name . to_s ] ] = value else res [ name ] = value end end res end
Trasform custom fields from their names to keys
Trasform custom fields from their names to keys
#Custom Field
params