From 1866d9f9403abbe6ad4e054ffcc0f3311ab4d2b5 Mon Sep 17 00:00:00 2001 From: Sebastian Grunow Date: Wed, 27 Nov 2019 12:10:39 +0100 Subject: [PATCH 1/2] Fixed issue when no media id is given on specific media query. An empty or null mediaId resulted in a Newtonsoft.Json error not really saying anything useful. --- Bynder/Sdk/Service/Asset/AssetService.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Bynder/Sdk/Service/Asset/AssetService.cs b/Bynder/Sdk/Service/Asset/AssetService.cs index c177ed7..bf16bbc 100644 --- a/Bynder/Sdk/Service/Asset/AssetService.cs +++ b/Bynder/Sdk/Service/Asset/AssetService.cs @@ -1,4 +1,4 @@ -// Copyright (c) Bynder. All rights reserved. +// Copyright (c) Bynder. All rights reserved. // Licensed under the MIT License. See LICENSE file in the project root for full license information. using System; @@ -130,6 +130,11 @@ public Task UploadFileAsync(UploadQuery query) /// Check for more information public Task GetMediaInfoAsync(MediaInformationQuery query) { + if (string.IsNullOrEmpty(query.MediaId)) + { + throw new ArgumentNullException(nameof(query), "Parameter cannot be null or empty."); + } + var request = new ApiRequest { Path = $"/api/v4/media/{query.MediaId}/", From 00bfbfffde3b6111feb0db6a46896f4db31a2772 Mon Sep 17 00:00:00 2001 From: Sebastian Grunow Date: Wed, 27 Nov 2019 12:10:59 +0100 Subject: [PATCH 2/2] Extended media and collection queries by missing fields. --- Bynder/Sdk/Model/OrderByType.cs | 13 ++++++ Bynder/Sdk/Query/Asset/MediaQuery.cs | 20 ++++++++- .../Query/Collection/GetCollectionsQuery.cs | 43 ++++++++++++++++++- 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 Bynder/Sdk/Model/OrderByType.cs diff --git a/Bynder/Sdk/Model/OrderByType.cs b/Bynder/Sdk/Model/OrderByType.cs new file mode 100644 index 0000000..84dd222 --- /dev/null +++ b/Bynder/Sdk/Model/OrderByType.cs @@ -0,0 +1,13 @@ +namespace Bynder.Sdk.Model +{ + public static class OrderByType + { + public static readonly string DateCreatedAscending = "dateCreated asc"; + + public static readonly string DateCreatedDescending = "dateCreated desc"; + + public static readonly string NameAscending = "name asc"; + + public static readonly string NameDescending = "name desc"; + } +} diff --git a/Bynder/Sdk/Query/Asset/MediaQuery.cs b/Bynder/Sdk/Query/Asset/MediaQuery.cs index aa5ffff..8f40145 100644 --- a/Bynder/Sdk/Query/Asset/MediaQuery.cs +++ b/Bynder/Sdk/Query/Asset/MediaQuery.cs @@ -1,4 +1,4 @@ -// Copyright (c) Bynder. All rights reserved. +// Copyright (c) Bynder. All rights reserved. // Licensed under the MIT License. See LICENSE file in the project root for full license information. using System.Collections.Generic; @@ -25,6 +25,24 @@ public class MediaQuery [ApiField("subBrandId")] public string SubBrandId { get; set; } + /// + /// Category id. Specify this property if you want only media for specific category. + /// + [ApiField("categoryId")] + public string CategoryId { get; set; } + + /// + /// Collection id. Specify this property if you want only media for specific collection. + /// + [ApiField("collectionId")] + public string CollectionId { get; set; } + + /// + /// List of asset ids. Will return an asset for each existing id. + /// + [ApiField("ids", Converter = typeof(ListConverter))] + public IEnumerable Ids { get; set; } + /// /// Limit of results per request. Max 1000. Default 50. /// diff --git a/Bynder/Sdk/Query/Collection/GetCollectionsQuery.cs b/Bynder/Sdk/Query/Collection/GetCollectionsQuery.cs index 188461c..c2dca83 100644 --- a/Bynder/Sdk/Query/Collection/GetCollectionsQuery.cs +++ b/Bynder/Sdk/Query/Collection/GetCollectionsQuery.cs @@ -1,10 +1,14 @@ -// Copyright (c) Bynder. All rights reserved. +// Copyright (c) Bynder. All rights reserved. // Licensed under the MIT License. See LICENSE file in the project root for full license information. using Bynder.Sdk.Query.Decoder; namespace Bynder.Sdk.Query.Collection { + using System.Collections.Generic; + + using Bynder.Sdk.Api.Converters; + /// /// Query to retrieve a list of collections /// @@ -21,5 +25,42 @@ public class GetCollectionsQuery /// [ApiField("page")] public int? Page { get; set; } + + /// + /// Desired order of returned collection set. + /// See for possible values. + /// + [ApiField("orderBy")] + public string OrderBy { get; set; } + + /// + /// List of collection ids. Will return the collection for each existing collection. + /// + [ApiField("ids", Converter = typeof(ListConverter))] + public IEnumerable Ids { get; set; } + + /// + /// Indicates whether or not the response should include count results. + /// + [ApiField("count")] + public bool? Count { get; set; } + + /// + /// Search on matching names. + /// + [ApiField("keyword")] + public string Keyword { get; set; } + + /// + /// Indicates whether or not the return should only contain collections marked as public. + /// + [ApiField("isPublic")] + public bool? IsPublic { get; set; } + + /// + /// Minimum collectionCount that the returned collections should have. + /// + [ApiField("minCount")] + public int? MinCount { get; set; } } }