namespace Pluto.Api {
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq;
    using PlutoServer.PracticeChoice;

    [RemObjects.SDK.Server.ClassFactories.StandardClassFactory()]
    [RemObjects.SDK.Server.Service(Name = "Schedule", InvokerClass = typeof(Schedule_Invoker), ActivatorClass = typeof(Schedule_Activator))]
    public class Schedule : RemObjects.SDK.Server.Service, ISchedule {
        private System.ComponentModel.Container components = null;
        public Schedule() :
            base() {
            this.InitializeComponent();
        }

        private void InitializeComponent() {
            this.RequireSession = true;
        }

        protected override void Dispose(bool aDisposing) {
            if(aDisposing) {
                if((this.components != null)) {
                    this.components.Dispose();
                }
            }
            base.Dispose(aDisposing);
        }
        public virtual AppointmentInfo1[] GetAppointments1(string apiKey, ProviderInfo1 providerInfo, System.DateTime startDate, System.DateTime endDate) {
            if(Utility.IsAPIKeyValid(apiKey)) {
                var authToken = (string)this.Session[SessionKeys.AuthToken];
                var calendar = new PlutoServer.PracticeChoice.Scheduling.Calendar();
                var apptList = calendar.GetAppointments(authToken, providerInfo, calendarId:0, startDateTime:startDate, endDateTime:endDate);
                return apptList.ToArray();

            } else {
                return null;
            }
        }

        #region ISchedule Members


        public bool AddAppointment1(string apiKey, AppointmentInfo1 appointmentInfo) {
            return true;
        }

        #endregion
    }
}
