Extending JSON API: Sending Confirmation Emails After Customer Deletion

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
Paulus-Ragnarr
Posts: 16
Joined: 15 Oct 2024, 07:02

Extending JSON API: Sending Confirmation Emails After Customer Deletion

Post by Paulus-Ragnarr » 05 Nov 2024, 02:54

Hello Aimeos,

I'm working on extending the JSON API customer delete function, and I would like to implement a feature that sends a confirmation email to the user after their account is deleted. Could you advise on the best way to achieve this functionality?

CustomerDecorator

Code: Select all

<?php

namespace Aimeos\Client\JsonApi\Customer;


class CustomerDecorator
    extends \Aimeos\Client\JsonApi\Base
    implements \Aimeos\Client\JsonApi\Iface
{
    public function delete()
    {
        
    }
}
Thank you for your assistance!

User avatar
aimeos
Administrator
Posts: 8356
Joined: 01 Jan 1970, 00:00

Re: Extending JSON API: Sending Confirmation Emails After Customer Deletion

Post by aimeos » 05 Nov 2024, 15:54

Usually, you want to send the e-mail also when the account is deleted in any other way (not only via the JSON:API). Also, doing it async has a lot of performance advantages because you can return immediately a response to the requester. Therefore, adding a message to a new queue for deleted accounts and processing that message by a job controller afterwards is the best and cleanest way.

Example for adding a message to a queue:
https://github.com/aimeos/ai-controller ... d.php#L429

How to create a job controller:
https://aimeos.org/docs/latest/cronjobs ... ontroller/

Example for a job controller using a message queue for sending e-mails:
https://github.com/aimeos/ai-controller ... andard.php
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
Paulus-Ragnarr
Posts: 16
Joined: 15 Oct 2024, 07:02

Re: Extending JSON API: Sending Confirmation Emails After Customer Deletion

Post by Paulus-Ragnarr » 06 Nov 2024, 00:05

Hello Aimeos, thank you for the response.

To clarify, am I correct in assuming that I need to extend the delete function found here: https://github.com/aimeos/ai-controller ... d.php#L324 and add a message to a queue within this function?

User avatar
aimeos
Administrator
Posts: 8356
Joined: 01 Jan 1970, 00:00

Re: Extending JSON API: Sending Confirmation Emails After Customer Deletion

Post by aimeos » 06 Nov 2024, 09:08

Yes, the customer frontend controller is the best place for that and you can extend it with a decorator, so you don't have to extend the class.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply