public ImageOptimizationResponse ProcessImage(ImageOptimizationRequest imageOptimizationRequest) { if (imageOptimizationRequest == null) { return new ImageOptimizationResponse(); } var smushItRequest = new SmushItRequest { ImageUrl = imageOptimizationRequest.ImageUrl }; SmushItResponse smushItResponse = this._smushItProxy.ProcessImage(smushItRequest); return smushItResponse.ConvertToResponse(); }
public SmushItResponse ProcessImage(SmushItRequest smushItRequest) { string jsonResponse = string.Empty; string endpoint = this.BuildUrl(smushItRequest.ImageUrl); try { jsonResponse = this._webClient.DownloadString(endpoint); } catch (WebException exception) { throw new WebException(exception.Message); } if (!string.IsNullOrEmpty(jsonResponse)) { return this._javaScriptSerializer.Deserialize<SmushItResponse>(jsonResponse); } return new SmushItResponse { Src = smushItRequest.ImageUrl }; }