public IResponseBase Execute(IRequestParameter parameters) { var result = new Response <PowerReviewSnapshotResponse>(); try { _request = (PowerReviewSnapshotRequest)parameters; var cacheKey = string.Format(Config.PowerReview.CacheKeySnapShot, _request.ProductId); result = CacheMemory.Get <Response <PowerReviewSnapshotResponse> >(cacheKey); if (result == null || (string.IsNullOrEmpty(result.resultset.Snapshot.average_rating))) { var communicationRequest = BuildUrl(parameters); _response = Communicate(communicationRequest); result = ParseResponse(_response); if (!string.IsNullOrEmpty(result.resultset.Snapshot.average_rating)) { if (Config.PowerReview.IsCacheEnabled) { CacheMemory.SetAndExpiresMinutesAsync(cacheKey, result, Config.PowerReview.Cache_TTL_InMinutes); } } } } catch (Exception ex) { _errors.Add(ex.Handle("PowerReviewGetSnapshot.Execute", ErrorSeverity.FollowUp, ErrorType.RequestError)); } return(result); }
private Snapshot GetPwSnapShots(string productId) { var snapshotResponse = new PowerReviewSnapshotResponse(); var snapshotRequest = new PowerReviewSnapshotRequest(); var snapshot = new PowerReviewGetSnapshot(_core); snapshotRequest.ProductId = productId; return(((Response <PowerReviewSnapshotResponse>)snapshot.Execute(snapshotRequest)).resultset.Snapshot); }