-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Marthijn van den Heuvel
committed
Oct 18, 2024
1 parent
f090b01
commit af4921e
Showing
65 changed files
with
2,176 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "nuget" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "weekly" | ||
groups: | ||
microsoft: | ||
patterns: | ||
- "Microsoft*" | ||
tests: | ||
patterns: | ||
- "AutoFixture" | ||
- "FluentAssertions" | ||
- "xunit*" | ||
- "*Test*" | ||
- "coverlet*" | ||
- package-ecosystem: "github-actions" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "weekly" |
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,48 @@ | ||
name: build | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- '*' | ||
|
||
env: | ||
DOTNET_NOLOGO: true | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-22.04 | ||
|
||
strategy: | ||
matrix: | ||
dotnet-version: [ '8.0.x' ] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup dotnet | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: ${{ matrix.dotnet-version }} | ||
- name: Install dependencies | ||
run: dotnet restore | ||
- name: Build | ||
run: dotnet build --configuration Release | ||
- name: Test with dotnet | ||
run: dotnet test --configuration Release | ||
/p:CollectCoverage=true | ||
/p:CoverletOutputFormat="\"cobertura,json\"" | ||
/p:CoverletOutput=coverage/ | ||
/p:IncludeTestAssembly=false | ||
- name: Upload dotnet test results | ||
uses: coverallsapp/github-action@v2.3.1 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
files: ${{ github.workspace }}/src/Sidio.OpenGraph.Tests/coverage/coverage.net8.0.cobertura.xml ${{ github.workspace }}/src/Sidio.OpenGraph.Tests/coverage/coverage.net481.cobertura.xml ${{ github.workspace }}/src/Sidio.OpenGraph.AspNetCore.Tests/coverage/coverage.cobertura.xml | ||
format: cobertura | ||
base-path: ${{ github.workspace }} | ||
debug: true | ||
if: ${{ always() }} |
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,43 @@ | ||
name: release | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- "[0-9]+.[0-9]+.[0-9]+" | ||
- "[0-9]+.[0-9]+.[0-9]+-preview" | ||
|
||
env: | ||
DOTNET_NOLOGO: true | ||
NuGetDirectory: ${{ github.workspace}}/nuget/release | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 15 | ||
strategy: | ||
matrix: | ||
dotnet-version: [ '8.0.x' ] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup dotnet | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: ${{ matrix.dotnet-version }} | ||
- name: Set RELEASE_VERSION variable from tag | ||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
- name: Print release version | ||
run: | | ||
echo $RELEASE_VERSION | ||
- name: Install dependencies | ||
run: dotnet restore | ||
- name: Build | ||
run: dotnet build --configuration Release /p:Version=${RELEASE_VERSION} | ||
- name: Test | ||
run: dotnet test --configuration Release /p:Version=${RELEASE_VERSION} --no-build | ||
- name: Pack | ||
run: dotnet pack --configuration Release /p:Version=${RELEASE_VERSION} --output ${{ env.NuGetDirectory }} -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg | ||
- name: Push | ||
run: dotnet nuget push ${{ env.NuGetDirectory }}/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${NUGET_API_KEY} | ||
env: | ||
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} |
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 |
---|---|---|
|
@@ -396,3 +396,4 @@ FodyWeavers.xsd | |
|
||
# JetBrains Rider | ||
*.sln.iml | ||
.idea/ |
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,2 +1,11 @@ | ||
# Sidio.RevenueCat | ||
Unofficial RevenueCat API and webhook SDK | ||
An unofficial .NET SDK for the RevenueCat API and webhooks. This library is not affiliated with RevenueCat. | ||
|
||
[![build](https://github.com/marthijn/Sidio.RevenueCat/actions/workflows/build.yml/badge.svg)](https://github.com/marthijn/Sidio.RevenueCat/actions/workflows/build.yml) | ||
[![NuGet Version](https://img.shields.io/nuget/v/Sidio.RevenueCat)](https://www.nuget.org/packages/Sidio.RevenueCat/) | ||
|
||
# Installation | ||
Add [the package](https://www.nuget.org/packages/Sidio.RevenueCat/) to your project. | ||
|
||
# Project status | ||
This package is currently in preview mode and is not yet feature complete. |
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,6 @@ | ||
# Security policy | ||
## Reporting a vulnerability | ||
Please report (suspected) security vulnerabilities by opening a GitHub Security Advisory private | ||
vulnerability report. | ||
You will receive a response from us within 48 hours. If the issue is confirmed, we will release a patch as soon | ||
as possible depending on complexity. |
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,45 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sidio.RevenueCat", "src\Sidio.RevenueCat\Sidio.RevenueCat.csproj", "{6FA8977A-7796-4585-8B5B-2A3962EA4B66}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Src", "Src", "{C1E71605-FACC-45BE-920E-CA28CD039CE4}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{03B0397E-E392-4C0E-8B88-A3E884F4EB64}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{8A28614B-AFF2-4D40-A97F-E9CC3299BB91}" | ||
ProjectSection(SolutionItems) = preProject | ||
.gitignore = .gitignore | ||
LICENSE = LICENSE | ||
README.md = README.md | ||
SECURITY.md = SECURITY.md | ||
EndProjectSection | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sidio.RevenueCat.Tests", "src\Sidio.RevenueCat.Tests\Sidio.RevenueCat.Tests.csproj", "{2B15D9FF-99D9-4D50-BBA2-159A1E8B48A8}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflows", "Workflows", "{4FB399C5-DA44-4C3E-BADC-67B3D6A99BDD}" | ||
ProjectSection(SolutionItems) = preProject | ||
.github\dependabot.yml = .github\dependabot.yml | ||
.github\workflows\build.yml = .github\workflows\build.yml | ||
.github\workflows\release.yml = .github\workflows\release.yml | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{6FA8977A-7796-4585-8B5B-2A3962EA4B66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{6FA8977A-7796-4585-8B5B-2A3962EA4B66}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{6FA8977A-7796-4585-8B5B-2A3962EA4B66}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{6FA8977A-7796-4585-8B5B-2A3962EA4B66}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{2B15D9FF-99D9-4D50-BBA2-159A1E8B48A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{2B15D9FF-99D9-4D50-BBA2-159A1E8B48A8}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{2B15D9FF-99D9-4D50-BBA2-159A1E8B48A8}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{2B15D9FF-99D9-4D50-BBA2-159A1E8B48A8}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{6FA8977A-7796-4585-8B5B-2A3962EA4B66} = {C1E71605-FACC-45BE-920E-CA28CD039CE4} | ||
{2B15D9FF-99D9-4D50-BBA2-159A1E8B48A8} = {03B0397E-E392-4C0E-8B88-A3E884F4EB64} | ||
EndGlobalSection | ||
EndGlobal |
40 changes: 40 additions & 0 deletions
40
src/Sidio.RevenueCat.Tests/Api/V1/Responses/SubscriberResponseTests.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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System.Reflection; | ||
using System.Text.Json; | ||
using Essentia.Web.RevenueCat.Api.V1.Responses; | ||
|
||
namespace Sidio.RevenueCat.Tests.Api.V1.Responses; | ||
|
||
public sealed class SubscriberResponseTests | ||
{ | ||
[Fact] | ||
public void Deserialize_ReturnsModel() | ||
{ | ||
// arrange | ||
var fileContent = GetFileContents("SubscriberResponse.json"); | ||
|
||
// act | ||
var result = JsonSerializer.Deserialize<SubscriberResponse>(fileContent); | ||
|
||
// assert | ||
result.Should().NotBeNull(); | ||
result!.Subscriber.OriginalAppUserId.Should().Be("XXX-XXXXX-XXXXX-XX"); | ||
result.Subscriber.Entitlements.Count.Should().Be(2); | ||
result.Subscriber.Entitlements.Should().ContainKeys("pro_cat", "pro_cat2"); | ||
} | ||
|
||
private static string GetFileContents(string filename) | ||
{ | ||
var fullPath = | ||
$"Sidio.RevenueCat.Tests.Api.V1.Responses.TestData.{filename}"; | ||
var assembly = Assembly.GetExecutingAssembly(); | ||
|
||
using var stream = assembly.GetManifestResourceStream(fullPath); | ||
using var reader = new StreamReader(stream!); | ||
|
||
var jsonFile = reader.ReadToEnd(); | ||
|
||
jsonFile.Should().NotBeNullOrEmpty("{0} should not be null or empty.", filename); | ||
|
||
return jsonFile; | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
src/Sidio.RevenueCat.Tests/Api/V1/Responses/TestData/SubscriberResponse.json
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,80 @@ | ||
{ | ||
"request_date": "2019-07-26T17:40:10Z", | ||
"request_date_ms": 1564162810884, | ||
"subscriber": { | ||
"entitlements": { | ||
"pro_cat": { | ||
"expires_date": null, | ||
"grace_period_expires_date": null, | ||
"product_identifier": "onetime", | ||
"purchase_date": "2019-04-05T21:52:45Z" | ||
}, | ||
"pro_cat2": { | ||
"expires_date": "2019-05-10T21:52:45Z", | ||
"grace_period_expires_date": null, | ||
"product_identifier": "onetime", | ||
"purchase_date": "2019-04-05T21:52:45Z" | ||
} | ||
}, | ||
"first_seen": "2019-02-21T00:08:41Z", | ||
"management_url": "https://apps.apple.com/account/subscriptions", | ||
"non_subscriptions": { | ||
"onetime": [ | ||
{ | ||
"id": "cadba0c81b", | ||
"is_sandbox": true, | ||
"purchase_date": "2019-04-05T21:52:45Z", | ||
"store": "app_store" | ||
} | ||
] | ||
}, | ||
"original_app_user_id": "XXX-XXXXX-XXXXX-XX", | ||
"original_application_version": "1.0", | ||
"original_purchase_date": "2019-01-30T23:54:10Z", | ||
"other_purchases": {}, | ||
"subscriptions": { | ||
"annual": { | ||
"auto_resume_date": null, | ||
"billing_issues_detected_at": null, | ||
"expires_date": "2019-08-14T21:07:40Z", | ||
"grace_period_expires_date": null, | ||
"is_sandbox": true, | ||
"original_purchase_date": "2019-02-21T00:42:05Z", | ||
"ownership_type": "PURCHASED", | ||
"period_type": "normal", | ||
"purchase_date": "2019-07-14T20:07:40Z", | ||
"refunded_at": null, | ||
"store": "app_store", | ||
"unsubscribe_detected_at": "2019-07-17T22:48:38Z" | ||
}, | ||
"onemonth": { | ||
"auto_resume_date": null, | ||
"billing_issues_detected_at": null, | ||
"expires_date": "2019-06-17T22:47:55Z", | ||
"grace_period_expires_date": null, | ||
"is_sandbox": true, | ||
"original_purchase_date": "2019-02-21T00:42:05Z", | ||
"ownership_type": "PURCHASED", | ||
"period_type": "normal", | ||
"purchase_date": "2019-06-17T22:42:55Z", | ||
"refunded_at": null, | ||
"store": "app_store", | ||
"unsubscribe_detected_at": "2019-06-17T22:48:38Z" | ||
}, | ||
"rc_promo_pro_cat_monthly": { | ||
"auto_resume_date": null, | ||
"billing_issues_detected_at": null, | ||
"expires_date": "2019-08-26T01:02:16Z", | ||
"grace_period_expires_date": null, | ||
"is_sandbox": false, | ||
"original_purchase_date": "2019-07-26T01:02:16Z", | ||
"ownership_type": "FAMILY_SHARED", | ||
"period_type": "normal", | ||
"purchase_date": "2019-07-26T01:02:16Z", | ||
"refunded_at": null, | ||
"store": "promotional", | ||
"unsubscribe_detected_at": null | ||
} | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/Sidio.RevenueCat.Tests/Api/V1/RevenueCatV1ClientTests.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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System.Net; | ||
using System.Text.Json; | ||
using Essentia.Web.RevenueCat.Api.V1.Responses; | ||
using RestSharp; | ||
using RestSharp.Serializers; | ||
using Sidio.RevenueCat.Api.V1; | ||
|
||
namespace Sidio.RevenueCat.Tests.Api.V1; | ||
|
||
public sealed class RevenueCatV1ClientTests | ||
{ | ||
private readonly IFixture _fixture = new Fixture(); | ||
|
||
[Fact] | ||
public async Task GetOrCreateSubscriberAsync_ReturnsData() | ||
{ | ||
// arrange | ||
var client = CreateClient(out var restClientMock); | ||
var userId = _fixture.Create<string>(); | ||
var data = _fixture.Create<SubscriberResponse>(); | ||
var responseData = JsonSerializer.Serialize(data); | ||
var response = new RestResponse<SubscriberResponse>(new RestRequest()) { StatusCode = HttpStatusCode.OK, Content = responseData, }; | ||
|
||
restClientMock.Setup(x => x.ExecuteAsync(It.IsAny<RestRequest>(), It.IsAny<CancellationToken>())).ReturnsAsync(response); | ||
|
||
// act | ||
var result = await client.GetOrCreateSubscriberAsync(userId); | ||
|
||
// assert | ||
result.Should().NotBeNull(); | ||
result.StatusCode.Should().Be(HttpStatusCode.OK); | ||
result.Data.Should().BeEquivalentTo(data); | ||
} | ||
|
||
private static RevenueCatV1Client CreateClient(out Mock<IRestClient> restClientMock) | ||
{ | ||
var config = new SerializerConfig(); | ||
config.UseDefaultSerializers(); | ||
restClientMock = new Mock<IRestClient>(); | ||
restClientMock.Setup(x => x.Serializers).Returns(new RestSerializers(config)); | ||
|
||
var client = new RevenueCatV1Client(restClientMock.Object); | ||
return client; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Sidio.RevenueCat.Tests/Api/V2/RevenueCatV2ClientTests.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using RestSharp; | ||
using Sidio.RevenueCat.Api.V2; | ||
|
||
namespace Sidio.RevenueCat.Tests.Api.V2; | ||
|
||
public sealed class RevenueCatV2ClientTests | ||
{ | ||
private readonly IFixture _fixture = new Fixture(); | ||
|
||
private static RevenueCatV2Client CreateClient(out Mock<IRestClient> restClientMock) | ||
{ | ||
restClientMock = new Mock<IRestClient>(); | ||
var client = new RevenueCatV2Client(restClientMock.Object); | ||
return client; | ||
} | ||
} |
Oops, something went wrong.