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.25 lib/dato/site/repo/field.rb
dato-0.3.24 lib/dato/site/repo/field.rb
dato-0.3.23 lib/dato/site/repo/field.rb
dato-0.3.22 lib/dato/site/repo/field.rb
dato-0.3.21 lib/dato/site/repo/field.rb
dato-0.3.20 lib/dato/site/repo/field.rb
dato-0.3.19 lib/dato/site/repo/field.rb
dato-0.3.18 lib/dato/site/repo/field.rb
dato-0.3.17 lib/dato/site/repo/field.rb
dato-0.3.16 lib/dato/site/repo/field.rb
dato-0.3.15 lib/dato/site/repo/field.rb
dato-0.3.14 lib/dato/site/repo/field.rb
dato-0.3.13 lib/dato/site/repo/field.rb
dato-0.3.12 lib/dato/site/repo/field.rb
dato-0.3.9.1 lib/dato/site/repo/field.rb
dato-0.3.11 lib/dato/site/repo/field.rb
dato-0.3.10 lib/dato/site/repo/field.rb
dato-0.3.9 lib/dato/site/repo/field.rb
dato-0.3.8 lib/dato/site/repo/field.rb
dato-0.3.7 lib/dato/site/repo/field.rb