Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose OAuth access token and introduce new MediaWithTotal #74

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
92b43b0
Add Labels dictionary
Yosif-Smint Feb 7, 2022
742d2a5
Expose get and set access token functionality
Yosif-Smint Feb 9, 2022
37c48bb
New GetMediaList method that returns total count of items
Yosif-Smint Feb 9, 2022
578c2e8
Add unit tests
Yosif-Smint Feb 9, 2022
790de2f
Revert ActiveOriginalFocusPoint response type to IDictionary<string, …
Yosif-Smint Feb 10, 2022
a38bda8
Add AssetOrderBy constants
Yosif-Smint Feb 16, 2022
3932f49
Create bool to string converter
Yosif-Smint Feb 16, 2022
38dc65b
Rename a bunch of stuff
Yosif-Smint Feb 21, 2022
154d013
Allow to query assets with counts from Bynder. This API has been miss…
smintrh78 Mar 3, 2022
67b6553
Fix active original focus point
smintrh78 Mar 3, 2022
43f7f71
Support media with count
smintrh78 Mar 3, 2022
e04fdc5
Support tags, orientations and multi asset type selection
smintrh78 Mar 3, 2022
84c178f
Revert changes
Yosif-Smint Mar 21, 2022
ea3b1df
Merge branch 'master' of https://github.com/smintio/bynder-c-sharp-sdk
smintrh78 Mar 21, 2022
a7d007d
Revert back to using decimal for ActiveOriginalFocusPoint
Yosif-Smint Mar 21, 2022
1323c1f
Merge branch 'master' of https://github.com/smintio/bynder-c-sharp-sdk
smintrh78 Mar 21, 2022
fe217f6
Extend Bynder SDK to exclude meta property options, due to request ti…
Yosif-Smint Mar 21, 2022
8449ae3
Merge pull request #1 from smintio/bugfix/get-metaproperties
rh78 Mar 21, 2022
5502f81
Merge pull request #2 from smintio/development
rh78 Mar 21, 2022
e1201b6
Extend the SDK to expose metaproperty option retrieve methods
Yosif-Smint Mar 24, 2022
e1886ef
Rename the method for searching the metaproperty options
Yosif-Smint Mar 24, 2022
a3997f2
Make limit and page assignable
Yosif-Smint Mar 24, 2022
e00fc03
SDK Support for PropertiesByKey
Yosif-Smint Mar 28, 2022
15185d8
Merge pull request #3 from smintio/feature/metaproperty-option-methods
rh78 Mar 28, 2022
d8b087d
Merge pull request #4 from smintio/development
rh78 Mar 28, 2022
662726a
Update documentation
Yosif-Smint Mar 29, 2022
4ece7a4
Add IsMultiFilter to the Metaproperty model
Yosif-Smint Oct 14, 2022
74f9fbc
Merge pull request #5 from smintio/feature/metaproperty-IsMultiFilter
rh78 Oct 14, 2022
da2f835
Merge pull request #6 from smintio/master
rh78 Oct 14, 2022
7649081
Change the package version
Yosif-Smint Oct 21, 2022
0d81150
Merge branch 'Bynder:master' into master
smintrh78 Feb 7, 2024
aa45425
Merge branch 'master' of https://github.com/smintio/bynder-c-sharp-sd…
smintrh78 Feb 7, 2024
6b334c5
Merge pull request #7 from smintio/development
smintrh78 Feb 7, 2024
3ff2aab
Update Newtonsoft.Json to 13.0.3
Yosif-Smint Feb 8, 2024
debb3ee
Merge pull request #8 from smintio/feature/update-newtonsoft
smintrh78 Feb 14, 2024
fc3acfa
Merge pull request #9 from smintio/development
smintrh78 Feb 15, 2024
b529495
Add parameters not yet present in Bynder SDK
smintrh78 May 21, 2024
bfc4257
Merge pull request #10 from smintio/development
smintrh78 May 21, 2024
5661568
Allow field null value as it suddenly comes through API
smintrh78 Oct 2, 2024
af841b2
Merge pull request #11 from smintio/development
smintrh78 Oct 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions Bynder/Sdk/Api/Converters/BoolConverter.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Class used to convert bool to string.
/// True is represented as "1" and false as "0"
/// </summary>
public class BoolConverter : ITypeToStringConverter
{
private const string _trueString = "1";
private const string _falseString = "0";

/// <summary>
/// Returns true if type is assignable from bool
/// </summary>
/// <param name="typeToConvert">Check <see cref="ITypeToStringConverter.CanConvert(Type)"/></param>
/// <returns>true if type is assignable from bool/></returns>
public bool CanConvert(Type typeToConvert)
{
return typeof(bool).IsAssignableFrom(typeToConvert);
}

/// <summary>
/// Converts bool to string represented as "1" or "0"
/// </summary>
/// <param name="value">bool value</param>
/// <returns>converted string</returns>
public string Convert(object value)
{
if (value is bool boolValue)
{
return boolValue
? _trueString
: _falseString;
}

return string.Empty;
}
}
}
4 changes: 2 additions & 2 deletions Bynder/Sdk/Bynder.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Product>Bynder.Sdk</Product>
<Copyright>Copyright © Bynder</Copyright>
<PackOnBuild>true</PackOnBuild>
<PackageVersion>2.2.12</PackageVersion>
<PackageVersion>2.2.12-fork</PackageVersion>
<Authors>BynderDevops</Authors>
<Description>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.</Description>
<PackageIcon>BynderLogo.png</PackageIcon>
Expand All @@ -26,7 +26,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
Expand Down
14 changes: 14 additions & 0 deletions Bynder/Sdk/Model/AssetOrderBy.cs
Original file line number Diff line number Diff line change
@@ -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";
}
}
2 changes: 1 addition & 1 deletion Bynder/Sdk/Model/AssetType.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 18 additions & 0 deletions Bynder/Sdk/Model/CountValue.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Bynder.Sdk.Model
{
/// <summary>
/// The count values as delivered by the API
/// </summary>
public class CountValue
{
/// <summary>
/// The property option key
/// </summary>
public string PropertyOptionKey { get; set; }

/// <summary>
/// the count
/// </summary>
public int Count { get; set; }
}
}
50 changes: 50 additions & 0 deletions Bynder/Sdk/Model/Counts.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Bynder.Sdk.Model
{
/// <summary>
/// Counts returned by the API
/// </summary>
public class Counts : Dictionary<string, object>
{
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<CountValue> 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<int>()
}
);
}
}
}
8 changes: 7 additions & 1 deletion Bynder/Sdk/Model/Media.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Media
/// by an x,y coordinate.
/// </summary>
[JsonProperty("activeOriginalFocusPoint")]
public IDictionary<string, int> ActiveOriginalFocusPoint { get; set; }
public IDictionary<string, decimal> ActiveOriginalFocusPoint { get; set; }

