static async Task Main(string[] args) { if (string.IsNullOrEmpty(apiKey) && args.Length < 1) { Console.WriteLine("No API key provided"); Console.WriteLine("Apikey can be provided as parameter or in code"); //coment return; } if (string.IsNullOrEmpty(apiKey)) { apiKey = args[0]; } //Changing end point : by default https://betabeeye.azurewebsites.net //TEST Server //WebApi.Proxies.Configuration.MyWebApiProxyBaseAddress = "https://eu.mybeeye.com"; // Server Europe //WebApi.Proxies.Configuration.MyWebApiProxyBaseAddress = "https://app.mybeeye.com"; // Server Canada WebApi.Proxies.Configuration.MyWebApiProxyBaseAddress = "https://betabeeye.azurewebsites.net"; using (var beeyeLoginApi = new LoginClient(handler, false)) using (var rhApi = new EmployesClient(handler, false)) { DemoSynchronousCalls(beeyeLoginApi, rhApi); await DemoAsyncCalls(beeyeLoginApi, rhApi); } if (handler != null) { handler.Dispose(); } }
static void DemoSynchronousCalls(LoginClient login, EmployesClient rh) { Console.WriteLine("Synchronous calls demo"); //Example of Sync conde //Call Login api. This call will also set up necessary cookie UpdateResultWithId loginResult = login.ApiLogin(apiKey); if (!CheckLogin(loginResult)) { return; } //getting list of actives (not deleted) users var employyes = rh.GetAllRessources(true); PrintUsers(employyes); //logining out. This is for demo purpose only _ = login.LogOut(); }
static async Task DemoAsyncCalls(LoginClient login, EmployesClient rh) { Console.WriteLine(Environment.NewLine + "Async calls demo"); //getting http response //Call Login api. This call will also set up necessary cookie var loginResponse = await login.ApiLoginAsync(apiKey); //Converting response into object. var loginResult = await loginResponse.Content.ReadAsAsync <UpdateResultWithId>(); if (!CheckLogin(loginResult)) { return; } //getting list of actives (not deleted) users var employeesResponse = await rh.GetAllRessourcesAsync(true); var employyes = await employeesResponse.Content.ReadAsAsync <IEnumerable <EmployeJS__> >(); PrintUsers(employyes); _ = login.LogOut(); }