CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Api v3
Pages: [1]

Author Topic: Api v3  (Read 728 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Api v3
January 12, 2011, 01:22:14 am
Coleman sent an e-mail to the API team with probably the most relevant questions possible to where we are going with the next release of the api so I thought I'd post it up here for elaboration..

So if there is a document somewhere about the master plan at work for v3, could someone please point me to it? If not, can someone please tell me:

Quote
    * When are we aiming to release v3?
    * Are there documented coding standards we're working from?
    * Is there a plan for a more standard way of validating $params? I would really like to see a single function in the utils.php that takes care of all validation.
    * Ditto for permission checking.
    * What's the best way for me to document bugs I find? For example, the most recent one I've banged my head against is that custom fields don't get processed when the user is logged-out, probably due to over-zealous permission checking.


Really we should update the answers here

http://forum.civicrm.org/index.php?action=post;board=41.0

But briefly

- hopefully we can get v3 in 3.4
-Tag.php should be the 'model' api - although it's not a contact based api so we need to build up one of them too (e.g contribution)
- There are 2 functions for validating $params:
    civicrm_verify_mandatory
    civicrm_verify_one_mandatory

verify one is for an either or e.g the $params would be array('id','name') meaning id OR name. It's just a wrapper  / reformatter for verify_mandatory

-     civicrm_api_check_permission(__FUNCTION__, $params, true); checks permissions but is not widely used - could do with some more detail

- document bugs by putting @todo in the code - it winds up in the todo list here http://api.civicrm.org/v3/

Also,

new standards are to use try & catch per http://api.civicrm.org/v3/__filesource/fsource_CiviCRM_APIv3_API_Contact_v3Contact.php.html#a61
And to use
civicrm_create_success
civicrm_create_error
to return results

  _civicrm_initialize( true ); in each function (as I think Coleman suggested)

Please feel free to interpret these onto the wiki (which is rather due a restructure)
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Api v3
January 12, 2011, 01:42:40 am
Be careful with the civicrm_create_success using the REST interface though. At the moment the REST interface only caters for two levels of arrays in the result if you use XML rather than JSON. Using civicrm_create_success adds a level to the arrays which might cause problems if you do use the REST and XML. I am in the process of fixing the REST so it caters for more levels....and I will do a forum post later on the 'new' civicrm_create_success in API v3!
Erik
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Api v3
January 12, 2011, 10:52:57 am
So, the API SHOULD use civicrm_create_success but the behaviour will change
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Api v3

This forum was archived on 2017-11-26.