<commit_before>module Esortcode
  class Client
    include HTTParty
    
    base_uri 'https://ws.esortcode.com/bankdetails.asmx'
    default_params :sIPAddress => ''
    
    # Creates an instance of the client.
    # 
    # +account_name+::
    #   The name of your account with esortcode.com. This 
    #   is sent to you via email and is listed as 
    #   AccountName and is uppercase.
    # +license_id+::
    #   The license ID of your account. This is a string 
    #   of letters and numbers intersperced with hyphens.
    def initialize(account_name, license_id)
      self.class.default_params :sUserName => account_name,
                                :sGUID => license_id
    end
    
    # This function is used to Validate a UK Bank Sortcode and Account Number.
    # 
    # If either +sort_code+ or +account_number+ are invalid an exception will
    # be raised, they are +InvalidSortcode+ and +InvalidAccountNumber+
    # respectively.
    def validate_account(sort_code, account_number)
      validate_sort_code(sort_code)
      validate_account_number(account_number)
      
      self.class.post('ValidateAccount',
        { :sSortcode => sort_code,
          :sAccountNumber => account_number})
    end
    
    # This function is used to return the Branch Details for a Sort Code.
    # 
    # If +sort_code+ is invalid an exception +InvalidSortcode+ will be
    # raised.
    def branch_details(sort_code)
      validate_sort_code(sort_code)
      
      self.class.post('BranchDetails', {:sSortcode => sort_code})
    end
    
    # This function is used to transpose Non-standard 
    # (i.e. 6, 7, 9 & 10 digit) Account Numbers into 
    # Standard (i.e. 8 digit) Account Numbers.
    # 
    # If either +sort_code+ or +account_number+ are invalid an exception will
    # be raised, they are +InvalidSortcode+ and +ValidationError+
    # respectively. The +ValidationError+ is raised in the case that
    # the +account_number+ is not composed of only digits.
    def standardise_account(sort_code, account_number)
      validate_sort_code(sort_code)
      unless account_number.match(/[0-9]+/)
        raise ValidationError, "#{account_number} is not valid."
      end<commit_msg>Ensure provided account numbers are at least 6 to 10 digits in length. Account numbers which are not 6 - 10 digits long will result in a validation error from the eSortCode service.<commit_after>module Esortcode
  class Client
    include HTTParty
    
    base_uri 'https://ws.esortcode.com/bankdetails.asmx'
    default_params :sIPAddress => ''
    
    # Creates an instance of the client.
    # 
    # +account_name+::
    #   The name of your account with esortcode.com. This 
    #   is sent to you via email and is listed as 
    #   AccountName and is uppercase.
    # +license_id+::
    #   The license ID of your account. This is a string 
    #   of letters and numbers intersperced with hyphens.
    def initialize(account_name, license_id)
      self.class.default_params :sUserName => account_name,
                                :sGUID => license_id
    end
    
    # This function is used to Validate a UK Bank Sortcode and Account Number.
    # 
    # If either +sort_code+ or +account_number+ are invalid an exception will
    # be raised, they are +InvalidSortcode+ and +InvalidAccountNumber+
    # respectively.
    def validate_account(sort_code, account_number)
      validate_sort_code(sort_code)
      validate_account_number(account_number)
      
      self.class.post('ValidateAccount',
        { :sSortcode => sort_code,
          :sAccountNumber => account_number})
    end
    
    # This function is used to return the Branch Details for a Sort Code.
    # 
    # If +sort_code+ is invalid an exception +InvalidSortcode+ will be
    # raised.
    def branch_details(sort_code)
      validate_sort_code(sort_code)
      
      self.class.post('BranchDetails', {:sSortcode => sort_code})
    end
    
    # This function is used to transpose Non-standard 
    # (i.e. 6, 7, 9 & 10 digit) Account Numbers into 
    # Standard (i.e. 8 digit) Account Numbers.
    # 
    # If either +sort_code+ or +account_number+ are invalid an exception will
    # be raised, they are +InvalidSortcode+ and +ValidationError+
    # respectively. The +ValidationError+ is raised in the case that
    # the +account_number+ is not composed of only digits.
    def standardise_account(sort_code, account_number)
      validate_sort_code(sort_code)
      unless account_number.match(/[0-9]{6,10}/)
        raise ValidationError, "#{account_number} is not valid."
      end
{'fraction_non_alphanumeric': 0.07692307692307693, 'fraction_numerical': 0.005447809980387884, 'mean_word_length': 2.762295081967213, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 2, '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': '2229905', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1317, 'n_words': 444}