<commit_before>=begin
Created on 2010/03/20

@author: <NAME>
@email: <EMAIL>

DomainRobot API interface
=end

require "XMLRPC/Client"
require "Digest/SHA2"

module INWX
  class DomainRobot
    attr_accessor :address, :username, :password, :language, :secure
    
    def initialize(address, username = false, password = <PASSWORD>, language = 'en', secure = false)
      @address = address
      @username = username
      @password = password
      @language = language
      @secure = secure
    end
    
    def call(object, method, params = {})
      if self.secure 
        # Get a one-time-"random" nonce
        nonce = Time.now.to_f
        
        # Generate hash from nonce and password.
        hash = Digest::SHA2.new(bitlen = 256) << nonce.to_s + self.password.to_s
        
        # Merge both into params
        params.merge! :nonce => nonce.to_s, :pass => hash.to_s        
      else               
        params.merge! :pass => <PASSWORD>.password
      end
      
      # Merge username into params
      params.merge! :user => self.username
     
      # Create a new client instance
      client = XMLRPC::Client.new(self.address, "/xmlrpc/" + object, "443", nil, nil, nil, nil, true, 900)
      
      # Call the remote method
      client.call(method, params)
    end
  end
end<commit_msg>The XMLRPC object is not part of the server url, but part of the method.<commit_after>=begin
Created on 2010/03/20

@author: <NAME>
@email: <EMAIL>

DomainRobot API interface
=end

require "XMLRPC/Client"
require "Digest/SHA2"

module INWX
  class DomainRobot
    attr_accessor :address, :username, :password, :language, :secure
    
    def initialize(address, username = false, password = <PASSWORD>, language = 'en', secure = false)
      @address = address
      @username = username
      @password = password
      @language = language
      @secure = secure
    end
    
    def call(object, method, params = {})
      if self.secure 
        # Get a one-time-"random" nonce
        nonce = Time.now.to_f
        
        # Generate hash from nonce and password.
        hash = Digest::SHA2.new(bitlen = 256) << nonce.to_s + self.password.to_s
        
        # Merge both into params
        params.merge! :nonce => nonce.to_s, :pass => hash.to_s        
      else               
        params.merge! :pass => <PASSWORD>
      end
      
      # Merge username into params
      params.merge! :user => self.username
     
      # Create a new client instance
      client = XMLRPC::Client.new(self.address, "/xmlrpc/", "443", nil, nil, nil, nil, true, 900)
      
      # Call the remote method
      client.call(object+"."+method, params)
    end
  end
end

{'fraction_non_alphanumeric': 0.10244428468727534, 'fraction_numerical': 0.013659237958303379, 'mean_word_length': 1.9924731182795699, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '7616275', 'n_tokens_mistral': 925, 'n_tokens_neox': 826, 'n_words': 244}