# Documentation for API Endpoints and Responses ## /available-appointments ### Description Returns a list of distinct available appointments (list/array of strings) for the selected date, if the `date` param is passed in the URL. If not, it returns a list of strings of available days (at least one appointment is available). ### Method `GET` ### Request Accepts `date` param in a `YYYY-MM-DD` string format. For example, `/available-appointments?date=2022-01-01` ### Response ### Date param passed #### Error ``` { 'status': 400, 'data': { 'success': False, 'error_message': /* See 'Error messages' for full error message details */ } } ``` ##### Error messages Here is a list of error messages returned at various failure points within the view: - No active Advisors in the database - 'There are no active Advisors.' - API error (authentication) when querying Advisor schedules - 'There was an API error when trying to get the available appointments.' - Generic error string if API error (invalid Advisor ical_link) when querying Advisor schedules - 'Unable to query Advisor schedules as one or more iCal links were invalid.' - API error message if API error (invalid Advisor ical_link) when querying Advisor schedules - e.g. 'The email address provided is not a valid SMTP address.' - API error when querying custom Advisor schedules - 'There was an error when trying to get the custom schedule for one or more Advisors.' #### Success ``` { 'status': 200, 'data': { 'success': True, 'appointments_list': [ '09:00:00', '10:30:00', '12:00:00', '13:30:00', ] } } ``` ### Date param not passed #### Error ``` { 'status': 400, 'data': { 'success': False, 'error_message': 'There was an error when getting the available days' } } ``` #### Success ``` { 'status': 200, 'data': { 'success': True, 'available_days_list': [ '2022-01-01', '2022-01-02', '2022-01-03', '2022-01-04', ] } } ``` ## /make-booking ### Description Creates the following: - Calendar entry in the Advisor's calendar - IO client entry for the main client - IO client entry for the joint client (if joint application) - Contact details (email and phone) records for the main client - Contact details (email and phone) records for the joint client (if joint application) - Address record for the main client - DPA agreement record for the main client - Marketing preferences record for the main client - Booking record (only used/accessible by middleware for sending appointment reminders) - AdvisorLog record (only used/accessible by middleware for allocating appointments) Sends the following: - Confirmation email to the client - Confirmation email to the Advisor ### Method `POST` ### Request _Fields marked with a * are required_ ``` data = { *'title': 'Mr', // string *'first_name': 'Test', // string *'last_name': 'Client', // string *'dob': '2000-01-01', // string 'YYYY-MM-DD' *'email': 'test@email.com', // string *'telephone': '07234456789', // string *'joint': True, // boolean 'joint_first_name': 'Joint', // string - required if joint is True 'joint_last_name': 'Client', // string - required if joint is True 'joint_email': 'joint@client.com', // string - required if joint is True 'joint_telephone': '07234456789', // string - required if joint is True 'joint_consent': True, // boolean - required and must be True if joint is True *'address': '123 Test Ave, Test', // string *'postcode': 'TE5 5ST, // string *'appointment_time': '2022-01-01 09:00:00', // string 'YYYY-MM-DD HH:MM:SS' *'appointment_type': 'video', // string 'video call | telephone call' *'career_grade': 'Test grade', // string *'bma': True, // boolean *'bma_consent': False, // boolean *'source': 'Test source', // string *'marketing_accept': False, // boolean *'privacy_accept': True, // boolean - must be True 'utm_source': 'Medical Marketing', // string 'utm_medium': 'O_Website', // string 'utm_campaign': 'Website', // string } ``` ### Response #### Error ##### Error with form fields ``` { 'status': 400, 'data': { 'success': False, 'error_message': 'Form could not be submitted.', 'errors': { 'first_name': 'This is required.', 'last_name': 'This is required.' } } } ``` ##### Other errors ``` { 'status': 400, 'data': { 'success': False, 'error_message': /* See 'Error messages' for full error message details */ 'io_client_url': None 'io_joint_client_url': None } } ``` ##### Error messages Here is a list of error messages returned at various failure points within the view: - No active Advisors in the database - 'There are no active Advisors.' - API error (authentication) when querying Advisor schedules - 'There was an API error when trying to get the available appointments.' - Generic error string if API error (invalid Advisor ical_link) when querying Advisor schedules - 'Unable to query Advisor schedules as one or more iCal links were invalid.' - API error message if API error (invalid Advisor ical_link) when querying Advisor schedules - e.g. 'The email address provided is not a valid SMTP address.' - No Advisors available at the selected time - 'No Advisors are available at that time.' - API error when creating calendar entry - 'There was an API error when trying to create the appointment in the Advisor's calendar.' - DB error when creating DB records - 'There was an error when creating internal Database records after creating calendar entry.' - Calendar entry created at this point - API error when creating client entry for main client - 'There was an API error when trying to create the main client entry.' - Calendar entry created and confirmation emails sent at this point - API error when creating client entry for joint client (if joint application) - 'There was an API error when trying to create the joint client entry.' - Calendar entry created, confirmation emails sent and main client entry created at this point - API error when creating email entry for main client - 'There was an API error when trying to create an email address entry for the main client.' - Calendar entry created, confirmation emails sent and main/joint client entries created at this point - API error when creating telephone entry for main client - 'There was an API error when trying to create a telephone entry for the main client.' - Calendar entry created, confirmation emails sent, main/joint client entries and main client email entry created at this point - API error when creating email entry for joint client (if joint application) - 'There was an API error when trying to create an email address entry for the joint client.' - Calendar entry created, confirmation emails sent, main/joint client, main client email/telephone entries created at this point - API error when creating telephone entry for joint client (if joint application) - 'There was an API error when trying to create a telephone entry for the joint client.' - Calendar entry created, confirmation emails sent, main/joint client, main client email/telephone and joint client email entries created at this point - API error when creating address entry for main client - 'There was an API error when trying to create an address entry for the main client.' - Calendar entry created, confirmation emails sent, main/joint client, main/joint client email/telephone entries created at this point - API error when creating DPA agreement entry for main client - 'There was an API error when trying to create a DPA agreement entry for the main client.' - Calendar entry created, confirmation emails sent, main/joint client, main/joint client email/telephone entries, main client address entry created at this point - API error when updating marketing preferences for main client - 'There was an API error when trying to update the marketing preferences for the main client.' - Calendar entry created, confirmation emails sent, main/joint client, main/joint client email/telephone entries, main client address and DPA agreement entries created at this point - API error when creating service case for main client - 'There was an API error when trying to create a service case entry for the main client.' - Calendar entry created, confirmation emails sent, main/joint client, main/joint client email/telephone entries, main client address and DPA agreement entries created, marketing preferences updated at this point - DB error when updating DB records after creating IO entries - 'There was an error when updating internal Database records after creating IO entries.' - All required actions completed at this point All returned error responses will contain the io_client_url following successful creation of the main client entry, and the io_joint_client_url following successful creation of the joint client entry. These URLs will be the relevant Client URLs in the IO Dashboard. #### Success ``` { 'status': 200, 'data': { 'success': True, 'io_client_url': 'https://office.gb.intelliflo.net/nio/clientDashboard/1234567/dashboard/' 'io_joint_client_url': 'https://office.gb.intelliflo.net/nio/clientDashboard/1234567/dashboard/' } } ```