From 92b43b07254dec06455ca39eb18cf3b32c590a4d Mon Sep 17 00:00:00 2001 From: Yosif Velev Date: Mon, 7 Feb 2022 16:19:34 +0200 Subject: [PATCH 01/25] Add Labels dictionary Fix wrong focus point data type --- Bynder/Sdk/Model/Media.cs | 2 +- Bynder/Sdk/Model/Metaproperty.cs | 14 +++++++++++++- Bynder/Sdk/Model/MetapropertyOption.cs | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Bynder/Sdk/Model/Media.cs b/Bynder/Sdk/Model/Media.cs index 2c28193..351ae14 100644 --- a/Bynder/Sdk/Model/Media.cs +++ b/Bynder/Sdk/Model/Media.cs @@ -30,7 +30,7 @@ public class Media /// by an x,y coordinate. /// [JsonProperty("activeOriginalFocusPoint")] - public IDictionary ActiveOriginalFocusPoint { get; set; } + public IDictionary ActiveOriginalFocusPoint { get; set; } /// /// Number of times the media has been downloaded diff --git a/Bynder/Sdk/Model/Metaproperty.cs b/Bynder/Sdk/Model/Metaproperty.cs index ce101e2..7b82279 100644 --- a/Bynder/Sdk/Model/Metaproperty.cs +++ b/Bynder/Sdk/Model/Metaproperty.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; @@ -71,5 +71,17 @@ public class Metaproperty /// [JsonProperty("zindex")] public int ZIndex { get; set; } + + /// + /// Type of the metaproperty + /// + [JsonProperty("type")] + public string Type { get; set; } + + /// + /// Returns label translation by culture (e.g. 'en_US', 'de_DE' and etc) + /// + [JsonProperty("labels")] + public IDictionary Labels { get; set; } = new Dictionary(); } } diff --git a/Bynder/Sdk/Model/MetapropertyOption.cs b/Bynder/Sdk/Model/MetapropertyOption.cs index c4f17e3..2952a05 100644 --- a/Bynder/Sdk/Model/MetapropertyOption.cs +++ b/Bynder/Sdk/Model/MetapropertyOption.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; @@ -53,5 +53,11 @@ public class MetapropertyOption /// [JsonProperty("linkedOptionIds")] public List LinkedOptionIds { get; set; } + + /// + /// Returns label translation by culture (e.g. 'en_US', 'de_DE' and etc) + /// + [JsonProperty("labels")] + public IDictionary Labels { get; set; } = new Dictionary(); } } From 742d2a54de39aa42abd6ce00067f75f896d4a0dc Mon Sep 17 00:00:00 2001 From: Yosif Velev Date: Wed, 9 Feb 2022 10:43:20 +0200 Subject: [PATCH 02/25] Expose get and set access token functionality --- Bynder/Sdk/Service/OAuth/IOAuthService.cs | 11 +++++++++++ Bynder/Sdk/Service/OAuth/OAuthService.cs | 24 +++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/Bynder/Sdk/Service/OAuth/IOAuthService.cs b/Bynder/Sdk/Service/OAuth/IOAuthService.cs index 30c6e0f..4660f26 100644 --- a/Bynder/Sdk/Service/OAuth/IOAuthService.cs +++ b/Bynder/Sdk/Service/OAuth/IOAuthService.cs @@ -10,6 +10,12 @@ namespace Bynder.Sdk.Service.OAuth /// public interface IOAuthService { + /// + /// Gets the access token. + /// + /// The access token. + string AccessToken { get; } + /// /// Gets the authorisation URL. /// @@ -35,5 +41,10 @@ public interface IOAuthService /// /// The task to get the refresh token Task GetRefreshTokenAsync(); + + /// + /// Explicitly set access token. + /// + void SetAccessToken(string accessToken); } } diff --git a/Bynder/Sdk/Service/OAuth/OAuthService.cs b/Bynder/Sdk/Service/OAuth/OAuthService.cs index 9c892ed..933c479 100644 --- a/Bynder/Sdk/Service/OAuth/OAuthService.cs +++ b/Bynder/Sdk/Service/OAuth/OAuthService.cs @@ -35,6 +35,12 @@ public OAuthService(Configuration configuration, ICredentials credentials, IApiR _requestSender = requestSender; } + /// + /// Gets the access token. + /// + /// The access token. + public string AccessToken => _credentials.AccessToken; + /// /// Check . /// @@ -151,5 +157,23 @@ public async Task GetRefreshTokenAsync() } } + /// + /// Explicitly set access token. + /// + public void SetAccessToken(string accessToken) + { + if (string.IsNullOrEmpty(accessToken)) + { + throw new ArgumentNullException(nameof(accessToken)); + } + + var token = new Token + { + AccessToken = accessToken, + ExpiresIn = 3600 + }; + + _credentials.Update(token); + } } } From 37c48bb938717485d173769730e595e71bb49002 Mon Sep 17 00:00:00 2001 From: Yosif Velev Date: Wed, 9 Feb 2022 10:43:46 +0200 Subject: [PATCH 03/25] New GetMediaList method that returns total count of items --- Bynder/Sdk/Model/MediaList.cs | 26 +++++++++++++++++++++++ Bynder/Sdk/Model/TotalCountResponse.cs | 16 ++++++++++++++ Bynder/Sdk/Query/Asset/MediaListQuery.cs | 19 +++++++++++++++++ Bynder/Sdk/Service/Asset/AssetService.cs | 15 +++++++++++++ Bynder/Sdk/Service/Asset/IAssetService.cs | 9 ++++++++ 5 files changed, 85 insertions(+) create mode 100644 Bynder/Sdk/Model/MediaList.cs create mode 100644 Bynder/Sdk/Model/TotalCountResponse.cs create mode 100644 Bynder/Sdk/Query/Asset/MediaListQuery.cs diff --git a/Bynder/Sdk/Model/MediaList.cs b/Bynder/Sdk/Model/MediaList.cs new file mode 100644 index 0000000..c3c94ff --- /dev/null +++ b/Bynder/Sdk/Model/MediaList.cs @@ -0,0 +1,26 @@ +// 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; +using Newtonsoft.Json; + +namespace Bynder.Sdk.Model +{ + /// + /// Media list model returned by API /media + /// + public class MediaList + { + /// + /// Media items + /// + [JsonProperty("media")] + public IList Items { get; set; } + + /// + /// Total of results + /// + [JsonProperty("total")] + public TotalCountResponse Total { get; set; } + } +} diff --git a/Bynder/Sdk/Model/TotalCountResponse.cs b/Bynder/Sdk/Model/TotalCountResponse.cs new file mode 100644 index 0000000..b1c69bf --- /dev/null +++ b/Bynder/Sdk/Model/TotalCountResponse.cs @@ -0,0 +1,16 @@ +// Copyright (c) Bynder. All rights reserved. +// Licensed under the MIT License. See LICENSE file in the project root for full license information. + +using Newtonsoft.Json; + +namespace Bynder.Sdk.Model +{ + public class TotalCountResponse + { + /// + /// The count + /// + [JsonProperty("count")] + public int Count { get; set; } + } +} diff --git a/Bynder/Sdk/Query/Asset/MediaListQuery.cs b/Bynder/Sdk/Query/Asset/MediaListQuery.cs new file mode 100644 index 0000000..f297330 --- /dev/null +++ b/Bynder/Sdk/Query/Asset/MediaListQuery.cs @@ -0,0 +1,19 @@ +using Bynder.Sdk.Query.Decoder; + +namespace Bynder.Sdk.Query.Asset +{ + public class MediaListQuery : MediaQuery + { + /// + /// Indicating whether or not the response should include the total count of results. Example: 1. Default: 0. + /// + [ApiField("total")] + public int Total { get; set; } + + /// + /// Order of the returned list of assets + /// + [ApiField("orderBy")] + public string OrderBy { get; set; } + } +} diff --git a/Bynder/Sdk/Service/Asset/AssetService.cs b/Bynder/Sdk/Service/Asset/AssetService.cs index f94f779..c188884 100644 --- a/Bynder/Sdk/Service/Asset/AssetService.cs +++ b/Bynder/Sdk/Service/Asset/AssetService.cs @@ -108,6 +108,21 @@ public async Task> GetMediaListAsync(MediaQuery query) }).ConfigureAwait(false); } + /// + /// Check for more information + /// + /// Check for more information + /// Check for more information + public async Task GetMediaListAsync(MediaListQuery query) + { + return await _requestSender.SendRequestAsync(new ApiRequest + { + Path = "/api/v4/media/", + HTTPMethod = HttpMethod.Get, + Query = query, + }).ConfigureAwait(false); + } + /// /// Check for more information /// diff --git a/Bynder/Sdk/Service/Asset/IAssetService.cs b/Bynder/Sdk/Service/Asset/IAssetService.cs index 8f0a7d8..3c50481 100644 --- a/Bynder/Sdk/Service/Asset/IAssetService.cs +++ b/Bynder/Sdk/Service/Asset/IAssetService.cs @@ -73,6 +73,15 @@ public interface IAssetService /// Can be thrown when requests to server can't be completed or HTTP code returned by server is an error Task> GetMediaListAsync(MediaQuery query); + /// + /// Gets a list of media using query information. The media information is not complete, for example + /// media items for media returned are not present. For that client needs to call + /// + /// information to correctly filter/paginate media list + /// Task with List of media. + /// Can be thrown when requests to server can't be completed or HTTP code returned by server is an error + Task GetMediaListAsync(MediaListQuery query); + /// /// Uploads a file async. /// From 578c2e8e7a91d9600e3618a93c07606497b436e1 Mon Sep 17 00:00:00 2001 From: Yosif Velev Date: Wed, 9 Feb 2022 18:38:53 +0200 Subject: [PATCH 04/25] Add unit tests --- Bynder/Test/Service/Asset/AssetServiceTest.cs | 20 +++++++++++++ Bynder/Test/Service/OAuth/OAuthServiceTest.cs | 29 +++++++++++++++++-- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/Bynder/Test/Service/Asset/AssetServiceTest.cs b/Bynder/Test/Service/Asset/AssetServiceTest.cs index 8b2d497..0735d00 100644 --- a/Bynder/Test/Service/Asset/AssetServiceTest.cs +++ b/Bynder/Test/Service/Asset/AssetServiceTest.cs @@ -124,6 +124,26 @@ public async Task GetMediaListCallsRequestSenderWithValidRequest() Assert.Equal(result, mediaList); } + [Fact] + public async Task GetMediaListItemsCallsRequestSenderWithValidRequest() + { + var result = new MediaList(); + _apiRequestSenderMock.Setup(sender => sender.SendRequestAsync(It.IsAny>())) + .ReturnsAsync(result); + var mediaListQuery = new MediaListQuery(); + var mediaList = await _assetService.GetMediaListAsync(mediaListQuery); + + _apiRequestSenderMock.Verify(sender => sender.SendRequestAsync( + It.Is>( + req => req.Path == "/api/v4/media/" + && req.HTTPMethod == HttpMethod.Get + && req.Query == mediaListQuery + ) + )); + + Assert.Equal(result, mediaList); + } + [Fact] public async Task GetDownloadFileUrlCallsRequestSenderWithValidRequest() { diff --git a/Bynder/Test/Service/OAuth/OAuthServiceTest.cs b/Bynder/Test/Service/OAuth/OAuthServiceTest.cs index 102a070..b323c39 100644 --- a/Bynder/Test/Service/OAuth/OAuthServiceTest.cs +++ b/Bynder/Test/Service/OAuth/OAuthServiceTest.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; @@ -33,9 +33,13 @@ public class OAuthServiceTest private Mock _apiRequestSenderMock; private OAuthService _oauthServiceClientCreds; private OAuthService _oauthServiceAuthCode; + private string _accessToken = Guid.NewGuid().ToString(); public OAuthServiceTest() { - _token = new Token(); + _token = new Token + { + AccessToken = _accessToken + }; _credentialsMock = new Mock(); _credentialsMock @@ -91,7 +95,7 @@ private void CheckTokenIsUpdated() { _credentialsMock.Verify(cred => cred.Update( It.Is( - token => token == _token + token => token.AccessToken == _token.AccessToken ) )); } @@ -168,5 +172,24 @@ public async Task GetRefreshTokenWithAuthCode() CheckTokenIsUpdated(); } + [Fact] + public void SetAccessTokenWithValue() + { + _oauthServiceAuthCode.SetAccessToken(_accessToken); + + CheckTokenIsUpdated(); + } + + [Fact] + public void SetAccessTokenWithNullValue() + { + Assert.Throws(() => _oauthServiceAuthCode.SetAccessToken(accessToken: null)); + } + + [Fact] + public void SetAccessTokenWithEmptyValue() + { + Assert.Throws(() => _oauthServiceAuthCode.SetAccessToken(accessToken: string.Empty)); + } } } From 790de2f6199117af6e3d30eb3cf09295bacfc8e5 Mon Sep 17 00:00:00 2001 From: Yosif Velev Date: Thu, 10 Feb 2022 11:48:59 +0200 Subject: [PATCH 05/25] Revert ActiveOriginalFocusPoint response type to IDictionary --- Bynder/Sdk/Model/Media.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bynder/Sdk/Model/Media.cs b/Bynder/Sdk/Model/Media.cs index 351ae14..2c28193 100644 --- a/Bynder/Sdk/Model/Media.cs +++ b/Bynder/Sdk/Model/Media.cs @@ -30,7 +30,7 @@ public class Media /// by an x,y coordinate. /// [JsonProperty("activeOriginalFocusPoint")] - public IDictionary ActiveOriginalFocusPoint { get; set; } + public IDictionary ActiveOriginalFocusPoint { get; set; } /// /// Number of times the media has been downloaded From a38bda8cd1f365fd00fc27356f2f0b9b2143b4f4 Mon Sep 17 00:00:00 2001 From: Yosif Velev Date: Wed, 16 Feb 2022 15:38:22 +0200 Subject: [PATCH 06/25] Add AssetOrderBy constants Change OrderBy summary description --- Bynder/Sdk/Model/AssetOrderBy.cs | 14 ++++++++++++++ Bynder/Sdk/Query/Asset/MediaListQuery.cs | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 Bynder/Sdk/Model/AssetOrderBy.cs diff --git a/Bynder/Sdk/Model/AssetOrderBy.cs b/Bynder/Sdk/Model/AssetOrderBy.cs new file mode 100644 index 0000000..4d4ad06 --- /dev/null +++ b/Bynder/Sdk/Model/AssetOrderBy.cs @@ -0,0 +1,14 @@ +namespace Bynder.Sdk.Model +{ + public static class AssetOrderBy + { + public const string DateCreatedAscending = "dateCreated asc"; + public const string DateCreatedDescending = "dateCreated desc"; + public const string DateModifiedAscending = "dateModified asc"; + public const string DateModifiedDescending = "dateModified desc"; + public const string DatePublishedAscending = "datePublished asc"; + public const string DatePublishedDescending = "datePublished desc"; + public const string NameAscending = "name asc"; + public const string NameDescending = "name desc"; + } +} diff --git a/Bynder/Sdk/Query/Asset/MediaListQuery.cs b/Bynder/Sdk/Query/Asset/MediaListQuery.cs index f297330..801b6ef 100644 --- a/Bynder/Sdk/Query/Asset/MediaListQuery.cs +++ b/Bynder/Sdk/Query/Asset/MediaListQuery.cs @@ -11,7 +11,8 @@ public class MediaListQuery : MediaQuery public int Total { get; set; } /// - /// Order of the returned list of assets + /// Desired order of returned assets. + /// See for possible values. /// [ApiField("orderBy")] public string OrderBy { get; set; } From 3932f4915e96871495b482d55ba369e4b6e83755 Mon Sep 17 00:00:00 2001 From: Yosif Velev Date: Wed, 16 Feb 2022 17:54:08 +0200 Subject: [PATCH 07/25] Create bool to string converter Rename MediaListQuery request parameter 'Total' to 'IncludeTotal' --- Bynder/Sdk/Api/Converters/BoolConverter.cs | 44 ++++++++++++++++++++++ Bynder/Sdk/Query/Asset/MediaListQuery.cs | 7 ++-- 2 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 Bynder/Sdk/Api/Converters/BoolConverter.cs diff --git a/Bynder/Sdk/Api/Converters/BoolConverter.cs b/Bynder/Sdk/Api/Converters/BoolConverter.cs new file mode 100644 index 0000000..a13538e --- /dev/null +++ b/Bynder/Sdk/Api/Converters/BoolConverter.cs @@ -0,0 +1,44 @@ +// Copyright (c) Bynder. All rights reserved. +// Licensed under the MIT License. See LICENSE file in the project root for full license information. + +using System; + +namespace Bynder.Sdk.Api.Converters +{ + /// + /// Class used to convert bool to string. + /// True is represented as "1" and false as "0" + /// + public class BoolConverter : ITypeToStringConverter + { + private const string _trueString = "1"; + private const string _falseString = "0"; + + /// + /// Returns true if type is assignable from bool + /// + /// Check + /// true if type is assignable from bool/> + public bool CanConvert(Type typeToConvert) + { + return typeof(bool).IsAssignableFrom(typeToConvert); + } + + /// + /// Converts bool to string represented as "1" or "0" + /// + /// bool value + /// converted string + public string Convert(object value) + { + if (value is bool boolValue) + { + return boolValue + ? _trueString + : _falseString; + } + + return string.Empty; + } + } +} diff --git a/Bynder/Sdk/Query/Asset/MediaListQuery.cs b/Bynder/Sdk/Query/Asset/MediaListQuery.cs index 801b6ef..6590298 100644 --- a/Bynder/Sdk/Query/Asset/MediaListQuery.cs +++ b/Bynder/Sdk/Query/Asset/MediaListQuery.cs @@ -1,3 +1,4 @@ +using Bynder.Sdk.Api.Converters; using Bynder.Sdk.Query.Decoder; namespace Bynder.Sdk.Query.Asset @@ -5,10 +6,10 @@ namespace Bynder.Sdk.Query.Asset public class MediaListQuery : MediaQuery { /// - /// Indicating whether or not the response should include the total count of results. Example: 1. Default: 0. + /// Indicating whether or not the response should include the total count of results. /// - [ApiField("total")] - public int Total { get; set; } + [ApiField("total", Converter = typeof(BoolConverter))] + public bool IncludeTotal { get; set; } /// /// Desired order of returned assets. From 38dc65bf0e15d94403c0624e6ace3c692f0c1286 Mon Sep 17 00:00:00 2001 From: Yosif Velev Date: Mon, 21 Feb 2022 11:20:04 +0200 Subject: [PATCH 08/25] Rename a bunch of stuff --- Bynder/Sdk/Model/{MediaList.cs => MediaWithTotal.cs} | 4 ++-- .../Query/Asset/{MediaListQuery.cs => MediaWithTotalQuery.cs} | 2 +- Bynder/Sdk/Service/Asset/AssetService.cs | 4 ++-- Bynder/Sdk/Service/Asset/IAssetService.cs | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) rename Bynder/Sdk/Model/{MediaList.cs => MediaWithTotal.cs} (85%) rename Bynder/Sdk/Query/Asset/{MediaListQuery.cs => MediaWithTotalQuery.cs} (92%) diff --git a/Bynder/Sdk/Model/MediaList.cs b/Bynder/Sdk/Model/MediaWithTotal.cs similarity index 85% rename from Bynder/Sdk/Model/MediaList.cs rename to Bynder/Sdk/Model/MediaWithTotal.cs index c3c94ff..4c7cc26 100644 --- a/Bynder/Sdk/Model/MediaList.cs +++ b/Bynder/Sdk/Model/MediaWithTotal.cs @@ -7,9 +7,9 @@ namespace Bynder.Sdk.Model { /// - /// Media list model returned by API /media + /// Media items returned by API /media including the total count /// - public class MediaList + public class MediaWithTotal { /// /// Media items diff --git a/Bynder/Sdk/Query/Asset/MediaListQuery.cs b/Bynder/Sdk/Query/Asset/MediaWithTotalQuery.cs similarity index 92% rename from Bynder/Sdk/Query/Asset/MediaListQuery.cs rename to Bynder/Sdk/Query/Asset/MediaWithTotalQuery.cs index 6590298..618392b 100644 --- a/Bynder/Sdk/Query/Asset/MediaListQuery.cs +++ b/Bynder/Sdk/Query/Asset/MediaWithTotalQuery.cs @@ -3,7 +3,7 @@ namespace Bynder.Sdk.Query.Asset { - public class MediaListQuery : MediaQuery + public class MediaWithTotalQuery : MediaQuery { /// /// Indicating whether or not the response should include the total count of results. diff --git a/Bynder/Sdk/Service/Asset/AssetService.cs b/Bynder/Sdk/Service/Asset/AssetService.cs index c188884..b177b22 100644 --- a/Bynder/Sdk/Service/Asset/AssetService.cs +++ b/Bynder/Sdk/Service/Asset/AssetService.cs @@ -113,9 +113,9 @@ public async Task> GetMediaListAsync(MediaQuery query) /// /// Check for more information /// Check for more information - public async Task GetMediaListAsync(MediaListQuery query) + public async Task GetMediaWithTotalAsync(MediaWithTotalQuery query) { - return await _requestSender.SendRequestAsync(new ApiRequest + return await _requestSender.SendRequestAsync(new ApiRequest { Path = "/api/v4/media/", HTTPMethod = HttpMethod.Get, diff --git a/Bynder/Sdk/Service/Asset/IAssetService.cs b/Bynder/Sdk/Service/Asset/IAssetService.cs index 3c50481..c340f01 100644 --- a/Bynder/Sdk/Service/Asset/IAssetService.cs +++ b/Bynder/Sdk/Service/Asset/IAssetService.cs @@ -74,13 +74,13 @@ public interface IAssetService Task> GetMediaListAsync(MediaQuery query); /// - /// Gets a list of media using query information. The media information is not complete, for example + /// Gets a list of media using query information including the total count. The media information is not complete, for example /// media items for media returned are not present. For that client needs to call /// /// information to correctly filter/paginate media list /// Task with List of media. /// Can be thrown when requests to server can't be completed or HTTP code returned by server is an error - Task GetMediaListAsync(MediaListQuery query); + Task GetMediaWithTotalAsync(MediaWithTotalQuery query); /// /// Uploads a file async. From 154d013805e9000d8e622a97c609b1a538bb3b6a Mon Sep 17 00:00:00 2001 From: Reinhard Holzner Date: Thu, 3 Mar 2022 15:20:22 +0100 Subject: [PATCH 09/25] Allow to query assets with counts from Bynder. This API has been missing before. --- Bynder/Sdk/Service/Asset/AssetService.cs | 15 +++++++++++++++ Bynder/Sdk/Service/Asset/IAssetService.cs | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/Bynder/Sdk/Service/Asset/AssetService.cs b/Bynder/Sdk/Service/Asset/AssetService.cs index b177b22..1ce3b94 100644 --- a/Bynder/Sdk/Service/Asset/AssetService.cs +++ b/Bynder/Sdk/Service/Asset/AssetService.cs @@ -123,6 +123,21 @@ public async Task GetMediaWithTotalAsync(MediaWithTotalQuery que }).ConfigureAwait(false); } + /// + /// Check for more information + /// + /// Check for more information + /// Check for more information + public async Task GetMediaWithCountAsync(MediaWithCountQuery query) + { + return await _requestSender.SendRequestAsync(new ApiRequest + { + Path = "/api/v4/media/", + HTTPMethod = HttpMethod.Get, + Query = query, + }).ConfigureAwait(false); + } + /// /// Check for more information /// diff --git a/Bynder/Sdk/Service/Asset/IAssetService.cs b/Bynder/Sdk/Service/Asset/IAssetService.cs index c340f01..d217ebd 100644 --- a/Bynder/Sdk/Service/Asset/IAssetService.cs +++ b/Bynder/Sdk/Service/Asset/IAssetService.cs @@ -82,6 +82,15 @@ public interface IAssetService /// Can be thrown when requests to server can't be completed or HTTP code returned by server is an error Task GetMediaWithTotalAsync(MediaWithTotalQuery query); + /// + /// Gets a list of media using query information including the individual counts. The media information is not complete, for example + /// media items for media returned are not present. For that client needs to call + /// + /// information to correctly filter/paginate media list + /// Task with List of media. + /// Can be thrown when requests to server can't be completed or HTTP code returned by server is an error + Task GetMediaWithCountAsync(MediaWithCountQuery query); + /// /// Uploads a file async. /// From 67b65532f324908e9bcad4cbd0810828bc471227 Mon Sep 17 00:00:00 2001 From: Reinhard Holzner Date: Thu, 3 Mar 2022 18:55:03 +0100 Subject: [PATCH 10/25] Fix active original focus point --- Bynder/Sdk/Model/Media.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bynder/Sdk/Model/Media.cs b/Bynder/Sdk/Model/Media.cs index 2c28193..97e7175 100644 --- a/Bynder/Sdk/Model/Media.cs +++ b/Bynder/Sdk/Model/Media.cs @@ -30,7 +30,7 @@ public class Media /// by an x,y coordinate. /// [JsonProperty("activeOriginalFocusPoint")] - public IDictionary ActiveOriginalFocusPoint { get; set; } + public IDictionary ActiveOriginalFocusPoint { get; set; } /// /// Number of times the media has been downloaded From 43f7f71172a104b39c30c16719f583c572514927 Mon Sep 17 00:00:00 2001 From: Reinhard Holzner Date: Thu, 3 Mar 2022 19:36:54 +0100 Subject: [PATCH 11/25] Support media with count --- Bynder/Sdk/Model/CountValue.cs | 18 +++++++ Bynder/Sdk/Model/Counts.cs | 50 +++++++++++++++++++ Bynder/Sdk/Model/MediaWithCount.cs | 26 ++++++++++ Bynder/Sdk/Query/Asset/MediaWithCountQuery.cs | 27 ++++++++++ 4 files changed, 121 insertions(+) create mode 100644 Bynder/Sdk/Model/CountValue.cs create mode 100644 Bynder/Sdk/Model/Counts.cs create mode 100644 Bynder/Sdk/Model/MediaWithCount.cs create mode 100644 Bynder/Sdk/Query/Asset/MediaWithCountQuery.cs diff --git a/Bynder/Sdk/Model/CountValue.cs b/Bynder/Sdk/Model/CountValue.cs new file mode 100644 index 0000000..2778913 --- /dev/null +++ b/Bynder/Sdk/Model/CountValue.cs @@ -0,0 +1,18 @@ +namespace Bynder.Sdk.Model +{ + /// + /// The count values as delivered by the API + /// + public class CountValue + { + /// + /// The property option key + /// + public string PropertyOptionKey { get; set; } + + /// + /// the count + /// + public int Count { get; set; } + } +} diff --git a/Bynder/Sdk/Model/Counts.cs b/Bynder/Sdk/Model/Counts.cs new file mode 100644 index 0000000..ba345d1 --- /dev/null +++ b/Bynder/Sdk/Model/Counts.cs @@ -0,0 +1,50 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Bynder.Sdk.Model +{ + /// + /// Counts returned by the API + /// + public class Counts : Dictionary + { + public long Total => GetTotalCount(); + + private long GetTotalCount() + { + if (!TryGetValue("total", out var total)) + return 0; + + if (total is long totalLong) + return totalLong; + + return 0; + } + + public IEnumerable GetCountValues(string propertyName) + { + if (string.IsNullOrEmpty(propertyName)) + throw new ArgumentNullException(nameof(propertyName)); + + if (!TryGetValue(propertyName, out var count)) + return null; + + if (!(count is JObject countJObject)) + return null; + + return countJObject.Children() + .Where(child => child is JProperty) + .Select(child => child as JProperty) + .Select(jProperty => + new CountValue() + { + PropertyOptionKey = jProperty.Name, + Count = jProperty.Value.Value() + } + ); + } + } +} diff --git a/Bynder/Sdk/Model/MediaWithCount.cs b/Bynder/Sdk/Model/MediaWithCount.cs new file mode 100644 index 0000000..39bacfe --- /dev/null +++ b/Bynder/Sdk/Model/MediaWithCount.cs @@ -0,0 +1,26 @@ +// 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; +using Newtonsoft.Json; + +namespace Bynder.Sdk.Model +{ + /// + /// Media items returned by API /media including the individual counts + /// + public class MediaWithCount + { + /// + /// Media items + /// + [JsonProperty("media")] + public IList Items { get; set; } + + /// + /// Counts + /// + [JsonProperty("count")] + public Counts Counts { get; set; } + } +} diff --git a/Bynder/Sdk/Query/Asset/MediaWithCountQuery.cs b/Bynder/Sdk/Query/Asset/MediaWithCountQuery.cs new file mode 100644 index 0000000..d524f8e --- /dev/null +++ b/Bynder/Sdk/Query/Asset/MediaWithCountQuery.cs @@ -0,0 +1,27 @@ +using Bynder.Sdk.Api.Converters; +using Bynder.Sdk.Query.Decoder; + +namespace Bynder.Sdk.Query.Asset +{ + public class MediaWithCountQuery : MediaQuery + { + /// + /// Indicating whether or not the response should include the total count of results. + /// + [ApiField("total", Converter = typeof(BoolConverter))] + public bool IncludeTotal { get; set; } + + /// + /// Indicating whether or not the response should include the individual count of results. + /// + [ApiField("count", Converter = typeof(BoolConverter))] + public bool IncludeCount { get; set; } + + /// + /// Desired order of returned assets. + /// See for possible values. + /// + [ApiField("orderBy")] + public string OrderBy { get; set; } + } +} From e04fdc5927074b27b6b876b14a31b4ea631a976b Mon Sep 17 00:00:00 2001 From: Reinhard Holzner Date: Thu, 3 Mar 2022 20:38:30 +0100 Subject: [PATCH 12/25] Support tags, orientations and multi asset type selection --- Bynder/Sdk/Model/AssetType.cs | 2 +- Bynder/Sdk/Query/Asset/MediaQuery.cs | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Bynder/Sdk/Model/AssetType.cs b/Bynder/Sdk/Model/AssetType.cs index e527a9f..220f3cd 100644 --- a/Bynder/Sdk/Model/AssetType.cs +++ b/Bynder/Sdk/Model/AssetType.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. namespace Bynder.Sdk.Model diff --git a/Bynder/Sdk/Query/Asset/MediaQuery.cs b/Bynder/Sdk/Query/Asset/MediaQuery.cs index 8f40145..ac45c6e 100644 --- a/Bynder/Sdk/Query/Asset/MediaQuery.cs +++ b/Bynder/Sdk/Query/Asset/MediaQuery.cs @@ -64,8 +64,20 @@ public class MediaQuery /// /// The type of the asset /// - [ApiField("type", Converter = typeof(LowerCaseEnumConverter))] - public AssetType? Type { get; set; } + [ApiField("type")] + public string Types { get; set; } + + /// + /// The tags of the asset + /// + [ApiField("tags")] + public string Tags { get; set; } + + /// + /// The tags of the asset + /// + [ApiField("orientation")] + public string Orientations { get; set; } /// /// Metaproperty option ids that the asset has to have From 84c178fb7119e5f7a763db7db1c7dec775146573 Mon Sep 17 00:00:00 2001 From: Yosif Velev Date: Mon, 21 Mar 2022 11:38:00 +0200 Subject: [PATCH 13/25] Revert changes --- Bynder/Sdk/Model/AssetType.cs | 2 +- Bynder/Sdk/Model/CountValue.cs | 18 +++++++ Bynder/Sdk/Model/Counts.cs | 50 +++++++++++++++++++ Bynder/Sdk/Model/Media.cs | 2 +- Bynder/Sdk/Model/MediaWithCount.cs | 26 ++++++++++ Bynder/Sdk/Query/Asset/MediaQuery.cs | 16 +++++- Bynder/Sdk/Query/Asset/MediaWithCountQuery.cs | 27 ++++++++++ 7 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 Bynder/Sdk/Model/CountValue.cs create mode 100644 Bynder/Sdk/Model/Counts.cs create mode 100644 Bynder/Sdk/Model/MediaWithCount.cs create mode 100644 Bynder/Sdk/Query/Asset/MediaWithCountQuery.cs diff --git a/Bynder/Sdk/Model/AssetType.cs b/Bynder/Sdk/Model/AssetType.cs index e527a9f..220f3cd 100644 --- a/Bynder/Sdk/Model/AssetType.cs +++ b/Bynder/Sdk/Model/AssetType.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. namespace Bynder.Sdk.Model diff --git a/Bynder/Sdk/Model/CountValue.cs b/Bynder/Sdk/Model/CountValue.cs new file mode 100644 index 0000000..2778913 --- /dev/null +++ b/Bynder/Sdk/Model/CountValue.cs @@ -0,0 +1,18 @@ +namespace Bynder.Sdk.Model +{ + /// + /// The count values as delivered by the API + /// + public class CountValue + { + /// + /// The property option key + /// + public string PropertyOptionKey { get; set; } + + /// + /// the count + /// + public int Count { get; set; } + } +} diff --git a/Bynder/Sdk/Model/Counts.cs b/Bynder/Sdk/Model/Counts.cs new file mode 100644 index 0000000..ba345d1 --- /dev/null +++ b/Bynder/Sdk/Model/Counts.cs @@ -0,0 +1,50 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Bynder.Sdk.Model +{ + /// + /// Counts returned by the API + /// + public class Counts : Dictionary + { + public long Total => GetTotalCount(); + + private long GetTotalCount() + { + if (!TryGetValue("total", out var total)) + return 0; + + if (total is long totalLong) + return totalLong; + + return 0; + } + + public IEnumerable GetCountValues(string propertyName) + { + if (string.IsNullOrEmpty(propertyName)) + throw new ArgumentNullException(nameof(propertyName)); + + if (!TryGetValue(propertyName, out var count)) + return null; + + if (!(count is JObject countJObject)) + return null; + + return countJObject.Children() + .Where(child => child is JProperty) + .Select(child => child as JProperty) + .Select(jProperty => + new CountValue() + { + PropertyOptionKey = jProperty.Name, + Count = jProperty.Value.Value() + } + ); + } + } +} diff --git a/Bynder/Sdk/Model/Media.cs b/Bynder/Sdk/Model/Media.cs index 97e7175..2c28193 100644 --- a/Bynder/Sdk/Model/Media.cs +++ b/Bynder/Sdk/Model/Media.cs @@ -30,7 +30,7 @@ public class Media /// by an x,y coordinate. /// [JsonProperty("activeOriginalFocusPoint")] - public IDictionary ActiveOriginalFocusPoint { get; set; } + public IDictionary ActiveOriginalFocusPoint { get; set; } /// /// Number of times the media has been downloaded diff --git a/Bynder/Sdk/Model/MediaWithCount.cs b/Bynder/Sdk/Model/MediaWithCount.cs new file mode 100644 index 0000000..39bacfe --- /dev/null +++ b/Bynder/Sdk/Model/MediaWithCount.cs @@ -0,0 +1,26 @@ +// 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; +using Newtonsoft.Json; + +namespace Bynder.Sdk.Model +{ + /// + /// Media items returned by API /media including the individual counts + /// + public class MediaWithCount + { + /// + /// Media items + /// + [JsonProperty("media")] + public IList Items { get; set; } + + /// + /// Counts + /// + [JsonProperty("count")] + public Counts Counts { get; set; } + } +} diff --git a/Bynder/Sdk/Query/Asset/MediaQuery.cs b/Bynder/Sdk/Query/Asset/MediaQuery.cs index 8f40145..ac45c6e 100644 --- a/Bynder/Sdk/Query/Asset/MediaQuery.cs +++ b/Bynder/Sdk/Query/Asset/MediaQuery.cs @@ -64,8 +64,20 @@ public class MediaQuery /// /// The type of the asset /// - [ApiField("type", Converter = typeof(LowerCaseEnumConverter))] - public AssetType? Type { get; set; } + [ApiField("type")] + public string Types { get; set; } + + /// + /// The tags of the asset + /// + [ApiField("tags")] + public string Tags { get; set; } + + /// + /// The tags of the asset + /// + [ApiField("orientation")] + public string Orientations { get; set; } /// /// Metaproperty option ids that the asset has to have diff --git a/Bynder/Sdk/Query/Asset/MediaWithCountQuery.cs b/Bynder/Sdk/Query/Asset/MediaWithCountQuery.cs new file mode 100644 index 0000000..d524f8e --- /dev/null +++ b/Bynder/Sdk/Query/Asset/MediaWithCountQuery.cs @@ -0,0 +1,27 @@ +using Bynder.Sdk.Api.Converters; +using Bynder.Sdk.Query.Decoder; + +namespace Bynder.Sdk.Query.Asset +{ + public class MediaWithCountQuery : MediaQuery + { + /// + /// Indicating whether or not the response should include the total count of results. + /// + [ApiField("total", Converter = typeof(BoolConverter))] + public bool IncludeTotal { get; set; } + + /// + /// Indicating whether or not the response should include the individual count of results. + /// + [ApiField("count", Converter = typeof(BoolConverter))] + public bool IncludeCount { get; set; } + + /// + /// Desired order of returned assets. + /// See for possible values. + /// + [ApiField("orderBy")] + public string OrderBy { get; set; } + } +} From a7d007d267855f689eb3103902135706f5e45413 Mon Sep 17 00:00:00 2001 From: Yosif Velev Date: Mon, 21 Mar 2022 11:42:26 +0200 Subject: [PATCH 14/25] Revert back to using decimal for ActiveOriginalFocusPoint --- Bynder/Sdk/Model/Media.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bynder/Sdk/Model/Media.cs b/Bynder/Sdk/Model/Media.cs index 2c28193..97e7175 100644 --- a/Bynder/Sdk/Model/Media.cs +++ b/Bynder/Sdk/Model/Media.cs @@ -30,7 +30,7 @@ public class Media /// by an x,y coordinate. /// [JsonProperty("activeOriginalFocusPoint")] - public IDictionary ActiveOriginalFocusPoint { get; set; } + public IDictionary ActiveOriginalFocusPoint { get; set; } /// /// Number of times the media has been downloaded From fe217f6af0fbcca125b0c1af43a47710ab355298 Mon Sep 17 00:00:00 2001 From: Yosif Velev Date: Mon, 21 Mar 2022 16:39:46 +0200 Subject: [PATCH 15/25] Extend Bynder SDK to exclude meta property options, due to request timeout. --- Bynder/Sdk/Service/Asset/AssetService.cs | 8 ++++++-- Bynder/Sdk/Service/Asset/IAssetService.cs | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Bynder/Sdk/Service/Asset/AssetService.cs b/Bynder/Sdk/Service/Asset/AssetService.cs index 1ce3b94..33e5348 100644 --- a/Bynder/Sdk/Service/Asset/AssetService.cs +++ b/Bynder/Sdk/Service/Asset/AssetService.cs @@ -56,11 +56,15 @@ public async Task> GetBrandsAsync() /// Check for more information /// /// Check for more information - public async Task> GetMetapropertiesAsync() + public async Task> GetMetapropertiesAsync(bool includeOptions) { + var path = includeOptions + ? "/api/v4/metaproperties/" + : "/api/v4/metaproperties/?options=0"; + return await _requestSender.SendRequestAsync(new ApiRequest> { - Path = "/api/v4/metaproperties/", + Path = path, HTTPMethod = HttpMethod.Get, }).ConfigureAwait(false); } diff --git a/Bynder/Sdk/Service/Asset/IAssetService.cs b/Bynder/Sdk/Service/Asset/IAssetService.cs index d217ebd..d83d2a3 100644 --- a/Bynder/Sdk/Service/Asset/IAssetService.cs +++ b/Bynder/Sdk/Service/Asset/IAssetService.cs @@ -35,9 +35,10 @@ public interface IAssetService /// Gets a dictionary of the metaproperties async. The key of the dictionary /// returned is the name of the metaproperty. /// + /// information whether to include methoproperties options /// Task with dictionary of metaproperties /// Can be thrown when requests to server can't be completed or HTTP code returned by server is an error - Task> GetMetapropertiesAsync(); + Task> GetMetapropertiesAsync(bool includeOptions); /// /// Retrieve specific Metaproperty From e1201b6619cbdbdb471f06c0d86f0ad2c4d609a5 Mon Sep 17 00:00:00 2001 From: Yosif Velev Date: Thu, 24 Mar 2022 14:33:57 +0200 Subject: [PATCH 16/25] Extend the SDK to expose metaproperty option retrieve methods --- .../Asset/MetapropertyOptionByIdsQuery.cs | 15 +++++++++ .../Asset/MetapropertyOptionSearchQuery.cs | 31 +++++++++++++++++++ Bynder/Sdk/Service/Asset/AssetService.cs | 29 +++++++++++++++++ Bynder/Sdk/Service/Asset/IAssetService.cs | 16 ++++++++++ 4 files changed, 91 insertions(+) create mode 100644 Bynder/Sdk/Query/Asset/MetapropertyOptionByIdsQuery.cs create mode 100644 Bynder/Sdk/Query/Asset/MetapropertyOptionSearchQuery.cs diff --git a/Bynder/Sdk/Query/Asset/MetapropertyOptionByIdsQuery.cs b/Bynder/Sdk/Query/Asset/MetapropertyOptionByIdsQuery.cs new file mode 100644 index 0000000..48d2fa2 --- /dev/null +++ b/Bynder/Sdk/Query/Asset/MetapropertyOptionByIdsQuery.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; +using Bynder.Sdk.Api.Converters; +using Bynder.Sdk.Query.Decoder; + +namespace Bynder.Sdk.Query.Asset +{ + public class MetapropertyOptionByIdsQuery + { + /// + /// List of meta property ids + /// + [ApiField("ids", Converter = typeof(ListConverter))] + public IEnumerable Ids { get; set; } + } +} diff --git a/Bynder/Sdk/Query/Asset/MetapropertyOptionSearchQuery.cs b/Bynder/Sdk/Query/Asset/MetapropertyOptionSearchQuery.cs new file mode 100644 index 0000000..e0f122d --- /dev/null +++ b/Bynder/Sdk/Query/Asset/MetapropertyOptionSearchQuery.cs @@ -0,0 +1,31 @@ +using Bynder.Sdk.Query.Decoder; + +namespace Bynder.Sdk.Query.Asset +{ + public class MetapropertyOptionSearchQuery + { + /// + /// Id of the media + /// + [ApiField("id")] + public string MetapropertyId { get; set; } + + /// + /// Name of the option + /// + [ApiField("name")] + public string Name { get; set; } + + /// + /// Maximum number of results + /// + [ApiField("limit")] + public int Limit { get; } = 50; + + /// + /// Offset page for results: return the N-th set of limit-results + /// + [ApiField("page")] + public int Page { get; } = 1; + } +} diff --git a/Bynder/Sdk/Service/Asset/AssetService.cs b/Bynder/Sdk/Service/Asset/AssetService.cs index 33e5348..dd570e0 100644 --- a/Bynder/Sdk/Service/Asset/AssetService.cs +++ b/Bynder/Sdk/Service/Asset/AssetService.cs @@ -167,6 +167,35 @@ public async Task GetDownloadFileUrlAsync(DownloadMediaQuery query) return downloadFileInformation.S3File; } + /// + /// Check for more information + /// + /// Check for more information + /// Check for more information + public async Task> GetMetapropertyOptionsByIdsAsync(MetapropertyOptionByIdsQuery query) + { + return await _requestSender.SendRequestAsync(new ApiRequest> + { + Path = $"/api/v4/metaproperties/options/", + HTTPMethod = HttpMethod.Get, + Query = query + }).ConfigureAwait(false); + } + + /// + /// Check for more information + /// + /// Check for more information + /// Check for more information + public async Task> GetMetapropertyOptionsByNameAsync(MetapropertyOptionSearchQuery query) + { + return await _requestSender.SendRequestAsync(new ApiRequest> + { + Path = $"/api/v4/metaproperties/{query.MetapropertyId}/options/?name={query.Name}&limit={query.Limit}&page={query.Page}", + HTTPMethod = HttpMethod.Get + }).ConfigureAwait(false); + } + /// /// Check for more information /// diff --git a/Bynder/Sdk/Service/Asset/IAssetService.cs b/Bynder/Sdk/Service/Asset/IAssetService.cs index d83d2a3..a85f667 100644 --- a/Bynder/Sdk/Service/Asset/IAssetService.cs +++ b/Bynder/Sdk/Service/Asset/IAssetService.cs @@ -92,6 +92,22 @@ public interface IAssetService /// Can be thrown when requests to server can't be completed or HTTP code returned by server is an error Task GetMediaWithCountAsync(MediaWithCountQuery query); + /// + /// Retrieve a list of metaproperty options by ids + /// + /// query containing the metaproperty options ids + /// Task with List of MetapropertyOption. + /// Can be thrown when requests to server can't be completed or HTTP code returned by server is an error + Task> GetMetapropertyOptionsByIdsAsync(MetapropertyOptionByIdsQuery query); + + /// + /// Retrieve a list of metaproperty options by meta property identifier and metaproperty option name + /// + /// query containing the metaproperty ID, name of the option, limit and page number + /// Task with List of MetapropertyOption. + /// Can be thrown when requests to server can't be completed or HTTP code returned by server is an error + Task> GetMetapropertyOptionsByNameAsync(MetapropertyOptionSearchQuery query); + /// /// Uploads a file async. /// From e1886ef4ceb2ab33b2ed0359e420f5607aa92550 Mon Sep 17 00:00:00 2001 From: Yosif Velev Date: Thu, 24 Mar 2022 15:38:38 +0200 Subject: [PATCH 17/25] Rename the method for searching the metaproperty options --- Bynder/Sdk/Service/Asset/AssetService.cs | 2 +- Bynder/Sdk/Service/Asset/IAssetService.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Bynder/Sdk/Service/Asset/AssetService.cs b/Bynder/Sdk/Service/Asset/AssetService.cs index dd570e0..ec23e9f 100644 --- a/Bynder/Sdk/Service/Asset/AssetService.cs +++ b/Bynder/Sdk/Service/Asset/AssetService.cs @@ -187,7 +187,7 @@ public async Task> GetMetapropertyOptionsByIdsAsync(Me /// /// Check for more information /// Check for more information - public async Task> GetMetapropertyOptionsByNameAsync(MetapropertyOptionSearchQuery query) + public async Task> GetMetapropertyOptionsAsync(MetapropertyOptionSearchQuery query) { return await _requestSender.SendRequestAsync(new ApiRequest> { diff --git a/Bynder/Sdk/Service/Asset/IAssetService.cs b/Bynder/Sdk/Service/Asset/IAssetService.cs index a85f667..a299487 100644 --- a/Bynder/Sdk/Service/Asset/IAssetService.cs +++ b/Bynder/Sdk/Service/Asset/IAssetService.cs @@ -106,7 +106,7 @@ public interface IAssetService /// query containing the metaproperty ID, name of the option, limit and page number /// Task with List of MetapropertyOption. /// Can be thrown when requests to server can't be completed or HTTP code returned by server is an error - Task> GetMetapropertyOptionsByNameAsync(MetapropertyOptionSearchQuery query); + Task> GetMetapropertyOptionsAsync(MetapropertyOptionSearchQuery query); /// /// Uploads a file async. From a3997f211a118cc9b65a9b22828e2563c5edf374 Mon Sep 17 00:00:00 2001 From: Yosif Velev Date: Thu, 24 Mar 2022 15:43:43 +0200 Subject: [PATCH 18/25] Make limit and page assignable --- Bynder/Sdk/Query/Asset/MetapropertyOptionSearchQuery.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Bynder/Sdk/Query/Asset/MetapropertyOptionSearchQuery.cs b/Bynder/Sdk/Query/Asset/MetapropertyOptionSearchQuery.cs index e0f122d..3f862ed 100644 --- a/Bynder/Sdk/Query/Asset/MetapropertyOptionSearchQuery.cs +++ b/Bynder/Sdk/Query/Asset/MetapropertyOptionSearchQuery.cs @@ -20,12 +20,12 @@ public class MetapropertyOptionSearchQuery /// Maximum number of results /// [ApiField("limit")] - public int Limit { get; } = 50; + public int Limit { get; set; } = 50; /// /// Offset page for results: return the N-th set of limit-results /// [ApiField("page")] - public int Page { get; } = 1; + public int Page { get; set; } = 1; } } From e00fc03588e4e251362680608cf828ae6ef6ca24 Mon Sep 17 00:00:00 2001 From: Yosif Velev Date: Mon, 28 Mar 2022 12:58:59 +0300 Subject: [PATCH 19/25] SDK Support for PropertiesByKey --- Bynder/Sdk/Query/Asset/MediaQuery.cs | 11 +++++++++++ Bynder/Sdk/Query/Asset/ModifyMediaQuery.cs | 4 ++-- Bynder/Sdk/Query/Decoder/QueryDecoder.cs | 4 ++-- Bynder/Sdk/Query/Upload/SaveMediaQuery.cs | 4 ++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Bynder/Sdk/Query/Asset/MediaQuery.cs b/Bynder/Sdk/Query/Asset/MediaQuery.cs index ac45c6e..063c464 100644 --- a/Bynder/Sdk/Query/Asset/MediaQuery.cs +++ b/Bynder/Sdk/Query/Asset/MediaQuery.cs @@ -84,5 +84,16 @@ public class MediaQuery /// [ApiField("propertyOptionId", Converter = typeof(ListConverter))] public IList PropertyOptionId { get; set; } = new List(); + + /// + /// Properties values by key + /// Examples + /// key: property_Name value: Amsterdam + /// or + /// key: property_Name value: 00000000-0000-0000-0000000000000000 + /// key property_Languages value: 00000000-0000-0000-0000000000000001 + /// + [ApiField("property_", Converter = typeof(MetapropertyOptionsConverter))] + public IDictionary> PropertiesByKey { get; set; } } } diff --git a/Bynder/Sdk/Query/Asset/ModifyMediaQuery.cs b/Bynder/Sdk/Query/Asset/ModifyMediaQuery.cs index fe571b7..e024569 100644 --- a/Bynder/Sdk/Query/Asset/ModifyMediaQuery.cs +++ b/Bynder/Sdk/Query/Asset/ModifyMediaQuery.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Bynder.Sdk.Api.Converters; using Bynder.Sdk.Query.Decoder; @@ -56,7 +56,7 @@ public ModifyMediaQuery(string mediaId) /// /// Metaproperty options to set on the asset. /// - [ApiField("metaproperty", Converter = typeof(MetapropertyOptionsConverter))] + [ApiField("metaproperty.", Converter = typeof(MetapropertyOptionsConverter))] public IDictionary> MetapropertyOptions { get; set; } /// diff --git a/Bynder/Sdk/Query/Decoder/QueryDecoder.cs b/Bynder/Sdk/Query/Decoder/QueryDecoder.cs index 345219b..e37619d 100644 --- a/Bynder/Sdk/Query/Decoder/QueryDecoder.cs +++ b/Bynder/Sdk/Query/Decoder/QueryDecoder.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; @@ -67,7 +67,7 @@ private void ConvertProperty(PropertyInfo propertyInfo, object query, IDictionar { foreach (var item in dictConverter.Convert(value)) { - AddParam(parameters, $"{apiField.ApiName}.{item.Key}", item.Value); + AddParam(parameters, $"{apiField.ApiName}{item.Key}", item.Value); } } diff --git a/Bynder/Sdk/Query/Upload/SaveMediaQuery.cs b/Bynder/Sdk/Query/Upload/SaveMediaQuery.cs index 0d8e01b..f99208e 100644 --- a/Bynder/Sdk/Query/Upload/SaveMediaQuery.cs +++ b/Bynder/Sdk/Query/Upload/SaveMediaQuery.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; @@ -46,7 +46,7 @@ internal class SaveMediaQuery /// /// Metaproperty options to set on the asset. /// - [ApiField("metaproperty", Converter = typeof(MetapropertyOptionsConverter))] + [ApiField("metaproperty.", Converter = typeof(MetapropertyOptionsConverter))] public IDictionary> MetapropertyOptions { get; set; } = new Dictionary>(); /// From 662726a565752b47163efe64fe098ac2cd37d58a Mon Sep 17 00:00:00 2001 From: Yosif Velev Date: Tue, 29 Mar 2022 11:08:08 +0300 Subject: [PATCH 20/25] Update documentation --- Bynder/Sdk/Query/Asset/MediaQuery.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Bynder/Sdk/Query/Asset/MediaQuery.cs b/Bynder/Sdk/Query/Asset/MediaQuery.cs index 063c464..8dbb017 100644 --- a/Bynder/Sdk/Query/Asset/MediaQuery.cs +++ b/Bynder/Sdk/Query/Asset/MediaQuery.cs @@ -88,10 +88,10 @@ public class MediaQuery /// /// Properties values by key /// Examples - /// key: property_Name value: Amsterdam + /// key: property_NAME value: Amsterdam /// or - /// key: property_Name value: 00000000-0000-0000-0000000000000000 - /// key property_Languages value: 00000000-0000-0000-0000000000000001 + /// key: property_NAME value: 00000000-0000-0000-0000000000000000 + /// key property_SomethingElse value: 00000000-0000-0000-0000000000000001 /// [ApiField("property_", Converter = typeof(MetapropertyOptionsConverter))] public IDictionary> PropertiesByKey { get; set; } From 4ece7a400741960688f88a1feba7328addc6c687 Mon Sep 17 00:00:00 2001 From: Yosif Velev Date: Fri, 14 Oct 2022 17:18:28 +0300 Subject: [PATCH 21/25] Add IsMultiFilter to the Metaproperty model --- Bynder/Sdk/Model/Metaproperty.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Bynder/Sdk/Model/Metaproperty.cs b/Bynder/Sdk/Model/Metaproperty.cs index 7b82279..058376f 100644 --- a/Bynder/Sdk/Model/Metaproperty.cs +++ b/Bynder/Sdk/Model/Metaproperty.cs @@ -42,6 +42,12 @@ public class Metaproperty [JsonProperty("isMultiSelect", ItemConverterType = typeof(BooleanJsonConverter))] public bool IsMultiSelect { get; set; } + /// + /// Returns true if Multifilter is selected for the metaproperty + /// + [JsonProperty("isMultiFilter", ItemConverterType = typeof(BooleanJsonConverter))] + public bool IsMultiFilter { get; set; } + /// /// Returns true if Required is selected for the metaproperty /// From 7649081336e6960a695a871b4bc9a42b0653d330 Mon Sep 17 00:00:00 2001 From: Yosif Velev Date: Fri, 21 Oct 2022 15:27:05 +0300 Subject: [PATCH 22/25] Change the package version --- Bynder/Sdk/Bynder.Sdk.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bynder/Sdk/Bynder.Sdk.csproj b/Bynder/Sdk/Bynder.Sdk.csproj index 97d7dfc..8f4c0e7 100644 --- a/Bynder/Sdk/Bynder.Sdk.csproj +++ b/Bynder/Sdk/Bynder.Sdk.csproj @@ -7,7 +7,7 @@ Bynder.Sdk Copyright © Bynder true - 2.2.11 + 2.2.11-fork BynderDevops The main goal of this SDK is to speed up the integration of Bynder customers who use C# making it easier to connect to the Bynder API (http://docs.bynder.apiary.io/) and executing requests on it. BynderLogo.png From 3ff2aabf91b3bb9cd82feff776143fc80fc8c68a Mon Sep 17 00:00:00 2001 From: Yosif Velev Date: Thu, 8 Feb 2024 18:31:19 +0200 Subject: [PATCH 23/25] Update Newtonsoft.Json to 13.0.3 --- Bynder/Sdk/Bynder.Sdk.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bynder/Sdk/Bynder.Sdk.csproj b/Bynder/Sdk/Bynder.Sdk.csproj index 33c0463..bbb5cd8 100644 --- a/Bynder/Sdk/Bynder.Sdk.csproj +++ b/Bynder/Sdk/Bynder.Sdk.csproj @@ -26,7 +26,7 @@ - + From b529495f5cbe685a19f13ee08a59a2b966301c77 Mon Sep 17 00:00:00 2001 From: Reinhard Holzner Date: Tue, 21 May 2024 15:11:53 +0200 Subject: [PATCH 24/25] Add parameters not yet present in Bynder SDK --- Bynder/Sdk/Model/Media.cs | 6 ++++++ Bynder/Sdk/Query/Asset/MediaWithCountQuery.cs | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/Bynder/Sdk/Model/Media.cs b/Bynder/Sdk/Model/Media.cs index 97e7175..f72ac9b 100644 --- a/Bynder/Sdk/Model/Media.cs +++ b/Bynder/Sdk/Model/Media.cs @@ -147,6 +147,12 @@ public class Media [JsonProperty("mediaItems")] public IList MediaItems { get; set; } + /// + /// Current active version + /// + [JsonProperty("version")] + public int? Version { get; set; } + /// /// Current active version /// diff --git a/Bynder/Sdk/Query/Asset/MediaWithCountQuery.cs b/Bynder/Sdk/Query/Asset/MediaWithCountQuery.cs index d524f8e..5210aa0 100644 --- a/Bynder/Sdk/Query/Asset/MediaWithCountQuery.cs +++ b/Bynder/Sdk/Query/Asset/MediaWithCountQuery.cs @@ -17,6 +17,18 @@ public class MediaWithCountQuery : MediaQuery [ApiField("count", Converter = typeof(BoolConverter))] public bool IncludeCount { get; set; } + /// + /// Indicating whether or not the response should include media items. + /// + [ApiField("includeMediaItems", Converter = typeof(BoolConverter))] + public bool IncludeMediaItems { get; set; } + + /// + /// Indicating whether or not the response should include the version number. + /// + [ApiField("includeVersionNumber", Converter = typeof(BoolConverter))] + public bool IncludeVersionNumber { get; set; } + /// /// Desired order of returned assets. /// See for possible values. From 566156837ce0336563f501d1ba7ee9624c69137a Mon Sep 17 00:00:00 2001 From: Reinhard Holzner Date: Wed, 2 Oct 2024 12:55:54 +0200 Subject: [PATCH 25/25] Allow field null value as it suddenly comes through API --- Bynder/Sdk/Model/MediaItem.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Bynder/Sdk/Model/MediaItem.cs b/Bynder/Sdk/Model/MediaItem.cs index be46cc7..b9b2495 100644 --- a/Bynder/Sdk/Model/MediaItem.cs +++ b/Bynder/Sdk/Model/MediaItem.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.ComponentModel; @@ -46,13 +46,13 @@ public class MediaItem /// Width /// [JsonProperty("width")] - public int Width { get; set; } + public int? Width { get; set; } /// /// Height /// [JsonProperty("height")] - public int Height { get; set; } + public int? Height { get; set; } /// /// true if it is corresponds to the current version of the asset