create method
Future<InvoiceModel>
create({
- required String email,
- required DateTime dueDate,
- required List<
Item> items, - String? returnUrl,
- String? expiredUrl,
- String? notificationUrl,
- String? customerId,
- String? subscriptionId,
- int? credits,
- Logs? logs,
- List<
CustomVariables> ? customVariables, - PayerModel? payer,
- List<
EarlyPaymentDiscounts> ? earlyPaymentDiscounts, - int? taxCents,
- int? discountCents,
- bool ignoreDueEmail = false,
- bool earlyPaymentDiscount = false,
- String? customApiToken,
- String paymentMethod = 'bank_slip',
Implementation
Future<InvoiceModel> create({
required String email,
required DateTime dueDate,
required List<Item> items,
String? returnUrl,
String? expiredUrl,
String? notificationUrl,
String? customerId,
String? subscriptionId,
int? credits,
Logs? logs,
List<CustomVariables>? customVariables,
PayerModel? payer,
List<EarlyPaymentDiscounts>? earlyPaymentDiscounts,
int? taxCents,
int? discountCents,
bool ignoreDueEmail = false,
bool earlyPaymentDiscount = false,
String? customApiToken,
String paymentMethod = 'bank_slip',
}) async {
var invoice = InvoiceRequestMessage(
email: email,
dueDate: dueDate.toString(),
items: items,
returnUrl: returnUrl,
expiredUrl: expiredUrl,
taxCents: taxCents,
discountCents: discountCents,
customerId: customerId,
ignoreDueDateMail: ignoreDueEmail,
subscriptionId: subscriptionId,
credits: credits,
logs: logs == null
? null
: [
logs
],
customVariables: customVariables,
notificationUrl: notificationUrl,
enableEarlyPaymentDiscount: earlyPaymentDiscount,
earlyPaymentDiscounts: earlyPaymentDiscounts,
payer: payer,
paymentMethod: paymentMethod);
var retorno = await apiResource.post(data: invoice.toMap(), apiUserToken: customApiToken);
return InvoiceModel.fromMap(retorno);
}