-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Enable nullability in project (ref: supabase-community/supabase-csh…
- Loading branch information
1 parent
503049f
commit 563f37b
Showing
7 changed files
with
117 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,43 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<PackOnBuild>true</PackOnBuild> | ||
<PackageId>functions-csharp</PackageId> | ||
<Authors>Joseph Schultz <[email protected]></Authors> | ||
<Copyright>MIT</Copyright> | ||
<NeutralLanguage>en</NeutralLanguage> | ||
<Owners>Joseph Schultz <[email protected]></Owners> | ||
<Summary>A C# client for Supabase functions</Summary> | ||
<Title>Function</Title> | ||
<Description>A C# client for Supabase functions</Description> | ||
<RootNamespace>Supabase.Functions</RootNamespace> | ||
<PackageIconUrl>https://avatars.githubusercontent.com/u/54469796?s=200&v=4</PackageIconUrl> | ||
<PackageLicenseUrl>https://github.com/supabase-community/functions-csharp/blob/master/LICENSE</PackageLicenseUrl> | ||
<PackageProjectUrl>https://github.com/supabase-community/functions-csharp</PackageProjectUrl> | ||
<PackageTags>supabase, functions</PackageTags> | ||
<PackageVersion>1.0.1</PackageVersion> | ||
<ReleaseVersion>1.0.1</ReleaseVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Version)' == '' "> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<PackOnBuild>true</PackOnBuild> | ||
<PackageId>functions-csharp</PackageId> | ||
<Authors>Joseph Schultz <[email protected]></Authors> | ||
<Copyright>MIT</Copyright> | ||
<NeutralLanguage>en</NeutralLanguage> | ||
<Owners>Joseph Schultz <[email protected]></Owners> | ||
<Summary>A C# client for Supabase functions</Summary> | ||
<Title>Function</Title> | ||
<Description>A C# client for Supabase functions</Description> | ||
<RootNamespace>Supabase.Functions</RootNamespace> | ||
<PackageIconUrl>https://avatars.githubusercontent.com/u/54469796?s=200&v=4</PackageIconUrl> | ||
<PackageLicenseUrl>https://github.com/supabase-community/functions-csharp/blob/master/LICENSE</PackageLicenseUrl> | ||
<PackageProjectUrl>https://github.com/supabase-community/functions-csharp</PackageProjectUrl> | ||
<PackageTags>supabase, functions</PackageTags> | ||
<PackageVersion>1.1.0</PackageVersion> | ||
<ReleaseVersion>1.1.0</ReleaseVersion> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<Nullable>enable</Nullable> | ||
<LangVersion>8.0</LangVersion> | ||
<WarningsAsErrors>CS8600;CS8602;CS8603</WarningsAsErrors> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Version)' == '' "> | ||
<VersionPrefix Condition=" '$(VersionPrefix)' == '' ">1.0.1</VersionPrefix> | ||
<VersionSuffix Condition=" '$(VersionSuffix)' == '' "> | ||
</VersionSuffix> | ||
<Version Condition=" '$(VersionSuffix)' != '' ">$(VersionPrefix)-$(VersionSuffix)</Version> | ||
<Version Condition=" '$(Version)' == '' ">$(VersionPrefix)</Version> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<LangVersion>8.0</LangVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<LangVersion>8.0</LangVersion> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | ||
</ItemGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<LangVersion>8.0</LangVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<LangVersion>8.0</LangVersion> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
|
||
namespace Supabase.Functions.Interfaces | ||
{ | ||
public interface IFunctionsClient | ||
{ | ||
Task<string> Invoke(string url, string? token = null, Client.InvokeFunctionOptions? options = null); | ||
Task<T?> Invoke<T>(string url, string? token = null, Client.InvokeFunctionOptions? options = null) where T : class; | ||
Task<HttpContent> RawInvoke(string url, string? token = null, Client.InvokeFunctionOptions? options = null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 57 additions & 59 deletions
116
FunctionsTests/Client.cs → FunctionsTests/ClientTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,57 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IdentityModel.Tokens.Jwt; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.IdentityModel.Tokens; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using static Supabase.Functions.Client; | ||
|
||
namespace FunctionsTests | ||
{ | ||
[TestClass] | ||
public class Client | ||
{ | ||
[TestMethod("Invokes a function.")] | ||
public async Task Invokes() | ||
{ | ||
var token = Environment.GetEnvironmentVariable("TOKEN"); | ||
var endpoint = Environment.GetEnvironmentVariable("FUNCTION_ENDPOINT"); | ||
|
||
var result = await Invoke(endpoint, token, new InvokeFunctionOptions | ||
{ | ||
Body = new Dictionary<string, object> | ||
{ | ||
{"name", "supabase" } | ||
} | ||
}); | ||
|
||
Assert.IsTrue(result.Contains("supabase")); | ||
|
||
|
||
var result2 = await Invoke<Dictionary<string, string>>(endpoint, token, new InvokeFunctionOptions | ||
{ | ||
Body = new Dictionary<string, object> | ||
{ | ||
{ "name", "functions" } | ||
} | ||
}); | ||
|
||
Assert.IsInstanceOfType(result2, typeof(Dictionary<string, string>)); | ||
Assert.IsTrue(result2.ContainsKey("message")); | ||
Assert.IsTrue(result2["message"].Contains("functions")); | ||
|
||
|
||
var result3 = await RawInvoke(endpoint, token, new InvokeFunctionOptions | ||
{ | ||
Body = new Dictionary<string, object> | ||
{ | ||
{ "name", "functions" } | ||
} | ||
}); | ||
|
||
var bytes = await result3.ReadAsByteArrayAsync(); | ||
|
||
Assert.IsInstanceOfType(bytes, typeof(byte[])); | ||
} | ||
} | ||
} | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Supabase.Functions; | ||
using static Supabase.Functions.Client; | ||
|
||
namespace FunctionsTests | ||
{ | ||
[TestClass] | ||
public class ClientTests | ||
{ | ||
[TestMethod("Invokes a function.")] | ||
public async Task Invokes() | ||
{ | ||
var token = Environment.GetEnvironmentVariable("TOKEN"); | ||
var endpoint = Environment.GetEnvironmentVariable("FUNCTION_ENDPOINT"); | ||
var client = new Client(); | ||
|
||
var result = await client.Invoke(endpoint, token, new InvokeFunctionOptions | ||
{ | ||
Body = new Dictionary<string, object> | ||
{ | ||
{"name", "supabase" } | ||
} | ||
}); | ||
|
||
Assert.IsTrue(result.Contains("supabase")); | ||
|
||
|
||
var result2 = await client.Invoke<Dictionary<string, string>>(endpoint, token, new InvokeFunctionOptions | ||
{ | ||
Body = new Dictionary<string, object> | ||
{ | ||
{ "name", "functions" } | ||
} | ||
}); | ||
|
||
Assert.IsInstanceOfType(result2, typeof(Dictionary<string, string>)); | ||
Assert.IsTrue(result2.ContainsKey("message")); | ||
Assert.IsTrue(result2["message"].Contains("functions")); | ||
|
||
|
||
var result3 = await client.RawInvoke(endpoint, token, new InvokeFunctionOptions | ||
{ | ||
Body = new Dictionary<string, object> | ||
{ | ||
{ "name", "functions" } | ||
} | ||
}); | ||
|
||
var bytes = await result3.ReadAsByteArrayAsync(); | ||
|
||
Assert.IsInstanceOfType(bytes, typeof(byte[])); | ||
} | ||
} | ||
} |