Sha256: f80fd92b5b4eaaf11d0c7415c335de65f9a9e5796e705a7d731ad0ae72d29685

Contents?: true

Size: 1.18 KB

Versions: 54

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true
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

54 entries across 54 versions & 1 rubygems

Version Path
dato-0.3.6 lib/dato/site/repo/field.rb
dato-0.3.5 lib/dato/site/repo/field.rb
dato-0.3.3 lib/dato/site/repo/field.rb
dato-0.3.2 lib/dato/site/repo/field.rb
dato-0.3.1 lib/dato/site/repo/field.rb
dato-0.3.0 lib/dato/site/repo/field.rb
dato-0.2.7 lib/dato/site/repo/field.rb
dato-0.2.6 lib/dato/site/repo/field.rb
dato-0.2.4 lib/dato/site/repo/field.rb
dato-0.1.31 lib/dato/site/repo/field.rb
dato-0.1.30 lib/dato/site/repo/field.rb
dato-0.1.29 lib/dato/site/repo/field.rb
dato-0.1.28 lib/dato/site/repo/field.rb
dato-0.1.27 lib/dato/site/repo/field.rb
dato-0.1.26 lib/dato/site/repo/field.rb
dato-0.1.25 lib/dato/site/repo/field.rb
dato-0.1.24 lib/dato/site/repo/field.rb
dato-0.1.23 lib/dato/site/repo/field.rb
dato-0.1.22 lib/dato/site/repo/field.rb
dato-0.1.21 lib/dato/site/repo/field.rb