<commit_before># encoding: utf-8
require 'net/http'

module GdeposylkaApi

  class Base

    def initialize(api_key)
      @api_key = api_key
    end # new

    # Список отправлений
    def list(area = "main")

      data = {}
      block_run do |http|

        uri = request("list", {
          area: area
        })

        log("[list] => #{uri}")

        res  = http.get(uri)
        data = ::JSON.parse(res.body) rescue {}

        log("[list] <= #{data}")

      end # block_run
      data

    end # list

    # Добавить отправление
    def add(id, async = true, country = "RU", descr = nil)

      data = {}
      block_run do |http|

        uri = request("add", {
          id:       id,
          async:    async,
          country:  country,
          descr:    descr
        })

        log("[add] => #{uri}")

        res  = http.get(uri)
        data = ::JSON.parse(res.body) rescue {}

        log("[add] <= #{data}")

      end # block_run
      data

    end # add

    # Статус отправления (информация об отправлении)
    def status(id)

      data = {}
      block_run do |http|

        uri = request("status", {
          id: id
        })

        log("[status] => #{uri}")

        res  = http.get(uri)
        data = ::JSON.parse(res.body) rescue {}

        log("[status] <= #{data}")

      end # block_run
      data

    end # status

    # Изменить срану назначения посылки
    def country(id, name)

      data = {}
      block_run do |http|

        uri = request("country", {
          id:       id,
          country:  name
        })

        log("[country] => #{uri}")

        res  = http.get(uri)
        data = ::JSON.parse(res.body) rescue {}

        log("[country] <= #{data}")

      end # block_run
      data

    end # country

    # Включить SMS уведомление для трека
    def sms(id, phone, descr, greeting)

      data = {}
      block_run do |http|

        uri = request("sms", {
          id:         id,
          phone:      phone,
          descr:      descr,
          greeting:   greeting
        })

        log("[sms] => #{uri}")

        res  = http.get(uri)
        data = ::JSON.parse(res.body) rescue {}

        log("[sms] <= #{data}")

      end # block_run
      data

    end # sms

    # Возобносить отслеживание отправления
    def resume(id)

      data = {}
      block_run do |http|

        uri = request("resume", {
          id: id
        })

        log("[resume] => #{uri}")

        res  = http.get(uri)
        data = ::JSON.parse(res.body) rescue {}

        log("[resume] <= #{data}")

      end # block_run
      data

    end # resume

    # Получить географические координаты почтового отделения
    def points(ops)

      data = {}
      block_run do |http|

        uri = request("points", {
          ops: ops
        })

        log("[points] => #{uri}")

        res  = http.get(uri)
        data = ::JSON.parse(res.body) rescue {}

        log("[points] <= #{data}")

      end # block_run
      data

    end # points

    private

    def request(func, datas = {})

      datas.delete_if { |k, v| v.nil? || v == '' }

      uri = "#{::GdeposylkaApi::API_VERSION}"
      uri << "/tracks.#{func}/"
      uri << "#{::GdeposylkaApi::API_TYPE}?apikey=#{::GdeposylkaApi.api_key}"

      unless datas.empty?
        url << "&"
        url << ::URI.encode_www_form(datas)
      end

      url

    end # request

    def escape(str)
      ::URI::escape(str || "")
    end # escape

    def log(msg)

      puts(msg) if ::GdeposylkaApi.debug?
      self

    end # log

    def block_run

      ::Net::HTTP.start( ::GdeposylkaApi::HOST, :use_ssl => ::GdeposylkaApi::USE_SSL ) do |http|

        begin
          yield(http)
        rescue => e
          puts e.message
          puts e.backtrace.join("\n")
        end

      end

    end # block_run

  end # Base

end # GdeposylkaApi
<commit_msg>Опечатка.<commit_after># encoding: utf-8
require 'net/http'

