/// <summary> /// get the info of a movie /// </summary> /// <param name="request">Models.MoviesGetByIdRequest</param> /// <param name="responseFormatters">response formmaters</param> public virtual async Task<Models.MoviesGetByIdResponse> GetById(Models.MoviesGetByIdRequest request, IEnumerable<MediaTypeFormatter> responseFormatters = null) { var url = "movies/{id}"; if (request.UriParameters == null) throw new InvalidOperationException("Uri Parameters cannot be null"); if (request.UriParameters.Id == null) throw new InvalidOperationException("Uri Parameter Id cannot be null"); url = url.Replace("{id}", request.UriParameters.Id.ToString()); var req = new HttpRequestMessage(HttpMethod.Get, url); if (request.RawHeaders != null) { foreach (var header in request.RawHeaders) { req.Headers.TryAddWithoutValidation(header.Key, string.Join(",", header.Value)); } } var response = await proxy.Client.SendAsync(req); if (proxy.SchemaValidation.Enabled && proxy.SchemaValidation.RaiseExceptions) { if (proxy.SchemaValidation.RaiseExceptions) { await SchemaValidator.ValidateWithExceptionAsync(Models.MoviesGetByIdResponse.GetSchema(response.StatusCode), response.Content); } } var headers = new Models.MultipleGetByIdHeader(); headers.SetProperties(response.Headers, response.StatusCode); return new Models.MoviesGetByIdResponse { RawContent = response.Content, Headers = headers, RawHeaders = response.Headers, Formatters = responseFormatters, StatusCode = response.StatusCode, ReasonPhrase = response.ReasonPhrase, SchemaValidation = new Lazy<SchemaValidationResults>(() => SchemaValidator.IsValid(Models.MoviesGetByIdResponse.GetSchema(response.StatusCode), response.Content), true) }; }
/// <summary> /// get the info of a movie /// </summary> /// <param name="id"></param> public virtual async Task<Models.MoviesGetByIdResponse> GetById(string id) { var url = "movies/{id}"; url = url.Replace("{id}", id.ToString()); var req = new HttpRequestMessage(HttpMethod.Get, url); var response = await proxy.Client.SendAsync(req); if (proxy.SchemaValidation.Enabled) { if (proxy.SchemaValidation.RaiseExceptions) { await SchemaValidator.ValidateWithExceptionAsync(Models.MoviesGetByIdResponse.GetSchema(response.StatusCode), response.Content); } } var headers = new Models.MultipleGetByIdHeader(); headers.SetProperties(response.Headers, response.StatusCode); return new Models.MoviesGetByIdResponse { RawContent = response.Content, Headers = headers, RawHeaders = response.Headers, StatusCode = response.StatusCode, ReasonPhrase = response.ReasonPhrase, SchemaValidation = new Lazy<SchemaValidationResults>(() => SchemaValidator.IsValid(Models.MoviesGetByIdResponse.GetSchema(response.StatusCode), response.Content), true) }; }