<commit_before>'use strict'

const RecurlyData = require('../recurly-data')
const _ = require('lodash')
const handleRecurlyError = require('../util').handleRecurlyError
const querystring = require('querystring')
const data2xml = require('data2xml')({
  undefined: 'empty',
  null: 'closed'
})
const debug = require('debug')('recurring')

class Invoice extends RecurlyData {
  constructor(recurring) {
    super({
      recurring,
      properties: [
        'account',
        'address',
        'adjustment',
        'created_at',
        'closed_at',
        'currency',
        'customer_notes',
        'collection_method',
        'invoice_number',
        'invoice_number_prefix',
        'line_items',
        'net_terms',
        'po_number',
        'state',
        'subtotal_in_cents',
        'tax_in_cents',
        'terms_and_conditions',
        'total_in_cents',
        'transactions',
        'uuid',
        'vat_number'
      ],
      idField: 'uuid',
      plural: 'invoices',
      singular: 'invoice'
    })
  }

  static get SINGULAR() {
    return 'invoice'
  }

  static get PLURAL() {
    return 'invoices'
  }

  static get ENDPOINT() {
    return `${RecurlyData.ENDPOINT}${Invoice.PLURAL}`
  }

  all(state, callback) {
    if (typeof callback === 'undefined' && typeof state === 'function') {
      callback = state
      state = 'active'
    }

    this.fetchAll('Invoice', `${Invoice.ENDPOINT}?${querystring.stringify({
      state
    })}`, (err, results) => {
      const data = { }
      _.each(results, invoice => {
        data[invoice.uuid] = invoice<commit_msg>fix: invalid_state error on Invoice#all (#59)<commit_after>'use strict'

const RecurlyData = require('../recurly-data')
const _ = require('lodash')
const handleRecurlyError = require('../util').handleRecurlyError
const querystring = require('querystring')
const data2xml = require('data2xml')({
  undefined: 'empty',
  null: 'closed'
})
const debug = require('debug')('recurring')

class Invoice extends RecurlyData {
  constructor(recurring) {
    super({
      recurring,
      properties: [
        'account',
        'address',
        'adjustment',
        'created_at',
        'closed_at',
        'currency',
        'customer_notes',
        'collection_method',
        'invoice_number',
        'invoice_number_prefix',
        'line_items',
        'net_terms',
        'po_number',
        'state',
        'subtotal_in_cents',
        'tax_in_cents',
        'terms_and_conditions',
        'total_in_cents',
        'transactions',
        'uuid',
        'vat_number'
      ],
      idField: 'uuid',
      plural: 'invoices',
      singular: 'invoice'
    })
  }

  static get SINGULAR() {
    return 'invoice'
  }

  static get PLURAL() {
    return 'invoices'
  }

  static get ENDPOINT() {
    return `${RecurlyData.ENDPOINT}${Invoice.PLURAL}`
  }

  all(state, callback) {
    let url = Invoice.ENDPOINT

    if (typeof callback === 'undefined' && typeof state === 'function') {
      callback = state
    } else {
      url += `?${querystring.stringify({ state })}`
    }

    this.fetchAll('Invoice', url, (err, results) => {
      const data = { }
      _.each(results, invoice => {
        data[invoice.uuid] = invoice
{'fraction_non_alphanumeric': 0.1462060456508328, 'fraction_numerical': 0.001850709438618137, 'mean_word_length': 2.517353579175705, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '6472480', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1025, 'n_words': 202}