static void Main(string[] args) { Console.WriteLine("Digite a chave do bot"); var key = Console.ReadLine(); Console.WriteLine("Digite o caminho do arquivo com os usuários:"); var file = Console.ReadLine(); var text = System.IO.File.ReadAllLines(file); foreach (var item in text) { var splitedText = item.Split(','); using (var client = new HttpClient()) { client.BaseAddress = new Uri("https://msging.net"); client.DefaultRequestHeaders.Add("Authorization", key); var request = new DelegationRequest() { id = EnvelopeId.NewId(), method = "set", resource = new ResourceDelegation() { envelopeTypes = new System.Collections.Generic.List <string>() { "command" }, target = $"{HttpUtility.UrlEncode(splitedText[0])}@blip.ai" }, to = "*****@*****.**", type = "application/vnd.lime.delegation+json", uri = "/delegations" }; var content = new StringContent(JsonConvert.SerializeObject(request), Encoding.Default, "application/json"); var responsePost = client.PostAsync("/commands", content).Result; var requestAdd = new AddRequest() { id = EnvelopeId.NewId(), method = "set", resource = new Resource() { identity = $"{HttpUtility.UrlEncode(splitedText[0])}@blip.ai", teams = splitedText[1].Split(';').ToList() }, to = "*****@*****.**", type = "application/vnd.iris.desk.attendant+json", uri = "/attendants" }; content = new StringContent(JsonConvert.SerializeObject(requestAdd), Encoding.Default, "application/json"); responsePost = client.PostAsync("/commands", content).Result; } } }
/// <summary> /// CTT has special test cases that checks the corner cases. /// Since we don't have an actual implementation but it is required for us to pass those tests, /// in order to test if CTT behaves as expected - we mock them. /// </summary> /// <returns></returns> private static bool IsMockedUnhappyFlowBehaviour(DelegationRequest delegationRequest) { var invalidPolicyIssuers = new[] { "EU.EORI.NLUNREGISTERED", "EU.EORI.NL100000015", "EU.EORI.NL000000003" }; if (invalidPolicyIssuers.Contains(delegationRequest.PolicyIssuer)) { return(true); } if (delegationRequest.Target.AccessSubject == "randomidentifier") { return(true); } return(false); }