/// <summary> /// gets already shipped orders /// </summary> /// <param name="request">ApiRequest</param> /// <param name="responseFormatters">response formmaters</param> public virtual async Task<Models.ShippedGetResponse> Get(ApiRequest request, IEnumerable<MediaTypeFormatter> responseFormatters = null) { var url = "orders/shipped"; 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("", response.Content); } } return new Models.ShippedGetResponse { RawContent = response.Content, RawHeaders = response.Headers, Formatters = responseFormatters, StatusCode = response.StatusCode, ReasonPhrase = response.ReasonPhrase, SchemaValidation = new Lazy<SchemaValidationResults>(() => SchemaValidator.IsValid("", response.Content), true) }; }
/// <summary> /// Retrieve a list of fstab entries - All fstab entries /// </summary> /// <param name="request">ApiRequest</param> /// <param name="responseFormatters">response formmaters</param> public virtual async Task<Models.EntriesGetResponse> Get(ApiRequest request, IEnumerable<MediaTypeFormatter> responseFormatters = null) { var url = "entries"; 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("{ \"id\": \"http://some.site.somewhere/entry-schema#\", \"$schema\": \"http://json-schema.org/draft-04/schema#\", \"description\": \"schema for an fstab entry\", \"type\": \"object\", \"required\": [ \"storage\" ], \"properties\": { \"storage\": { \"type\": \"object\", \"oneOf\": [ { \"$ref\": \"#/definitions/diskDevice\" }, { \"$ref\": \"#/definitions/diskUUID\" }, { \"$ref\": \"#/definitions/nfs\" }, { \"$ref\": \"#/definitions/tmpfs\" } ] }, \"fstype\": { \"enum\": [ \"ext3\", \"ext4\", \"btrfs\" ] }, \"options\": { \"type\": \"array\", \"minItems\": 1, \"items\": { \"type\": \"string\" }, \"uniqueItems\": true }, \"readonly\": { \"type\": \"boolean\" } }, \"definitions\": { \"diskDevice\": { \"properties\": { \"type\": { \"enum\": [ \"disk\" ] }, \"device\": { \"type\": \"string\", \"pattern\": \"^/dev/[^/]+(/[^/]+)*$\" } }, \"required\": [ \"type\", \"device\" ], \"additionalProperties\": false }, \"diskUUID\": { \"properties\": { \"type\": { \"enum\": [ \"disk\" ] }, \"label\": { \"type\": \"string\", \"pattern\": \"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$\" } }, \"required\": [ \"type\", \"label\" ], \"additionalProperties\": false }, \"nfs\": { \"properties\": { \"type\": { \"enum\": [ \"nfs\" ] }, \"remotePath\": { \"type\": \"string\", \"pattern\": \"^(/[^/]+)+$\" }, \"server\": { \"type\": \"string\", \"oneOf\": [ { \"format\": \"host-name\" }, { \"format\": \"ipv4\" }, { \"format\": \"ipv6\" } ] } }, \"required\": [ \"type\", \"server\", \"remotePath\" ], \"additionalProperties\": false }, \"tmpfs\": { \"properties\": { \"type\": { \"enum\": [ \"tmpfs\" ] }, \"sizeInMB\": { \"type\": \"integer\", \"minimum\": 16, \"maximum\": 512 } }, \"required\": [ \"type\", \"sizeInMB\" ], \"additionalProperties\": false } }}", response.Content); } } return new Models.EntriesGetResponse { RawContent = response.Content, RawHeaders = response.Headers, Formatters = responseFormatters, StatusCode = response.StatusCode, ReasonPhrase = response.ReasonPhrase, SchemaValidation = new Lazy<SchemaValidationResults>(() => SchemaValidator.IsValid("{ \"id\": \"http://some.site.somewhere/entry-schema#\", \"$schema\": \"http://json-schema.org/draft-04/schema#\", \"description\": \"schema for an fstab entry\", \"type\": \"object\", \"required\": [ \"storage\" ], \"properties\": { \"storage\": { \"type\": \"object\", \"oneOf\": [ { \"$ref\": \"#/definitions/diskDevice\" }, { \"$ref\": \"#/definitions/diskUUID\" }, { \"$ref\": \"#/definitions/nfs\" }, { \"$ref\": \"#/definitions/tmpfs\" } ] }, \"fstype\": { \"enum\": [ \"ext3\", \"ext4\", \"btrfs\" ] }, \"options\": { \"type\": \"array\", \"minItems\": 1, \"items\": { \"type\": \"string\" }, \"uniqueItems\": true }, \"readonly\": { \"type\": \"boolean\" } }, \"definitions\": { \"diskDevice\": { \"properties\": { \"type\": { \"enum\": [ \"disk\" ] }, \"device\": { \"type\": \"string\", \"pattern\": \"^/dev/[^/]+(/[^/]+)*$\" } }, \"required\": [ \"type\", \"device\" ], \"additionalProperties\": false }, \"diskUUID\": { \"properties\": { \"type\": { \"enum\": [ \"disk\" ] }, \"label\": { \"type\": \"string\", \"pattern\": \"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$\" } }, \"required\": [ \"type\", \"label\" ], \"additionalProperties\": false }, \"nfs\": { \"properties\": { \"type\": { \"enum\": [ \"nfs\" ] }, \"remotePath\": { \"type\": \"string\", \"pattern\": \"^(/[^/]+)+$\" }, \"server\": { \"type\": \"string\", \"oneOf\": [ { \"format\": \"host-name\" }, { \"format\": \"ipv4\" }, { \"format\": \"ipv6\" } ] } }, \"required\": [ \"type\", \"server\", \"remotePath\" ], \"additionalProperties\": false }, \"tmpfs\": { \"properties\": { \"type\": { \"enum\": [ \"tmpfs\" ] }, \"sizeInMB\": { \"type\": \"integer\", \"minimum\": 16, \"maximum\": 512 } }, \"required\": [ \"type\", \"sizeInMB\" ], \"additionalProperties\": false } }}", response.Content), true) }; }
/// <summary> /// get all movies that are not currently rented /// </summary> /// <param name="request">ApiRequest</param> /// <param name="responseFormatters">response formmaters</param> public virtual async Task<Models.AvailableGetResponse> Get(ApiRequest request, IEnumerable<MediaTypeFormatter> responseFormatters = null) { var url = "movies/available"; 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("{ \"$schema\": \"http://json-schema.org/draft-03/schema\", \"type\": \"array\", \"description\": \"movies\", \"items\": { \"type\": \"object\", \"properties\": { \"id\": { \"type\": \"integer\" }, \"name\": { \"type\": \"string\"}, \"director\": { \"type\": \"string\"}, \"genre\": { \"type\": \"string\" }, \"cast\":{ \"type\": \"string\" }, \"duration\":{ \"type\": \"number\" }, \"storyline\":{ \"type\": \"string\" }, \"language\":{ \"type\": \"string\" }, \"rented\":{ \"type\": \"boolean\" } } }}", response.Content); } } return new Models.AvailableGetResponse { RawContent = response.Content, RawHeaders = response.Headers, Formatters = responseFormatters, StatusCode = response.StatusCode, ReasonPhrase = response.ReasonPhrase, SchemaValidation = new Lazy<SchemaValidationResults>(() => SchemaValidator.IsValid("{ \"$schema\": \"http://json-schema.org/draft-03/schema\", \"type\": \"array\", \"description\": \"movies\", \"items\": { \"type\": \"object\", \"properties\": { \"id\": { \"type\": \"integer\" }, \"name\": { \"type\": \"string\"}, \"director\": { \"type\": \"string\"}, \"genre\": { \"type\": \"string\" }, \"cast\":{ \"type\": \"string\" }, \"duration\":{ \"type\": \"number\" }, \"storyline\":{ \"type\": \"string\" }, \"language\":{ \"type\": \"string\" }, \"rented\":{ \"type\": \"boolean\" } } }}", response.Content), true) }; }
/// <summary> /// gets the current user movies wishlist /// </summary> /// <param name="request">ApiRequest</param> /// <param name="responseFormatters">response formmaters</param> public virtual async Task<Models.WishlistGetResponse> Get(ApiRequest request, IEnumerable<MediaTypeFormatter> responseFormatters = null) { var url = "movies/wishlist"; var req = new HttpRequestMessage(HttpMethod.Get, url); if (string.IsNullOrEmpty(proxy.OAuthAccessToken)) throw new InvalidOperationException("This API call is secured with OAuth, you must provide an access token (set OAuthAccessToken before calling this method)"); req.Headers.Add("Authorization", "Bearer " + proxy.OAuthAccessToken); 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("{ \"$schema\": \"http://json-schema.org/draft-03/schema\", \"type\": \"array\", \"description\": \"movies\", \"items\": { \"type\": \"object\", \"properties\": { \"id\": { \"type\": \"integer\" }, \"name\": { \"type\": \"string\"}, \"director\": { \"type\": \"string\"}, \"genre\": { \"type\": \"string\" }, \"cast\":{ \"type\": \"string\" }, \"duration\":{ \"type\": \"number\" }, \"storyline\":{ \"type\": \"string\" }, \"language\":{ \"type\": \"string\" }, \"rented\":{ \"type\": \"boolean\" } } }}", response.Content); } } return new Models.WishlistGetResponse { RawContent = response.Content, RawHeaders = response.Headers, Formatters = responseFormatters, StatusCode = response.StatusCode, ReasonPhrase = response.ReasonPhrase, SchemaValidation = new Lazy<SchemaValidationResults>(() => SchemaValidator.IsValid("{ \"$schema\": \"http://json-schema.org/draft-03/schema\", \"type\": \"array\", \"description\": \"movies\", \"items\": { \"type\": \"object\", \"properties\": { \"id\": { \"type\": \"integer\" }, \"name\": { \"type\": \"string\"}, \"director\": { \"type\": \"string\"}, \"genre\": { \"type\": \"string\" }, \"cast\":{ \"type\": \"string\" }, \"duration\":{ \"type\": \"number\" }, \"storyline\":{ \"type\": \"string\" }, \"language\":{ \"type\": \"string\" }, \"rented\":{ \"type\": \"boolean\" } } }}", response.Content), true) }; }