asciisd / zoho

Zoho package for Laravel
36 stars 37 forks source link

getResponseJSON for single record #10

Open ibmgeniuz opened 3 years ago

ibmgeniuz commented 3 years ago

Hello, Thanks for the package. It really helps with my work. I realized that I could use for eg:

$contacts = ZohoManager::useModule('Contacts');
$contacts->getRecord($record_id)->getData();

This works well, however, if there are nested data, they are ignored and returned as

{
    ...
    "Nested_Item": {} 
}

NB: Though Nested_Item shows empty, it actually has data in it.

I think it is because the response ignores arrays in the array. I couldn't loop through with for each because the empty Nested_Item is also returned as a ZCRMRecord. I thought looping through and doing getData() on it was going to expand that, but nothing. I think the getResponseJSON() does this out of the box.

If you use eg:

$related = $record->getRelatedListRecords('deals');

You can then use

$related->getResponseJSON();

It returns

{
    ...
    "Nested_Item_With_Data": {
             data: {...}
      }
}

Is it possible to have such a response for getting a single item or if it already exists, can you please point me in the right direction?

Thanks in advance