REST API design to upload multiple multipart files - spring

I am struggling to understand the concept on how to design an API. The statement given to me is
API to create Categories(5), products(2 for each category), upload images for each product and its price.
I am using spring to handle the REST end point . On looking at above statement , I can think of creating two separate POST requests . One to create category(ex:http://appname:port/CreateCategory). While saving the category entity , I would create id for each category called categoryId.
The post request JSON would be like this
{
"categoryName":"abc"
}
I would create other separate POST request , (ex:http://appname:port/CreateProduct)this time a multipartfile and I would associate each product with category id generated previously and save them in product table.The JSON request would look like this
{
multipart file// the uploaded image
"productName":"xyz",
"CategoryId":"123"
}
But the statement seems to be telling to create a single API to do all actions at once . In that case, I may have multiple multipartFiles and I have to keep track of which multipart file belongs to which product. How should I handle this scenario using SpringBoot?

Related

creating dynamic records in single form using JS and store the info in a List or set object using spring mvc

I need to create form fields like name , age and city inside a form and this should happen every time i click add record. i dont want multiple forms all dynamic group should be created within a single form. on submitting the data should be taken by controller using modelattribute, and store in arraylist or any ...help out to find it. i have used following links and almost got it but unfortunately got deleted.
https://viralpatel.net/blogs/spring-mvc-multi-row-submit-java-list/
http://www.nobukimi.com/?p=237
answer
https://netjs.blogspot.com/2018/09/spring-mvc-binding-list-of-objects-example.html

Push data using routes in laravel

I'm trying to have an api which stores the information into my CRM, to push the details I've following parameters/details to store into the data:
Called_number, caller_number, agent_number, date, time, call_status, total_call_duration, Call_UUID, Recording_URL, conversation_duration
I've created the migration table with the same data name mentioned above, request protocol is HTTP, request data type is Query String and response data type is JSON.
Data is being sent by simple URL from third party so I'm using simple post route to insert the data into the database like this:
Route::post('/calllogs/{called_number}/{caller_number}/{agent_number}/{date}/{time}/{call_status}/{total_call_duration}/{call_UUID}/{recording_URL}/{converstation_duration}', 'CalllogController#insert')
Is there any way to secure this with some dynamic API keys to prevent inserting fake data? I mean any person having idea of the URL, can make the url and will insert data into my database, I want to have something like this:
Route::post('/calllogs/{api_key}/{caller_number}....
where I can check the api_key dynamically and then insert into the database.
Thanks.
This library (API Guard) is probably what you're looking for, it does exactly what you want: securing API calls with authorization keys.

Overview of all fluidcontent FCEs

For complex TYPO3 project using fluidcontent I'm looking for a tool, which show me the followering informations:
which FCE exists
how often and on what pages are they in use
which partials are used
which flux form fields are used (with name and type)
diposit some meta informations, e.g. tags, description ...
How would be the smartest way to implement this library in a typo3 project?
My idea is, to develop an extension which read the fluidcontent templates and show the informations in a frontend plugin with examples. But i have no idea to read out the information like "used partials" or "used flux form fields".
Any ideas?
Thanks.
FCE's are just cType elements in the tt_content table. you can write a simple query to count the different cTypes, thus gives you a list with all the used FCE's on your site. you can know on witch page they are used because every tt_content entry has a pageUId
for the flux fields. you will have to create a function that fetch all content elements that uses flux and then parse all the flexform fields. note that flux can also store data in other fields then flexform xml.
you can create a basic extbase plugin for this to show it in the front or backend

Laravel multiple models in controller

This question regards the structure of applications when using laravel.
I have a view for making a sale/purchase from a company. This single view contains a client search, product list, service list and a staff list. Each of the items listed above has their own model. In the view, i would say search for a client which will call a function within the controller and populate a list. Same for the products and services etc etc.
What confuses me is that for the client search i would click a button that would fire to a url like /clients/search/search string, which would return the array of clients to display on the page. This function seems as if it would be appropriate within the client controller. I am unsure as to how i would be able to maintain the information from the client search and other parts of the sale to then submit it all together under one single controller (let's call it InvoiceController).
Can controllers share the functions from other controller? Do i simply store the information in a session variable? Do i simply put all relative functions to this sale under the InvoiceController?
Thanks for any help!
I would do a search for clients against the client controller, then when you select the client add this (client_id) to your invoice form. then save this with other invoice info via the invoice controller
After much deliberation, it appeared that AJAX was the simplest answer. In this case i used Angular JS and had that running a controller to fetch each segment of the Invoice, then use the main InvoiceController in Laravel to fire the final update.

Google Places Api get category Id

How I can get place category or category id?
Here all categories and subcategories
http://support.google.com/places/bin/answer.py?hl=en&topic=1656882&answer=1722104#category
But places api doesn`t return cat_id
The Places API has a slightly different set of "types", which are returned in the API's Place Details response.
If you add a new place via the API should use these types, whereas bulk uploaded data should use the appropriate code in the help article you mentioned.

Resources