module GdeposylkaApi

  class Base

    def initialize(api_key)
      @api_key = api_key
    end # new

    # Список отправлений
    def list(area = "main")

      data = {}
      block_run do |http|

        uri = request("list", {
          area: area
        })

        log("[list] => #{uri}")

        res  = http.get(uri)
        data = ::JSON.parse(res.body) rescue {}

        log("[list] <= #{data}")

      end # block_run
      data

    end # list

    # Добавить отправление
    def add(id, async = true, country = "RU", descr = nil)

      data = {}
      block_run do |http|

        uri = request("add", {
          id:       id,
          async:    async,
          country:  country,
          descr:    descr
        })

        log("[add] => #{uri}")

        res  = http.get(uri)
        data = ::JSON.parse(res.body) rescue {}

        log("[add] <= #{data}")

      end # block_run
      data

    end # add

    # Статус отправления (информация об отправлении)
    def status(id)

      data = {}
      block_run do |http|

        uri = request("status", {
          id: id
        })

        log("[status] => #{uri}")

        res  = http.get(uri)
        data = ::JSON.parse(res.body) rescue {}

        log("[status] <= #{data}")

      end # block_run
      data

    end # status

    # Изменить срану назначения посылки
    def country(id, name)

      data = {}
      block_run do |http|

        uri = request("country", {
          id:       id,
          country:  name
        })

        log("[country] => #{uri}")

        res  = http.get(uri)
        data = ::JSON.parse(res.body) rescue {}

        log("[country] <= #{data}")

      end # block_run
      data

    end # country

    # Включить SMS уведомление для трека
    def sms(id, phone, descr, greeting)

      data = {}
      block_run do |http|

        uri = request("sms", {
          id:         id,
          phone:      phone,
          descr:      descr,
          greeting:   greeting
        })

        log("[sms] => #{uri}")

        res  = http.get(uri)
        data = ::JSON.parse(res.body) rescue {}

        log("[sms] <= #{data}")

      end # block_run
      data

    end # sms

    # Возобносить отслеживание отправления
    def resume(id)

      data = {}
      block_run do |http|

        uri = request("resume", {
          id: id
        })

        log("[resume] => #{uri}")

        res  = http.get(uri)
        data = ::JSON.parse(res.body) rescue {}

        log("[resume] <= #{data}")

      end # block_run
      data

    end # resume

    # Получить географические координаты почтового отделения
    def points(ops)

      data = {}
      block_run do |http|

        uri = request("points", {
          ops: ops
        })

        log("[points] => #{uri}")

        res  = http.get(uri)
        data = ::JSON.parse(res.body) rescue {}

        log("[points] <= #{data}")

      end # block_run
      data

    end # points

    private

    def request(func, datas = {})

      datas.delete_if { |k, v| v.nil? || v == '' }

      uri = "/#{::GdeposylkaApi::API_VERSION}"
      uri << "/tracks.#{func}/"
      uri << "#{::GdeposylkaApi::API_TYPE}?apikey=#{::GdeposylkaApi.api_key}"

      unless datas.empty?
        uri << "&"
        uri << ::URI.encode_www_form(datas)
      end

      uri

    end # request

    def escape(str)
      ::URI::escape(str || "")
    end # escape

    def log(msg)

      puts(msg) if ::GdeposylkaApi.debug?
      self

    end # log

    def block_run

      ::Net::HTTP.start( ::GdeposylkaApi::HOST, :use_ssl => ::GdeposylkaApi::USE_SSL ) do |http|

        begin
          yield(http)
        rescue => e
          puts e.message
          puts e.backtrace.join("\n")
        end

      end

    end # block_run

  end # Base

end # GdeposylkaApi

{'fraction_non_alphanumeric': 0.14331743781415132, 'fraction_numerical': 0.0002577651759247326, 'mean_word_length': 1.5823627287853577, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4196765', 'n_tokens_mistral': 2666, 'n_tokens_neox': 2605, 'n_words': 590}