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.1.20 lib/dato/site/repo/field.rb
dato-0.1.19 lib/dato/site/repo/field.rb
dato-0.1.18 lib/dato/site/repo/field.rb
dato-0.1.17 lib/dato/site/repo/field.rb
dato-0.1.16 lib/dato/site/repo/field.rb
dato-0.1.15 lib/dato/site/repo/field.rb
dato-0.1.14 lib/dato/site/repo/field.rb
dato-0.1.13 lib/dato/site/repo/field.rb
dato-0.1.12 lib/dato/site/repo/field.rb
dato-0.1.11 lib/dato/site/repo/field.rb
dato-0.1.10 lib/dato/site/repo/field.rb
dato-0.1.9 lib/dato/site/repo/field.rb
dato-0.1.8 lib/dato/site/repo/field.rb
dato-0.1.6 lib/dato/site/repo/field.rb