# 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", "referred_by": Contact id of the referrer, "details": (optional) [{ "key": "Key value for a new field, ex. Phone, Email, Address, Bank A/C, 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', 'referred_by', 'address.city', 'address.state', 'address.postal_code', 'address.country', 'bank.accnt_num', 'bank.bank_code', 'bank.accnt_type', 'bank.bank_name', 'bank.swift_code']. - 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* _all_ of the following permissions - 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", "referred_by": {'first_name': '', last_name: '', 'id': xx}, "referral_link": "https://xxx/rfrl/xxxx/xxxx", "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": ... }, "bank_accounts": [{ "accnt_num": "Bank a/c number", "accnt_type": "A/C type", "bank_code": "Bank code", "bank_name": "Name of the bank", "swift_code": "SWIFT Code for international transfers" }], ...] } ``` - 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** *Flags* - deny_anon **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}" - country_code > ISO 3166-1 alpha-2 country code. Key id should be "Address-{address_id}" - postal_code > New postal code value. Key id should be "Address-{address_id}" - accnt_num > Bank Account number. Key Id shoudl be "Bank-{bank_id}" - accnt_type > Bank Account type. Key Id shoudl be "Bank-{bank_id}" - bank_code > Bank branch code. Key Id shoudl be "Bank-{bank_id}" - bank_name > Bank Name. Key Id shoudl be "Bank-{bank_id}" - swift_code > SWIFT code. Key Id shoudl be "Bank-{bank_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/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** *Flags* - deny_anon **Parameters** - first_name > New value to replace the contact's first name. - last_name > New value to replace the contact's last name. - referred_by > Contact id of the customer who referred this customer - 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 - bank.<key> > Update the bank details. Only the first bank account will be updated. key should be one of accnt_num, accnt_type, bank_code, bank_name, swift_code - status_code > 200 - description > Contact updated successfully. **Outputs** - 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