New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Api][Address] Browsing AddressBook #11914
Conversation
Tomanhez
commented
Oct 7, 2020
Q | A |
---|---|
Branch? | master |
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
Deprecations? | no |
License | MIT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally I have problem with scenario tagged @javascript
, it looks like UI feature, and IMO we shouldn't cover it with API especially when you added step And my billing address is fulfilled automatically after filling field which is matching to field from my address book's address
in API we don't have behaviour like automatically do sth
it should be call to addresses/index
and the UI should fill address with data from addressbook, But of course i am open to discussion.
public function thisAddressShouldBeAssignedTo(string $fullName): void | ||
{ | ||
/** @var AddressInterface $address */ | ||
$address = $this->sharedStorage->get('address_assigned_to_' . $fullName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fullName
has space between first and last name IMO you shouldn't have the key in shared storage with spaces,
address_assigned_to_Joe Doe
ith looks bad :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you aright, but $fullName
is behind the scene, I can convert it to loverCase and add padding here and in places when I must get it by customer name, but for me its unnecessary confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use StringInflector class, just add there an method
public static function nameToSnakeCase(string $value): string
{
return (string) u($value)->snake();
}
```
src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/Address.xml
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/Address.xml
Outdated
Show resolved
Hide resolved
@@ -6,15 +6,15 @@ Feature: Viewing my address book | |||
|
|||
Background: | |||
Given the store operates on a single channel in "United States" | |||
And I am a logged in customer | |||
And I am a logged in customer with name "Lucifer Morningstar" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you need to change that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it, because IMO scenario Inability to view the addresses of other customers
is not clearly and which is customer about in step this address should be assigned to "Lucifer Morningstar"
, we have added address with this name for this customer, but this customer is not "Lucifer Morningstar"
but random named
...es/checkout/addressing_order/choosing_billing_and_shipping_address_from_address_book.feature
Outdated
Show resolved
Hide resolved
src/Sylius/Component/Core/Repository/AddressRepositoryInterface.php
Outdated
Show resolved
Hide resolved
I think that few tests for addressBook like |
I'm not fully convinced but we could implement the existing scenarios without adding these unneeded (unclear for me) new steps. The proper behaviour for getting address from customer's address book could be implemented in the existing steps in API context. |
ed13b6d
to
83872a4
Compare
83872a4
to
8b4b882
Compare
Thanks, Tomasz! 🎉 |
if ( | ||
$address['firstName'] === $addressToCompare->getFirstName() && | ||
$address['lastName'] === $addressToCompare->getLastName() && | ||
$address['countryCode'] === $addressToCompare->getCountryCode() && | ||
$address['street'] === $addressToCompare->getStreet() && | ||
$address['city'] === $addressToCompare->getCity() && | ||
$address['postcode'] === $addressToCompare->getPostcode() && | ||
($addressToCompare->getProvinceName() !== null && isset($address['provinceName'])) ? | ||
$address['provinceName'] === $addressToCompare->getProvinceName() : true | ||
) { | ||
return true; | ||
} | ||
|
||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be simplified to one return
This PR was merged into the 1.9-dev branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Related tickets | partially #11914 ( this needs to be merged first) | License | MIT Commits ------- b566cd5 add api delete address book d0d71cc fixed small issues in PR ef7b2fd merged scenarios in one