<commit_before>require 'digest'
require 'net/http'
require 'net/https'
require 'json'

module Goldenpay
  module Request

    def self.get_payment_key(options)

      uri = URI(Goldenpay.payment_key_url)

      # Create client<commit_msg>Get Results<commit_after>require 'digest'
require 'net/http'
require 'net/https'
require 'json'

module Goldenpay
  module Request
    def self.get_results(payment_key)

      auth_key = Goldenpay.auth_key
      hash_code = Digest::MD5.hexdigest(auth_key + payment_key)

      uri = URI(Goldenpay.payment_result_url + '?payment_key=' + payment_key + '&hash_code=' + hash_code)

      # Create client
      http = Net::HTTP.new(uri.host, uri.port)
      http.use_ssl = true
      http.verify_mode = OpenSSL::SSL::VERIFY_PEER

      # Create Request
      req =  Net::HTTP::Post.new(uri)
      req.add_field "Content-Type", "application/json"
      req.add_field "Accept", "application/json"

      # Fetch Request
      res = http.request(req)

      parsed_res = JSON.parse(res.body)

      if parsed_res["status"]["code"] == 1
        parsed_res
      else
        raise GoldenpayResponseError, "Goldenpay responded with: #{parsed_res["status"]["code"]} | #{parsed_res["status"]["message"]}"
      end
    rescue StandardError => e
      raise HTTPResponseError, "Goldenpay request failed: #{res.code}"
    end

    def self.get_payment_key(options)

      uri = URI(Goldenpay.payment_key_url)

      # Create client
{'fraction_non_alphanumeric': 0.1161512027491409, 'fraction_numerical': 0.0013745704467353953, 'mean_word_length': 3.3333333333333335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '6056167', 'n_tokens_mistral': 474, 'n_tokens_neox': 467, 'n_words': 97}