Sha256: 3a1af9be876025c24395bcb01d29629e00a6aa9e0c3393867eaad35cb3f98a36

Contents?: true

Size: 1.49 KB

Versions: 4

Compression:

Stored size: 1.49 KB

Contents

module MailerLite
  module Clients
    # MailerLite Fields
    module Fields
      # Get subscriber fields of account
      #
      # @see https://developers.mailerlite.com/docs/all-fields
      #
      # @return [Array] Response from API.
      def fields
        connection.get('fields')
      end

      # Create new custom field in account
      #
      # @see https://developers.mailerlite.com/docs/create-field
      #
      # @param options [Hash] A customizable set of options.
      # @option options [String] :title Title of field
      # @option options [String] :type Type of field. Available values:
      #   TEXT, INTEGER, DATE
      #
      # @return [Hash] Response from API.
      def create_field(options = {})
        connection.post('fields', options)
      end

      # Update custom field in account
      #
      # @see https://developers.mailerlite.com/docs/update-field
      #
      # @param id [Integer] ID of field.
      # @param options [Hash] A customizable set of options.
      # @option options [String] :title Title of field
      #
      # @return [Hash] Response from API.
      def update_field(id, options = {})
        connection.put("fields/#{id}", options)
      end

      # Remove custom field from account
      #
      # @see https://developers.mailerlite.com/docs/remove-field
      #
      # @param id [Integer] ID of field.
      #
      # @return [Hash] Response from API.
      def delete_field(id)
        connection.delete("fields/#{id}")
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mailerlite-1.2.0 lib/mailerlite/clients/fields.rb
mailerlite-1.1.0 lib/mailerlite/clients/fields.rb
mailerlite-1.0.2 lib/mailerlite/clients/fields.rb
mailerlite-1.0.1 lib/mailerlite/clients/fields.rb