-
Notifications
You must be signed in to change notification settings - Fork 0
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
WIP - Migration of .io to .com + sync/async/webhook methods #2
Open
AJCJ1
wants to merge
138
commits into
master
Choose a base branch
from
iss-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
AJCJ1
changed the title
Migration of .io to .com
WIP Migration of .io to .com + sync/async/webhook methods
Oct 16, 2024
…ponse types and custom deserializer
…ss and failure cases
AJCJ1
changed the title
WIP Migration of .io to .com + sync/async/webhook methods
Migration of .io to .com + sync/async/webhook methods
Oct 18, 2024
AJCJ1
changed the title
Migration of .io to .com + sync/async/webhook methods
WIP - Migration of .io to .com + sync/async/webhook methods
Oct 18, 2024
… readme to refer to assets dir
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Updates the occurrences of .io to .com in:
It also prepares the repo for upload to nuget, by adding a license.txt, readme.md, and additional metadata to the core .csproj file.
Updates dotnet package from 2.0 to 6.0
The package has been update to target dotnet 6.0. This is to support the various security, performance, and language enhancements to c# and .NET. It has not been updated to 8.0 due to the current LTS for 6.0. It is presumed that a large number of users may not have upgraded their .NET projects to 8.0 just yet.
Refactors options to be typed class
The Urlbox options are now a class, with typed properties based on the Urlbox documentation.
Implements render and renderAsync
The render and render async methods have been implemented. These will make a POST request to Urlbox, which will be handled by the private method
MakeUrlboxPostRequest()
. This method returns the interface IUrlboxResponse, which is then cast to aSyncUrlboxResponse
orAsyncUrlboxResponse
depending on the endpoint called. These give the end user a type to handle when making requests toRender()
orRenderAsync()
.Tests have also been written for these method which depend on a genuine Urlbox key and secret. This requires the developer to set environment variables via
dotnet user-secrets init
anddotnet user-secrets set
with theURLBOX_KEY
andURLBOX_SECRET
. Instructions for this are detailed in the readme undercontributing
. These secrets would be required if this were to be placed in a GH actions runner, but could simply be set via the settings page of the GH repo, because the tests utilise a fallback if the env vars are not found in the default local file for dotnet user-secrets.Implements a webhook verification method
This method held within the new UrlboxWebhookValidator class, verifies the header of the Urlbox webhook POST request
x-urlbox-signature
. It does this by following the instructions from the docs.Updates the download() method to throw with the x-urlbox-error-message for more meaningful debugging
Implements fromCredentials static
This is a static method to create an instance of Urlbox via a static method over the
new
keyword.Implements subtypes in the
SyncUrlboxResponse
type formetadata
,metadataUrl
,markdownUrl
,mhtmlUrl
,htmlUrl
This includes a further subtype in the metadata class for
OgImage
.Rename GenerateUrlboxUrl() to GenerateRenderLink()
The update also makes signing with the user's secret key optional. Passing
sign: true
will sign the render link.Rename Namespace from
Screenshots
toUrlboxSDK
Implement error exception
If one of the render methods fails, a UrlboxException will be thrown, which takes the error body from the Urlbox API and deserialises it into a meaningful exception object.
Nice To haves:
Some potential nice to haves that we could add either now or in future:
Tests:
The test project files
Urlbox.MsTest.csproj
andUrlbox.xUnitTest.csproj
were updated to .NET core v6.Additionally, the paths to the Urlbox class in the test .csproj files, which used '', were replaced with '/' for compatibility with macOs development.
Tests have been written for each resource to ensure getters work appropriately + when nullable. Tests have also been written for each new method, testing each case where success and failure occur. Tests have also been written for the trickier options, such as cookie/header.
The tests have been primarily written into the MsTest project.
Passing Tests: