Sha256: 85502e7e2b6e7d7796b02406164a9ff7414284e41fbe1b0d75d031f2e76f5ff0

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require 'dato/repo/base'

module Dato
  module Repo
    class Field < Base

      def create(item_type_id, resource_attributes)
        body = JsonApiSerializer.new(
          type: :field,
          attributes: %i(api_key appeareance field_type hint label localized position validators),
          required_attributes: %i(api_key appeareance field_type hint label localized position validators),
        ).serialize(resource_attributes)

        post_request "/item-types/#{item_type_id}/fields", body
      end

      def update(field_id, resource_attributes)
        body = JsonApiSerializer.new(
          type: :field,
          attributes: %i(api_key appeareance hint label localized position validators),
        ).serialize(resource_attributes, field_id)

        put_request "/fields/#{field_id}", body
      end

      def all(item_type_id)
        get_request "/item-types/#{item_type_id}/fields"
      end

      def find(field_id)
        get_request "/fields/#{field_id}"
      end

      def destroy(field_id)
        delete_request "/fields/#{field_id}"
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dato-0.1.1 lib/dato/repo/field.rb
dato-0.1.0 lib/dato/repo/field.rb