Sha256: 839f6ae284ffde8d518e38d05b51d7fc5fd02bf28bf98acf66251d4e8e8aaf20

Contents?: true

Size: 1.65 KB

Versions: 9

Compression:

Stored size: 1.65 KB

Contents

# frozen_string_literal: true
require 'dato/site/repo/base'

module Dato
  module Site
    module Repo
      class ItemType < Base
        def create(resource_attributes)
          body = JsonApiSerializer.new(
            type: :item_type,
            attributes: %i(api_key modular_block name ordering_direction singleton sortable tree),
            relationships: { ordering_field: { collection: false, type: :field } },
            required_attributes: %i(api_key modular_block name ordering_direction singleton sortable tree),
            required_relationships: %i(ordering_field)
          ).serialize(resource_attributes)

          post_request '/item-types', body
        end

        def update(item_type_id, resource_attributes)
          body = JsonApiSerializer.new(
            type: :item_type,
            attributes: %i(api_key modular_block name ordering_direction singleton sortable tree),
            relationships: { ordering_field: { collection: false, type: :field } },
            required_attributes: %i(api_key modular_block name ordering_direction singleton sortable tree),
            required_relationships: %i(ordering_field)
          ).serialize(resource_attributes, item_type_id)

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

        def all
          get_request '/item-types'
        end

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

        def duplicate(item_type_id)
          post_request "/item-types/#{item_type_id}/duplicate"
        end

        def destroy(item_type_id)
          delete_request "/item-types/#{item_type_id}"
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dato-0.4.1 lib/dato/site/repo/item_type.rb
dato-0.4.0 lib/dato/site/repo/item_type.rb
dato-0.3.31 lib/dato/site/repo/item_type.rb
dato-0.4.0.pre lib/dato/site/repo/item_type.rb
dato-0.3.30 lib/dato/site/repo/item_type.rb
dato-0.3.29 lib/dato/site/repo/item_type.rb
dato-0.3.28 lib/dato/site/repo/item_type.rb
dato-0.3.27 lib/dato/site/repo/item_type.rb
dato-0.3.26 lib/dato/site/repo/item_type.rb