/// <summary>
/// Number of times the media has been downloaded
Expand Down Expand Up @@ -147,6 +147,12 @@ public class Media
[JsonProperty("mediaItems")]
public IList<MediaItem> MediaItems { get; set; }

/// <summary>
/// Current active version
/// </summary>
[JsonProperty("version")]
public int? Version { get; set; }

/// <summary>
/// Current active version
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions Bynder/Sdk/Model/MediaItem.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -46,13 +46,13 @@ public class MediaItem
/// Width
/// </summary>
[JsonProperty("width")]
public int Width { get; set; }
public int? Width { get; set; }

/// <summary>
/// Height
/// </summary>
[JsonProperty("height")]
public int Height { get; set; }
public int? Height { get; set; }

/// <summary>
/// true if it is corresponds to the current version of the asset
Expand Down
26 changes: 26 additions & 0 deletions Bynder/Sdk/Model/MediaWithCount.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Media items returned by API /media including the individual counts
/// </summary>
public class MediaWithCount
{
/// <summary>
/// Media items
/// </summary>
[JsonProperty("media")]
public IList<Media> Items { get; set; }

/// <summary>
/// Counts
/// </summary>
[JsonProperty("count")]
public Counts Counts { get; set; }
}
}
26 changes: 26 additions & 0 deletions Bynder/Sdk/Model/MediaWithTotal.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Media items returned by API /media including the total count
/// </summary>
public class MediaWithTotal
{
/// <summary>
/// Media items
/// </summary>
[JsonProperty("media")]
public IList<Media> Items { get; set; }

/// <summary>
/// Total of results
/// </summary>
[JsonProperty("total")]
public TotalCountResponse Total { get; set; }
}
}
20 changes: 19 additions & 1 deletion Bynder/Sdk/Model/Metaproperty.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -42,6 +42,12 @@ public class Metaproperty
[JsonProperty("isMultiSelect", ItemConverterType = typeof(BooleanJsonConverter))]
public bool IsMultiSelect { get; set; }

