/// <summary> /// Create an event filter for person. /// </summary> /// <param name="personIdOrEmail">Person id or email to be filtered.</param> /// <param name="personIdType"><see cref="PersonIdType"/> for personIdOrEmail filter.</param> public PersonFilter(string personIdOrEmail, PersonIdType personIdType = PersonIdType.Detect) : base("personId", personIdOrEmail) { personIdType = TeamsAPIClient.DetectPersonIdType(personIdOrEmail, personIdType); if (personIdType == PersonIdType.Email) { this.Key = "personEmail"; } }
/// <summary> /// Initializes a new instance of the <see cref="WebexClientWrapper"/> class. /// Creates a Webex Client Wrapper. See <see cref="WebexAdapterOptions"/> for a full definition of the allowed parameters. /// </summary> /// <param name="options">An object containing API credentials, a webhook verification token and other options.</param> public WebexClientWrapper(WebexAdapterOptions options) { Options = options ?? throw new ArgumentNullException(nameof(options)); if (string.IsNullOrWhiteSpace(Options.WebexAccessToken)) { throw new ArgumentException(nameof(options.WebexAccessToken)); } if (Options.WebexPublicAddress == null) { throw new ArgumentException(nameof(options.WebexPublicAddress)); } _api = TeamsAPI.CreateVersion1Client(Options.WebexAccessToken); }
/// <summary> /// Initializes a new instance of the <see cref="WebexClientWrapper"/> class. /// Creates a Webex Client Wrapper. See <see cref="WebexAdapterOptions"/> for a full definition of the allowed parameters. /// </summary> /// <param name="config">An object containing API credentials, a webhook verification token and other options.</param> public WebexClientWrapper(WebexAdapterOptions config) { _config = config ?? throw new ArgumentNullException(nameof(config)); if (string.IsNullOrWhiteSpace(_config.AccessToken)) { throw new ArgumentException(nameof(config.AccessToken)); } if (_config.PublicAddress == null) { throw new ArgumentException(nameof(config.PublicAddress)); } _api = TeamsAPI.CreateVersion1Client(_config.AccessToken); }
/// <summary> /// Appends mention to a person. /// </summary> /// <param name="personIdOrEmail">PersonId or PersonEmail to be mentioned.</param> /// <param name="name">Mentioned name.</param> /// <param name="personIdType"><see cref="PersonIdType"/> of personIdOrEmail parameter.</param> /// <returns>A reference to this instance after the append operation has completed.</returns> public MarkdownBuilder AppendMentionToPerson(string personIdOrEmail, string name, PersonIdType personIdType = PersonIdType.Detect) { personIdType = TeamsAPIClient.DetectPersonIdType(personIdOrEmail, personIdType); switch (personIdType) { case PersonIdType.Email: this.markdown.AppendFormat("<@personEmail:{0}|{1}>", encodeHtml(personIdOrEmail), encodeHtml(name)); break; default: this.markdown.AppendFormat("<@personId:{0}|{1}>", encodeHtml(personIdOrEmail), encodeHtml(name)); break; } return(this); }
public static async Task Init(TestContext testContext) { byte[] encryptedInfo; byte[] entropy; Person me = null; try { string userDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); var dirInfo = new DirectoryInfo(String.Format("{0}{1}.thrzn41{1}unittest{1}teams", userDir, Path.DirectorySeparatorChar)); using (var stream = new FileStream(String.Format("{0}{1}teamsinfo.dat", dirInfo.FullName, Path.DirectorySeparatorChar), FileMode.Open, FileAccess.Read, FileShare.Read)) using (var memory = new MemoryStream()) { stream.CopyTo(memory); encryptedInfo = memory.ToArray(); } using (var stream = new FileStream(String.Format("{0}{1}infoentropy.dat", dirInfo.FullName, Path.DirectorySeparatorChar), FileMode.Open, FileAccess.Read, FileShare.Read)) using (var memory = new MemoryStream()) { stream.CopyTo(memory); entropy = memory.ToArray(); } var info = TeamsObject.FromJsonString <TeamsInfo>(LocalProtectedString.FromEncryptedData(encryptedInfo, entropy).DecryptToString()); teams = TeamsAPI.CreateVersion1Client(info.APIToken); var rMe = await teams.GetMeAsync(); if (rMe.IsSuccessStatus) { me = rMe.Data; } } catch (DirectoryNotFoundException) { } catch (FileNotFoundException) { } checkTeamsAPIClient(me); }
public static async Task <Space> FindSampleSpaceAsync(TeamsAPIClient teams) { Space space = null; var e = (await teams.ListSpacesAsync(type: SpaceType.Group)).GetListResultEnumerator(); while (await e.MoveNextAsync()) { var r = e.CurrentResult; if (r.IsSuccessStatus && r.Data.HasItems) { foreach (var item in r.Data.Items) { if (item.Title.EndsWith("#WebexTeamsAPIClientV1SamplesSpace")) { space = item; break; } } } if (space != null) { // Sample space is found. break; } } if (space == null) { ShowMessage("Sample space is not found. You must run 'S0010SetupSamples' to setup the samples first."); } return(space); }
public static async Task Init(TestContext testContext) { byte[] encryptedInfo; byte[] entropy; Person me = null; try { string userDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); var dirInfo = new DirectoryInfo(String.Format("{0}{1}.thrzn41{1}unittest{1}teams", userDir, Path.DirectorySeparatorChar)); using (var stream = new FileStream(String.Format("{0}{1}teamsintegration.dat", dirInfo.FullName, Path.DirectorySeparatorChar), FileMode.Open, FileAccess.Read, FileShare.Read)) using (var memory = new MemoryStream()) { stream.CopyTo(memory); encryptedInfo = memory.ToArray(); } using (var stream = new FileStream(String.Format("{0}{1}integrationentropy.dat", dirInfo.FullName, Path.DirectorySeparatorChar), FileMode.Open, FileAccess.Read, FileShare.Read)) using (var memory = new MemoryStream()) { stream.CopyTo(memory); entropy = memory.ToArray(); } var token = TeamsObject.FromJsonString <TeamsIntegrationInfo>(LocalProtectedString.FromEncryptedData(encryptedInfo, entropy).DecryptToString()); teams = TeamsAPI.CreateVersion1Client(token.TokenInfo, new TeamsRetryOnErrorHandler(4, TimeSpan.FromSeconds(15.0f))); var rMe = await teams.GetMeAsync(); if (rMe.IsSuccessStatus) { me = rMe.Data; var e = (await teams.ListSpacesAsync(type: SpaceType.Group, sortBy: SpaceSortBy.Created, max: 50)).GetListResultEnumerator(); while (await e.MoveNextAsync()) { var r = e.CurrentResult; if (r.IsSuccessStatus && r.Data.HasItems) { foreach (var item in r.Data.Items) { if (item.Title.Contains(UNIT_TEST_SPACE_TAG)) { unitTestSpace = item; break; } } } if (unitTestSpace != null) { break; } } } } catch (DirectoryNotFoundException) { } catch (FileNotFoundException) { } checkTeamsAPIClient(me); checkUnitTestSpace(); }
/// <summary> /// Create an event filter for mentioned people. /// </summary> /// <param name="mentionedPeople">Mentioned people to be filtered.</param> public MentionedPeopleFilter(IEnumerable <string> mentionedPeople) : base("mentionedPeople", TeamsAPIClient.BuildCommaSeparatedString(mentionedPeople)) { }