<commit_before>#
# The FastbillAutomatic::Customer class wraps basic interactions for
# customer.get|update|delete service calls.
#
module FastbillAutomatic
  class Customer
    PARSED_ATTRIBUTES = %w(customer_id customer_number
      salutation first_name last_name organization
      address zipcode city country_code phone email
      days_for_payment payment_type currency_code customer_type
      bank_name bank_account_number bank_code bank_account_owner vat_id
      show_payment_notice comment newsletter_optin
      created lastupdate customer_ext_uid
    )

    def self.parse data
      customer = self.new()

      PARSED_ATTRIBUTES.each do |attribute|
        customer.attributes[attribute.downcase] = data.fetch(attribute.upcase, '')
      end

      return customer
    end

    # returns an Enumerable containing Customer objects
    # filter supports the following keys:
    #   * customer_id      same as .find_by_id
    #   * customer_number  search customer by exact customer_number
    #   * country_code     search customers by country
    #   * city             search customers by city
    #   * term             search customers by term (only ORGANIZATION, FIRST_NAME, LAST_NAME, ADDRESS, ADDRESS_2, ZIPCODE, EMAIL)
    def self.all filter = {}, client = FastbillAutomatic.client
      response = client.execute_request('customer.get', { filter: filter })

      results = []
      if response.success?
        results = response.fetch('customers').map { |data| Customer.parse(data) }
      else
        # TODO handle error case
        p response.errors
      end
      return results
    end

    # returns an Customer or UnknownCustomer if id is unknown
    def self.find_by_id id, client = FastbillAutomatic.client
      response = client.execute_request('customer.get', { filter: { customer_id: id } })

      if response.success? && (customers_data = response.fetch('customers')).length > 0
        self.parse(customers_data[0])
      else
        return UnknownCustomer.new
      end
    end

    attr_accessor :client
    attr_accessor :attributes

    def initialize client = FastbillAutomatic.client
      @client = client
      @attributes = Hash.new
    end

    def create
      # customer.create
    end
<commit_msg>update Customer RDoc<commit_after>#
# The FastbillAutomatic::Customer class wraps basic interactions for
# customer.get|update|delete service calls.
#
module FastbillAutomatic
  class Customer
    PARSED_ATTRIBUTES = %w(customer_id customer_number
      salutation first_name last_name organization
      address zipcode city country_code phone email
      days_for_payment payment_type currency_code customer_type
      bank_name bank_account_number bank_code bank_account_owner vat_id
      show_payment_notice comment newsletter_optin
      created lastupdate customer_ext_uid
    )

    def self.parse data
      customer = self.new()

      PARSED_ATTRIBUTES.each do |attribute|
        customer.attributes[attribute.downcase] = data.fetch(attribute.upcase, '')
      end

      return customer
    end

    # returns an Enumerable containing Customer objects.
    #
    # Filter supports the following keys:
    # * customer_id      same as .find_by_id
    # * customer_number  search customer by exact customer_number
    # * country_code     search customers by country
    # * city             search customers by city
    # * term             search customers by term (only ORGANIZATION, FIRST_NAME, LAST_NAME, ADDRESS, ADDRESS_2, ZIPCODE, EMAIL)
    def self.all filter = {}, client = FastbillAutomatic.client
      response = client.execute_request('customer.get', { filter: filter })

      results = []
      if response.success?
        results = response.fetch('customers').map { |data| Customer.parse(data) }
      else
        # TODO handle error case
        p response.errors
      end
      return results
    end

    # returns an Customer if the id is known.
    # otherwise returns an instance of UnknownCustomer
    def self.find_by_id id, client = FastbillAutomatic.client
      response = client.execute_request('customer.get', { filter: { customer_id: id } })

      if response.success? && (customers_data = response.fetch('customers')).length > 0
        self.parse(customers_data[0])
      else
        return UnknownCustomer.new
      end
    end

    attr_accessor :client
    attr_accessor :attributes

    def initialize client = FastbillAutomatic.client
      @client = client
      @attributes = Hash.new
    end

    def create
      # customer.create
    end

{'fraction_non_alphanumeric': 0.06589062156819679, 'fraction_numerical': 0.001317812431363936, 'mean_word_length': 2.8790459965928448, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4919115', 'n_tokens_mistral': 1254, 'n_tokens_neox': 1215, 'n_words': 357}