Sha256: c54285e1c9965b1a5c5f4c6591731c88fdd7fe7af446484d384fde2c1600ceac

Contents?: true

Size: 454 Bytes

Versions: 1

Compression:

Stored size: 454 Bytes

Contents

require 'hashie'

module AmoCRM
  class CustomFields < Hashie::Mash
    def as_json
      map do |id, value|
        values = Array(value).map { |value|
          if value.is_a? Hash
            value.map do |k, v|
              {
                value: v,
                enum: k,
              }
            end
          else
            { value: value }
          end
        }.flatten

        { id: id, values: values }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
amo_crm-0.2.2 lib/amo_crm/entities/custom_fields.rb