loginCustomer method

dynamic loginCustomer({
  1. required String username,
  2. required String password,
})

Authenticates the user via JWT and returns a WooCommerce customer object of the current logged in customer.

Implementation

loginCustomer({
  required String username,
  required String password,
}) async {
  WooCustomer? customer;
  try {
    var response =
        await authenticateViaJWT(username: username, password: password);
    _printToLog('attempted token : ' + response.toString());
    if (response is String) {
      int? id = await fetchLoggedInUserId();
      customer = await getCustomerById(id: id);
    }
    return customer;
  } catch (e) {
    return e.toString();
  }
}