deleteInvoice method

  1. @override
Future<bool> deleteInvoice(
  1. String invoiceNumber
)
override

Delete invoice, by its number.

Throw UnauthorizedException when the secret key is invalid. Throw NotFoundException when no match was found with the invoiceNumber. It throws exception TelePayException with any other error.

Implementation

@override
Future<bool> deleteInvoice(String invoiceNumber) async {
  try {
    final response = await _dio.post<Map<String, dynamic>>(
      'deleteInvoice/$invoiceNumber',
      options: Options(headers: _headers),
    );
    if (response.statusCode == 200 && response.data != null) {
      return response.data!['status'] as String == 'deleted';
    }
  } on DioError catch (e) {
    _handlerError(e, 'delete invoice');
  }
  throw const TelePayException('Failed to delete invoice.');
}