<commit_before>module Neteller
  class Client
    include HTTParty

    def self.config=(config)
      @@config = config
    end

    def self.config
      @@config
    end

    def initialize
      @client_id, @client_secret, @webhook_key = @@config.to_a
    end

    def headers
      {
        "Content-Type" => "application/json",
        "Authorization" => "Bearer #{obtain_access_token['accessToken']}"
      }
    end

    def pay!(payment)
      response = HTTParty.post("https://test.api.neteller.com/v1/orders", :body => payment.to_h.to_json, :headers => headers )
      Response.new(response).to_h
    end

    def obtain_access_token
      HTTParty.post("https://test.api.neteller.com/v1/oauth2/token?grant_type=client_credentials",
                    :headers => { 'Content-Type' => 'application/json', 'Cache-control' => 'no-cache' },
                    :basic_auth => { username: @client_id, password: <PASSWORD> })
    end

    def order_lookup(url)
      HTTParty.get(url[0..-9], :headers => headers).to_h
    end
  end
end<commit_msg>Refractor payment method<commit_after>module Neteller
  class Client
    include HTTParty

    def self.config=(config)
      @@config = config
    end

    def self.config
      @@config
    end

    def initialize
      @client_id, @client_secret, @webhook_key = @@config.to_a
    end

    def headers
      {
        "Content-Type" => "application/json",
        "Authorization" => "Bearer #{obtain_access_token['accessToken']}"
      }
    end

    def pay!(order)
      response = HTTParty.post("https://test.api.neteller.com/v1/orders", :body => order.to_h.to_json, :headers => headers )
      Response.new(response).to_h
    end


    def obtain_access_token
      HTTParty.post("https://test.api.neteller.com/v1/oauth2/token?grant_type=client_credentials",
                    :headers => { 'Content-Type' => 'application/json', 'Cache-control' => 'no-cache' },
                    :basic_auth => { username: @client_id, password: <PASSWORD> })
    end

    def order_lookup(url)
      HTTParty.get(url[0..-9], :headers => headers).to_h
    end
  end
end
{'fraction_non_alphanumeric': 0.13516068052930058, 'fraction_numerical': 0.004725897920604915, 'mean_word_length': 2.552013422818792, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 4, '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': '6681392', 'n_tokens_mistral': 702, 'n_tokens_neox': 673, 'n_words': 125}