<commit_before>module Besepa

  class Customer < Besepa::Resource
    
    include Besepa::ApiCalls::List
    include Besepa::ApiCalls::Create
    include Besepa::ApiCalls::Update
    include Besepa::ApiCalls::Destroy
        
    FIELDS = [:id, :name, :taxid, :reference,
              :contact_name, :contact_email, :contact_phone, :contact_language,
              :address_street, :address_city, :address_postalcode, :address_state, :address_country,
              :status]
    
    FIELDS.each do |f|
      attr_accessor f
    end
    
    def bank_accounts
      BankAccount.all( {:customer_id => id} )
    end
    
    def debits
      Debit.all( {:customer_id => id} )
    end
    
    def subscriptions
      Subscription.all( {:customer_id => id} )
    end

    def add_bank_account(iban, bic, bank_name=nil)
      params = {:iban => iban, :bic => bic }
      params[:bank_name] = bank_name if bank_name
      BankAccount.create( params, {:customer_id => id} )
    end
    
    def add_debit(mandate_id, reference, description, amount, collect_at, creditor_account_id=nil, metadata=nil)
      params = {:reference => reference, :description => description, :mandate_id => mandate_id,
                :amount => amount, :collect_at => collect_at}
      params[:creditor_account_id] = creditor_account_id if creditor_account_id
      params[:metadata] = metadata if metadata
      Debit.create( params, {:customer_id => id} )
    end<commit_msg>using debtor_bank_account instead of mandate to create debits<commit_after>module Besepa

  class Customer < Besepa::Resource
    
    include Besepa::ApiCalls::List
    include Besepa::ApiCalls::Create
    include Besepa::ApiCalls::Update
    include Besepa::ApiCalls::Destroy
        
    FIELDS = [:id, :name, :taxid, :reference,
              :contact_name, :contact_email, :contact_phone, :contact_language,
              :address_street, :address_city, :address_postalcode, :address_state, :address_country,
              :status]
    
    FIELDS.each do |f|
      attr_accessor f
    end
    
    def bank_accounts
      BankAccount.all( {:customer_id => id} )
    end
    
    def debits
      Debit.all( {:customer_id => id} )
    end
    
    def subscriptions
      Subscription.all( {:customer_id => id} )
    end

    def add_bank_account(iban, bic, bank_name=nil)
      params = {:iban => iban, :bic => bic }
      params[:bank_name] = bank_name if bank_name
      BankAccount.create( params, {:customer_id => id} )
    end
    
    def add_debit(debtor_bank_account_id, reference, description, amount, collect_at, creditor_account_id=nil, metadata=nil)
      params = {:reference => reference, :description => description, :debtor_bank_account_id => debtor_bank_account_id,
                :amount => amount, :collect_at => collect_at}
      params[:creditor_account_id] = creditor_account_id if creditor_account_id
      params[:metadata] = metadata if metadata
      Debit.create( params, {:customer_id => id} )
    end
{'fraction_non_alphanumeric': 0.10441767068273092, 'fraction_numerical': 0.0, 'mean_word_length': 3.0283018867924527, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '733147', 'n_tokens_mistral': 969, 'n_tokens_neox': 924, 'n_words': 210}