<commit_before>require "json"

module Messenger
  module Bot
    # Represent links to be embedded in messages
    class Link
      # Create a Link with *title* and either *url* or *callback*
      # Both will be displayed as links in messenger with *title* as link text,
      # but links with *callback* will link back to the both with this payload while
      # links with *url*  will link to a website.
      def self.create(title : String, url : String = nil, callback : String = nil)
        if url
          URLLink.new(title, url)
        elsif callback
          CallbackLink.new(title, callback)
        else
          raise "Need either callback or url"
        end
      end

      # :nodoc:
      def to_json_string
        raise "Not implemented"
      end

      def to_tuple
        raise "Not implemented"
      end
    end

    # :nodoc:<commit_msg>Implement to_json in Link<commit_after>require "json"

module Messenger
  module Bot
    # Represent links to be embedded in messages
    class Link
      # Create a Link with *title* and either *url* or *callback*
      # Both will be displayed as links in messenger with *title* as link text,
      # but links with *callback* will link back to the both with this payload while
      # links with *url*  will link to a website.
      def self.create(title : String, url : String = nil, callback : String = nil)
        if url
          URLLink.new(title, url)
        elsif callback
          CallbackLink.new(title, callback)
        else
          raise "Need either callback or url"
        end
      end

      # :nodoc:
      def to_json_string
        raise "Not implemented"
      end

      def to_json(io : IO)
        to_tuple.to_json(io)
      end

      def to_tuple
        raise "Not implemented"
      end
    end

    # :nodoc:
{'fraction_non_alphanumeric': 0.06294864715626726, 'fraction_numerical': 0.0, 'mean_word_length': 2.0301003344481607, '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': '2819182', 'n_tokens_mistral': 505, 'n_tokens_neox': 494, 'n_words': 209}