Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build Test Publish

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch: # Allows manual triggering of the workflow

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json

- name: Install dependencies
run: dotnet restore

- name: Build
run: dotnet build -c Release --no-restore

- name: Test
run: dotnet test --no-restore --verbosity normal

- name: Publish to nuget
if: github.event_name == 'workflow_dispatch' # Only runs when manually triggered for deployment
run: dotnet nuget push ShopifyNet/bin/Release/*.nupkg -s https://api.nuget.org/v3/index.json --skip-duplicate -k "${{ secrets.NUGET_API_KEY }}"
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@ CodeCoverage/
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
nunit-*.xml
.vs/
.vscode/
10 changes: 10 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project>
<PropertyGroup>
<!--if upgrading .NET version, also upgrade the version used by global.json -->
<TargetFramework>net9.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
</PropertyGroup>
</Project>
13 changes: 13 additions & 0 deletions ShopifyNet.TypeGenerator/ShopifyNet.TypeGenerator.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GraphQLSharp" Version="2.1.0" />
<PackageReference Include="ShopifySharp" Version="6.22.0-b221" />
</ItemGroup>
</Project>
45 changes: 45 additions & 0 deletions ShopifyNet.TypeGenerator/TypeGenerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System.Text.Json;
using GraphQLSharp;
using ShopifySharp;

var options = new GraphQLTypeGeneratorOptions
{
Namespace = "ShopifyNet.AdminTypes",
ScalarNameTypeToTypeName = new Dictionary<string, string>
{
{ "UnsignedInt64", "ulong" },
{ "Money", "decimal" },
{ "Float", "decimal" },
{ "Decimal", "decimal" },
{ "DateTime", "DateTime" },
{ "Date", "DateOnly" },
{ "UtcOffset", "TimeSpan" },
{ "URL", "string" },
{ "HTML", "string" },
{ "JSON", "string" },
{ "FormattedString", "string" },
{ "ARN", "string" },
{ "StorefrontID", "string" },
{ "Color", "string" },
{ "BigInt", "long" },
},
GraphQLTypeToTypeNameOverride = new Dictionary<(string, string), string>
{
{ ("ShopifyPaymentsDispute", "evidenceDueBy"), "DateTime" },
{ ("ShopifyPaymentsDispute", "evidenceSentOn"), "DateTime" },
{ ("ShopifyPaymentsDispute", "finalizedOn"), "DateTime" },
},
EnumMembersAsString = true
};

var generator = new GraphQLTypeGenerator();
string csharpCode = await generator.GenerateTypesAsync(options, async query =>
{
string shopId = Environment.GetEnvironmentVariable("SHOPIFYNET_SHOPID", EnvironmentVariableTarget.User)!;
string token = Environment.GetEnvironmentVariable("SHOPIFYNET_TOKEN", EnvironmentVariableTarget.User)!;
var res = await new GraphService(shopId, token, "2024-10").PostAsync(query);
var doc = JsonDocument.Parse(res.ToString());
return doc;
});

File.WriteAllText(@"../../../../ShopifyNet/AdminTypes.cs", csharpCode);
48 changes: 48 additions & 0 deletions ShopifyNet.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShopifyNet", "ShopifyNet\ShopifyNet.csproj", "{F402CA4F-E89F-46CE-849B-EA7AAC13F7E6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShopifyNet.TypeGenerator", "ShopifyNet.TypeGenerator\ShopifyNet.TypeGenerator.csproj", "{2A893113-4D49-409B-9511-07122FDFB81A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F402CA4F-E89F-46CE-849B-EA7AAC13F7E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F402CA4F-E89F-46CE-849B-EA7AAC13F7E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F402CA4F-E89F-46CE-849B-EA7AAC13F7E6}.Debug|x64.ActiveCfg = Debug|Any CPU
{F402CA4F-E89F-46CE-849B-EA7AAC13F7E6}.Debug|x64.Build.0 = Debug|Any CPU
{F402CA4F-E89F-46CE-849B-EA7AAC13F7E6}.Debug|x86.ActiveCfg = Debug|Any CPU
{F402CA4F-E89F-46CE-849B-EA7AAC13F7E6}.Debug|x86.Build.0 = Debug|Any CPU
{F402CA4F-E89F-46CE-849B-EA7AAC13F7E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F402CA4F-E89F-46CE-849B-EA7AAC13F7E6}.Release|Any CPU.Build.0 = Release|Any CPU
{F402CA4F-E89F-46CE-849B-EA7AAC13F7E6}.Release|x64.ActiveCfg = Release|Any CPU
{F402CA4F-E89F-46CE-849B-EA7AAC13F7E6}.Release|x64.Build.0 = Release|Any CPU
{F402CA4F-E89F-46CE-849B-EA7AAC13F7E6}.Release|x86.ActiveCfg = Release|Any CPU
{F402CA4F-E89F-46CE-849B-EA7AAC13F7E6}.Release|x86.Build.0 = Release|Any CPU
{2A893113-4D49-409B-9511-07122FDFB81A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2A893113-4D49-409B-9511-07122FDFB81A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A893113-4D49-409B-9511-07122FDFB81A}.Debug|x64.ActiveCfg = Debug|Any CPU
{2A893113-4D49-409B-9511-07122FDFB81A}.Debug|x64.Build.0 = Debug|Any CPU
{2A893113-4D49-409B-9511-07122FDFB81A}.Debug|x86.ActiveCfg = Debug|Any CPU
{2A893113-4D49-409B-9511-07122FDFB81A}.Debug|x86.Build.0 = Debug|Any CPU
{2A893113-4D49-409B-9511-07122FDFB81A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A893113-4D49-409B-9511-07122FDFB81A}.Release|Any CPU.Build.0 = Release|Any CPU
{2A893113-4D49-409B-9511-07122FDFB81A}.Release|x64.ActiveCfg = Release|Any CPU
{2A893113-4D49-409B-9511-07122FDFB81A}.Release|x64.Build.0 = Release|Any CPU
{2A893113-4D49-409B-9511-07122FDFB81A}.Release|x86.ActiveCfg = Release|Any CPU
{2A893113-4D49-409B-9511-07122FDFB81A}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Loading
Loading