Abrar Posted August 2, 2021 Share Posted August 2, 2021 Hi Friends, I am trying to do an API with oracle database. The JSON request from 3rd party will look like below. { "contact_id": "1", "serial_no": "100", "name": "baby", "inv_date": "2018-06-27", "due_date": "2018-06-27", "currency": "KD", "subtotal": "143", "tax_total": "13", "shipment_data": [ { "serial_no": "33", "master_no": "55", "house_no": "77", "cost_revenue_items": [ { "charge_ref": "rr", "currency": "INR", "quantity": "2", "selling_rate": "45", "exchange_rate": "7", "taxes": [ { "serial_no": "1", "ref": "INR", "voiding_remarks": "oo" },{ "serial_no": "2", "ref": "KWD", "voiding_remarks": "asd" } ] } ] } ] } how to handle request for JSON in which master is updated (PUT) and child record is (Either INSERTED, UPDATED or DELETED) ? Quote Link to comment https://forums.phpfreaks.com/topic/313472-required-help-in-api/ Share on other sites More sharing options...
NotionCommotion Posted August 2, 2021 Share Posted August 2, 2021 is your concern that you will potentially be creating a resource without a POST HTTP request, deleting a record without a DELETE HTTP request, etc? Not sure what the RESTful people would say. If the client that creates the request is out of your hands, I would just get the current state from the DB, use the various array intersect and diff functions to find the changes, adds, deletes, and update the DB. Be sure to use a transaction. Quote Link to comment https://forums.phpfreaks.com/topic/313472-required-help-in-api/#findComment-1588805 Share on other sites More sharing options...
Abrar Posted August 4, 2021 Author Share Posted August 4, 2021 Thanks for the suggestion @NotionCommotion. I have contacted the client team that creates the request and asked them about the details, waiting for their reply. I believe after their reply it would we clear and i can proceed accordingly. Quote Link to comment https://forums.phpfreaks.com/topic/313472-required-help-in-api/#findComment-1588846 Share on other sites More sharing options...
Abrar Posted August 10, 2021 Author Share Posted August 10, 2021 (edited) Hi @NotionCommotion, Hope you doing great! I contacted the clients and below is their reply with JSON data. { "contact_id": "dfg3453", "serial_no": "I/TEST/21-45", "name": "Bill's TEST Shop", "inv_date": "2021-01-23", "due_date": "2021-01-23", "currency": "KWD", "subtotal": "1065.0", "tax_total": "106.5", "shipment_data": [ { "serial_no": "I/TEST/21-45", "master_no": "123-26365653", "house_no": "QAS2131204", "cost_revenue_items": [ { "charge_ref": "K0067", "currency": "USD", "quantity": "1.0", "selling_rate": "1500.0", "exchange_rate": "0.71", "taxes": ["VAT"] } ] } ] } Their reply -> " The request type is up to your team to specify, as the request will be sent from our side to yours, please find attached the requested sample." My Question: How will they do a delete request for the above JSON data? Currently as you know i have done 3 different request for the same JSON data(Request(POST),Request(PUT),Request(DELETE)) all in a single PHP file, is this right? Edited August 10, 2021 by Abrar Quote Link to comment https://forums.phpfreaks.com/topic/313472-required-help-in-api/#findComment-1588966 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.