Skip to content

Commit

Permalink
Merge branch 'Bynder:master' into feature/add-uploadfile-response
Browse files Browse the repository at this point in the history
  • Loading branch information
kunalshetye committed Oct 22, 2021
2 parents 44b6384 + 7810cb0 commit a140e4d
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
dotnet-version: '5.0.x'
- name: Build
run: dotnet build --configuration Release

Expand All @@ -36,7 +36,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
dotnet-version: '5.0.x'

- name: Install dependencies
run: dotnet restore
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
dotnet-version: '5.0.x'
- name: Build
run: dotnet build --configuration Release

Expand Down
2 changes: 1 addition & 1 deletion Bynder/Sample/Bynder.Sample.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<AssemblyVersion>2.0.0</AssemblyVersion>
<FileVersion>2.0.0</FileVersion>
<Company>Bynder</Company>
Expand Down
3 changes: 2 additions & 1 deletion Bynder/Sdk/Api/Converters/TagsOrderByConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public bool CanConvert(Type typeToConvert)
/// <returns>converted string</returns>
public string Convert(object value)
{
switch (value) {
switch (value)
{
case TagsOrderBy.TagAscending:
return "tag asc";
case TagsOrderBy.TagDescending:
Expand Down
6 changes: 2 additions & 4 deletions Bynder/Sdk/Api/RequestSender/ApiRequestSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Threading;
using System.Threading.Tasks;
using Bynder.Sdk.Api.Requests;
using Bynder.Sdk.Extensions;
using Bynder.Sdk.Query.Decoder;
using Bynder.Sdk.Service.OAuth;
using Bynder.Sdk.Settings;
Expand Down Expand Up @@ -132,10 +133,7 @@ private static class HttpRequestMessageFactory
internal static HttpRequestMessage Create(
string baseUrl, HttpMethod method, IDictionary<string, string> requestParams, string urlPath)
{
var builder = new UriBuilder(baseUrl)
{
Path = urlPath
};
var builder = new UriBuilder(baseUrl).AppendPath(urlPath);

if (HttpMethod.Get == method)
{
Expand Down
15 changes: 6 additions & 9 deletions Bynder/Sdk/Bynder.Sdk.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyVersion>2.2.4.0</AssemblyVersion>
<FileVersion>2.2.4.0</FileVersion>
<TargetFrameworks>netstandard2.1;net48</TargetFrameworks>
<AssemblyVersion>2.2.7.0</AssemblyVersion>
<FileVersion>2.2.7.0</FileVersion>
<Company>Bynder</Company>
<Product>Bynder.Sdk</Product>
<Copyright>Copyright © Bynder</Copyright>
<PackOnBuild>true</PackOnBuild>
<PackageVersion>2.2.5</PackageVersion>
<PackageVersion>2.2.7</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>
<PackageIconUrl>https://bynder.com/static/3.0/img/favicon-black.ico</PackageIconUrl>
Expand All @@ -16,19 +16,16 @@
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Owners>BynderDevops</Owners>
<PackageProjectUrl>https://github.com/Bynder/bynder-c-sharp-sdk</PackageProjectUrl>
<PackageReleaseNotes>Downgraded .NET standard from 2.1 back to 2.0, to ensure compatibility with .NET framework.</PackageReleaseNotes>
<PackageReleaseNotes>Resolved an issue regarding the construction of API urls.</PackageReleaseNotes>
<Summary>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.</Summary>
<PackageTags>Bynder API C# SDK</PackageTags>
<Title>Bynder.Sdk</Title>
<PackageId>Bynder.Sdk</PackageId>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NuGet.Build.Packaging" Version="0.2.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
Expand Down
3 changes: 3 additions & 0 deletions Bynder/Sdk/Bynder.Sdk.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@
<copyright>Copyright © Bynder</copyright>
<tags>Bynder API C# SDK</tags>
</metadata>
<files>
<file src=".\**" target="lib/{framework name}[{version}]" />
</files>
</package>
28 changes: 28 additions & 0 deletions Bynder/Sdk/Extensions/UriBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;

namespace Bynder.Sdk.Extensions
{
public static class UriBuilderExtensions
{
/// <summary>
/// Allows to append a path to a url without overriding the existing path
/// (which happens when you would set the Path property).
///
/// For example, UriBuilder("https://example.com/base") { Path = "path/to/something" }
/// will result in "https://example.com/path/to/something" (removing the "base" part)
///
/// While UriBuilder("https://example.com/base").AppendPath("path/to/something")
/// will result in "https://example.com/base/path/to/something"
///
/// It will automatically ensure that the paths are combined correctly using only one "/".
/// </summary>
/// <param name="uriBuilder">extended UriBuilder instance</param>
/// <param name="path">path to be appended to the full url</param>
/// <returns>UriBuilder instance with the appended path</returns>
public static UriBuilder AppendPath(this UriBuilder uriBuilder, String path)
{
uriBuilder.Path = $"{uriBuilder.Path.TrimEnd('/')}/{path.TrimStart('/')}";
return uriBuilder;
}
}
}
4 changes: 2 additions & 2 deletions Bynder/Sdk/Service/OAuth/OAuthService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading.Tasks;
using Bynder.Sdk.Api.Requests;
using Bynder.Sdk.Api.RequestSender;
using Bynder.Sdk.Extensions;
using Bynder.Sdk.Model;
using Bynder.Sdk.Query;
using Bynder.Sdk.Settings;
Expand Down Expand Up @@ -48,7 +49,6 @@ public string GetAuthorisationUrl(string state, string scopes)

return new UriBuilder(_configuration.BaseUrl)
{
Path = AuthPath,
Query = Utils.Url.ConvertToQuery(
new Dictionary<string, string>
{
Expand All @@ -59,7 +59,7 @@ public string GetAuthorisationUrl(string state, string scopes)
{ "state", state }
}
)
}.ToString();
}.AppendPath(AuthPath).ToString();
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Bynder/Test/Bynder.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<IsTestProject>true</IsTestProject>
<AssemblyVersion>2.0.0</AssemblyVersion>
<FileVersion>2.0.0</FileVersion>
Expand Down
20 changes: 20 additions & 0 deletions Bynder/Test/Extensions/UriBuilderExtensionsTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using Bynder.Sdk.Extensions;
using Xunit;

namespace Bynder.Test.Extensions
{
public class UriBuilderExtensionsTest
{
[Fact]
public void PathsAreCorrectlyAppended()
{
var expectedUrl = "https://example.com:443/base/path/to/something";
Assert.Equal(expectedUrl, new UriBuilder("https://example.com/base").AppendPath("path/to/something").ToString());
Assert.Equal(expectedUrl, new UriBuilder("https://example.com/base").AppendPath("/path/to/something").ToString());
Assert.Equal(expectedUrl, new UriBuilder("https://example.com/base/").AppendPath("path/to/something").ToString());
Assert.Equal(expectedUrl, new UriBuilder("https://example.com/base/").AppendPath("/path/to/something").ToString());
}
}

}

0 comments on commit a140e4d

Please sign in to comment.