customerUpdate method
Updates the customer to which customerAccessToken
belongs to.
Implementation
Future<void> customerUpdate({
String? email,
String? firstName,
String? lastName,
String? password,
String? phoneNumber,
String? customerAccessToken,
bool? acceptsMarketing,
}) async {
Map<String, dynamic> variableMap = {};
Map<String, dynamic> dataMap = {};
dataMap['email'] = email;
dataMap['firstName'] = firstName;
dataMap['lastName'] = lastName;
dataMap['acceptsMarketing'] = acceptsMarketing;
dataMap['customerAccessToken'] = customerAccessToken;
if (phoneNumber != null && phoneNumber.isNotEmpty) {
dataMap['phone'] = phoneNumber;
}
if (password != null && password.isNotEmpty) {
dataMap['password'] = password;
}
dataMap.forEach((k, v) => v != {} ? variableMap[k] = v : {});
final MutationOptions _options = MutationOptions(
document: gql(createValidMutationString(variableMap)),
variables: variableMap);
QueryResult result = await _graphQLClient!.mutate(_options);
checkForError(
result,
key: 'customerUpdate',
errorKey: 'customerUserErrors',
);
}