Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

[Customer] Rename dob to date_of_birth #911 #919

Merged
merged 9 commits into from
Oct 2, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ public function execute(CustomerInterface $customer): array
$customerData['group_id'] = null;
$customerData['model'] = $customer;
$customerData['id'] = null;

if (!empty($customerData['dob'])) {
$customerData['date_of_birth'] = $customerData['dob'];
}
return $customerData;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ public function resolve(
if (!$this->newsLetterConfig->isActive(ScopeInterface::SCOPE_STORE)) {
$args['input']['is_subscribed'] = false;
}

if (isset($args['input']['date_of_birth'])) {
$args['input']['dob'] = $args['input']['date_of_birth'];
}
$customer = $this->createCustomerAccount->execute(
$args['input'],
$context->getExtensionAttributes()->getStore()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public function resolve(
if (empty($args['input']) || !is_array($args['input'])) {
throw new GraphQlInputException(__('"input" value should be specified'));
}
if (isset($args['input']['date_of_birth'])) {
$args['input']['dob'] = $args['input']['date_of_birth'];
}

$customer = $this->getCustomer->execute($context);
$this->updateCustomerAccount->execute(
Expand Down
6 changes: 4 additions & 2 deletions app/code/Magento/CustomerGraphQl/etc/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ input CustomerInput {
lastname: String @doc(description: "The customer's family name")
suffix: String @doc(description: "A value such as Sr., Jr., or III")
email: String @doc(description: "The customer's email address. Required")
dob: String @doc(description: "The customer's date of birth")
dob: String @doc(description: "Deprecated: Use `date_of_birth` instead")
date_of_birth: String @doc(description: "The customer's date of birth")
taxvat: String @doc(description: "The customer's Tax/VAT number (for corporate customers)")
gender: Int @doc(description: "The customer's gender(Male - 1, Female - 2)")
password: String @doc(description: "The customer's password")
Expand All @@ -87,7 +88,8 @@ type Customer @doc(description: "Customer defines the customer name and address
email: String @doc(description: "The customer's email address. Required")
default_billing: String @doc(description: "The ID assigned to the billing address")
default_shipping: String @doc(description: "The ID assigned to the shipping address")
dob: String @doc(description: "The customer's date of birth")
dob: String @doc(description: "The customer's date of birth") @deprecated(reason: "Use `date_of_birth` instead")
date_of_birth: String @doc(description: "The customer's date of birth")
taxvat: String @doc(description: "The customer's Tax/VAT number (for corporate customers)")
id: Int @doc(description: "The ID assigned to the customer") @deprecated(reason: "id is not needed as part of Customer because on server side it can be identified based on customer token used for authentication. There is no need to know customer ID on the client side.")
is_subscribed: Boolean @doc(description: "Indicates whether the customer is subscribed to the company's newsletter") @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\IsSubscribed")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function testUpdateCustomer()
middlename: "{$newMiddlename}"
lastname: "{$newLastname}"
suffix: "{$newSuffix}"
dob: "{$newDob}"
date_of_birth: "{$newDob}"
taxvat: "{$newTaxVat}"
email: "{$newEmail}"
password: "{$currentPassword}"
Expand All @@ -82,7 +82,7 @@ public function testUpdateCustomer()
middlename
lastname
suffix
dob
date_of_birth
taxvat
email
gender
Expand All @@ -102,7 +102,7 @@ public function testUpdateCustomer()
$this->assertEquals($newMiddlename, $response['updateCustomer']['customer']['middlename']);
$this->assertEquals($newLastname, $response['updateCustomer']['customer']['lastname']);
$this->assertEquals($newSuffix, $response['updateCustomer']['customer']['suffix']);
$this->assertEquals($newDob, $response['updateCustomer']['customer']['dob']);
$this->assertEquals($newDob, $response['updateCustomer']['customer']['date_of_birth']);
$this->assertEquals($newTaxVat, $response['updateCustomer']['customer']['taxvat']);
$this->assertEquals($newEmail, $response['updateCustomer']['customer']['email']);
$this->assertEquals($newGender, $response['updateCustomer']['customer']['gender']);
Expand Down