UserService
extends Service
in package
Uses
ServiceTrait, AddressTrait, NewsletterTrait, StockAlertsTrait, WishlistTrait
This is the user service class.
This class will retrieve the users from LogiCommerce API and transform them to objects. All the needed users operations previous to Framework must be done here.
Splitted on traits to divide the methods between them.
Tags
Table of Contents
DELETE | = \SDK\Core\Enums\MethodType::DELETE | |
---|---|---|
GET | = \SDK\Core\Enums\MethodType::GET | |
ITEMS | = 'items' | |
POST | = \SDK\Core\Enums\MethodType::POST | |
PUT | = \SDK\Core\Enums\MethodType::PUT | |
addGetAddress() | Add the request to get the address identified by the given id | : void |
addGetBillingAddresses() | Add the request to get the billing addresses for the current user | : void |
addGetCustomTags() | Add the request to get the custom tags filtered with the given parameters for the current user | : void |
addGetOrders() | Add the request to get the orders filtered with the given parameters for the current user | : void |
addGetRelatedItems() | Add the request to get the user related items | : void |
addGetRewardPoints() | Add the request to get the reward points filtered with the given parameters for the current user | : void |
addGetRMAs() | Add the request to get returnable products filtered with the given parameters | : void |
addGetSalesAgentCustomers() | Add the request to get sales agent customers with the given parameters for the current user | : void |
addGetSalesAgentOrders() | Add the request to get the orders filtered with the given parameters for the current user | : void |
addGetSalesAgentSales() | Add the request to get the orders filtered with the given parameters for the current user | : void |
addGetShippingAddresses() | Add the request to get the shipping addresses for the current user | : void |
addGetStockAlerts() | Add the request to get the areas filtered with the given parameters | : void |
addGetUser() | Add the request to get the current user information. | : void |
addGetUserExists() | Add the request to get the check that sets if there is a user identified with the given parameter. | : UserExists|null |
addGetVouchers() | Add the request to get the vouchers filtered with the given parameters for the current user | : void |
addGetWishlist() | Add the request to add the request to get the areas filtered with the given parameters | : void |
addWishlistProduct() | Add product to the user wishlist | : Status|null |
createBillingAddress() | Create new billing for the current user. | : Address|null |
createShippingAddress() | Create new shipping address for the current user. | : Address|null |
createUser() | Create the current user information. | : Basket|null |
deleteAddress() | Delete the user address identified by the given id | : Status|null |
deleteStockAlerts() | Delete the user address identified by the given id | : Status|null |
deleteUser() | Delete the current user. | : Basket|null |
deleteWishlistProduct() | Remove product to the user wishlist | : Status|null |
getAddress() | Returns the address identified by the given id | : Address|null |
getBillingAddresses() | Returns the billing addresses for the current user | : ElementCollection|null |
getCustomTags() | Returns the custom tags filtered with the given parameters for the current user | : ElementCollection|null |
getInstance() | Returns the requested model instance. | : Service |
getOauth() | Returns the current user information. | : UserOauthUrl|null |
getOrders() | Returns the orders filtered with the given parameters for the current user | : ElementCollection|null |
getRelatedItems() | Returns the user related items | : ElementCollection|null |
getRewardPoints() | Returns the reward points filtered with the given parameters for the current user | : ElementCollection|null |
getRMAs() | Returns the RMAs for the current user | : ElementCollection|null |
getSalesAgentCustomers() | Return current sales agent customers | : ElementCollection|null |
getSalesAgentOrders() | For a sales agent, returns the given customer's orders | : ElementCollection|null |
getSalesAgentSales() | Return current sales agent sales | : ElementCollection|null |
getShippingAddresses() | Returns the shipping addresses for the current user | : ElementCollection|null |
getStockAlerts() | Returns the areas filtered with the given parameters | : ElementCollection|null |
getUser() | Returns the current user information. | : User|null |
getUserExists() | Check if there is a user identified with the given parameter. | : UserExists|null |
getVouchers() | Returns the vouchers filtered with the given parameters for the current user | : ElementCollection|null |
getWishlist() | Returns the areas filtered with the given parameters | : ElementCollection|null |
login() | User login | : Basket|null |
logout() | User logout | : Basket|null |
newsletterCheckStatus() | Check status user in the newsletter | : NewsletterSubscription|null |
newsletterSubscribe() | Subscribe user to the newsletter | : NewsletterSubscription|null |
newsletterUnsubscribe() | Unsubscribe user to the newsletter | : NewsletterSubscription|null |
recoverPassword() | Recover the current user password (this will send an email to recover the password). | : Status|null |
resendVerification() | Resend the verification email. | : Status|null |
salesAgentLogin() | Sales Agent - Login simulated user | : Basket|null |
salesAgentLogout() | Sales Agent - Logout simulated user | : Basket|null |
sendWishlist() | Send the newsletter to the given email | : Status|null |
setCurrency() | Sets a new navigation currency for the current user | : Basket|null |
setLanguage() | Sets a new navigation language for the current user | : Basket|null |
setNewPassword() | Change the user password (the action is done with the hash inside de received email). | : Status|null |
setOauth() | Returns the current user information. | : UserOauth|null |
updateAddress() | Update the address identified by the given id. | : Address|null |
updatePassword() | Update the current user password. | : Status|null |
updateUser() | Update the current user information. | : Basket|null |
validateRecoverPasswordHash() | Validate if the given token stills valid | : Status|null |
verify() | Verify the user that matches the given uniqueId. | : Status|null |
__construct() | : mixed | |
call() | : array<string|int, mixed> | |
extractParameters() | : array<string|int, mixed> | |
getCollection() | : mixed | |
getConnection() | : Connection | |
getElement() | : Element|null | |
getElements() | : ElementCollection|null | |
getResourceElement() | : Element|null | |
getResponse() | : ElementCollection|null | |
prepareElement() | : Element|null | |
prepareElements() | : array<string|int, mixed> | |
replaceWildcards() | : string |
Constants
DELETE
protected
mixed
DELETE
= \SDK\Core\Enums\MethodType::DELETE
GET
protected
mixed
GET
= \SDK\Core\Enums\MethodType::GET
ITEMS
protected
mixed
ITEMS
= 'items'
POST
protected
mixed
POST
= \SDK\Core\Enums\MethodType::POST
PUT
protected
mixed
PUT
= \SDK\Core\Enums\MethodType::PUT
Methods
addGetAddress()
Add the request to get the address identified by the given id
public
addGetAddress(BatchRequests $batchRequests, string $batchName, int $id) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $id : int
Return values
void —addGetBillingAddresses()
Add the request to get the billing addresses for the current user
public
addGetBillingAddresses(BatchRequests $batchRequests, string $batchName) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
Return values
void —addGetCustomTags()
Add the request to get the custom tags filtered with the given parameters for the current user
public
addGetCustomTags(BatchRequests $batchRequests, string $batchName[, UserCustomTagsParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $params : UserCustomTagsParametersGroup = null
-
object with the needed filters to send to the API user resource
Return values
void —addGetOrders()
Add the request to get the orders filtered with the given parameters for the current user
public
addGetOrders(BatchRequests $batchRequests, string $batchName[, OrderParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $params : OrderParametersGroup = null
-
object with the needed filters to send to the API user orders resource
Return values
void —addGetRelatedItems()
Add the request to get the user related items
public
addGetRelatedItems(BatchRequests $batchRequests, string $batchName[, string $type = '' ][, RelatedItemsParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $type : string = ''
-
Optional. This param will set the kind of related we want to retrieve. Valid values are inside RelatedItemsType class. If not given all the related items will be returned inside the RelatedItems object.
- $params : RelatedItemsParametersGroup = null
Return values
void —addGetRewardPoints()
Add the request to get the reward points filtered with the given parameters for the current user
public
addGetRewardPoints(BatchRequests $batchRequests, string $batchName[, RewardPointsParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $params : RewardPointsParametersGroup = null
-
object with the needed filters to send to the API user resource
Return values
void —addGetRMAs()
Add the request to get returnable products filtered with the given parameters
public
addGetRMAs(BatchRequests $batchRequests, string $batchName) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
Return values
void —addGetSalesAgentCustomers()
Add the request to get sales agent customers with the given parameters for the current user
public
addGetSalesAgentCustomers(BatchRequests $batchRequests, string $batchName[, SalesAgentCustomersParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $params : SalesAgentCustomersParametersGroup = null
-
object with the needed filters to send to the API user resource
Return values
void —addGetSalesAgentOrders()
Add the request to get the orders filtered with the given parameters for the current user
public
addGetSalesAgentOrders(BatchRequests $batchRequests, string $batchName, int $customerId[, SalesAgentCustomersParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $customerId : int
- $params : SalesAgentCustomersParametersGroup = null
Return values
void —addGetSalesAgentSales()
Add the request to get the orders filtered with the given parameters for the current user
public
addGetSalesAgentSales(BatchRequests $batchRequests, string $batchName[, SalesAgentCustomersParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $params : SalesAgentCustomersParametersGroup = null
Return values
void —addGetShippingAddresses()
Add the request to get the shipping addresses for the current user
public
addGetShippingAddresses(BatchRequests $batchRequests, string $batchName) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
Return values
void —addGetStockAlerts()
Add the request to get the areas filtered with the given parameters
public
addGetStockAlerts(BatchRequests $batchRequests, string $batchName) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
Return values
void —addGetUser()
Add the request to get the current user information.
public
addGetUser(BatchRequests $batchRequests, string $batchName) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
Return values
void —addGetUserExists()
Add the request to get the check that sets if there is a user identified with the given parameter.
public
addGetUserExists(BatchRequests $batchRequests, string $batchName, string $userIdentifier) : UserExists|null
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $userIdentifier : string
-
this parameter can match the email or the public id of the user. Depends on the ecommerce settings.
Return values
UserExists|null —addGetVouchers()
Add the request to get the vouchers filtered with the given parameters for the current user
public
addGetVouchers(BatchRequests $batchRequests, string $batchName[, UserVouchersParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $params : UserVouchersParametersGroup = null
-
object with the needed filters to send to the API user resource
Return values
void —addGetWishlist()
Add the request to add the request to get the areas filtered with the given parameters
public
addGetWishlist(BatchRequests $batchRequests, string $batchName) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
Return values
void —addWishlistProduct()
Add product to the user wishlist
public
addWishlistProduct(int $id) : Status|null
Parameters
- $id : int
-
The identifier of the product we want to add to the wishlist
Return values
Status|null —createBillingAddress()
Create new billing for the current user.
public
createBillingAddress([BillingAddressParametersGroup $data = null ][, string $dataValidatior = '' ]) : Address|null
Parameters
- $data : BillingAddressParametersGroup = null
- $dataValidatior : string = ''
-
Data validatior PId to apply
Return values
Address|null —createShippingAddress()
Create new shipping address for the current user.
public
createShippingAddress([ShippingAddressParametersGroup $data = null ][, string $dataValidatior = '' ]) : Address|null
Parameters
- $data : ShippingAddressParametersGroup = null
- $dataValidatior : string = ''
-
Data validatior PId to apply
Return values
Address|null —createUser()
Create the current user information.
public
createUser([CreateUserParametersGroup $data = null ][, string $dataValidatior = '' ]) : Basket|null
Parameters
- $data : CreateUserParametersGroup = null
- $dataValidatior : string = ''
-
Data validatior PId to apply
Return values
Basket|null —deleteAddress()
Delete the user address identified by the given id
public
deleteAddress(int $id) : Status|null
Parameters
- $id : int
Return values
Status|null —deleteStockAlerts()
Delete the user address identified by the given id
public
deleteStockAlerts(int $id) : Status|null
Parameters
- $id : int
Return values
Status|null —deleteUser()
Delete the current user.
public
deleteUser(string $password) : Basket|null
Parameters
- $password : string
Return values
Basket|null —deleteWishlistProduct()
Remove product to the user wishlist
public
deleteWishlistProduct(int $id) : Status|null
Parameters
- $id : int
-
The identifier of the product we want to remove from wishlist
Return values
Status|null —getAddress()
Returns the address identified by the given id
public
getAddress(int $id) : Address|null
Parameters
- $id : int
Return values
Address|null —getBillingAddresses()
Returns the billing addresses for the current user
public
getBillingAddresses() : ElementCollection|null
Return values
ElementCollection|null —getCustomTags()
Returns the custom tags filtered with the given parameters for the current user
public
getCustomTags([UserCustomTagsParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $params : UserCustomTagsParametersGroup = null
-
object with the needed filters to send to the API user resource
Return values
ElementCollection|null —getInstance()
Returns the requested model instance.
public
static getInstance() : Service
If is not setted, this method will set it.
Return values
Service —getOauth()
Returns the current user information.
public
getOauth(string $plugin) : UserOauthUrl|null
Parameters
- $plugin : string
Return values
UserOauthUrl|null —getOrders()
Returns the orders filtered with the given parameters for the current user
public
getOrders([OrderParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $params : OrderParametersGroup = null
-
object with the needed filters to send to the API user orders resource
Return values
ElementCollection|null —getRelatedItems()
Returns the user related items
public
getRelatedItems([string $type = '' ][, RelatedItemsParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $type : string = ''
-
Optional. This param will set the kind of related we want to retrieve. Valid values are inside RelatedItemsType class. If not given all the related items will be returned inside the RelatedItems object.
- $params : RelatedItemsParametersGroup = null
Return values
ElementCollection|null —getRewardPoints()
Returns the reward points filtered with the given parameters for the current user
public
getRewardPoints([RewardPointsParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $params : RewardPointsParametersGroup = null
-
object with the needed filters to send to the API user resource
Return values
ElementCollection|null —getRMAs()
Returns the RMAs for the current user
public
getRMAs() : ElementCollection|null
Return values
ElementCollection|null —getSalesAgentCustomers()
Return current sales agent customers
public
getSalesAgentCustomers([SalesAgentCustomersParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $params : SalesAgentCustomersParametersGroup = null
-
object with the needed filters to send to the API user sales agent customers resource
Return values
ElementCollection|null —getSalesAgentOrders()
For a sales agent, returns the given customer's orders
public
getSalesAgentOrders(int $customerId[, SalesAgentOrdersParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $customerId : int
- $params : SalesAgentOrdersParametersGroup = null
-
object with the needed filters to send to the API user sales agent orders resource
Return values
ElementCollection|null —getSalesAgentSales()
Return current sales agent sales
public
getSalesAgentSales([SalesAgentCustomersParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $params : SalesAgentCustomersParametersGroup = null
-
object with the needed filters to send to the API user sales agent customers resource
Return values
ElementCollection|null —getShippingAddresses()
Returns the shipping addresses for the current user
public
getShippingAddresses() : ElementCollection|null
Return values
ElementCollection|null —getStockAlerts()
Returns the areas filtered with the given parameters
public
getStockAlerts() : ElementCollection|null
Return values
ElementCollection|null —getUser()
Returns the current user information.
public
getUser() : User|null
Return values
User|null —getUserExists()
Check if there is a user identified with the given parameter.
public
getUserExists(string $userIdentifier) : UserExists|null
Parameters
- $userIdentifier : string
-
this parameter can match the email or the public id of the user. Depends on the ecommerce settings.
Return values
UserExists|null —getVouchers()
Returns the vouchers filtered with the given parameters for the current user
public
getVouchers([UserVouchersParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $params : UserVouchersParametersGroup = null
-
object with the needed filters to send to the API user resource
Return values
ElementCollection|null —getWishlist()
Returns the areas filtered with the given parameters
public
getWishlist() : ElementCollection|null
Return values
ElementCollection|null —login()
User login
public
login([LoginParametersGroup $data = null ]) : Basket|null
Parameters
- $data : LoginParametersGroup = null
-
object that contains username & password
Return values
Basket|null —logout()
User logout
public
logout() : Basket|null
Return values
Basket|null —newsletterCheckStatus()
Check status user in the newsletter
public
newsletterCheckStatus(NewsletterSubscriptionParametersGroup $params) : NewsletterSubscription|null
Parameters
- $params : NewsletterSubscriptionParametersGroup
Return values
NewsletterSubscription|null —newsletterSubscribe()
Subscribe user to the newsletter
public
newsletterSubscribe(NewsletterSubscriptionParametersGroup $params) : NewsletterSubscription|null
Parameters
- $params : NewsletterSubscriptionParametersGroup
Return values
NewsletterSubscription|null —newsletterUnsubscribe()
Unsubscribe user to the newsletter
public
newsletterUnsubscribe(NewsletterSubscriptionParametersGroup $params) : NewsletterSubscription|null
Parameters
- $params : NewsletterSubscriptionParametersGroup
Return values
NewsletterSubscription|null —recoverPassword()
Recover the current user password (this will send an email to recover the password).
public
recoverPassword(string $email) : Status|null
Parameters
- $email : string
Return values
Status|null —resendVerification()
Resend the verification email.
public
resendVerification(string $email) : Status|null
Parameters
- $email : string
Return values
Status|null —salesAgentLogin()
Sales Agent - Login simulated user
public
salesAgentLogin(int $customerId) : Basket|null
Parameters
- $customerId : int
Return values
Basket|null —salesAgentLogout()
Sales Agent - Logout simulated user
public
salesAgentLogout() : Basket|null
Return values
Basket|null —sendWishlist()
Send the newsletter to the given email
public
sendWishlist([SendWishlistParametersGroup $params = null ]) : Status|null
Parameters
- $params : SendWishlistParametersGroup = null
Return values
Status|null —setCurrency()
Sets a new navigation currency for the current user
public
setCurrency(string $currencyInitials) : Basket|null
Parameters
- $currencyInitials : string
Return values
Basket|null —setLanguage()
Sets a new navigation language for the current user
public
setLanguage(string $languageCode) : Basket|null
Parameters
- $languageCode : string
Return values
Basket|null —setNewPassword()
Change the user password (the action is done with the hash inside de received email).
public
setNewPassword(string $password, string $hash) : Status|null
Parameters
- $password : string
- $hash : string
Return values
Status|null —setOauth()
Returns the current user information.
public
setOauth(string $pluginModule, string $code) : UserOauth|null
Parameters
- $pluginModule : string
- $code : string
Return values
UserOauth|null —updateAddress()
Update the address identified by the given id.
public
updateAddress(int $id[, AddressParametersGroup $data = null ][, string $dataValidatior = '' ]) : Address|null
Parameters
- $id : int
- $data : AddressParametersGroup = null
- $dataValidatior : string = ''
-
Data validatior PId to apply
Return values
Address|null —updatePassword()
Update the current user password.
public
updatePassword([UpdatePasswordParametersGroup $data = null ]) : Status|null
Parameters
- $data : UpdatePasswordParametersGroup = null
-
object that contains password & new password
Return values
Status|null —updateUser()
Update the current user information.
public
updateUser([UpdateUserParametersGroup $data = null ][, string $dataValidatior = '' ]) : Basket|null
Parameters
- $data : UpdateUserParametersGroup = null
- $dataValidatior : string = ''
-
Data validatior PId to apply
Return values
Basket|null —validateRecoverPasswordHash()
Validate if the given token stills valid
public
validateRecoverPasswordHash(string $hash) : Status|null
Parameters
- $hash : string
Return values
Status|null —verify()
Verify the user that matches the given uniqueId.
public
verify(string $uniqueId) : Status|null
Parameters
- $uniqueId : string
Return values
Status|null —__construct()
protected
__construct() : mixed
Return values
mixed —call()
protected
call(Request $request[, string $apiUrl = null ]) : array<string|int, mixed>
Parameters
- $request : Request
- $apiUrl : string = null
Return values
array<string|int, mixed> —extractParameters()
protected
extractParameters([ParametersGroup|null $parametersGroup = null ]) : array<string|int, mixed>
Parameters
- $parametersGroup : ParametersGroup|null = null
Return values
array<string|int, mixed> —getCollection()
protected
getCollection(array<string|int, mixed> $data, string $class) : mixed
Parameters
- $data : array<string|int, mixed>
- $class : string
Return values
mixed —getConnection()
protected
getConnection() : Connection
Return values
Connection —getElement()
protected
getElement(string $class, string $resource[, int $id = null ][, mixed $params = null ]) : Element|null
Parameters
- $class : string
- $resource : string
- $id : int = null
- $params : mixed = null
Return values
Element|null —getElements()
protected
getElements(string $class, string $resource[, ParametersGroup $parameters = null ]) : ElementCollection|null
Parameters
- $class : string
- $resource : string
- $parameters : ParametersGroup = null
Return values
ElementCollection|null —getResourceElement()
protected
getResourceElement(string $class, string $resource[, mixed $params = [] ]) : Element|null
Parameters
- $class : string
- $resource : string
- $params : mixed = []
Return values
Element|null —getResponse()
protected
getResponse(array<string|int, mixed> $data, string $class) : ElementCollection|null
Parameters
- $data : array<string|int, mixed>
- $class : string
Return values
ElementCollection|null —prepareElement()
protected
prepareElement(array<string|int, mixed> $data, string $class) : Element|null
Parameters
- $data : array<string|int, mixed>
- $class : string
Return values
Element|null —prepareElements()
protected
prepareElements(array<string|int, mixed> $data, string $class) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed>
- $class : string
Return values
array<string|int, mixed> —replaceWildcards()
protected
replaceWildcards(string $resource, array<string|int, mixed> $wildcards) : string
Parameters
- $resource : string
- $wildcards : array<string|int, mixed>