Sha256: 5a006f0fa3c939b0b1cbd73cb35c6a2f23830a0288a0554ba3e8e3eb998fba6d

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

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 name singleton sortable),
            required_attributes: %i(api_key name singleton sortable),
          ).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 name singleton sortable),
            required_attributes: %i(api_key name singleton sortable),
          ).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 destroy(item_type_id)
          delete_request "/item-types/#{item_type_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/item_type.rb
dato-0.1.4 lib/dato/site/repo/item_type.rb
dato-0.1.3 lib/dato/site/repo/item_type.rb
dato-0.1.2 lib/dato/site/repo/item_type.rb