<commit_before>module ToolSlots
  class Create < Mutations::Command
    required do
      model :device, class: Device
      string :name
      integer :x
      integer :y
      integer :z
      integer :tool_bay_id
    end

    def validate
      if !device.tool_bays.where(id: tool_bay_id).any?
        add_error :tool_bay_id,
                  :not_found,
                  "Can't find tool bay with id #{tool_bay_id}"
      end
    end

    def execute
      ToolSlot.create!(inputs.except(:device))
    end
  end
end
<commit_msg>Make fields optional on API<commit_after>module ToolSlots
  class Create < Mutations::Command
    required do
      model :device, class: Device
      integer :tool_bay_id
    end

    optional do
      integer :tool_id
      string :name
      integer :x
      integer :y
      integer :z
    end

    def validate
      if !device.tool_bays.where(id: tool_bay_id).any?
        add_error :tool_bay_id,
                  :not_found,
                  "Can't find tool bay with id #{tool_bay_id}"
      end
    end

    def execute
      ToolSlot.create!(inputs.except(:device))
    end
  end
end

{'fraction_non_alphanumeric': 0.07168141592920355, 'fraction_numerical': 0.0, 'mean_word_length': 1.9530026109660574, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6181641', 'n_tokens_mistral': 360, 'n_tokens_neox': 340, 'n_words': 99}