public static AdvertiseResult CollateResults(string jobReference, AdvertiseActionType actionType, List<AdvertiseResult> results) { var errors = new List<Error>(); var warnings = new List<Warning>(); foreach (var result in results) { errors.AddRange(result.Errors); warnings.AddRange(result.Warnings); } return new AdvertiseResult { JobReference = jobReference, ActionType = actionType, Errors = errors, Warnings = warnings, Message = BuildMessage(errors, warnings), ProviderName = Constants.ProviderName, Status = errors.Count >= results.Count ? AdvertiseResultStatus.Error : warnings.Any() ? AdvertiseResultStatus.Warning : AdvertiseResultStatus.Success }; }
public static AdvertiseResult BuildResultFromRmResponse(AdvertiseActionType actionType, RmrtdfResponseSendProperty response) { if (response == null) { return BuildNoResponseResult(actionType); } response.clean();//Ensure there are no null Ienumerables else the next statement will error return new AdvertiseResult { ActionType = actionType, Errors = ErrorFactory.Build(response.errors.Select(e => e.toString(response.property.agent_ref)).ToList()), Warnings = WarningFactory.Build(response.warnings.Select(e => e.toString(response.property.agent_ref)).ToList()), Message = response.message, ProviderName = Constants.ProviderName, Status = !response.success ? AdvertiseResultStatus.Error : response.warnings.Any() ? AdvertiseResultStatus.Warning : AdvertiseResultStatus.Success }; }
public static AdvertiseResult BuildNoResponseResult(AdvertiseActionType actionType) { return new AdvertiseResult { ActionType = actionType, Errors = new List<Error> {ErrorFactory.BuildNoResponseError()}, Message = "No Response from Provider", ProviderName = Constants.ProviderName, Status = AdvertiseResultStatus.Error }; }
public static AdvertiseResult BuildNoResponseResult(string jobReference, AdvertiseActionType actionType, string exception) { return new AdvertiseResult { JobReference = jobReference, ActionType = actionType, Errors = new List<Error> { ErrorFactory.BuildNoResponseError() }, Message = exception, ProviderName = Constants.ProviderName, Status = AdvertiseResultStatus.Error }; }
public static AdvertiseResult BuildSuccessResult(string jobReference, AdvertiseActionType actionType) { return new AdvertiseResult { JobReference = jobReference, ActionType = actionType, Errors = new List<Error>(), Message = "Successfully Uploaded - No other info provided", ProviderName = Constants.ProviderName, Status = AdvertiseResultStatus.Success, Warnings = new List<Warning> ()/*{ "This is a test Upload data is not live"}*/ }; }
public static string ParseAutoAdvertiseActionType(AdvertiseActionType autoAdvertiseActionType) { switch (autoAdvertiseActionType) { case AdvertiseActionType.Unknown: return "Unknown"; case AdvertiseActionType.AdvertiseSingle: return "Advertise Single"; case AdvertiseActionType.AdvertiseAll: return "Advertise All"; default: return string.Empty; } }
public static AdvertiseResult BuildResultFromZooplaResponse(AdvertiseActionType actionType, ZrtdfResponseSendListing response) { if (response == null) { return BuildNoResponseResult(actionType); } var result = new AdvertiseResult { ActionType = actionType, Errors = ErrorFactory.Build(response.errors), Warnings = new List<Warning>(), Message = response.status, ProviderName = Constants.ProviderName, Status = response.status.Equals("OK", StringComparison.InvariantCulture) ? AdvertiseResultStatus.Success : AdvertiseResultStatus.Error }; return result; }
private static AdvertiseResult SendAutoAdvertiseRequestToRightmove(object requestObject, string endpoint, AdvertiseActionType actionType) { var response = ExecuteRightmoveRequest(requestObject, endpoint); var rmResponse = JsonConvert.DeserializeObject<RmrtdfResponseSendProperty>(response.Content); return AutoAdvertiseResultFactory.BuildResultFromRmResponse(actionType, rmResponse); }
private static AdvertiseResult SendAutoAdvertiseRequestToZoopla(object requestObject, string endpoint, AdvertiseActionType actionType) { var response = ExecuteZooplaRequest(requestObject, endpoint); var zResponse = JsonConvert.DeserializeObject<ZrtdfResponseSendListing>(response.Content); return AutoAdvertiseResultFactory.BuildResultFromZooplaResponse(actionType, zResponse); }
public static AdvertiseResult BuildNoResponseResult(string jobReference, AdvertiseActionType actionType) { return BuildNoResponseResult(jobReference, actionType, "No Response From 3rd Party"); }