public override void SetValueAfterCreate(string value, ApplicantResponse applicant, ApiHttpClient apiClient) { if (value.HasValue()) { new ApplicantHistoryPutRequest(applicant.Id, BuildHistoryParameter(value)).LoadResult(apiClient); } }
public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient) { if (value.HasValue() && IsCountryAvailable(value, apiClient)) { applicant.Country = value; } }
public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient) { if (value.HasValue()) { applicant.ReferrerAdditionalInfo = value; } }
public virtual async Task <ApiResult> PutClearTokenAsync(string identifier) { if (!Connectivity.IsConnected) { return(HandledNotConnected()); } using (var client = new ApiHttpClient()) { var requestMessage = new TokenHttpRequestMessage { Method = HttpMethod.Put, RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/identifier/", identifier, "/clear-token")) }; try { var response = await client.SendAsync(requestMessage).ConfigureAwait(false); if (!response.IsSuccessStatusCode) { return(await HandleErrorAsync(response).ConfigureAwait(false)); } return(ApiResult.Success(response.StatusCode)); } catch (WebException) { return(HandledWebException()); } } }
private void Bind(ApiHttpClient client, ServiceModel[] ms) { if (ms != null && ms.Length > 0) { var count = client.Services.Count; foreach (var item in ms) { var addrs = item.Address.Split(","); foreach (var elm in addrs) { client.Services.Add(new ApiHttpClient.Service { Name = item.Client, Address = new Uri(elm), Weight = item.Weight, }); } } // 删掉旧的 for (var i = count - 1; i >= 0; i--) { client.Services.RemoveAt(i); } } }
private bool IsCustomFieldValueValid([CanBeNull] string value, ApiHttpClient apiClient) { var customField = GetCustomField(apiClient); switch (customField.Type) { case CustomFieldResponse.CustomFieldType.TextMultiLine: case CustomFieldResponse.CustomFieldType.TextSingleLine: return(true); case CustomFieldResponse.CustomFieldType.CheckBox: return(value.IsNoE() || value.Is("X")); case CustomFieldResponse.CustomFieldType.DropdownList: return(value.IsNoE() || customField.PossibleValues.Any(x => x.Is(value))); case CustomFieldResponse.CustomFieldType.CheckboxList: return(value.IsNoE() || (value ?? "").Split(',').Select(x => x.Trim()).Where(x => x.HasValue()).All(x => customField.PossibleValues.Any(y => y.Is(x)))); case CustomFieldResponse.CustomFieldType.Date: return(value.IsNoE() || ParseDate(value) != null); default: throw new ArgumentOutOfRangeException(); } }
public virtual async Task <ApiResult> PostPasswordHintAsync(PasswordHintRequest requestObj) { if (!Connectivity.IsConnected) { return(HandledNotConnected()); } using (var client = new ApiHttpClient()) { var requestMessage = new TokenHttpRequestMessage(requestObj) { Method = HttpMethod.Post, RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/password-hint")), }; try { var response = await client.SendAsync(requestMessage).ConfigureAwait(false); if (!response.IsSuccessStatusCode) { return(await HandleErrorAsync(response).ConfigureAwait(false)); } return(ApiResult.Success(response.StatusCode)); } catch (WebException) { return(HandledWebException()); } } }
public AccountController(ApiHttpClient apiClient, CustomSettings settings, LoadJobsService jobsService, UpdateApplicantService updateApplicantService, UpdateApplicantFileService updateApplicantFileService) : base(apiClient, settings) { _updateApplicantFileService = updateApplicantFileService; _updateApplicantService = updateApplicantService; _jobsService = jobsService; }
private IEnumerable<string> GetTitles(bool beforeName, ApiHttpClient apiClient) { _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient); if (beforeName) return _mandator.TitlesBeforeName.Select(x => x.Name); return _mandator.TitlesAfterName.Select(x => x.Name); }
public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient) { if (value.HasValue()) { applicant.ClassificationReason = value; } }
static void Main(string[] args) { var exp = new BlockExplorer(); var latestBlock = exp.GetLatestBlockAsync().Result; var apiCode = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; var httpClient = new ApiHttpClient(apiCode, "http://127.0.0.1:3000"); using (ApiHelper apiHelper = new ApiHelper(apiCode: apiCode, serviceHttpClient: httpClient, serviceUrl: "http://127.0.0.1:3000/")) { var walletCreator = new Wallet.WalletCreator(httpClient); var walletCreated = walletCreator.CreateAsync("password").Result; var wallet = apiHelper.InitializeWallet(walletCreated.Identifier, "password"); var addressList = wallet.ListAddressesAsync().Result; var address = wallet.GetAddressAsync(walletCreated.Address).Result; var balance = wallet.GetBalanceAsync().Result; for (var i = 0; i < 3; i++) { var addr = wallet.NewAddressAsync("Label " + i).Result; } var addressListFinal = wallet.ListAddressesAsync().Result; } Console.ReadLine(); }
public static async Task ExecuteStinkBid() { var authenticator = new Authenticator( "F5QR8MJE-HN5LH4WJ-8X9758YH-NDLRE7NJ", "0be35048de6102dfa9927504b4099aac222636f2dd96983f9713fe0c9b93d489f38ae08d9e3e3b4b3509ef77c182f9000a4b8b21c49d8af84ad0863c6937f932"); var client = new ApiHttpClient(authenticator); var balances = await client.Wallet.GetCompleteBalances(); var btcBalance = balances["BTC"]; var availableBtc = btcBalance.Available; var stinkBid = new StinkBid { AmountInBtc = 5m, BuyPrice = 0.00000001m, CurrencyPair = "BTC_ETH", }; var allowance = Math.Min(stinkBid.AmountInBtc, availableBtc); var rate = stinkBid.BuyPrice; var purchaseAmount = Math.Round(allowance / rate, 8); var orderNumber = await client.Trading.Buy(stinkBid.CurrencyPair, rate, purchaseAmount); var isCancelled = await client.Trading.CancelOrder(stinkBid.CurrencyPair, orderNumber); Console.WriteLine(isCancelled); }
protected T GetFromAPI <T>(string apiMethodwithParameter, out bool error) where T : class { error = false; WebApiResult <T> result = null; try { ApiHttpClient <T> httpClient = new ApiHttpClient <T>(ServiceUrl, false); SetToken(httpClient); result = httpClient.GetAsync(apiMethodwithParameter).Result; if (!result.HasError) { return(result.Data); } else { error = true; Error(apiMethodwithParameter, result.ErrorMessages); } } catch (Exception ex) { _logger.Error(ex.ToString()); } return(null); }
public virtual async Task <ApiResult <TResponse> > PostAsync(TRequest requestObj) { if (!Connectivity.IsConnected) { return(HandledNotConnected <TResponse>()); } using (var client = new ApiHttpClient()) { var requestMessage = new TokenHttpRequestMessage(requestObj) { Method = HttpMethod.Post, RequestUri = new Uri(client.BaseAddress, ApiRoute), }; try { var response = await client.SendAsync(requestMessage).ConfigureAwait(false); if (!response.IsSuccessStatusCode) { return(await HandleErrorAsync <TResponse>(response).ConfigureAwait(false)); } var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false); var responseObj = JsonConvert.DeserializeObject <TResponse>(responseContent); return(ApiResult <TResponse> .Success(responseObj, response.StatusCode)); } catch (WebException) { return(HandledWebException <TResponse>()); } } }
public SyndicationController(ApiHttpClient apiClient, CustomSettings settings, LoadJobsService jobsService, UrlBuilderService urlBuilder, ReferrerService referrerService) : base(apiClient, settings) { _referrerService = referrerService; _urlBuilder = urlBuilder; _jobsService = jobsService; }
private void SetToken <S, R>(ApiHttpClient <S, R> httpClient) where S : class where R : class { if (Servicetoken != null) { httpClient.Client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Servicetoken); } }
/// <summary> /// Method for posting data when expecting a returned data also /// </summary> /// <typeparam name="T"></typeparam> /// <typeparam name="S"></typeparam> /// <param name="apiMethod"></param> /// <param name="data"></param> /// <param name="error"></param> /// <returns></returns> protected S PostToApi <T, S>(string apiMethod, T data, out bool error) where T : class where S : class { error = false; try { ApiHttpClient <T, S> httpClient = new ApiHttpClient <T, S>(ServiceUrl, false); SetToken(httpClient); WebApiResult <S> postResult = httpClient.PostAsync(apiMethod, data).Result; if (!postResult.HasError) { return(postResult.Data); } else { error = true; Error(apiMethod, postResult.ErrorMessages); return(postResult.Data); } } catch (Exception ex) { _logger.Error(ex.ToString()); } return(null); }
public override void SetValueAfterCreate(string value, ApplicantResponse applicant, ApiHttpClient apiClient) { if (IsCustomFieldAvailable(apiClient) && IsCustomFieldValueValid(value, apiClient)) { var customField = GetCustomField(apiClient); var parameter = new CustomFieldValueParameter { CustomField = customField.Name }; switch (customField.Type) { case CustomFieldResponse.CustomFieldType.TextMultiLine: case CustomFieldResponse.CustomFieldType.TextSingleLine: case CustomFieldResponse.CustomFieldType.DropdownList: parameter.Value = value; break; case CustomFieldResponse.CustomFieldType.CheckBox: parameter.Value = value.Is("X").ToString().ToLower(); break; case CustomFieldResponse.CustomFieldType.CheckboxList: parameter.Values = (value ?? "").Split(',').Select(x => x.Trim()).Where(x => x.HasValue()); break; case CustomFieldResponse.CustomFieldType.Date: var date = ParseDate(value); parameter.Value = date.HasValue ? date.Value.ToString(CultureInfo.InvariantCulture) : null; break; } new ApplicantCustomFieldPostRequest(applicant.Id, parameter).LoadResult(apiClient); } }
public virtual async Task <ApiResult <CipherHistoryResponse> > GetByRevisionDateWithHistoryAsync(DateTime since) { if (!Connectivity.IsConnected) { return(HandledNotConnected <CipherHistoryResponse>()); } using (var client = new ApiHttpClient()) { var requestMessage = new TokenHttpRequestMessage() { Method = HttpMethod.Get, RequestUri = new Uri(client.BaseAddress, string.Concat(ApiRoute, "/history", "?since=", since)), }; try { var response = await client.SendAsync(requestMessage).ConfigureAwait(false); if (!response.IsSuccessStatusCode) { return(await HandleErrorAsync <CipherHistoryResponse>(response).ConfigureAwait(false)); } var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false); var responseObj = JsonConvert.DeserializeObject <CipherHistoryResponse>(responseContent); return(ApiResult <CipherHistoryResponse> .Success(responseObj, response.StatusCode)); } catch (WebException) { return(HandledWebException <CipherHistoryResponse>()); } } }
public static async Task <ulong> ExecuteStinkBid(User user, StinkBid stinkBid) { var publicKey = user.PublicKey; var privateKey = user.PrivateKey; var authenticator = new Authenticator(publicKey, privateKey); var client = new ApiHttpClient(authenticator); var balances = await client.Wallet.GetCompleteBalances(); var btcBalance = balances["BTC"]; var availableBtc = btcBalance.Available; var allowance = Math.Min(stinkBid.AmountInBtc, availableBtc); var rate = stinkBid.BuyPrice; var purchaseAmount = Math.Round(allowance / rate, 8); var orderNumber = await client.Trading.Buy(stinkBid.CurrencyPair, rate, purchaseAmount); return(orderNumber); //var isCancelled = await client.Trading.CancelOrder(stinkBid.CurrencyPair, orderNumber); //Console.WriteLine(isCancelled); }
/// <summary> /// Generic method for getting API client request for single source /// </summary> /// <typeparam name="T"></typeparam> /// <param name="apiMethodwithParameter"></param> /// <returns></returns> protected List <T> GetManyFromAPI <T>(string apiMethodwithParameter) where T : class { WebApiResult <IEnumerable <T> > result = null; try { ApiHttpClient <T> httpClient = new ApiHttpClient <T>(ServiceUrl, false); SetToken(httpClient); result = httpClient.GetManyAsync(apiMethodwithParameter).Result; if (!result.HasError) { if (result.Data != null) { return(result.Data.ToList()); } else { return(null); } } else { Error(apiMethodwithParameter, result.ErrorMessages); } } catch (Exception ex) { _logger.Error(ex.ToString()); } return(null); }
public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient) { if (value.HasValue() && IsNationalityAvailable(value, apiClient)) { applicant.Citizenship = value; } }
private void Valid() { if (Server.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(Server)); } if (AppId.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(AppId)); } if (_client == null) { if (!AppId.IsNullOrEmpty()) { _tokenFilter = new TokenHttpFilter { UserName = AppId, Password = Secret, } } ; _client = new ApiHttpClient(Server) { Filter = _tokenFilter }; } }
public async Task Initialize() { if (status == BootupStatus.Initializing || status == BootupStatus.Initialized) { return; } status = BootupStatus.Initializing; var client = new ApiHttpClient(); var dict = await client.Public.GetTicker(); foreach (var item in dict) { var val = item.Value; var tick = new Tick { CurrencyPair = item.Key, Last = val.Last, LowestAsk = val.LowestAsk, HighestBid = val.HighestBid, PercentChange = val.PercentChange, BaseVolume = val.BaseVolume, QuoteVolume = val.Quotevolume, IsFrozen = val.IsFrozen, }; map[tick.CurrencyPair] = tick; } status = BootupStatus.Initialized; }
public async Task <IActionResult> CriarPedido(string sessionId, string numeroCartao) { var pedidoCriadoAnteriormente = await _pedidoRepository.GetPedidoPorSessionId(sessionId); if (pedidoCriadoAnteriormente != null) { return(BadRequest("Este pedido já havia sido criado anterirmente para esta sessionId")); } var carrinho = HttpContext.Session.GetObject <List <ItemCarrinho> >(sessionId); if (carrinho == null) { return(BadRequest("Carrinho não encontrado.")); } if (carrinho.Count < 1) { return(BadRequest("Carrinho não possui itens.")); } var livrosPedido = await _livrariaRespository.GetLivrosPorItensCarrinhoAsync(carrinho); var apiHttpClient = new ApiHttpClient(null, "http://localhost:62000/", _httpClient); var dadosPagamento = new DadosPagamento() { NumeroCartao = numeroCartao, Valor = livrosPedido.Sum(l => l.ValorTotal) }; var pagamentoValido = Convert.ToBoolean(await apiHttpClient.HttpClient.PostAsync("v1/private/pagamento", JsonConvert.SerializeObject(dadosPagamento))); if (pagamentoValido) { var novoPedido = new Pedido { Id = Guid.NewGuid(), SessionId = sessionId, Itens = livrosPedido, ValorTotal = livrosPedido.Sum(l => l.ValorTotal), Status = StatusPedido.EmAberto }; var sucessoInsertPedido = await _pedidoRepository.InsertPedidoAsync(novoPedido); if (sucessoInsertPedido) { return(Ok(novoPedido)); } } else { return(BadRequest("Erro ao validar o número do cartão")); } return(BadRequest("Erro ao criar novo pedido")); }
/// <summary> /// Runs the "ping" request to check if the specified API endpoint is up and running. /// </summary> /// <param name="client"></param> /// <returns></returns> private static async Task Ping(ApiHttpClient client) { using (var logger = new Logger("Pinging ... ", client)) { var result = await new PingRequest().LoadResultAsync(client); logger.Write("{0}", result); } }
public Logger(string message, ApiHttpClient client) { _client = client; if (message.HasValue()) { Console.Write(message); } }
private bool IsKnowledgeLevelAvailable(string value, ApiHttpClient apiClient) { if (value.IsNoE()) return false; _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient); return _mandator.KnowledgeLevels.Any(x => x.Is(value)); }
private bool IsDocumentTypeAvailable(ApiHttpClient apiClient) { if (SubType.IsNoE()) return false; _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient); return _mandator.ApplicantDocumentTypes.Any(x => x.Is(SubType)); }
private bool IsKnowledgeAvailable(ApiHttpClient apiClient) { if (SubType.IsNoE()) return false; _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient); return _mandator.Knowledges.Any(x => x.Is(SubType)); }
public async Task <ApplicantResponse> LinkProfileToApplicant([NotNull] ApiHttpClient apiClient, [NotNull] MandatorResponse mandatorResponse, [CanBeNull] ApplicantResponse loggedInApplicantResponse, [NotNull] IProfile profile, ThirdParty thirdParty) { if (profile == null) { throw new ArgumentNullException("profile"); } ApplicantResponse applicant; try { applicant = loggedInApplicantResponse ?? await new ApplicantGetRequest(profile.Id, thirdParty).LoadResult(apiClient); } catch { applicant = null; } //we don't have an applicant that is logged in or has a matching profile //so, lets create a new applicant if (applicant == null) { //this should never happen, because we catch this case earlier, before calling this method //this is just to make absolutely sure ;) if (await IsEmailAddressAlreadyInUse(apiClient, mandatorResponse, profile.Email)) { return(null); } bool?gender = null; if (profile.Gender == Gender.Female) { gender = false; } else if (profile.Gender == Gender.Male) { gender = true; } var parameter = new ApplicantParameter { Email = profile.Email, FirstName = profile.FirstName, LastName = profile.LastName, Gender = gender }; applicant = await new ApplicantPutRequest(parameter).LoadResult(apiClient); } //now link the profile var linkRequest = thirdParty == ThirdParty.Xing ? new LinkXingRequest(applicant.Id, profile.Id, profile.Url) : (HttpRequestMessage <ApplicantResponse>) new LinkLinkedInRequest(applicant.Id, profile.Id, profile.Url); applicant = await linkRequest.LoadResult(apiClient); return(applicant); }
public static async Task Run(ApiHttpClient client) { UserResponse user; using (var logger = new Program.Logger("Loading all users ... ", client)) { var users = await new UsersRequest().LoadResultAsync(client); logger.Write("{0} users loaded.", users.Count()); } using (var logger = new Program.Logger("Creating new user ... ", client)) { user = await new UserPutRequest(new UserCreateParameter { Email = Guid.NewGuid() + "@server.com", FirstName = "Mario", LastName = "Mustermann", IsEnabled = true, Password = "******" }).LoadResultAsync(client); logger.Write("User '{0} {1}' created.", user.FirstName, user.LastName); } using (var logger = new Program.Logger("Loading specific user ... ", client)) { user = await new UserRequest(user.Id).LoadResultAsync(client); logger.Write("User '{0} {1}' loaded.", user.FirstName, user.LastName); } using (var logger = new Program.Logger("Updating user ... ", client)) { user = await new UserPostRequest(user.Id, new UserUpdateParameter { FirstName = "Maria", IsEnabled = false, LastName = "Musterfrau" }).LoadResultAsync(client); logger.Write("User '{0} {1}' updated.", user.FirstName, user.LastName); } using (var logger = new Program.Logger("Creating user and merging it ... ", client)) { var anotherUser = await new UserPutRequest(new UserCreateParameter { Email = Guid.NewGuid() + "@server.com", Password = "******" }).LoadResultAsync(client); user = await new UserMergeAndDeleteRequest(anotherUser.Id, user.Id).LoadResultAsync(client); logger.Write("User '{0} {1}' merged into.", user.FirstName, user.LastName); } using (var logger = new Program.Logger("Deleting user ... ", client)) { user = await new UserDeleteRequest(user.Id).LoadResultAsync(client); logger.Write("User '{0} {1}' deleted.", user.FirstName, user.LastName); } }
public override bool IsColumnConfigurationValid(ApiHttpClient apiClient) { if (!IsCustomFieldAvailable(apiClient)) { Program.WriteWarning("There is no custom field '" + SubType + "'."); return(false); } return(true); }
public override bool IsColumnConfigurationValid(ApiHttpClient apiClient) { if (!IsCustomFieldAvailable(apiClient)) { Program.WriteWarning("There is no custom field '" + SubType + "'."); return false; } return true; }
public override bool IsValueValid(string value, ApiHttpClient apiClient) { if (value.HasValue() && ParseDate(value) == null) { Program.WriteWarning("The value '" + value + "' is not a valid date for column '" + Header + "'. Format '" + DateFormat + "' expected."); return(false); } return(true); }
private IEnumerable <string> GetTitles(bool beforeName, ApiHttpClient apiClient) { _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient); if (beforeName) { return(_mandator.TitlesBeforeName.Select(x => x.Name)); } return(_mandator.TitlesAfterName.Select(x => x.Name)); }
/// <summary>指定服务端地址来实例化跟踪器</summary> /// <param name="server"></param> public StarTracer(String server) : this() { var http = new ApiHttpClient(server) { Tracer = this }; Client = http; }
public override bool IsValueValid(string value, ApiHttpClient apiClient) { if (value != null && value.HasValue() && !Regex.IsMatch(value, @"[-0-9a-zA-Z.+_]+@[-0-9a-zA-Z.+_]+\.[a-zA-Z]{2,4}")) { Program.WriteWarning("The value '" + value + "' is not a valid e-mail address."); return(false); } return(true); }
public override bool IsValueValid(string value, ApiHttpClient apiClient) { if (value.HasValue() && !IsRegionAvailable(value, apiClient)) { Program.WriteWarning("There is no region '" + value + "'."); return false; } return true; }
public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient) { if (value.HasValue() && IsJobProfileAvailable(value, apiClient)) { var jobProfiles = (applicant.JobProfiles ?? new List<string>()).ToList(); jobProfiles.Add(value); applicant.JobProfiles = jobProfiles; } }
public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient) { if (value.HasValue()) { var date = ParseDate(value); if (date != null) applicant.BirthDate = date.Value; } }
public override bool IsValueValid(string value, ApiHttpClient apiClient) { if (value.HasValue() && !IsRegionAvailable(value, apiClient)) { Program.WriteWarning("There is no region '" + value + "'."); return(false); } return(true); }
private static async Task <JObject> GetOffice365Detail(Token token) { ApiHttpClient <JObject> client = new ApiHttpClient <JObject>(Settings.GraphApiDiscoveryPath, false); client.Client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(token.token_type, token.access_token); var result = await client.GetAsync(""); return(result.Data); }
public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient) { if (value.HasValue() && IsRegionAvailable(value, apiClient)) { var regions = (applicant.Regions ?? new List<string>()).ToList(); regions.Add(value); applicant.Regions = regions; } }
public override bool IsValueValid(string value, ApiHttpClient apiClient) { if (value.HasValue() && ParseDate(value) == null) { Program.WriteWarning("The value '" + value + "' is not a valid date for column '" + Header + "'. Format '" + DateFormat + "' expected."); return false; } return true; }
public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient) { if (value.HasValue()) { var date = ParseDate(value); if (date != null) applicant.EarliestPossibleBeginDate = new FlexDate(date.Value); } }
public override bool IsValueValid(string value, ApiHttpClient apiClient) { if (value != null && value.HasValue() && !Regex.IsMatch(value, @"[-0-9a-zA-Z.+_]+@[-0-9a-zA-Z.+_]+\.[a-zA-Z]{2,4}")) { Program.WriteWarning("The value '" + value + "' is not a valid e-mail address."); return false; } return true; }
public async void SlaveTest() { var client = new ApiHttpClient("http://127.0.0.1:10000,http://127.0.0.1:20000," + _Address); var ac = client as IApiClient; var infs = await ac.InvokeAsync <IDictionary <String, Object> >("api/info"); Assert.NotNull(infs); }
public override bool IsValueValid(string value, ApiHttpClient apiClient) { if (value != null && value.HasValue() && !File.Exists(value) && !Directory.Exists(value)) { Program.WriteWarning("The file or directory '" + value + "' in column '" + Header + "' does not exist or is not accessible."); return false; } return true; }
public override bool IsValueValid(string value, ApiHttpClient apiClient) { if (IsCustomFieldAvailable(apiClient) && !IsCustomFieldValueValid(value, apiClient)) { Program.WriteWarning("'" + value + "' is not a valid value for '" + Header + "'."); return false; } return true; }
public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient) { if (value.HasValue()) { if (IsTitleAfterNameAvailable(value, apiClient)) applicant.TitleAfterName = value; else if (IsTitleBeforeNameAvailable(value, apiClient)) applicant.TitleBeforeName = value; } }
public override void SetValueAfterCreate(string value, ApplicantResponse applicant, ApiHttpClient apiClient) { if (IsKnowledgeAvailable(apiClient) && IsKnowledgeLevelAvailable(value, apiClient)) { new ApplicantKnowledgePutRequest(applicant.Id, new ApplicantKnowledgeParameter { Knowledge = SubType, Level = value }).LoadResult(apiClient); } }
public override void SetValueAfterCreate(string value, ApplicantResponse applicant, ApiHttpClient apiClient) { if (value.HasValue() && File.Exists(value)) { var bytes = File.ReadAllBytes(value); new ApplicantCvPutRequest(applicant.Id, new ApplicantCvParameter { Content = bytes, FileExtension = Path.GetExtension(value) }).LoadResult(apiClient); } }
public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient) { if (value.HasValue()) { var gender = Gender.Unknown; if (_maleValues.Any(x => x.Is(value))) gender = Gender.Male; else if (_femaleValues.Any(x => x.Is(value))) gender = Gender.Female; applicant.Gender = gender; } }
public static ApiHttpClient GetClient(Configuration config) { var client = new ApiHttpClient(new Uri(config.Api.Endpoint), () => new ApiTokenParameter { ClientInfo = "eRecruiter.ApplicantImport", Key = config.Api.Key, MandatorId = config.Api.MandatorId }, () => TokenCache); return client; }
private void SetFile(string filePath, ApplicantResponse applicant, ApiHttpClient apiClient) { var bytes = File.ReadAllBytes(filePath); new ApplicantDocumentPutRequest(applicant.Id, new ApplicantDocumentParameter { Content = bytes, Name = Path.GetFileName(filePath), FileExtension = Path.GetExtension(filePath), Type = SubType, IsPublic = false }).LoadResult(apiClient); }
public override void SetValueAfterCreate(string value, ApplicantResponse applicant, ApiHttpClient apiClient) { if (value != null && value.HasValue() && IsDocumentTypeAvailable(apiClient)) { if (File.Exists(value)) { SetFile(value, applicant, apiClient); } else if (Directory.Exists(value)) { foreach (var file in Directory.GetFiles(value)) SetFile(file, applicant, apiClient); } } }
public override bool IsColumnConfigurationValid(ApiHttpClient apiClient) { if (SubType.IsNoE()) { Program.WriteWarning("No subtype specified for column '" + Header + "'."); return false; } if (!IsKnowledgeAvailable(apiClient)) { Program.WriteWarning("There is no knowledge '" + SubType + "'."); return false; } return true; }
public override bool IsValueValid(string value, ApiHttpClient apiClient) { if (value.HasValue() && !File.Exists(value)) { Program.WriteWarning("The file '" + value + "' in column '" + Header + "' does not exist or is not accessible."); return false; } var extension = (Path.GetExtension(value) ?? "").Trim('.').ToLowerInvariant(); var allowedExtensions = new[] { "doc", "docx", "pdf", "txt", "rtf", "odt", "xls", "xlsx" }; if (allowedExtensions.All(x => x != extension)) { Program.WriteWarning("The file '" + value + "' in column '" + Header + "' does not have a valid file extension for a CV."); return false; } return true; }
public override bool IsValueValid(string value, ApiHttpClient apiClient) { if (value.HasValue()) { if (!value.IsInt()) { Program.WriteWarning("'" + value + "' is not a valid applicant #."); return false; } try { new ApplicantGetRequest(value.GetInt()).LoadResult(apiClient); return true; } catch { Program.WriteWarning("Applicant '#" + value + "' not found."); return false; } } return true; }