<commit_before>class ExternalType
  attr_reader :url, :client

  def initialize(url, client: ExternalType::ClientWithCache.new)
    @url = url
    @client = client
  end

  def valid?
    expected = %w(locales item_name fields)
    (expected - json.keys).empty?
  rescue ExternalType::Client::NotFound
    false
  end

  def name(locale=I18n.locale)
    json["item_name"][locale.to_s]
  end

  def locales
    json["locales"]
  end

  def find_item(id)
    item_json = get("items", id)
    ExternalType::Item.from_json(item_json)
  end

  def all_items
    # TODO: support pagination
    @items ||= begin
      items_json = get("items")
      items_json["results"].map(&ExternalType::Item.method(:from_json))
    end<commit_msg>Parse id as int, to allow pretty params<commit_after>class ExternalType
  attr_reader :url, :client

  def initialize(url, client: ExternalType::ClientWithCache.new)
    @url = url
    @client = client
  end

  def valid?
    expected = %w(locales item_name fields)
    (expected - json.keys).empty?
  rescue ExternalType::Client::NotFound
    false
  end

  def name(locale=I18n.locale)
    json["item_name"][locale.to_s]
  end

  def locales
    json["locales"]
  end

  def find_item(id)
    item_json = get("items", id.to_i.to_s)
    ExternalType::Item.from_json(item_json)
  end

  def all_items
    # TODO: support pagination
    @items ||= begin
      items_json = get("items")
      items_json["results"].map(&ExternalType::Item.method(:from_json))
    end
{'fraction_non_alphanumeric': 0.11595174262734584, 'fraction_numerical': 0.002680965147453083, 'mean_word_length': 3.5242424242424244, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5187277', 'n_tokens_mistral': 517, 'n_tokens_neox': 496, 'n_words': 110}