Example #1
0
        /// <inheritdoc/>
        public async Task <IListResult <RoomMembership> > GetRoomMembershipsAsync(string roomId, int max = 100)
        {
            var membershipParams = BuildMembershipQuery(max, null, roomId);
            var path             = await GetPathWithQueryAsync(WxTeamsConstants.MembershipsUrl, membershipParams);

            return(await TeamsClient.GetResultsAsync <RoomMembership>(path));
        }
Example #2
0
        /// <inheritdoc/>
        public async Task <IListResult <ResourceGroupMembership> > GetResourceGroupMembershipsAsync(int max            = 100, string licenseId = "", string personId = "",
                                                                                                    string personOrgId = "", ResourceMembershipStatus?status = null)
        {
            var resourceParams = new List <KeyValuePair <string, string> >();

            if (max != 100)
            {
                resourceParams.Add(new KeyValuePair <string, string>(nameof(max), max.ToString()));
            }

            if (!string.IsNullOrEmpty(licenseId))
            {
                resourceParams.Add(new KeyValuePair <string, string>(nameof(licenseId), licenseId));
            }

            if (!string.IsNullOrEmpty(personId))
            {
                resourceParams.Add(new KeyValuePair <string, string>(nameof(personId), personId));
            }

            if (!string.IsNullOrEmpty(personOrgId))
            {
                resourceParams.Add(new KeyValuePair <string, string>(nameof(personOrgId), personOrgId));
            }

            if (status != null)
            {
                resourceParams.Add(new KeyValuePair <string, string>(nameof(status), status.ToString()));
            }

            var path = await GetPathWithQueryAsync(WxTeamsConstants.ResourceMembershipsUrl, resourceParams);

            return(await TeamsClient.GetResultsAsync <ResourceGroupMembership>(path));
        }
Example #3
0
        /// <inheritdoc/>
        public async Task <IListResult <Person> > GetUsersAsync(string email            = "", string displayName = "",
                                                                IEnumerable <string> id = default, string orgId  = "", int max = 100)
        {
            var roomParams = new List <KeyValuePair <string, string> >();

            if (id != null && id.Any() && IdIsAcceptableLength(id))
            {
                roomParams.Add(new KeyValuePair <string, string>(nameof(id), string.Join(",", id)));
            }

            if (max != 100)
            {
                roomParams.Add(new KeyValuePair <string, string>(nameof(max), max.ToString()));
            }

            if (!string.IsNullOrEmpty(email))
            {
                roomParams.Add(new KeyValuePair <string, string>(nameof(email), email));
            }

            if (!string.IsNullOrEmpty(displayName))
            {
                roomParams.Add(new KeyValuePair <string, string>(nameof(displayName), displayName));
            }

            if (!string.IsNullOrEmpty(orgId))
            {
                roomParams.Add(new KeyValuePair <string, string>(nameof(orgId), orgId));
            }

            var path = await GetPathWithQueryAsync(WxTeamsConstants.PeopleUrl, roomParams);

            return(await TeamsClient.GetResultsAsync <Person>(path));
        }
Example #4
0
        /// <inheritdoc/>
        public async Task <IListResult <RoomMembership> > GetMembershipsAssociatedWithAsync(string userIdOrEmail, int max = 100)
        {
            var membershipParams = BuildMembershipQuery(max, userIdOrEmail, null);
            var path             = await GetPathWithQueryAsync(WxTeamsConstants.MembershipsUrl, membershipParams);

            return(await TeamsClient.GetResultsAsync <RoomMembership>(path));
        }
Example #5
0
        /// <inheritdoc/>
        public async Task <IListResult <Room> > GetRoomsAsync(int max       = 100, string teamId  = "",
                                                              RoomType?type = null, SortBy?sortBy = null)
        {
            var roomParams = new List <KeyValuePair <string, string> >();

            if (max != 100)
            {
                roomParams.Add(new KeyValuePair <string, string>(nameof(max), max.ToString()));
            }

            if (!string.IsNullOrEmpty(teamId))
            {
                roomParams.Add(new KeyValuePair <string, string>(nameof(teamId), teamId));
            }

            if (type != null)
            {
                roomParams.Add(new KeyValuePair <string, string>(nameof(type), type.ToString().ToLower()));
            }

            if (sortBy != null)
            {
                roomParams.Add(new KeyValuePair <string, string>(nameof(sortBy), sortBy.ToString().ToLower()));
            }

            var path = await GetPathWithQueryAsync(WxTeamsConstants.RoomsUrl, roomParams);

            return(await TeamsClient.GetResultsAsync <Room>(path));
        }
Example #6
0
        /// <inheritdoc/>
        public async Task <IListResult <Team> > GetTeamsAsync(int max = 100)
        {
            var teamParams = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>(nameof(max), max.ToString())
            };

            var path = await GetPathWithQueryAsync(WxTeamsConstants.TeamsUrl, teamParams);

            return(await TeamsClient.GetResultsAsync <Team>(path));
        }
