Skip to content

Commit

Permalink
[shopsys] added mutations and queries to work with customer structure…
Browse files Browse the repository at this point in the history
… (#3286)
  • Loading branch information
malyMiso committed Aug 9, 2024
2 parents 39a79c3 + 61eefe3 commit 594fff9
Show file tree
Hide file tree
Showing 32 changed files with 616 additions and 223 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CustomerUserRoleGroup:
type: object
inherits:
- 'CustomerUserRoleGroupDecorator'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
AddNewCustomerUserDataInput:
type: input-object
inherits:
- 'AddNewCustomerUserDataInputDecorator'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
EditCustomerUserPersonalDataInput:
type: input-object
inherits:
- 'EditCustomerUserPersonalDataInputDecorator'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RemoveCustomerUserDataInput:
type: input-object
inherits:
- 'RemoveCustomerUserDataInputDecorator'

This file was deleted.

This file was deleted.

2 changes: 2 additions & 0 deletions app/config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ security:
ROLE_STOCK_FULL: [ROLE_STOCK_VIEW]
ROLE_HEUREKA_FULL: [ROLE_HEUREKA_VIEW]
ROLE_LANGUAGE_CONSTANTS_FULL: [ROLE_LANGUAGE_CONSTANTS_VIEW]
# FE API ROLES
ROLE_API_ALL: [ROLE_API_CUSTOMER_SELF_MANAGE]

providers:
administrators:
Expand Down
85 changes: 76 additions & 9 deletions app/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
input AddNewCustomerUserDataInput {
"Customer user email."
email: String!
"Customer user first name"
firstName: String!
"Customer user last name"
lastName: String!
"Customer user role group uuid."
roleGroupUuid: Uuid!
"The customer's telephone number"
telephone: String!
}

input AddOrderItemsToCartInput {
"Cart identifier or null if customer is logged in"
cartUuid: Uuid = null
Expand Down Expand Up @@ -510,6 +523,8 @@ input ChangePaymentInOrderInput {
}

input ChangePersonalDataInput {
"UUID"
billingAddressUuid: Uuid = null
"Billing address city name (will be on the tax invoice)"
city: String!
"Determines whether the customer is a company or not."
Expand Down Expand Up @@ -547,7 +562,9 @@ input ChangeTransportInCartInput {

"Represents an currently logged customer user"
type CompanyCustomerUser implements CustomerUser {
"Billing address city name"
"UUID"
billingAddressUuid: Uuid!
"city name"
city: String
"The customer’s company name (only when customer is a company)"
companyName: String
Expand All @@ -571,11 +588,14 @@ type CompanyCustomerUser implements CustomerUser {
lastName: String
"Whether customer user receives newsletters or not"
newsletterSubscription: Boolean!
"Billing address zip code"
"zip code"
postcode: String
"The name of the customer pricing group"
pricingGroup: String!
"Billing address street name"
"The customer user role group"
roleGroup: CustomerUserRoleGroup!
roles: [String!]!
"street name"
street: String
"Phone number"
telephone: String
Expand Down Expand Up @@ -608,7 +628,9 @@ type CreateOrderResult {

"Represents an currently logged customer user"
interface CustomerUser {
"Billing address city name"
"UUID"
billingAddressUuid: Uuid!
"city name"
city: String
"Billing address country"
country: Country!
Expand All @@ -626,18 +648,28 @@ interface CustomerUser {
lastName: String
"Whether customer user receives newsletters or not"
newsletterSubscription: Boolean!
"Billing address zip code"
"zip code"
postcode: String
"The name of the customer pricing group"
pricingGroup: String!
"Billing address street name"
"The customer user role group"
roleGroup: CustomerUserRoleGroup!
roles: [String!]!
"street name"
street: String
"Phone number"
telephone: String
"UUID"
uuid: Uuid!
}

type CustomerUserRoleGroup {
"Customer user group name"
name: String!
"UUID"
uuid: Uuid!
}

"Represents and encapsulates an ISO-8601 encoded UTC date-time value"
scalar DateTime

Expand Down Expand Up @@ -683,6 +715,19 @@ input DeliveryAddressInput {
uuid: Uuid = null
}

input EditCustomerUserPersonalDataInput {
"UUID"
customerUserUuid: Uuid
"Customer user first name"
firstName: String!
"Customer user last name"
lastName: String!
"Customer user role group uuid."
roleGroupUuid: Uuid!
"The customer's telephone number"
telephone: String!
}

"Represents a flag"
type Flag implements Hreflang & Slug & Breadcrumb & ProductListable {
"Hierarchy of the current element in relation to the structure"
Expand Down Expand Up @@ -878,6 +923,8 @@ type MainVariant implements Product & Hreflang & Breadcrumb & Slug {
scalar Money

type Mutation {
"Add new customer user to customer"
AddNewCustomerUser(input: AddNewCustomerUserDataInput!): CustomerUser!
"Fills cart based on a given order, possibly merging it with the current cart"
AddOrderItemsToCart(input: AddOrderItemsToCartInput!): Cart!
"Adds a product to a product list"
Expand All @@ -904,6 +951,8 @@ type Mutation {
CreateOrder(input: OrderInput!): CreateOrderResult!
"Delete delivery address by Uuid"
DeleteDeliveryAddress(deliveryAddressUuid: Uuid!): [DeliveryAddress!]!
"edit customer user to customer"
EditCustomerUserPersonalData(input: EditCustomerUserPersonalDataInput!): CustomerUser!
"Edit delivery address by Uuid"
EditDeliveryAddress(input: DeliveryAddressInput!): [DeliveryAddress!]!
"Login user and return login result data (consisting of access and refresh tokens, and information about cart merge)"
Expand All @@ -920,6 +969,8 @@ type Mutation {
RefreshTokens(input: RefreshTokenInput!): Token!
"Register new customer user"
Register(input: RegistrationDataInput!): LoginResult!
"delete customer user"
RemoveCustomerUser(input: RemoveCustomerUserDataInput!): Boolean!
"Remove product from cart"
RemoveFromCart(input: RemoveFromCartInput!): Cart!
"Removes a product from a product list"
Expand Down Expand Up @@ -1663,6 +1714,10 @@ type Query {
countries: [Country!]!
"Returns currently logged in customer user"
currentCustomerUser: CustomerUser
"Returns all customer user role groups"
customerUserRoleGroups: [CustomerUserRoleGroup!]!
"Returns all customer users assigned to the current customer"
customerUsers: [CustomerUser!]!
"Returns a flag by uuid or url slug"
flag(urlSlug: String, uuid: Uuid): Flag
"Returns a complete list of the flags"
Expand Down Expand Up @@ -1772,6 +1827,8 @@ input RefreshTokenInput {

"Represents the main input object to register customer user"
input RegistrationDataInput {
"UUID"
billingAddressUuid: Uuid = null
"Uuid of the cart that should be merged to the cart of the newly registered user"
cartUuid: Uuid = null
"Billing address city name (will be on the tax invoice)"
Expand Down Expand Up @@ -1810,7 +1867,9 @@ input RegistrationDataInput {

"Represents an currently logged customer user"
type RegularCustomerUser implements CustomerUser {
"Billing address city name"
"UUID"
billingAddressUuid: Uuid!
"city name"
city: String
"Billing address country"
country: Country!
Expand All @@ -1828,11 +1887,14 @@ type RegularCustomerUser implements CustomerUser {
lastName: String
"Whether customer user receives newsletters or not"
newsletterSubscription: Boolean!
"Billing address zip code"
"zip code"
postcode: String
"The name of the customer pricing group"
pricingGroup: String!
"Billing address street name"
"The customer user role group"
roleGroup: CustomerUserRoleGroup!
roles: [String!]!
"street name"
street: String
"Phone number"
telephone: String
Expand Down Expand Up @@ -1909,6 +1971,11 @@ type RegularProduct implements Product & Hreflang & Breadcrumb & Slug {
uuid: Uuid!
}

input RemoveCustomerUserDataInput {
"Customer user UUID"
customerUserUuid: Uuid!
}

input RemoveFromCartInput {
"Cart item UUID"
cartItemUuid: Uuid!
Expand Down
6 changes: 6 additions & 0 deletions app/src/DataFixtures/Demo/CompanyDataFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Shopsys\FrameworkBundle\Model\Customer\User\CustomerUserData;
use Shopsys\FrameworkBundle\Model\Customer\User\CustomerUserDataFactory;
use Shopsys\FrameworkBundle\Model\Customer\User\CustomerUserFacade;
use Shopsys\FrameworkBundle\Model\Customer\User\Role\CustomerUserRoleGroup;
use Shopsys\FrameworkBundle\Model\Pricing\Group\PricingGroup;

class CompanyDataFixture extends AbstractReferenceFixture implements DependentFixtureInterface
Expand Down Expand Up @@ -48,6 +49,7 @@ class CompanyDataFixture extends AbstractReferenceFixture implements DependentFi
private const string KEY_ADDRESS_FIRST_NAME = 'firstName';
private const string KEY_ADDRESS_LAST_NAME = 'lastName';
private const string KEY_CUSTOMER_USER_REFERENCE = 'customerUserReference';
private const string KEY_CUSTOMER_ROLE_GROUP = 'roleGroup';

/**
* @param \Faker\Generator $faker
Expand Down Expand Up @@ -180,6 +182,7 @@ private function createCustomerUserData(
$customerUserData->defaultDeliveryAddress = $defaultDeliveryAddress;
$customerUserData->pricingGroup = $this->getReferenceForDomain(PricingGroupDataFixture::PRICING_GROUP_ORDINARY, $domainId, PricingGroup::class);
$customerUserData->domainId = $domainId;
$customerUserData->roleGroup = $customerDataProvider[self::KEY_CUSTOMER_ROLE_GROUP];

return $customerUserData;
}
Expand All @@ -198,6 +201,7 @@ private function getDefaultCustomerUsersDataProvider(): array
self::KEY_CUSTOMER_USER_DATA_PASSWORD => 'user123',
self::KEY_CUSTOMER_USER_DATA_TELEPHONE => '606060605',
self::KEY_CUSTOMER_USER_REFERENCE => self::COMPANY_USER_JOZEF_NOVOTNY,
self::KEY_CUSTOMER_ROLE_GROUP => $this->getReference(CustomerUserRoleGroupDataFixture::ROLE_GROUP_OWNER, CustomerUserRoleGroup::class),
],
self::KEY_DELIVERY_ADDRESS => [
self::KEY_ADDRESS_FIRST_NAME => 'Jozef',
Expand All @@ -217,6 +221,7 @@ private function getDefaultCustomerUsersDataProvider(): array
self::KEY_CUSTOMER_USER_DATA_PASSWORD => 'user123',
self::KEY_CUSTOMER_USER_DATA_TELEPHONE => '606060606',
self::KEY_CUSTOMER_USER_REFERENCE => self::COMPANY_USER_PETER_KOVAC,
self::KEY_CUSTOMER_ROLE_GROUP => $this->getReference(CustomerUserRoleGroupDataFixture::ROLE_GROUP_OWNER, CustomerUserRoleGroup::class),
],
self::KEY_DELIVERY_ADDRESS => [
self::KEY_ADDRESS_FIRST_NAME => 'Eva',
Expand All @@ -236,6 +241,7 @@ private function getDefaultCustomerUsersDataProvider(): array
self::KEY_CUSTOMER_USER_DATA_PASSWORD => 'user123',
self::KEY_CUSTOMER_USER_DATA_TELEPHONE => '606060607',
self::KEY_CUSTOMER_USER_REFERENCE => self::COMPANY_USER_MAREK_HORVATH,
self::KEY_CUSTOMER_ROLE_GROUP => $this->getReference(CustomerUserRoleGroupDataFixture::ROLE_GROUP_USER, CustomerUserRoleGroup::class),
],
self::KEY_DELIVERY_ADDRESS => [
self::KEY_ADDRESS_FIRST_NAME => 'Marek',
Expand Down
Loading

0 comments on commit 594fff9

Please sign in to comment.