public ICalendarService InitCalendarService(string token, EventSource source)
        {
            if (token == null)
            {
                throw new Exception("API token is null");
            }

            ICalendarService calendarAPI = null;

            switch (source)
            {
            case EventSource.Microsoft:
                var serviceClient = GraphClient.GetAuthenticatedClient(token);
                calendarAPI = new MSGraphCalendarAPI(serviceClient);
                break;

            case EventSource.Google:
                var googleClient       = GoogleClient.GetGoogleClient(_settings);
                var googlePeopleClient = GoogleCalendarAPI.GetServiceClient(googleClient, token);
                calendarAPI = new GoogleCalendarAPI(googlePeopleClient);
                break;

            default:
                throw new Exception("Event Type not Defined");
            }

            return(new CalendarService(calendarAPI, source));
        }
Exemplo n.º 2
0
        public IContactProvider GetContactProvider(string token, ContactSource source)
        {
            switch (source)
            {
            case ContactSource.Microsoft:
                var serviceClient = GraphClient.GetAuthenticatedClient(token);
                return(new GraphContactProvider(serviceClient));

            case ContactSource.Google:
                var googleClient = new GoogleClient(_settings, token);
                return(new GoogleContactProvider(googleClient));

            default:
                throw new Exception($"ContactSource not covered in switch statement: {source.ToString()}");
            }
        }
        /// <inheritdoc/>
        public IMailService InitMailService(string token, TimeZoneInfo timeZoneInfo, MailSource source)
        {
            switch (source)
            {
            case MailSource.Microsoft:
                var serviceClient = GraphClient.GetAuthenticatedClient(token, timeZoneInfo);
                return(new MSGraphMailAPI(serviceClient, timeZoneInfo));

            case MailSource.Google:
                var googleClient        = GoogleClient.GetGoogleClient(_settings);
                var googleServiceClient = GMailService.GetServiceClient(googleClient, token);
                return(new GMailService(googleServiceClient));

            default:
                throw new Exception("Event Type not Defined");
            }
        }
Exemplo n.º 4
0
        public IUserService InitUserService(string token, EventSource source)
        {
            switch (source)
            {
            case EventSource.Microsoft:
                var serviceClient = GraphClient.GetAuthenticatedClient(token);
                return(new MSGraphUserService(serviceClient));

            case EventSource.Google:
                var googleClient       = GoogleClient.GetGoogleClient(_skillConfig);
                var googlePeopleClient = GooglePeopleService.GetServiceClient(googleClient, token);
                return(new GooglePeopleService(googlePeopleClient));

            default:
                throw new Exception("Event Type not Defined");
            }
        }
Exemplo n.º 5
0
        public IUserService InitUserService(string token, EventSource source)
        {
            IUserService userService = null;

            switch (source)
            {
            case EventSource.Microsoft:
                var serviceClient = GraphClient.GetAuthenticatedClient(token);
                userService = new MSGraphUserService(serviceClient);
                break;

            case EventSource.Google:
                var googleClient       = GoogleClient.GetGoogleClient(_settings);
                var googlePeopleClient = GooglePeopleService.GetServiceClient(googleClient, token);
                userService = new GooglePeopleService(googlePeopleClient);
                break;

            default:
                throw new Exception("Event Type not Defined");
            }

            return(new UserService(userService));
        }