customerAddressCreate method

Future<Address> customerAddressCreate({
  1. String? address1,
  2. String? address2,
  3. String? company,
  4. String? city,
  5. String? country,
  6. String? firstName,
  7. String? lastName,
  8. String? phone,
  9. String? province,
  10. String? zip,
  11. String? customerAccessToken,
  12. bool deleteThisPartOfCache = false,
})

Creates a address for the customer to which customerAccessToken belongs to.

Implementation

Future<Address> customerAddressCreate(
    {String? address1,
    String? address2,
    String? company,
    String? city,
    String? country,
    String? firstName,
    String? lastName,
    String? phone,
    String? province,
    String? zip,
    String? customerAccessToken,
    bool deleteThisPartOfCache = false}) async {
  final MutationOptions _options = MutationOptions(
      document: gql(customerAddressCreateMutation),
      variables: {
        'address1': address1,
        'address2': address2,
        'company': company,
        'city': city,
        'country': country,
        'firstName': firstName,
        'lastName': lastName,
        'phone': phone,
        'province': province,
        'zip': zip,
        'customerAccessToken': customerAccessToken,
      });
  final QueryResult result = await _graphQLClient!.mutate(_options);
  checkForError(
    result,
    key: 'customerAddressCreate',
    errorKey: 'customerUserErrors',
  );
  if (deleteThisPartOfCache) {
    _graphQLClient!.cache.writeQuery(_options.asRequest, data: {});
  }

  return Address.fromJson(
      (result.data!['customerAddressCreate']['customerAddress'] ?? {}));
}