findByNumber method

Future<Invoice?> findByNumber(
  1. String number
)

Find an invoice by its number

Implementation

Future<Invoice?> findByNumber(String number) async {
  final response = await WebClient().get(
      '${InvoiceNinjaAdmin.url}/api/v1/invoices?invoice_number=$number',
      token: InvoiceNinjaAdmin.token);

  final data = InvoiceList.fromJson(response).data;

  return data.isEmpty ? null : data.first;
}