Sha256: 6c72a5b9f2e3c5c2464951885d3b2effa95a491eb219ede7d0eda55bf351ba56

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

require 'dato/site/repo/base'

module Dato
  module Site
    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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dato-0.1.5 lib/dato/site/repo/field.rb
dato-0.1.4 lib/dato/site/repo/field.rb
dato-0.1.3 lib/dato/site/repo/field.rb
dato-0.1.2 lib/dato/site/repo/field.rb