<commit_before># encoding: UTF-8

require "faraday"
require "json"

class SmsUslugiApi

  BASE_API_URL = "https://lcab.sms-uslugi.ru/lcabApi"

  def initialize(username, password)
    @username = username
    @password = password
    @api = Faraday.new
  end

  # https://lcab.sms-uslugi.ru/integration/lcabApi#main/Другое/orgInfo
  def info
    api_request("info.php")
  end

  # https://lcab.sms-uslugi.ru/integration/lcabApi#main/pager/send
  # txt must be in UTF-8 encoding!
  #def send(txt, to, idGroup = nil, source = nil, flash = 0, dateTimeSend = nil, onlydelivery = 0, use_alfasource = nil, discountID = nil)
  def send(txt, to, options = {})
    options.default = nil
    api_request("sendSms.php", {
      txt: txt,
      to: to,
      idGroup: options[:idGroup],
      source: options[:source],
      flash: options[:flash],
      dateTimeSend: options[:dateTimeSend],
      onlydelivery: options[:onlydelivery],
      use_alfasource: options[:use_alfasource],
      discountID: options[:discountID]
    })
  end

  def get_phone_info(phone)
    api_request("getPhoneInfo.php", {
      phone: phone
    })
  end

  private

  def api_request(url, options = {})
    url = "#{BASE_API_URL}/#{url}"
    options[:login] = @username
    options[:password] = <PASSWORD>
    JSON::parse @api.get(url, options).body, symbolize_names: true
  end

end
<commit_msg>Update sms-uslugi-api.rb<commit_after># encoding: UTF-8

require "faraday"
require "json"

class SmsUslugiApi

  BASE_API_URL = "https://lcab.sms-uslugi.ru/lcabApi"

  def initialize(username, password)
    @username = username
    @password = password
    @api = Faraday.new
  end

  # https://lcab.sms-uslugi.ru/integration/lcabApi#main/Другое/orgInfo
  def info
    api_request("info.php")
  end

  # https://lcab.sms-uslugi.ru/integration/lcabApi#main/pager/send
  # txt must be in UTF-8 encoding!
  #def send(txt, to, idGroup = nil, source = nil, flash = 0, dateTimeSend = nil, onlydelivery = 0, use_alfasource = nil, discountID = nil)
  def send(txt, to, options = {})
    options.default = nil
    api_request("sendSms.php", {
      txt: txt,
      to: to,
      idGroup: options[:idGroup],
      source: options[:source],
      flash: options[:flash],
      dateTimeSend: options[:dateTimeSend],
      onlydelivery: options[:onlydelivery],
      use_alfasource: options[:use_alfasource],
      discountID: options[:discountID],
      channel: options[:channel]
    })
  end

  def get_phone_info(phone)
    api_request("getPhoneInfo.php", {
      phone: phone
    })
  end

  private

  def api_request(url, options = {})
    url = "#{BASE_API_URL}/#{url}"
    options[:login] = @username
    options[:password] = <PASSWORD>
    JSON::parse @api.get(url, options).body, symbolize_names: true
  end

end

{'fraction_non_alphanumeric': 0.13467770975873244, 'fraction_numerical': 0.0028808066258552397, 'mean_word_length': 3.347417840375587, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 6, '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': '4081102', 'n_tokens_mistral': 1006, 'n_tokens_neox': 981, 'n_words': 201}