public void Not_supported_private_key_creation() { //ARRANGE var client = PrepareClient <AppSettings>((options) => { var addressGenerator = new Mock <IAddressGenerator>(); var transactionSigner = new Mock <ITransactionSigner>(); addressGenerator.Setup(x => x.CreateAddressAsync()) .ThrowsAsync(new OperationNotSupportedException("Address creation is not supported")); options.IntegrationName = $"{nameof(SignServiceClientTests)}+{nameof(Can_create_private_key)}"; options.AddressGeneratorFactory = (context) => addressGenerator.Object; options.TransactionSignerFactory = (context) => transactionSigner.Object; }); //ACT && ASSERT var base64EncryptionKey = MyPublicKey; var request = new CreateAddressRequest(base64EncryptionKey); Assert.ThrowsAsync <NotImplementedWebApiException>(async() => { CreateAddressResponse result = await client.CreateAddressAsync(request); result?.PrivateKey?.DecryptToString(MyPrivateKey); }); }
internal virtual CreateAddressResponse CreateAddress(CreateAddressRequest request) { var marshaller = CreateAddressRequestMarshaller.Instance; var unmarshaller = CreateAddressResponseUnmarshaller.Instance; return(Invoke <CreateAddressRequest, CreateAddressResponse>(request, marshaller, unmarshaller)); }
/// <summary> /// Creates an address for a Snowball to be shipped to. /// /// /// <para> /// Addresses are validated at the time of creation. The address you provide must be located /// within the serviceable area of your region. If the address is invalid or unsupported, /// then an exception is thrown. /// </para> /// </summary> /// <param name="request">Container for the necessary parameters to execute the CreateAddress service method.</param> /// /// <returns>The response from the CreateAddress service method, as returned by Snowball.</returns> /// <exception cref="Amazon.Snowball.Model.InvalidAddressException"> /// The address provided was invalid. Check the address with your region's carrier, and /// try again. /// </exception> /// <exception cref="Amazon.Snowball.Model.UnsupportedAddressException"> /// The address is either outside the serviceable area for your region, or an error occurred. /// Check the address with your region's carrier and try again. If the issue persists, /// contact AWS Support. /// </exception> public CreateAddressResponse CreateAddress(CreateAddressRequest request) { var marshaller = new CreateAddressRequestMarshaller(); var unmarshaller = CreateAddressResponseUnmarshaller.Instance; return(Invoke <CreateAddressRequest, CreateAddressResponse>(request, marshaller, unmarshaller)); }
public BaseResponse <GetAddressResponse> CreateAddress(string customerId, CreateAddressRequest request) { var method = HttpMethod.Post; var endpoint = $"/customers/{customerId}/addresses"; return(this.HttpClientUtil.SendRequest <GetAddressResponse>(method, endpoint, request)); }
/// <summary> /// Initiates the asynchronous execution of the CreateAddress operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateAddress operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task <CreateAddressResponse> CreateAddressAsync(CreateAddressRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new CreateAddressRequestMarshaller(); var unmarshaller = CreateAddressResponseUnmarshaller.Instance; return(InvokeAsync <CreateAddressRequest, CreateAddressResponse>(request, marshaller, unmarshaller, cancellationToken)); }
/// <summary> /// Initiates the asynchronous execution of the CreateAddress operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateAddress operation on AmazonSnowballClient.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndCreateAddress /// operation.</returns> public IAsyncResult BeginCreateAddress(CreateAddressRequest request, AsyncCallback callback, object state) { var marshaller = new CreateAddressRequestMarshaller(); var unmarshaller = CreateAddressResponseUnmarshaller.Instance; return(BeginInvoke <CreateAddressRequest>(request, marshaller, unmarshaller, callback, state)); }
internal virtual CreateAddressResponse CreateAddress(CreateAddressRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = CreateAddressRequestMarshaller.Instance; options.ResponseUnmarshaller = CreateAddressResponseUnmarshaller.Instance; return(Invoke <CreateAddressResponse>(request, options)); }
/// <summary> /// Initiates the asynchronous execution of the CreateAddress operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateAddress operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/snowball-2016-06-30/CreateAddress">REST API Reference for CreateAddress Operation</seealso> public virtual Task <CreateAddressResponse> CreateAddressAsync(CreateAddressRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = CreateAddressRequestMarshaller.Instance; options.ResponseUnmarshaller = CreateAddressResponseUnmarshaller.Instance; return(InvokeAsync <CreateAddressResponse>(request, options, cancellationToken)); }
public async Task <Address> CreateAddressAsync(CreateAddressRequest createAddressRequest, long customerId) { ValidateModel(createAddressRequest); var response = await PostAsJsonAsync($"/customers/{customerId}/addresses", JsonConvert.SerializeObject(createAddressRequest)).ConfigureAwait(false); return(JsonConvert.DeserializeObject <AddressResponse>( await response.Content.ReadAsStringAsync().ConfigureAwait(false)).Address); }
public static CreateCustomerRequest ConverteNovoClienteDbEmApi(ClienteDb clienteDb) { try { var metadata = new Dictionary <string, string>(); metadata.Add("id", clienteDb.Codigo); var address = new CreateAddressRequest { Line1 = clienteDb.Endereco_1, Line2 = clienteDb.Endereco_2, ZipCode = clienteDb.Cep, City = clienteDb.Cidade, State = clienteDb.Uf, Country = "BR" }; var phones = new CreatePhonesRequest { HomePhone = new CreatePhoneRequest { AreaCode = clienteDb.Fone1.Substring(0, 2), CountryCode = "55", Number = clienteDb.Fone1.Substring(3, clienteDb.Fone1.Length - 3) }, MobilePhone = new CreatePhoneRequest { AreaCode = clienteDb.Fone2.Substring(0, 2), CountryCode = "55", Number = clienteDb.Fone2.Substring(3, clienteDb.Fone2.Length - 3) }, }; var request = new CreateCustomerRequest { Name = clienteDb.Nome, Email = clienteDb.Email, Type = "individual", Document = clienteDb.Documento, Gender = clienteDb.Sexo, Code = clienteDb.Codigo, Phones = phones, Address = address, Metadata = metadata }; return(request); } catch (Exception ex) { throw new Exception(ex.Message); } }
private Address CreateAddress(CreateAddressRequest request) { return(new Address() { Name = request.Name, DistrictId = request.DistrictId, CityId = request.CityId, CountryId = request.CountryId, Street = request.Street, PostalCode = request.PostalCode, CreatedBy = _httpContextAccessor.HttpContext.User.Identity.Name }); }
private void InsertSuiteAddress(AMCustomer.AMAddress addrDetails, SuiteContact suiteContact, string logId) { try { var suiteWrapper = new SuiteWrapper(); suitesessionId = suiteWrapper.Login().GetAwaiter().GetResult(); var addressrequest = new CreateAddressRequest(); addressrequest.Name = suiteContact.Name; addressrequest.Country = addrDetails.Country_code; addressrequest.Address1 = addrDetails.Street_address; addressrequest.City = addrDetails.Locality; addressrequest.Client_number_c = suiteContact.Client_number_c; addressrequest.State = addrDetails.Region; addressrequest.Zip = addrDetails.Postal_code; if (addrDetails.Type == "home" || addrDetails.Type == null) { addressrequest.Shipping_address = true; } if (addrDetails.Type == "billing") { addressrequest.Billing_address = true; } addressrequest.Contacts_add1_addresses_1contacts_ida = suiteContact.Id; var request = new InsertRequest(); request.SessionId = suitesessionId; request.ModuleName = "add1_Addresses"; request.Entity = addressrequest; var resp = suiteWrapper.Insert(request).GetAwaiter().GetResult(); if (resp == null) { SuiteWrapper.WriteTraceLog("InsertSuiteAddress", "Error : In updating Address for client Number"); } } catch (Exception ex) { common.InsertSuiteAmIntegrationLogDetail(new CreateTraceLogRequest() { Description = "Error : " + ex.Message, Name = "InsertSuiteAddress", Entity_c = "Registration" }, logId); SuiteWrapper.WriteTraceLog("InsertSuiteAddress", "Error : " + ex.Message); } }
/// <summary> /// Add or Edit an existing address /// </summary> /// <param name="cityId"></param> /// <param name="request"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task <Response> AddOrEditAddressAsync(int addressId, CreateAddressRequest request, CancellationToken cancellationToken = default) { var responseModel = new Response(); if (addressId != 0) { var address = await _addressRepository.FindByIdAsync(addressId); if (address != null) { address.Name = request.Name; address.CountryId = request.CountryId; address.CityId = request.CityId; address.DistrictId = request.DistrictId; address.Street = request.Street; address.PostalCode = request.PostalCode; address.LastModifiedBy = _httpContextAccessor.HttpContext.User.Identity.Name; address.LastModifiedOn = DateTime.UtcNow; await _addressRepository.UpdateAsync(address); } else { responseModel.AddError(ExceptionCreator.CreateNotFoundError(nameof(address), $"address id: {addressId} not found")); return(responseModel); } } else { if (await AddressExistsAsync(request.CountryId, request.CityId, request.DistrictId, request.Street, request.Name)) { responseModel.AddError(ExceptionCreator.CreateBadRequestError("address", "naddress name does already exist")); return(responseModel); } try { await _addressRepository.AddAsync(CreateAddress(request)); } catch (Exception ex) { responseModel.AddError(ExceptionCreator.CreateInternalServerError(ex.ToString())); } } return(responseModel); }
public override async Task <CreateAddressResponse> CreateAddressAsync(CreateAddressRequest request, ServerCallContext context) { await _addressService.CreateAddressAsync(new AddressCreateDto { Province = request.Province, City = request.City, County = request.County }); return(new CreateAddressResponse { Succeed = true, Message = "创建成功" }); }
internal static CreateAddressRequest BuildCreateAddressRequest() { var request = new CreateAddressRequest() { City = "City", Complement = "Complement", Country = "BR", Neighborhood = "Neighborhood", Number = "123", State = "RJ", Street = "Street", ZipCode = "22221010" }; return(request); }
/// <summary> /// Upserts the standard mailing address. /// </summary> /// <param name="bpId">The bp identifier.</param> /// <param name="address">The address.</param> /// <param name="jwt">The JWT.</param> /// <returns></returns> public async Task <long> UpsertStandardMailingAddressAsync(long bpId, UpdateMailingAddressModel address, string jwt) { _logger.LogInformation($"UpsertStandardMailingAddress({nameof(bpId)}: {bpId}," + $"{nameof(address)}: {address.ToJson()})"); //Format To SaP Address From Cassandra var addressFormatRequest = Mapper.Map <AddressDefinedTypeRequest>(address); var addressResponse = await _addressApi.ToMcfMailingAddressAsync(addressFormatRequest); if (addressResponse != null) { var addressInfo = addressResponse.Data; var response = _mcfClient.GetStandardMailingAddress(jwt, bpId); var addressId = response.Result?.AddressID; if (addressId != null) { var request = new UpdateAddressRequest { AccountID = bpId, AddressID = addressId.Value, AddressInfo = addressInfo }; UpdateStandardAddress(jwt, request); } else { var request = new CreateAddressRequest { AccountID = bpId, AddressInfo = addressInfo }; addressId = CreateStandardAddress(jwt, request).Result.AddressID; } return(addressId.Value); } return(default(long)); }
public async Task CreateStandardAddress_ValidUser() { //Arrange var user = TestHelper.ActivePaUser; var loginResponse = await AuthClient.GetJwtToken(user.Username, "Start@123"); user.SetJwtEncodedString(loginResponse.Data.JwtAccessToken); var request = new CreateAddressRequest { AccountID = user.BPNumber, AddressInfo = new McfAddressinfo { StandardFlag = "X", City = "Bellevue", PostalCode = "98004", POBoxPostalCode = "", POBox = "", Street = "110th Ave NE", HouseNo = "355", CountryID = "US", Region = "WA", HouseNo2 = "" } }; // Act var response = McfClient.CreateAddress(user.JwtEncodedString, request); var requestAddress = request.AddressInfo; var responsetAddress = response.Result.AddressInfo; //Assert responsetAddress.StandardFlag.ShouldBe(requestAddress.StandardFlag); responsetAddress.City.ShouldBe(requestAddress.City); responsetAddress.PostalCode.ShouldBe(requestAddress.PostalCode); responsetAddress.Street.ShouldBe(requestAddress.Street); responsetAddress.HouseNo.ShouldBe(requestAddress.HouseNo); responsetAddress.CountryID.ShouldBe(requestAddress.CountryID); responsetAddress.Region.ShouldBe(requestAddress.Region); }
public async Task <IActionResult> Create([FromBody] CreateAddressRequest createModel) { var addressEntity = _mapper.Map <Address>(createModel); var createdCustomerId = int.Parse(HttpContext.GetUserIdFromRequest()); var isCreateSuccess = await _addressService.CreateAsync(addressEntity, createdCustomerId); if (!isCreateSuccess) { return(BadRequest()); } var addressUri = _uriService.GetByIdUri( ApiRoutes.Address.GetById.Replace("{addressId}", addressEntity.Id.ToString())); var addressResponse = _mapper.Map <AddressResponse>(addressEntity); return(Created( addressUri, new Response <AddressResponse>(addressResponse))); }
public async Task <ActionResult <CreateAddressResponse> > CreateAddress(CreateAddressRequest request) { var creationResult = await _addressGenerator.CreateAddressAsync(); if (creationResult == null) { throw new InvalidOperationException("Not null creation result object expected"); } var encryptedPrivateKey = creationResult.PrivateKey.Encrypt(request.EncryptionPublicKey); var response = new CreateAddressResponse ( encryptedPrivateKey, creationResult.Address, creationResult.AddressContext ); return(Ok(response)); }
public IHttpActionResult Post( [FromUri] CreateAddressRequest request, [FromBody] WriteAddressPayload payload) { if (!ModelState.IsValid) { return(BadRequestWithErrors()); } request.Payload = payload; var result = _createProcessor.Process(request); if (result.IsSuccess) { return(Ok(result)); } return(BadRequest()); }
public async Task <IActionResult> AddAddressAsync([FromBody] CreateAddressRequest request) { var user = await _userService.GetUserAsync(User); var result = await _addressService.AddAddressAsync( user.Id.ConvertTo <UserId>(), request.CountryIsoCode.ToEnumeration <Country>(), request.Line1, request.Line2, request.City, request.State, request.PostalCode); if (result.IsValid) { return(this.Ok(_mapper.Map <AddressDto>(result.Response))); } result.AddToModelState(ModelState); return(this.BadRequest(new ValidationProblemDetails(ModelState))); }
public CreateAddressResponse SaveAddress(CreateAddressRequest addressRequest) { var createAddressResponse = new CreateAddressResponse(); var address = _messageMapper.MapToAddress(addressRequest.Address); try { _addressRepository.SaveAddress(address); var addressDto = _messageMapper.MapToAddressDto(address); createAddressResponse.Address = addressDto; createAddressResponse.Messages.Add("Successfully saved the address"); createAddressResponse.StatusCode = HttpStatusCode.Created; } catch (Exception e) { var error = e.ToString(); createAddressResponse.Messages.Add(error); createAddressResponse.StatusCode = HttpStatusCode.InternalServerError; } return(createAddressResponse); }
public async Task Can_create_private_key() { //ARRANGE var address = Guid.NewGuid().ToString(); var privateKey = Guid.NewGuid().ToString(); var addressContext = "AddressContext"; var client = PrepareClient <AppSettings>((options) => { Mock <IAddressGenerator> addressGenerator = new Mock <IAddressGenerator>(); Mock <ITransactionSigner> transactionSigner = new Mock <ITransactionSigner>(); addressGenerator.Setup(x => x.CreateAddressAsync()) .ReturnsAsync(new AddressCreationResult( address, privateKey, Base64String.Encode(addressContext))); options.IntegrationName = $"{nameof(SignServiceClientTests)}+{nameof(Can_create_private_key)}"; options.AddressGeneratorFactory = (context) => addressGenerator.Object; options.TransactionSignerFactory = (context) => transactionSigner.Object; }); //ACT var base64EncryptionKey = MyPublicKey; var request = new CreateAddressRequest(base64EncryptionKey); CreateAddressResponse result = await client.CreateAddressAsync(request); var decryptedPk = result?.PrivateKey?.DecryptToString(MyPrivateKey); //ASSERT Assert.True(result != null); Assert.True(!string.IsNullOrEmpty(result.Address.Value)); Assert.True(result.Address.Value == address); Assert.True(decryptedPk == privateKey); Assert.True(result.AddressContext?.DecodeToString() == addressContext); }
/// <summary> /// Create an address for the token specified by TokenUID. /// </summary> /// <param name="request">The request.</param> /// <returns>The response that was returned by the API.</returns> public Task <CreateAddressResponse> CreateAddressAsync(CreateAddressRequest request) { return(PostAsync <CreateAddressRequest, CreateAddressResponse>(@"create_address", request)); }
/// <summary> /// Create an address for the token specified by TokenUID. /// </summary> /// <param name="request">The request.</param> /// <returns>The response that was returned by the API.</returns> public CreateAddressResponse CreateAddress(CreateAddressRequest request) { return(Post <CreateAddressRequest, CreateAddressResponse>(@"create_address", request)); }
public async Task <ActionResult <GetCustomerAddressResponse> > CreateAddress(Guid customerId, [FromBody] CreateAddressRequest dto) { var customer = await _customerService.GetCustomerById(customerId); // validate if (customer is null) { return(NotFound(new { message = "Customer does not exist" })); } if (customer.AccountId != Account.Id && Account.Role != Role.Manager) { return(Unauthorized(new { message = "Unauthorized" })); } var customerAddress = await _customerService.CreateAddress(customerId, dto); return(CreatedAtAction("GetAddressById", new { customerId = customerAddress.Customer.Id, addressId = customerAddress.Address.Id }, customerAddress)); }
public async Task <IActionResult> AddOrEditAddressAsync([FromRoute] int addressId, [FromBody] CreateAddressRequest request, CancellationToken cancellationToken = default) { try { var apiResponse = await _addressService.AddOrEditAddressAsync(addressId, request, cancellationToken); if (apiResponse.Success) { return(Ok(apiResponse)); } else if (apiResponse.Errors[0].Code == StatusCodes.Status404NotFound) { return(NotFound(apiResponse)); } return(BadRequest(apiResponse)); } catch (Exception exception) { return(_actionResultMapper.Map(exception)); } }
// TEST /// <summary> /// Метод сохраняет адреса контрагента отправителя/получателя. /// </summary> /// <param name="properties">Свойства метода.</param> /// <returns>Ответ от API новой почты.</returns> public Task <ApiResponse <CreatedAddress> > CreateAddressAsync(CreateAddressRequest properties) { var request = _creator.CreateAddress(_config.ApiKey, properties); return(_client.RequestForResponseAsync <CreatedAddress>(request)); }
public ApiRequest CreateAddress(string apiKey, CreateAddressRequest properties) => CreateAddress(apiKey, "save", properties);
public ActionResult <CreateAddressResponse> PostAddress(CreateAddressRequest createAddressRequest) //Model binding { var createAddressResponse = _addressService.SaveAddress(createAddressRequest); return(createAddressResponse); }