<commit_before># encoding: utf-8
require 'socket'
require 'openssl'
require 'json'
require 'net-http2'

require 'jwt'

module APNS

  class Http2Client

    attr_reader :host, :port, :key_id, :team_id

    def initialize(auth_key, key_id, team_id, mode = :development)
      check_openssl_version
      @mode = mode
      @host = production? ? 'api.push.apple.com' : 'api.development.push.apple.com'
      @auth_key = auth_key.is_a?(String) ? OpenSSL::PKey::EC.new(auth_key) : auth_key
      @key_id = key_id
      @team_id = team_id
      @client = NetHttp2::Client.new("https://#{@host}")
    end

    def production?
      @mode == :production
    end

    def send_notification(device_token, bundle_identifier, message)
      send_notifications([APNS::Notification.new(device_token, message)], bundle_identifier)
    end<commit_msg>Allow to provide an error callback into this weirdo async system<commit_after># encoding: utf-8
require 'socket'
require 'openssl'
require 'json'
require 'net-http2'

require 'jwt'

module APNS

  class Http2Client

    attr_reader :host, :port, :key_id, :team_id

    def initialize(auth_key, key_id, team_id, mode = :development, error_callback = nil)
      check_openssl_version
      @mode = mode
      @host = production? ? 'api.push.apple.com' : 'api.development.push.apple.com'
      @auth_key = auth_key.is_a?(String) ? OpenSSL::PKey::EC.new(auth_key) : auth_key
      @key_id = key_id
      @team_id = team_id
      @client = NetHttp2::Client.new("https://#{@host}")
      if error_callback
        @client.on(:error) do |exception|
          error_callback.call(exception)
        end
      end
    end

    def production?
      @mode == :production
    end

    def send_notification(device_token, bundle_identifier, message)
      send_notifications([APNS::Notification.new(device_token, message)], bundle_identifier)
    end
{'fraction_non_alphanumeric': 0.11739594450373532, 'fraction_numerical': 0.004268943436499467, 'mean_word_length': 3.528985507246377, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '5087886', 'n_tokens_mistral': 625, 'n_tokens_neox': 610, 'n_words': 137}