Skip to content

BremzeLV/task-rectangle-generator-api

Repository files navigation

Live ip on AWS: http://18.184.62.150

Routes

GET http://18.184.62.150/generation-status?id={id}
POST http://18.184.62.150/generate-rectangles

    {
    "width": 1024,
    "height": 1024,
    "color": "#fff",
    "rectangles": [{
    "id": "my-id3",
    "x": 10,
    "y": 10,
    "height": 100,
    "width": 200,
    "color": "#000"
    },
    {
    "id": "my-id4",
    "x": 100,
    "y": 100,
    "height": 100,
    "width": 200,
    "color": "#000"
    }]}
GET http://18.184.62.150/generate-rectangles

Task description:

Izveidot php API, kas spēj ģenerēt PNG bildes ar aizpildītiem taisnstūriem
Detalizēta specifikācija

  1. API Atbild uz HTTP pieprasījumu, reģistrē PNG bildes ģenerēšanas pieteikumu un atgriež tā unikālo identifikātoru. Ja pieprasījuma kvadrāti pārklājas, robežojas ar citiem kvadrātiem vai bildes malām, kā arī, ja pieprasījumā tiek nosūtīti dati, kas kaut kādā veidā nav izpildāmi (negatīvas, nepareizas vērtības, nekorekta json struktūra utml.), tad jāatgriež kļūdu paziņojumi ar informāciju par datu nesakritību. Pieprasījuma piemērs

curl -X POST http://your-server/generate-rectangles -d ' { width: 1024, // jebkāds pozitīvs skaitlis robežās [640, 1920] height: 1024, // jebkāds pozitīvs skaitlis robežās [480, 1080] color: '#fff', // jebkāds HEX krāsu kods rectangles: [ { id: 'my-id' //jebkāds teksts vai skaitlis, kas nepārsniedz 255 simbolus un ir unikāls visa rectangles masīva ietvaros x: 10, // jebkāds pozitīvs skaitlis y: 10, // jebkāds pozitīvs skaitlis height: 100, // jebkāds pozitīvs skaitlis width: 200, // jebkāds pozitīvs skaitlis color: '#000' // jebkāds HEX krāsu kods }, ... ] }'

Veiksmīgas apstrādes atbildes piemērs: { success: true, id: auto-generated-identifier }

Neveiksmīgas atbildes piemērs (kļūdu paziņojumu struktūra ir atvērta interpretācijai): { success: false, errors: { 'rectangles_overlap': ['rectangle_id', ...], 'rectangles_out_of_bounds': ['rectangle_id'], 'image_doesnt_fit_constraints': ['width'], 'malformatted_json': [] } }

2) Pēc manuāla faila izsaukuma (aka CRON) uzģenerē vecāko bildes ģenerēšanas pieteikumu
3) Pēc pieprasījuma curl -X GET http://your-server/generation-status?id=auto-generated-identifier atgriež šobrīdējo bildes ģenerēšanas stāvokli (pending, failed, in_progress, done)
Piemērs pending: { status: 'pending' queue_length: 5 // bilžu skaits, kas ir priekšā }

Piemērs failed:
{ status: 'failed' reason: 'item_not_found' //notikusi kāda kļūme }

Piemērs in_progress:
{ status: 'in_progress' }

Piemērs done:
{ status: 'done' url: 'http://your-server/generated-image-location //bildes url, kurā to var saņemt kā (Content-Type: image/png) }

Build Status Total Downloads Latest Stable Version License

About Laravel

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:

Laravel is accessible, powerful, and provides tools required for large, robust applications.

Learning Laravel

Laravel has the most extensive and thorough documentation and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.

If you don't feel like reading, Laracasts can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.

Laravel Sponsors

We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel Patreon page.

Contributing

Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the Laravel documentation.

Code of Conduct

In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via taylor@laravel.com. All security vulnerabilities will be promptly addressed.

License

The Laravel framework is open-sourced software licensed under the MIT license.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published