<commit_before>module Iugu
  class Invoice < APIResource
    include Iugu::APIFetch
    include Iugu::APICreate
    include Iugu::APISave
    include Iugu::APIDelete

    def customer
      return false unless @attributes['customer_id']
      Customer.fetch @attributes['customer_id']
    end

    def cancel
      copy Iugu::Factory.create_from_response(self.class.object_type, APIRequest.request('PUT', "#{self.class.url(id)}/cancel"))
      self.errors = nil
      true
    rescue Iugu::RequestWithErrors => ex
      self.errors = ex.errors
      false
    end

    def delete<commit_msg>Invoice capture method<commit_after>module Iugu
  class Invoice < APIResource
    include Iugu::APIFetch
    include Iugu::APICreate
    include Iugu::APISave
    include Iugu::APIDelete

    def customer
      return false unless @attributes['customer_id']
      Customer.fetch @attributes['customer_id']
    end

    def cancel
      copy Iugu::Factory.create_from_response(self.class.object_type, APIRequest.request('PUT', "#{self.class.url(id)}/cancel"))
      self.errors = nil
      true
    rescue Iugu::RequestWithErrors => ex
      self.errors = ex.errors
      false
    end

    def capture
      copy Iugu::Factory.create_from_response(self.class.object_type, APIRequest.request('POST', "#{self.class.url(id)}/capture"))
      self.errors = nil
      true
    rescue Iugu::RequestWithErrors => ex
      self.errors = ex.errors
      false
    end

    def delete
{'fraction_non_alphanumeric': 0.09897610921501707, 'fraction_numerical': 0.0, 'mean_word_length': 3.1064425770308124, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '5902540', 'n_tokens_mistral': 439, 'n_tokens_neox': 432, 'n_words': 97}