/// <summary> /// Posts the claim. /// </summary> /// <returns>The claim.</returns> /// <param name="claim">Claim.</param> public async Task <string> PostClaim(ClaimInputs claim) { if (claim == null) { throw new ArgumentNullException(nameof(claim), "Cannot be null"); } Console.WriteLine("[{0}] : Creating the claim # : [ {1} ] : with taskID : [ {2} ] ", ApiHelpers.GetCurrentTimeStamp(DateTime.Now), claim.claimNumber, claim.taskId); string serializedClaim = JsonConvert.SerializeObject(claim, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); var requestBody = new StringContent(serializedClaim, Encoding.UTF8, "application/json"); string accessToken = InMemoryStorage.Instance().StoredDriverToken; var httpClient = new HttpClient(); var requestMessage = new HttpRequestMessage { RequestUri = new Uri($"{_mbeUrl}api/claims?access_token={accessToken}"), Method = HttpMethod.Post, Content = requestBody }; requestMessage.Headers.Add("correlation_id", ApiHelpers.GetRandomString()); HttpResponseMessage responseMessage = await httpClient.SendAsync(requestMessage); if (_errorStatus.Contains(responseMessage.ReasonPhrase, StringComparer.OrdinalIgnoreCase)) { await InMemoryStorage.Instance().FetchDriverToken(_mbeUrl); return(await PostClaim(claim)); } if (responseMessage.StatusCode != HttpStatusCode.OK && responseMessage.StatusCode != HttpStatusCode.Created) { return(string.Empty); } return(await responseMessage.Content.ReadAsStringAsync()); }
public async Task <PaymentResponseModel> PostPremium(PremiumRequestModel model) { var user = await _userService.GetUserByPrincipalAsync(User); if (user == null) { throw new UnauthorizedAccessException(); } var valid = model.Validate(_globalSettings); UserLicense license = null; if (valid && _globalSettings.SelfHosted) { license = await ApiHelpers.ReadJsonFileFromBody <UserLicense>(HttpContext, model.License); } if (!valid && !_globalSettings.SelfHosted && string.IsNullOrWhiteSpace(model.Country)) { throw new BadRequestException("Country is required."); } if (!valid || (_globalSettings.SelfHosted && license == null)) { throw new BadRequestException("Invalid license."); } var result = await _userService.SignUpPremiumAsync(user, model.PaymentToken, model.PaymentMethodType.Value, model.AdditionalStorageGb.GetValueOrDefault(0), license, new TaxInfo { BillingAddressCountry = model.Country, BillingAddressPostalCode = model.PostalCode, }); var profile = new ProfileResponseModel(user, null, await _userService.TwoFactorIsEnabledAsync(user)); return(new PaymentResponseModel { UserProfile = profile, PaymentIntentClientSecret = result.Item2, Success = result.Item1 }); }
public async Task <CreateContactResponse> CreateContactAsync(CreateContactRequest createContactRequest) { if (createContactRequest == null) { throw new ArgumentNullException(nameof(createContactRequest), $"{nameof(createContactRequest)} can not be null."); } if (createContactRequest.FirstName == null) { throw new ArgumentNullException(nameof(createContactRequest), $"{nameof(createContactRequest.FirstName)} can not be null."); } if (createContactRequest.LastName == null) { throw new ArgumentNullException(nameof(createContactRequest), $"{nameof(createContactRequest.LastName)} can not be null."); } var requestRoute = ContactApiEndpoints.Base.Create(); var requestString = JsonConvert.SerializeObject(createContactRequest, this.jsonSerializerSettings); var requestContent = ApiHelpers.GetStringContent(requestString); var response = await this.httpClient.PostAsync(requestRoute, requestContent); if (!response.IsSuccessStatusCode) { throw new FactroApiException( "Could not create contact.", response.RequestMessage.RequestUri.ToString(), response.StatusCode, response.Content == null ? null : await response.Content.ReadAsStringAsync()); } var responseContentString = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <CreateContactResponse>( responseContentString, this.jsonSerializerSettings); return(result); }
public async Task <CreateProjectCommentResponse> CreateProjectCommentAsync(string projectId, CreateProjectCommentRequest createProjectCommentRequest) { if (string.IsNullOrWhiteSpace(projectId)) { throw new ArgumentNullException(nameof(projectId), $"{nameof(projectId)} can not be null, empty or whitespace."); } if (createProjectCommentRequest == null) { throw new ArgumentNullException(nameof(createProjectCommentRequest), $"{nameof(createProjectCommentRequest)} can not be null."); } if (createProjectCommentRequest.Text == null) { throw new ArgumentNullException(nameof(createProjectCommentRequest), $"{nameof(createProjectCommentRequest.Text)} can not be null."); } var requestRoute = ProjectApiEndpoints.Comment.Create(projectId); var requestString = JsonConvert.SerializeObject(createProjectCommentRequest, this.jsonSerializerSettings); var requestContent = ApiHelpers.GetStringContent(requestString); var response = await this.httpClient.PostAsync(requestRoute, requestContent); if (!response.IsSuccessStatusCode) { throw new FactroApiException( $"Could not create comment in project with id '{projectId}'.", response.RequestMessage.RequestUri.ToString(), response.StatusCode, response.Content == null ? null : await response.Content.ReadAsStringAsync()); } var responseContentString = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <CreateProjectCommentResponse>( responseContentString, this.jsonSerializerSettings); return(result); }
public async Task <OrganizationResponseModel> PostLicense(OrganizationCreateLicenseRequestModel model) { var user = await _userService.GetUserByPrincipalAsync(User); if (user == null) { throw new UnauthorizedAccessException(); } var license = await ApiHelpers.ReadJsonFileFromBody <OrganizationLicense>(HttpContext, model.License); if (license == null) { throw new BadRequestException("Invalid license"); } var result = await _organizationService.SignUpAsync(license, user, model.Key, model.CollectionName); return(new OrganizationResponseModel(result.Item1)); }
public override void RequestModify(HttpRequestMessage request, CancellationToken cancellationToken) { var headers = request.Headers; var prevData = ApiHelpers.DecodeUrlEncodedBody(request.Content.ReadAsStringAsync().Result).ToList(); var postData = new List <KeyValuePair <string, string> >(); postData.Add(new KeyValuePair <string, string>("nonce", GetNonce().ToString())); postData.AddRange(prevData); var bodyDataEnc = postData.Select(x => $"{x.Key}={x.Value}").ToArray(); var message = string.Join("&", bodyDataEnc); var sign = HashHMACSHA512Hex(message, ApiKey.Secret); request.Content = new FormUrlEncodedContent(postData); headers.Add("KEY", ApiKey.Key); headers.Add("Sign", sign); }
/// <summary> /// This method abstracts the orchestration to add a comment to a given claim. /// </summary> /// <returns>The claim comments.</returns> /// <param name="claimId">Represents the claim id.</param> /// <param name="claimNumber">Represents the claim number.</param> /// <param name="orgId">Represents the organization id.</param> /// <param name="comments">Represents the comments text.</param> public async Task <HttpResponseMessage> SubmitClaimComments(string claimId, string claimNumber, string orgId, string comments) { if (string.IsNullOrEmpty(claimId) || claimId.Trim().Length == 0) { throw new ArgumentNullException(nameof(claimId), NullEmptyArgumentMessage); } if (string.IsNullOrEmpty(claimNumber) || claimNumber.Trim().Length == 0) { throw new ArgumentNullException(nameof(claimNumber), NullEmptyArgumentMessage); } if (string.IsNullOrEmpty(orgId) || orgId.Trim().Length == 0) { throw new ArgumentNullException(nameof(orgId), NullEmptyArgumentMessage); } if (string.IsNullOrEmpty(comments) || comments.Trim().Length == 0) { throw new ArgumentNullException(nameof(comments), NullEmptyArgumentMessage); } string resourceUrl = $"{_mbeUrl}api/claims/{claimId}/attachmentcomments?access_token={InMemoryStorage.Instance().StoredToken}"; Console.WriteLine($"[ {ApiHelpers.GetCurrentTimeStamp(DateTime.Now)} ] : POST ATTACHMENT COMMENT BY ID : " + $"{claimId} - Resource URL [ {resourceUrl} ]"); var httpClient = new HttpClient(); var attComment = new { comments, claimNumber, orgId, synched = false }; var requestBody = new StringContent(JsonConvert.SerializeObject(attComment), Encoding.UTF8, "application/json"); HttpResponseMessage responseMessage = await httpClient.PostAsync(resourceUrl, requestBody); return(responseMessage); }
public void UserSor_Create_User() { var user = new UserGenerator(); try { user.CreateInDatabase(); _test.Log(LogStatus.Info, $"Created user: {user.Id} - {user.UserName}"); // wait a few seconds for the data to be sent Thread.Sleep(TimeSpan.FromSeconds(WaitTime)); var userSyncData = ApiHelpers.GetProductAccessUser($"{TestEnvironment.DefaultUserType}", new IdCreator(TestEnvironment.ClientCode, (int)user.Id, user.UserName).ToString()); Assert.IsTrue(String.IsNullOrWhiteSpace(userSyncData["Flid"].ToString()), "The Flid is not null"); _test.Log(LogStatus.Pass, "The Flid is null"); Assert.AreEqual(user.FirstName, userSyncData["FirstName"], "First name does not match"); _test.Log(LogStatus.Pass, "The first names match"); Assert.AreEqual(user.LastName, userSyncData["LastName"], "Last name does not match"); _test.Log(LogStatus.Pass, "The last names match"); Assert.AreEqual(user.Email, userSyncData["Email"], "Email does not match"); _test.Log(LogStatus.Pass, "The emails match"); Assert.IsTrue(String.IsNullOrWhiteSpace(userSyncData["ExternalId"].ToString()), "ExternalId is not null"); _test.Log(LogStatus.Pass, "The external ID is null"); user.DeleteFromDatabase(); } catch (Exception e) { ReportException(e); throw; } }
public async Task <object> SubmitAssignment([FromBody] ClaimInputs claimData) { try { Console.WriteLine("[{0}] submitAssignment : Creating the claim : [{1}] for task Id : [{2}]", ApiHelpers.GetCurrentTimeStamp(DateTime.Now), claimData.claimNumber, claimData.taskId); if (claimData == null) { throw new ArgumentNullException(nameof(claimData), "Cannot be null"); } ValidationResults validationResult = _claimValidators.ValidateClaim(claimData); if (!validationResult.ValidationsPassed) { return(StatusCode((int)HttpStatusCode.BadRequest, validationResult)); } string createdClaim = await _mbe.PostClaim(claimData); if (string.IsNullOrEmpty(createdClaim)) { return(StatusCode((int)HttpStatusCode.InternalServerError, new { message = "The MBE core was not able to process the request." })); } var claimPutDataObj = JsonConvert.DeserializeObject <ClaimInputs>(createdClaim); ClaimOutputs claimPutOutput = ApiHelpers.ConvertClaimData(claimPutDataObj); return(StatusCode((int)HttpStatusCode.Created, claimPutOutput)); } catch (Exception exc) { Console.WriteLine($"[ {ApiHelpers.GetCurrentTimeStamp(DateTime.Now)} ] : PostClaim : Error while posting a new claim. Error message: {exc.Message}"); return(StatusCode((int)HttpStatusCode.InternalServerError, exc)); } }
/// <summary> /// This method updates an existing claim. /// </summary> /// <param name="id">Represents the claim identifier.</param> /// <param name="data">Represents the claim data.</param> /// <returns>The recently created claim serialized.</returns> public async Task <string> UpdateClaim(string id, object data) { if (string.IsNullOrEmpty(id)) { throw new ArgumentNullException(nameof(id), "Cannot be null or emtpy."); } if (data == null) { throw new ArgumentNullException(nameof(data), "Cannot be null."); } string jsonData = JsonConvert.SerializeObject(data); var jsonContent = new StringContent(jsonData, Encoding.UTF8, "application/json"); HttpResponseMessage claimPutResponse = await PutClaimToMbe(id, jsonContent); Console.WriteLine("[ {0} ] : UPDATE CLAIM : Received response from MBE with reason phrase as : [ {1} ]", ApiHelpers.GetCurrentTimeStamp(DateTime.Now), claimPutResponse.ReasonPhrase); if (_errorStatus.Contains(claimPutResponse.ReasonPhrase, StringComparer.OrdinalIgnoreCase)) { await InMemoryStorage.Instance().FetchAccessToken(_mbeUrl); claimPutResponse = await PutClaimToMbe(id, jsonContent); } if (claimPutResponse.ReasonPhrase == "Not Found") { return(null); } string claimPutResult = await claimPutResponse.Content.ReadAsStringAsync(); Console.WriteLine("[ {0} ] : UPDATE CLAIM : Received response from MBE with updated claim as : [ {1} ]", ApiHelpers.GetCurrentTimeStamp(DateTime.Now), claimPutResult); return(claimPutResult); }
public void OnActionExecuting(ActionExecutingContext filterContext) { if (!filterContext.ModelState.IsValid) { if (filterContext.HttpContext.Request.Method == "GET") { var result = new BadRequestResult(); filterContext.Result = result; } else { var result = new ContentResult() { Content = ApiHelpers.JsonSerialize(new ApiError(filterContext.ModelState)), ContentType = "application/json" }; filterContext.HttpContext.Response.StatusCode = 400; filterContext.Result = result; } } }
public void UserSor_Update_User() { var user = new UserGenerator(); var userDataAccessor = new UserDataAccessor(); try { user.CreateInDatabase(); _test.Log(LogStatus.Info, $"Created user: {user.Id} - {user.UserName}"); var createdUser = userDataAccessor.GetUser(user.Id); createdUser.FullName = "Newfirst Newlast"; createdUser.Email = "*****@*****.**"; userDataAccessor.UpdateUser(createdUser); // wait a few seconds for the data to be sent Thread.Sleep(TimeSpan.FromSeconds(WaitTime)); var userSyncData = ApiHelpers.GetProductAccessUser($"{TestEnvironment.DefaultUserType}", new IdCreator(TestEnvironment.ClientCode, (int)user.Id, user.UserName).ToString()); Assert.AreEqual(createdUser.FirstName, userSyncData["FirstName"], "First name does not match"); _test.Log(LogStatus.Pass, "The changed first name matches"); Assert.AreEqual(createdUser.LastName, userSyncData["LastName"], "Last name does not match"); _test.Log(LogStatus.Pass, "The changed last name matches"); Assert.AreEqual(createdUser.Email, userSyncData["Email"], "Email does not match"); _test.Log(LogStatus.Pass, "The changed email matches"); user.DeleteFromDatabase(); } catch (Exception e) { ReportException(e); throw; } }
public async Task MovePackageIntoProjectAsync(string projectId, string packageId, SetProjectAssociationRequest setProjectAssociationRequest) { if (string.IsNullOrWhiteSpace(projectId)) { throw new ArgumentNullException(nameof(projectId), $"{nameof(projectId)} can not be null, empty or whitespace."); } if (string.IsNullOrWhiteSpace(packageId)) { throw new ArgumentNullException(nameof(packageId), $"{nameof(packageId)} can not be null, empty or whitespace."); } if (setProjectAssociationRequest == null) { throw new ArgumentNullException(nameof(setProjectAssociationRequest), $"{nameof(setProjectAssociationRequest)} can not be null."); } if (string.IsNullOrWhiteSpace(setProjectAssociationRequest.ProjectId)) { throw new ArgumentNullException(nameof(setProjectAssociationRequest), $"{nameof(setProjectAssociationRequest.ProjectId)} can not be null, empty or whitespace."); } var requestRoute = PackageApiEndpoints.Association.MoveIntoProject(projectId, packageId); var requestString = JsonConvert.SerializeObject(setProjectAssociationRequest, this.jsonSerializerSettings); var requestContent = ApiHelpers.GetStringContent(requestString); var response = await this.httpClient.PutAsync(requestRoute, requestContent); if (!response.IsSuccessStatusCode) { throw new FactroApiException( $"Could not move package with id '{packageId}' of project with id '{projectId}' into project with id '{setProjectAssociationRequest.ProjectId}'.", response.RequestMessage.RequestUri.ToString(), response.StatusCode, response.Content == null ? null : await response.Content.ReadAsStringAsync()); } }
/// <summary> /// Async tast to post claim claim video from MBE using GetVideoUrlForClaim() /// Uses AXN token and Generate DRIVERS token if expires /// </summary> /// <param name="photoData">Represents the photo data.</param> /// <returns>The serialized response from MBE</returns> public async Task <string> PostClaimPhoto(HttpContent photoData) { HttpResponseMessage photoUploadResponse = await PostClaimPhotoToMbe(photoData); Console.WriteLine("[ {0} ] : POST PHOTO : Response received from MBE with reason phrase as : [ {1} ] ", ApiHelpers.GetCurrentTimeStamp(DateTime.Now), photoUploadResponse.ReasonPhrase); if (_errorStatus.Contains(photoUploadResponse.ReasonPhrase, StringComparer.OrdinalIgnoreCase)) { await InMemoryStorage.Instance().FetchDriverToken(_mbeUrl); photoUploadResponse = await PostClaimPhotoToMbe(photoData); } if (photoUploadResponse.ReasonPhrase == "Not Found") { return(null); } string photoUploadResult = await photoUploadResponse.Content.ReadAsStringAsync(); return(photoUploadResult); }
private static Func <T, TRq, IDependencyResolver, Task> CreateExecuteActionFunction <TRq>(MethodInfo method) { var returnType = method.ReturnType; if (returnType == typeof(void) || returnType == typeof(Task)) { return(ApiHelpers.CreateExecuteActionFunctionVoid <TRq>(method)); } else { if (returnType.IsGenericType && returnType.GetGenericTypeDefinition() == typeof(Task <>)) { returnType = returnType.GetGenericArguments()[0]; } //public static Func<T, TRq, IDependencyResolver, Task<TReturn>> CreateExecuteActionFunction<TRq, TReturn>(MethodInfo method) var executeFunction = Expression.Constant( typeof(ApiHelpers).GetRuntimeMethodExt("CreateExecuteActionFunction", p => true).MakeGenericMethod(typeof(TRq), returnType).Invoke(null, new[] { method }), typeof(Func <, , ,>).MakeGenericType(typeof(T), typeof(TRq), typeof(IDependencyResolver), typeof(Task <>).MakeGenericType(returnType)) ); //public static Func<TRq, TReturn, IDependencyResolver> CreateWriteResultLambda<TRq, TReturn>() var sendResultFunction = Expression.Constant( typeof(ApiHelpers).GetRuntimeMethodExt("CreateWriteResultLambda", p => true).MakeGenericMethod(typeof(TRq), returnType).Invoke(null, new object[] { }), typeof(Func <, , ,>).MakeGenericType(typeof(TRq), returnType, typeof(IDependencyResolver), typeof(Task)) ); //public static async Task ExecuteActionAndSendResult<TRq, TReturn>(T controller, TRq ctx, IDependencyResolver resolver, Func<T, TRq, IDependencyResolver, Task<TReturn>> executeControllerActionFunction, Action<TRq, TReturn, IDependencyResolver> sendResultAction) var wrapperMethod = typeof(ApiHelpers).GetRuntimeMethodExt("ExecuteActionAndSendResult", p => true).MakeGenericMethod(typeof(TRq), returnType); var controller = Expression.Parameter(typeof(T), "controller"); var ctx = Expression.Parameter(typeof(TRq), "ctx"); var resolver = Expression.Parameter(typeof(IDependencyResolver), "resolver"); return(Expression.Lambda <Func <T, TRq, IDependencyResolver, Task> >(Expression.Call(wrapperMethod, controller, ctx, resolver, executeFunction, sendResultFunction), controller, ctx, resolver).Compile()); } }
public async Task <UpdateCompanyResponse> UpdateCompanyAsync(string companyId, UpdateCompanyRequest updateCompanyRequest) { if (string.IsNullOrWhiteSpace(companyId)) { throw new ArgumentNullException(nameof(companyId), $"{nameof(companyId)} can not be null, empty or whitespace."); } if (updateCompanyRequest == null) { throw new ArgumentNullException(nameof(updateCompanyRequest), $"{nameof(updateCompanyRequest)} can not be null."); } var requestRoute = CompanyApiEndpoints.Base.Update(companyId); var requestString = JsonConvert.SerializeObject(updateCompanyRequest, this.jsonSerializerSettings); var requestContent = ApiHelpers.GetStringContent(requestString); var response = await this.httpClient.PutAsync(requestRoute, requestContent); if (!response.IsSuccessStatusCode) { throw new FactroApiException( $"Could not update company with id '{companyId}'.", response.RequestMessage.RequestUri.ToString(), response.StatusCode, response.Content == null ? null : await response.Content.ReadAsStringAsync()); } var responseContentString = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <UpdateCompanyResponse>( responseContentString, this.jsonSerializerSettings); return(result); }
public async Task ShiftTasksOfPackageAsync( string projectId, string packageId, ShiftPackageWithSuccessorsRequest shiftPackageWithSuccessorsRequest) { if (string.IsNullOrWhiteSpace(projectId)) { throw new ArgumentNullException(nameof(projectId), $"{nameof(projectId)} can not be null, empty or whitespace."); } if (string.IsNullOrWhiteSpace(packageId)) { throw new ArgumentNullException(nameof(packageId), $"{nameof(packageId)} can not be null, empty or whitespace."); } if (shiftPackageWithSuccessorsRequest == null) { throw new ArgumentNullException(nameof(shiftPackageWithSuccessorsRequest), $"{nameof(shiftPackageWithSuccessorsRequest)} can not be null."); } var requestRoute = PackageApiEndpoints.ShiftTasksOfPackage.ShiftTasksWithSuccessors(projectId, packageId); var requestString = JsonConvert.SerializeObject(shiftPackageWithSuccessorsRequest, this.jsonSerializerSettings); var requestContent = ApiHelpers.GetStringContent(requestString); var response = await this.httpClient.PostAsync(requestRoute, requestContent); if (!response.IsSuccessStatusCode) { throw new FactroApiException( $"Could not shift package with id '{packageId}' of project with id '{projectId}' by '{shiftPackageWithSuccessorsRequest.DaysDelta.ToString(CultureInfo.InvariantCulture)}' days.", response.RequestMessage.RequestUri.ToString(), response.StatusCode, response.Content == null ? null : await response.Content.ReadAsStringAsync()); } }
public static Task <ApiResponse <MarketPrices> > GetPricingAsync(IPublicPricingProvider provider, PublicPricesContext context) { return(ApiHelpers.WrapExceptionAsync(() => provider.GetPricingAsync(context), nameof(GetPricing), provider, context)); }
static void Main(string[] args) { try { using (var mutex = new Mutex(true, MutexName)) { if (!mutex.WaitOne(MutexTimeout)) { MessageBox.Show(Resources.SingleInstanceMessage, Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } // install services NLog.GlobalDiagnosticsContext.Set("logDirectory", PathHelpers.GetLogPath()); Container.Install(new KFlearningModulesInstaller()); _logger = Container.Resolve <ILogger>(); // find vscode var path = Container.Resolve <IPathManager>(); if (!path.IsVscodeInstalled) { _logger.Debug("Visual Studio Code not found"); MessageBox.Show(Resources.VscodeNotInstalled, Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } // find mingw if (!path.IsKfMingwInstalled) { _logger.Debug("KF-MinGW not found"); MessageBox.Show(Resources.KfmingwNotInstalled, Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } // enable TLS _logger.Debug("Enabling TLS support"); ApiHelpers.EnableTls(); // app exit handler Application.ApplicationExit += Application_ApplicationExit; // bootstrapper _logger.Debug("Bootstrapping application"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(Container.Resolve <KFlearningApplicationContext>()); } } catch (Exception e) { _logger.Fatal("Application shutdown unexpectedly", e); MessageBox.Show("Aplikasi mengalami crash dan harus ditutup. Harap laporkan kepada asprak.", Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { NLog.LogManager.Shutdown(); } }
public static Task <ApiResponse <PublicVolumeResponse> > GetAggVolumeDataAsync(IAggVolumeDataProvider provider, AggVolumeDataContext context) { return(ApiHelpers.WrapExceptionAsync(() => provider.GetAggVolumeDataAsync(context), nameof(GetAggVolumeData), provider, context)); }
public static Task <ApiResponse <AggregatedAssetPairData> > GetCoinSnapshotAsync(ICoinSnapshotAggregationProvider provider, AssetPairDataContext context) { return(ApiHelpers.WrapExceptionAsync(() => provider.GetCoinSnapshotAsync(context), nameof(GetCoinSnapshot), provider, context)); }
public static Task <ApiResponse <List <AssetInfo> > > GetCoinInformationAsync(ICoinInformationProvider provider, NetworkProviderContext context = null) { context = context ?? new NetworkProviderContext(); return(ApiHelpers.WrapExceptionAsync(() => provider.GetCoinInformationAsync(context), nameof(GetCoinInformation), provider, context)); }
public static Task <ApiResponse <BalanceResults> > GetBalancesAsync(IBalanceProvider provider, NetworkProviderPrivateContext context) { return(ApiHelpers.WrapExceptionAsync(() => CheckedBalancesAsync(provider, context), nameof(GetBalances), provider, context)); }
public static Task <ApiResponse <TransferSuspensions> > GetTransferSuspensionsAsync(IDepositProvider provider, NetworkProviderContext context = null) { context = context ?? new NetworkProviderContext(); return(ApiHelpers.WrapExceptionAsync(() => provider.GetTransferSuspensionsAsync(context), nameof(GetTransferSuspensions), provider, context)); }
public static Task <ApiResponse <OhlcDataResponse> > GetOhlcAsync(IOhlcProvider provider, OhlcContext context) { return(ApiHelpers.WrapExceptionAsync(() => provider.GetOhlcAsync(context), nameof(GetOhlc), provider, context)); }
public static Task <ApiResponse <AssetPairs> > GetAssetPairsAsync(IAssetPairsProvider provider, NetworkProviderContext context = null) { context = context ?? new NetworkProviderContext(); return(AssetPairCache.I.TryAsync(provider, () => ApiHelpers.WrapExceptionAsync(() => provider.GetAssetPairsAsync(context), nameof(GetAssetPairs), provider, context))); }
/// <summary> /// Обновить сессию анонимного пользователя /// </summary> /// <param name="sessionKey">Ключ сессии</param> public void UpdateAnonymousSession(string sessionKey) { var request = ApiHelpers.BuildRequest(sessionKey); var result = WebHostCache.Current.GetResponse <XElement>(@"api/security/UpdateAnonymousSession", request); }
public static Task <ApiResponse <OrderBook> > GetOrderBookAsync(IOrderBookProvider provider, OrderBookContext context) { return(ApiHelpers.WrapExceptionAsync(() => provider.GetOrderBookAsync(context), nameof(GetOrderBook), provider, context)); }
/// <summary> /// Обновить метку последней активности пользователя /// </summary> /// <param name="userId">ID пользователя</param> /// <param name="sessionKey">Ключ текущей сессии</param> public void UpdateUserLastActivity(int userId, string sessionKey) { var request = ApiHelpers.BuildRequest(sessionKey, new XElement("userId", userId)); var result = WebHostCache.Current.GetResponse <XElement>(@"api\security\UpdateUserLastActivity", request); }
public static Task <ApiResponse <bool> > TestApiAsync(INetworkProviderPrivate provider, ApiPrivateTestContext context) { return(ApiHelpers.WrapExceptionAsync(() => provider.TestPrivateApiAsync(context), nameof(TestApi), provider, context)); }