Sha256: 1f2db24c6cfa75bfb34c42714fc46f3927ab4cb2a960cc6bf20cc82cd31d28e2

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

require 'dato/repo/base'

module Dato
  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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dato-0.1.1 lib/dato/repo/item_type.rb
dato-0.1.0 lib/dato/repo/item_type.rb