Sha256: edc978c84bd6fdf2373b89870df739a593478f55268f5f2b20b7b4f6aa2cfbcf

Contents?: true

Size: 1.55 KB

Versions: 12

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true

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

      # Create new custom field in account
      #
      # @see https://developers.mailerlite.com/v2/reference#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/v2/reference#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/v2/reference#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

12 entries across 12 versions & 1 rubygems

Version Path
mailerlite-1.16.0 lib/mailerlite/clients/fields.rb
mailerlite-1.15.0 lib/mailerlite/clients/fields.rb
mailerlite-1.14.0 lib/mailerlite/clients/fields.rb
mailerlite-1.13.1 lib/mailerlite/clients/fields.rb
mailerlite-1.13.0 lib/mailerlite/clients/fields.rb
mailerlite-1.12.0 lib/mailerlite/clients/fields.rb
mailerlite-1.11.0 lib/mailerlite/clients/fields.rb
mailerlite-1.10.0 lib/mailerlite/clients/fields.rb
mailerlite-1.9.0 lib/mailerlite/clients/fields.rb
mailerlite-1.8.0 lib/mailerlite/clients/fields.rb
mailerlite-1.7.0 lib/mailerlite/clients/fields.rb
mailerlite-1.6.1 lib/mailerlite/clients/fields.rb