Jump to content

Recommended Posts

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) ?

Link to comment
https://forums.phpfreaks.com/topic/313472-required-help-in-api/
Share on other sites

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.

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 by Abrar
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.