public async Task <string> GetCustomerToken(CdkCustomer cdkCustomer, string roofTopId) { if (cdkCustomer == null) { throw new ArgumentNullException(nameof(cdkCustomer)); } if (roofTopId == null) { throw new ArgumentNullException(nameof(roofTopId)); } var dealerCDKConfig = _dealerCDKConfigurationDAL.GetDealerCDKConfigurations(roofTopId, cdkCustomer.CommunityId); if (dealerCDKConfig == null) { throw new DealerCDKConfigurationException(ExceptionMessages.InvalidDealerCDKConfiguration); } var customerToken = await RequestAndActivateCustomerToken(cdkCustomer, dealerCDKConfig, roofTopId, cdkCustomer.Token) ?? await RequestAndActivateCustomerToken(cdkCustomer, dealerCDKConfig, roofTopId, null); cdkCustomer.Token = new Guid(customerToken); await _cdkCustomerService.SaveCdkCustomer(cdkCustomer); return(customerToken); }
public async Task <string> RegisterCustomer(CustomerVehicleRegisterRequest customerVehicleRegisterRequest) { customerVehicleRegisterRequest.AppToken = await _tokenService.GetAppToken(customerVehicleRegisterRequest.CommunityId, customerVehicleRegisterRequest.RoofTopId); var cdkCustomer = _cdkCustomerService.MapCdkCustomer(customerVehicleRegisterRequest); // Send request to register customer on CDK auto line api var registerApiResponse = await _customerService.RegisterCustomer(customerVehicleRegisterRequest, cdkCustomer); if (registerApiResponse == null || !registerApiResponse.Success) { throw new CDKAutolineException(UtilityHelper.SerializeObject(registerApiResponse?.Errors)); } await _cdkCustomerService.SaveCdkCustomer(cdkCustomer); return($"Customer {cdkCustomer.CustomerLoginId} registered successfully"); }