<commit_before>=begin
Represents the 3D Cart Customer response object
=end
module ThreeDeeCart
  class Customer < ThreeDeeCart::Base

    attr_accessor :customer_id
    attr_accessor :user_id
    attr_accessor :password
    attr_accessor :last_login_date
    attr_accessor :web_site
    attr_accessor :discount_group
    attr_accessor :cust_other1
    attr_accessor :account_number
    attr_accessor :mail_list
    attr_accessor :customer_type
    attr_accessor :last_update
    attr_accessor :cust_enabled
    attr_accessor :comments
    attr_reader   :billing_address
    attr_reader   :shipping_address
    attr_reader   :additional_fields
    
    # Invoke a :get_customer SOAP operation
    # Request options: 
    # storeURL*       - 3dCart Store URL from which the information will be requested. i.e.: www.3dcart.com
    # batchSize*      - Number of records to pull. Range: 1 to 100.
    # startNum*       - Position to start the search. Range: 1 to x
    # customersFilter - Comma delimited string with zero or more search parameters. Allowed parameters: firstname,
    #                   lastname, email, countrycode, statecode, city, phone.
    #                   i.e.: firstname=John,email=<EMAIL>, countrycode=US,statecode=FL,city=Margate
    #
    # Returns ThreeDeeCart::Customer instances for each returned value
    def self.find(request_options)
      resp = self.request(:get_customer, request_options)

      resp_obj = resp[:customers_request_response][:customer]
      if resp_obj.is_a?(Hash)
        self.new(resp_obj)
      else
        customer_arr = []
        resp_obj.each do |resp_hash|
          customer_arr << self.new(resp_hash)
        end

        customer_arr
      end
    end

    # Invoke :get_customer_count SOAP operation
    # Request Options:
    # storeURL*       - 3dCart Store URL from which the information will be requested. i.e.: www.3dcart.com
    # 
    # Returns total customer count for the store
    def self.count(request_options)
      resp = self.request(:get_customer_count, request_options)
      resp[:customer_count_response][:customer_count].to_i
    end

    # Invoke :edit_customer SOAP operation
    # Request Options:
    # customer_data   - customer data initialized with one of the valid actions [:insert, :update, :delete] and hash of attributes
    # storeURL*       - 3dCart Store URL from which the information will be requested. i.e.: www.3dcart.com
    # 
    # Returns total customer count for the store
    def self.edit(customer_data, request_options = {})
      if not customer_data.valid?
        return false
      end

      resp = self.request(:edit_customer, request_options.merge(:customerData => customer_data.to_query, :action => customer_data.action))
      resp[:edit_customer_response][:result] == "OK"
    end

    # Custom setter for billing address, creates a ThreeDeeCart::BillingAddress instance
    def billing_address=(value)
      if value.class.name != "Hash"<commit_msg>[DOC] fix edit customer documentation<commit_after>=begin
Represents the 3D Cart Customer response object
=end
module ThreeDeeCart
  class Customer < ThreeDeeCart::Base

    attr_accessor :customer_id
    attr_accessor :user_id
    attr_accessor :password
    attr_accessor :last_login_date
    attr_accessor :web_site
    attr_accessor :discount_group
    attr_accessor :cust_other1
    attr_accessor :account_number
    attr_accessor :mail_list
    attr_accessor :customer_type
    attr_accessor :last_update
    attr_accessor :cust_enabled
    attr_accessor :comments
    attr_reader   :billing_address
    attr_reader   :shipping_address
    attr_reader   :additional_fields
    
    # Invoke a :get_customer SOAP operation
    # Request options: 
    # storeURL*       - 3dCart Store URL from which the information will be requested. i.e.: www.3dcart.com
    # batchSize*      - Number of records to pull. Range: 1 to 100.
    # startNum*       - Position to start the search. Range: 1 to x
    # customersFilter - Comma delimited string with zero or more search parameters. Allowed parameters: firstname,
    #                   lastname, email, countrycode, statecode, city, phone.
    #                   i.e.: firstname=John,email=<EMAIL>, countrycode=US,statecode=FL,city=Margate
    #
    # Returns ThreeDeeCart::Customer instances for each returned value
    def self.find(request_options)
      resp = self.request(:get_customer, request_options)

      resp_obj = resp[:customers_request_response][:customer]
      if resp_obj.is_a?(Hash)
        self.new(resp_obj)
      else
        customer_arr = []
        resp_obj.each do |resp_hash|
          customer_arr << self.new(resp_hash)
        end

        customer_arr
      end
    end

    # Invoke :get_customer_count SOAP operation
    # Request Options:
    # storeURL*       - 3dCart Store URL from which the information will be requested. i.e.: www.3dcart.com
    # 
    # Returns total customer count for the store
    def self.count(request_options)
      resp = self.request(:get_customer_count, request_options)
      resp[:customer_count_response][:customer_count].to_i
    end

    # Invoke :edit_customer SOAP operation
    # customer_data   - customer data initialized with one of the valid actions [:insert, :update, :delete] and hash of attributes
    # Request Options:
    # storeURL*       - 3dCart Store URL from which the information will be requested. i.e.: www.3dcart.com
    # 
    # Returns total customer count for the store
    def self.edit(customer_data, request_options = {})
      if not customer_data.valid?
        return false
      end

      resp = self.request(:edit_customer, request_options.merge(:customerData => customer_data.to_query, :action => customer_data.action))
      resp[:edit_customer_response][:result] == "OK"
    end

    # Custom setter for billing address, creates a ThreeDeeCart::BillingAddress instance
    def billing_address=(value)
      if value.class.name != "Hash"
{'fraction_non_alphanumeric': 0.07341602413677506, 'fraction_numerical': 0.004358028830036876, 'mean_word_length': 3.061946902654867, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '495979', 'n_tokens_mistral': 1762, 'n_tokens_neox': 1711, 'n_words': 491}