Example #7
0
        /// <inheritdoc/>
        public async Task <IListResult <ResourceGroup> > GetResourceGroupsAsync(string orgId = "")
        {
            var groupParams = new List <KeyValuePair <string, string> >();

            if (!string.IsNullOrEmpty(orgId))
            {
                groupParams.Add(new KeyValuePair <string, string>(nameof(orgId), orgId));
            }

            var path = await GetPathWithQueryAsync(WxTeamsConstants.ResourceGroupsUrl, groupParams);

            return(await TeamsClient.GetResultsAsync <ResourceGroup>(path));
        }
Example #8
0
        /// <inheritdoc/>
        public async Task <IListResult <Message> > GetDirectMessagesAsync(string userIdOrEmail)
        {
            var queryBy = "personId";

            if (RegexUtilities.IsValidEmail(userIdOrEmail))
            {
                queryBy = "personEmail";
            }

            var messageParams = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>(queryBy, userIdOrEmail)
            };

            var path = await GetPathWithQueryAsync($"{WxTeamsConstants.MessagesUrl}/direct", messageParams);

            return(await TeamsClient.GetResultsAsync <Message>(path));
        }
Example #9
0
        /// <inheritdoc/>
        public async Task <IListResult <Message> > GetRoomMessagesAsync(string roomId, int max = 50, bool userMentioned = false,
                                                                        ICollection <string> mentionedPeople = default, DateTimeOffset before = default, string beforeMessage = "")
        {
            var messageParams = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>(nameof(roomId), roomId)
            };

            if (mentionedPeople == null)
            {
                mentionedPeople = new List <string>();
            }

            if (max != 50)
            {
                messageParams.Add(new KeyValuePair <string, string>(nameof(max), max.ToString()));
            }

            if (userMentioned)
            {
                mentionedPeople.Add("me");
            }

            if (mentionedPeople.Any())
            {
                messageParams.Add(new KeyValuePair <string, string>(nameof(mentionedPeople), string.Join(',', mentionedPeople)));
            }

            if (before != DateTimeOffset.MinValue)
            {
                messageParams.Add(new KeyValuePair <string, string>(nameof(before), before.ToFormattedUTCTime()));
            }

            if (!string.IsNullOrEmpty(beforeMessage))
            {
                messageParams.Add(new KeyValuePair <string, string>(nameof(beforeMessage), beforeMessage));
            }

            var path = await GetPathWithQueryAsync(WxTeamsConstants.MessagesUrl, messageParams);

            return(await TeamsClient.GetResultsAsync <Message>(path));
        }
Example #10
0
        /// <inheritdoc/>
        public async Task <IListResult <Event> > GetEventsAsync(int max        = 100, EventResource?resource = null, EventType?type       = null,
                                                                string actorId = "", DateTimeOffset from     = default, DateTimeOffset to = default)
        {
            var eventParams = new List <KeyValuePair <string, string> >();

            if (max != 100)
            {
                eventParams.Add(new KeyValuePair <string, string>(nameof(max), max.ToString()));
            }

            if (resource != null)
            {
                eventParams.Add(new KeyValuePair <string, string>(nameof(resource), resource.ToString().FirstCharToLower()));
            }

            if (type != null)
            {
                eventParams.Add(new KeyValuePair <string, string>(nameof(type), type.ToString().FirstCharToLower()));
            }

            if (!string.IsNullOrEmpty(actorId))
            {
                eventParams.Add(new KeyValuePair <string, string>(nameof(actorId), actorId));
            }

            if (from != DateTimeOffset.MinValue)
            {
                eventParams.Add(new KeyValuePair <string, string>(nameof(from), from.ToFormattedUTCTime()));
            }

            if (to != DateTimeOffset.MinValue)
            {
                eventParams.Add(new KeyValuePair <string, string>(nameof(to), to.ToFormattedUTCTime()));
            }

            var path = await GetPathWithQueryAsync(WxTeamsConstants.EventsUrl, eventParams);

            return(await TeamsClient.GetResultsAsync <Event>(path));
        }
Example #11
0
 /// <inheritdoc/>
 public async Task <IListResult <Role> > GetRolesAsync()
 => await TeamsClient.GetResultsAsync <Role>(WxTeamsConstants.RolesUrl);
Example #12
0
 /// <inheritdoc/>
 public async Task <IListResult <Organization> > GetOrganizationsAsync()
 => await TeamsClient.GetResultsAsync <Organization>(WxTeamsConstants.OrganizationsUrl);
Example #13
0
 /// <inheritdoc/>
 public async Task <IListResult <License> > GetLicensesAsync()
 => await TeamsClient.GetResultsAsync <License>(WxTeamsConstants.LicensesUrl);