# Contacts New contact --------- ```eval_rst .. http:put:: /aalam/base/contacts ``` Create and save a new contact and it's details **Permissions** *Permissions* _all_ of the following permissions - Contacts/create **Outputs** - Contact created successfully. *Status code*: 200 *Content type*: application/json *Content specification* ``` { "id": "Integer denoting the identifier for the newly created contact" } ``` - 'first_name', 'last_name' and 'other_info' are all null in input. *Status code*: 400 **Inputs** - In the JSON input, either one 'first_name', 'last_name' or 'other_info' should be a non-null value. 'details' fields is optional. *Content type*: application/json *Content specification* ``` { "fist_name": "First name of the contact", "last_name": "Last name of the contact", "other_info": "Additional information to classify the contact", "details": (optional) [{ "key": "Key value for a new field, ex. Phone, Email, Address, etc", "value": "Value corresponding to the 'key' of this field }, ... ] } ``` Get contacts --------- ```eval_rst .. http:get:: /aalam/base/contacts ``` Get a list of contacts qualifying the filters applied **Permissions** *Flags* - deny_anon *Permissions* _all_ of the following permissions - Contacts/access **Parameters** - fields > List of fields separated by comma to be presented in the output. Valid values are - ['first_name', 'last_name', 'other_info', 'detail.%' ex. detail.mobile, 'id', 'address.city', 'address.state', 'address.postal_code', 'address.country']. - first_name(_like) > Filter apps with 'first_name' qualifying the value. - last_name(_like) > Filter apps with 'last_name' qualifying the value. - other_info(_like) > Filter apps witn 'other_info' qualifying the value. - value(_like) > Filter apps with any of its field values qualying the value. - key(_like) > Filter apps with any of its field keys qualying the value. **Outputs** - Queried contacts successfully. The output fields in varies with the choice of fields in the url parameters. *Status code*: 200 *Content type*: application/json *Content specification* ``` { "id": "Integer identifier for the contact", "first_name": "First name of the contact", "last_name": "Last name of the contact", "other_info": "Additional information of the contact" } ``` - Some input parameters are mandatory. *Status code*: 400 Add details --------- ```eval_rst .. http:put:: /aalam/base/contact/{contact_id} ``` Add new details to an already existing contact. **Permissions** *Permissions* _any_ of the following permissions - Contacts/create - Contacts/delete - Contacts/add-details **Outputs** - Created details for the contact. *Status code*: 200 - The input data seems to be not valid *Status code*: 400 - Contact not found. *Status code*: 404 **Inputs** - Input should be a list of dictionaries. *Content type*: application/json *Content specification* ``` [ { "key": "Key value for the value, ex. Phone, Mobile, Email", "value": "Value corresponding the key" }, ... ] ``` Get contact --------- ```eval_rst .. http:get:: /aalam/base/contact/{contact_id} ``` Get detailed information of a contact. **Permissions** *Flags* - deny_anon *Permissions* _all_ of the following permissions - Contacts/access **Outputs** - Queried contact information successfully *Status code*: 200 *Content type*: application/json *Content specification* ``` { "first_name": "First name of the contact", "last_name": "Last name of the contact", "other_info": "Additional information of the contact", "details": [{ "id": "Contact field id" "key": "Key value of the contact", "value": "Value corresponding to the key" }, ... ], "addresses": [{ "id": "Address id", "name": "Contact name", "line1": "Line 1", "line2": ..., "line3": ..., "line4": ..., "city": ..., "state": ..., "country": ..., "postal_code": ..., "contact_num": ..., "contact_email": ... }, ...] } ``` - Contact not found *Status code*: 404 Update field --------- ```eval_rst .. http:post:: /aalam/base/contact/{contact_id}/{key_id} ``` Update field information of a contact. The {key_id} can be obtainedfrom the 'Get contact details' API. **Permissions** *Permissions* _any_ of the following permissions - Contacts/create - Contacts/delete - Contacts/add-details - Contacts/delete-details **Parameters** - key > New value to replace the contact field's key if key is detail id - value > New value to replace the contact filed's value if key is detail id - line1 > New address line4 value. Key id should be "Address-{address_id}" - line2 > New address line2 value. Key id should be "Address-{address_id}" - city > New city value. Key id should be "Address-{address_id}" - state > New state value. Key id should be "Address-{address_id}" - country > New country value. Key id should be "Address-{address_id}" - postal_code > New postal code value. Key id should be "Address-{address_id}" **Outputs** - Contact field updated successfully *Status code*: 200 - Contact or Field not found. *Status code*: 404 Delete field --------- ```eval_rst .. http:delete:: /aalam/base/contact/{contact_id}/{key_id} ``` Delete a key-value field of a contact. The {key_id} of a field can beobtained from the 'Get contact details' API.If prefixed with "Address-{address_id}" then the address detail bedeleted **Permissions** *Permissions* _any_ of the following permissions - Contacts/create - Contacts/delete - Contacts/delete-details **Outputs** - Field deleted successfully. *Status code*: 200 - Contact or Field not found. *Status code*: 404 Update contact --------- ```eval_rst .. http:post:: /aalam/base/contact/{contact_id} ``` Update name details of a contact. **Permissions** *Permissions* _any_ of the following permissions - Contacts/create - Contacts/delete **Parameters** - first_name > New value to replace the contact's first name. - last_name > New value to replace the contact's last name. - other_info > New value to replace the contact's additional information. - detail.<key> > Update new value for the details with key. If key doesn't exist, add it as a new key - address.<key> > Update the address parameters. Only the first address will be update. Key should be one of line1, line2, line3, line4, city, state, postal_code, country **Outputs** - Contact updated successfully. *Status code*: 200 - Contact not found. *Status code*: 404 Delete contact --------- ```eval_rst .. http:delete:: /aalam/base/contact/{contact_id} ``` Delete a contact and it's fields. **Permissions** *Permissions* _any_ of the following permissions - Contacts/delete **Outputs** - Deleted contact successufully. *Status code*: 200 - Contact not found. *Status code*: 404