Skip to content

Commit

Permalink
ENGCOM-5985: [Customer] Rename dob to date_of_birth #911 #919
Browse files Browse the repository at this point in the history
 - Merge Pull Request magento/graphql-ce#919 from XxXgeoXxX/graphql-ce:2.3-develop#911
 - Merged commits:
   1. fa8f566
   2. aaee0c8
   3. e9879d1
   4. da62bd1
   5. 2c4adbf
   6. d167013
   7. 33d8148
   8. adb6517
   9. f52ba88
  • Loading branch information
magento-engcom-team committed Oct 1, 2019
2 parents 6f1a6f7 + f52ba88 commit 84870f6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,16 @@ public function execute(CustomerInterface $customer): array
}
}
$customerData = array_merge($customerData, $customAttributes);
//Field is deprecated and should not be exposed on storefront.
//Fields are deprecated and should not be exposed on storefront.
$customerData['group_id'] = null;
$customerData['model'] = $customer;
$customerData['id'] = null;

$customerData['model'] = $customer;

//'dob' is deprecated, 'date_of_birth' is used instead.
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

0 comments on commit 84870f6

Please sign in to comment.