anuditverma / org.civicrm.osdi

OSDI API Implementation for CiviCRM - Google Summer of Code (GSoC) 2015
Other
1 stars 3 forks source link

/people endpoint: blank values should be skipped #2

Open j-ro opened 9 years ago

j-ro commented 9 years ago

Testing here:

http://camus.fuzion.co.nz/hal-browser/browser.html#/sites/default/ext/osdi/api/v3/People/index.php

Blank values should be simply not returned. Right now, "" is being outputted for blank names, null for other blank values, etc... Instead, if there's no data, the field should be not included.

joemcl commented 9 years ago

Jason, if some records have data in these fields - first name, last name etc - and others do not - and these are dummy records simply for testing the implementation - we don't want to exclude first name (given name), last name (family name), etc. I'll fill in some of the missing data in the dummy records. but would rather not exclude those fields.

j-ro commented 9 years ago

That's not what I'm saying. I'm saying if no data exists for that particular person on that field, the endpoint should not return the field, rather than showing a blank field. If it exists for another person, of course it should be returned.

So, for dummy people that don't have first names, the first name field should not be on their resource. For ones that do, it should be there.

joemcl commented 9 years ago

Got it, thanks. Any empty or null field for any record should not be returned.

anuditverma commented 9 years ago

I started resolving this issue first, there are numerous ways which do not allow to print/return the field when it is empty but actually I have used the library https://github.com/blongden/hal which uses array() within a function to generate the embedded resource. So if I try to use something like if(!empty($myarray)) {//return field} against each field to check if it is empty or not but this can't be done done within the array() when I inline this if expression in front of the fields. I am figuring out to how do this, I'll try different approaches like creating a separate function before passing in the values or I'll try to make changes in the Get.php entity file.

j-ro commented 9 years ago

I'd guess that checking for emptiness before passing the values to HAL is the way to go. But Eileen might have other suggestions.

eileenmcnaughton commented 9 years ago

no - checking & eliminating empties sounds like part of the role of reformatting CiviCRM API output to osdi output - which would be done in this extension