/// <summary>
/// Returns true if Multifilter is selected for the metaproperty
/// </summary>
[JsonProperty("isMultiFilter", ItemConverterType = typeof(BooleanJsonConverter))]
public bool IsMultiFilter { get; set; }

/// <summary>
/// Returns true if Required is selected for the metaproperty
/// </summary>
Expand Down Expand Up @@ -71,5 +77,17 @@ public class Metaproperty
/// </summary>
[JsonProperty("zindex")]
public int ZIndex { get; set; }

/// <summary>
/// Type of the metaproperty
/// </summary>
[JsonProperty("type")]
public string Type { get; set; }

/// <summary>
/// Returns label translation by culture (e.g. 'en_US', 'de_DE' and etc)
/// </summary>
[JsonProperty("labels")]
public IDictionary<string, string> Labels { get; set; } = new Dictionary<string, string>();
}
}
8 changes: 7 additions & 1 deletion Bynder/Sdk/Model/MetapropertyOption.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -53,5 +53,11 @@ public class MetapropertyOption
/// </summary>
[JsonProperty("linkedOptionIds")]
public List<string> LinkedOptionIds { get; set; }

/// <summary>
/// Returns label translation by culture (e.g. 'en_US', 'de_DE' and etc)
/// </summary>
[JsonProperty("labels")]
public IDictionary<string, string> Labels { get; set; } = new Dictionary<string, string>();
}
}
16 changes: 16 additions & 0 deletions Bynder/Sdk/Model/TotalCountResponse.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// The count
/// </summary>
[JsonProperty("count")]
public int Count { get; set; }
}
}
27 changes: 25 additions & 2 deletions Bynder/Sdk/Query/Asset/MediaQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,36 @@ public class MediaQuery
/// <summary>
/// The type of the asset
/// </summary>
[ApiField("type", Converter = typeof(LowerCaseEnumConverter))]
public AssetType? Type { get; set; }
[ApiField("type")]
public string Types { get; set; }

/// <summary>
/// The tags of the asset
/// </summary>
[ApiField("tags")]
public string Tags { get; set; }

/// <summary>
/// The tags of the asset
/// </summary>
[ApiField("orientation")]
public string Orientations { get; set; }

/// <summary>
/// Metaproperty option ids that the asset has to have
/// </summary>
[ApiField("propertyOptionId", Converter = typeof(ListConverter))]
public IList<string> PropertyOptionId { get; set; } = new List<string>();

/// <summary>
/// Properties values by key
/// Examples
/// key: property_NAME value: Amsterdam
/// or
/// key: property_NAME value: 00000000-0000-0000-0000000000000000
/// key property_SomethingElse value: 00000000-0000-0000-0000000000000001
/// </summary>
[ApiField("property_", Converter = typeof(MetapropertyOptionsConverter))]
public IDictionary<string, IList<string>> PropertiesByKey { get; set; }
}
}
Loading