Rest - Contacts - Staff: Difference between revisions
No edit summary |
|||
Line 5: | Line 5: | ||
===Base URL=== | ===Base URL=== | ||
http://app.views.coop/api/restful/contacts/staff | http://app.views.coop/api/restful/contacts/staff | ||
===Schema=== | |||
<nowiki>http://app.views.coop/api/restful/contacts/staffs/schema(.xml|.json|.xsd)</nowiki> | |||
==Creating a staff record== | ==Creating a staff record== | ||
Once you have created your data file, you can send it using the following: | Once you have created your data file, you can send it using the following: | ||
Line 45: | Line 43: | ||
curl --url <Base URL>/search?q=<query> -u<username>:<password> -H Content-Type:text/xml | curl --url <Base URL>/search?q=<query> -u<username>:<password> -H Content-Type:text/xml | ||
* query - This is a text string to use to search for in the staff records | * query - This is a text string to use to search for in the staff records | ||
You can search for any field for a specific value by setting the field as a parameter. Please refer to the schema for field names. | |||
There are also a series of fields that you use -from and -to modifiers to express a range: | |||
* DateOfBirth - yyyy-mm-dd | |||
* Age - int (Please note that this is in days) | |||
* Created - yyyy-mm-dd | |||
* Updated - yyyy-mm-dd | |||
* Archived - yyyy-mm-dd | |||
==Updating a staff record== | ==Updating a staff record== |
Revision as of 14:25, 9 July 2012
Purpose
TUsed for creating, editing and deleting Staff from the Views system.
Base URL
http://app.views.coop/api/restful/contacts/staff
Schema
http://app.views.coop/api/restful/contacts/staffs/schema(.xml|.json|.xsd)
Creating a staff record
Once you have created your data file, you can send it using the following:
curl --url <Base URL> -u<username>:<password> -H Content-Type:text/xml -X POST -d "<xml>"
If there is a problem with creating that record, you will get a response containing all the errors, plus a copy of the translated data you supplied.
If the record was created successfully, the service will return a complete reocrd for the newly created record if the attribute id set as the newly created id.
Fetching a staff record
curl --url <Base URL>/<id> -u<username>:<password> -H Content-Type:text/xml
This will return an xml file similar to this
<?xml version="1.0" encoding="utf-8"?> <staff id="100001"> <Nickname></Nickname> <Forename>John</Forename> <Surname>Smith</Surname> ... <Created>2011-05-09 10:26:09</Created> <CreatedBy>a.user</CreatedBy> <Updated>2011-05-09 10:26:09</Updated> <UpdatedBy>a.user</UpdatedBy> <Archived>0000-00-00 00:00:00</Archived> <ArchivedBy></ArchivedBy> <Type>1</Type> <PersonID>100001</PersonID> <TypeName>staff</TypeName> </staff>
Searching for a staff record
curl --url <Base URL>/search?q=<query> -u<username>:<password> -H Content-Type:text/xml
- query - This is a text string to use to search for in the staff records
You can search for any field for a specific value by setting the field as a parameter. Please refer to the schema for field names.
There are also a series of fields that you use -from and -to modifiers to express a range:
- DateOfBirth - yyyy-mm-dd
- Age - int (Please note that this is in days)
- Created - yyyy-mm-dd
- Updated - yyyy-mm-dd
- Archived - yyyy-mm-dd
Updating a staff record
curl --url <Base URL>/<id> -u<username>:<password> -H Content-Type:text/xml -X PUT -d "<xml>"
- id - The ID of the staff
The XML should be in the same format as the create XML. However, you only need to supply fields that you wish to update. For example:
<?xml version="1.0" encoding="utf-8"?> <staff id="100001"> <Forename>Jane</Forename> <Surname>Smith</Surname> </staff>
The above would result in updating staff 1000001's Forename and Surname values
Archiving a staff record
curl --url <Base URL>/<id> -u<username>:<password> -H Content-Type:text/xml -X PUT -d '<status>1</status>'
- id - The ID of the staff record
This will set the archive flag on a staff record. If you set the status to 0, then it will remove the archive flag.
Deleting a staff record
curl --url <Base URL>/<id> -u<username>:<password> -H Content-Type:text/xml -X DELETE
- id - The ID of the staff
This should be used with great care as it will permenently delete a staff record.