/post-notifications

Read from api and trigger Posts notifications

Primary LanguagePHPMIT LicenseMIT

Post Notifications

Sample project that expose read from APIs users and posts and trigger an email notification.

Requirements

Create a tool that reads two API responses and sends an email. The email should contain the posts written by every user. Please note that you should take only the first 3 posts.

E.g.

John Smith has written:

  • Title 1
  • Title 2
  • Title 3

Paul Johnson has written:

  • Title 1
  • Title 2
  • Title 3

Tech Stack

Server: Symfony 5.3

Install

Start docker container with

docker-compose up -d --build

and then, after enter into php-fpm container, run

symfony composer install

Running Tests

To run tests, run the following command

  symfony php vendor/bin/phpspec run -vvv

Execute

Run main command with

symfony console app:notification:send-user-posts

you can also pass following arguments:

  • limit: Number of posts to show (default 3)
  • offset: Initial position of posts to show (default 0)
symfony console app:notification:send-user-posts --limit=5 --offset=2
# or
symfony console app:notification:send-user-posts -l 5 -o 2

That produce follow email sent with Mailhog (http://127.0.0.1:18025/):

Email

Best-practice

Authors

👤 Fabiano Roberto