public async Task CreateBusinessPartnerAddressPhone_ValidUser_ContactInfoRetrieved() { // Arrange var user = TestHelper.PaDev1; var loginResponse = await AuthClient.GetJwtToken(user.Username, "Start@123"); user.JwtEncodedString = loginResponse.Data.JwtAccessToken; user.JwtEncodedString.ShouldNotBeNullOrWhiteSpace(); var phone = user.Phones.First(p => p.Type == PhoneType.Home); var request = new CreateAddressDependantPhoneRequest { BusinessPartnerId = user.BPNumber, PhoneNumber = phone.Number, Extension = phone.Extension ?? "", IsHome = true, IsStandard = true, PhoneType = "1" }; var addressResponse = McfClient.GetStandardMailingAddress(user.JwtEncodedString, user.BPNumber); request.AddressId = addressResponse.Result.AddressID.ToString(); if (request.BusinessPartnerId == user.BPNumber) { Assert.Fail("Bypass by debugging in order to avoid posting excess rows on server"); } // Act var response = McfClient.CreateAddressDependantPhone(user.JwtEncodedString, request); // Assert response.Result.ShouldNotBeNull(); //response.Result.Metadata.Id.ShouldBe("https://10.41.53.54:8001/sap/opu/odata/sap/ZERP_UTILITIES_UMC_PSE_SRV/AccountAddressIndependentPhones(" + // $"AccountID=\'{user.BPNumber}\',SequenceNo=\'{phones.Count:D3}\')"); }
/// <summary> /// Saves the cell phone number at the BP level /// </summary> /// <param name="jwt">Java web token for authentication</param> /// <param name="phone">Customer's cell phone</param> /// <param name="bpId">Business partner ID</param> public async Task PutPhoneNumberAsync(string jwt, Phone phone, long bpId) { _logger.LogInformation($"PutEmailAddressAsync({nameof(phone)}: {phone.ToJson()}," + $"{nameof(bpId)}: {bpId})"); // Call MCF to update SAP first. If no error, then update Cassandra. McfResponse <GetPhoneResponse> response = null; McfResponse <GetAccountAddressesResponse> addressResponse = null; if (phone.Type == PhoneType.Cell) { // Prepare MCF request var mcfRequest = new CreateAddressIndependantPhoneRequest { BusinessPartnerId = bpId, PhoneNumber = phone.Number, Extension = phone.Extension ?? "", IsHome = true, IsStandard = true, PhoneType = AddressIndependantContactInfoEnum.AccountAddressIndependentMobilePhones }; // Save phone via MCF response = _mcfClient.CreateBusinessPartnerMobilePhone(jwt, mcfRequest); } else { addressResponse = _mcfClient.GetStandardMailingAddress(jwt, bpId); if (addressResponse.Error == null) { // Prepare MCF request var mcfDepRequest = new CreateAddressDependantPhoneRequest { BusinessPartnerId = bpId, AddressID = addressResponse.Result.AddressID.ToString(), PhoneNumber = phone.Number, Extension = phone.Extension ?? "", IsHome = true, IsStandard = true, PhoneType = "1" }; // Save phone via MCF response = _mcfClient.CreateAddressDependantPhone(jwt, mcfDepRequest); } } if (response?.Error != null) { _logger.LogError($"Failure saving phone number to SAP: {response.Error.ToJson()}"); throw new Exception($"Failure saving phone number to SAP: {response.Error.Message.Value}"); } if (addressResponse?.Error != null) { _logger.LogError($"Failure getting standard mail address: {addressResponse.Error.ToJson()}"); throw new Exception($"Failure getting standard mail address: {addressResponse.Error.Message.Value}"); } // This returns an empty set and the IsFullyFetched property is true. // There is apparently no way to determine if any rows were updated or not, // so unless an exception occurs, NoContent will always be returned. await _customerRepository.UpdateCustomerPhoneNumber(phone, bpId); _logger.LogInformation($"Success saving phone number to SAP: {response?.Result.ToJson()}"); }