This library is MIT Licensed
The Transdirect Library is a .NET Standard wrapper for Transdirect API v4 (https://www.transdirect.com.au/education/developers-centre/rest-api/, document at http://docs.transdirectapiv4.apiary.io/). The library is compatible with .NET Standard 1.4+ (.NET Core 1.0+, .NETFramework 4.5+).
At the moment the following endpoints are implemented:
- Simple Quote
- Bookings (CURD, Confirm, Track)
- Booking Items (CURD)
- Members (Get current member)
- Couriers (Get all supported couriers)
Additional endpoints are in development.
NuGet.org package shall be available in the future. At the moment, please either add MyGet package source (built straight from master
) or add direct reference to the repo.
Following instructions: https://www.myget.org/feed/nkahoang/package/nuget/Transdirect-NetStandard
- Clone this repo:
git clone https://github.com/nkahoang/Transdirect.git
- Add preference to this project in your .csproj file:
<ItemGroup>
<ProjectReference Include="..\Transdirect\Transdirect.csproj" />
<!-- [Other preferences]-->
</ItemGroup>
Access https://www.transdirect.com.au/members/api/apimodules, create a "Custom Site" module for your project.
There are two methods to use the library:
var options = new TransdirectOptions() {
ApiKey = "api-key-goes-here";
// Other configs
};
var transdirectService = new TransdirectService(options);
// All endpoints are exposed via transdirectService object.
Put the following in your appsettings.json
(or your application's config file):
{
// [...] your other settings
// Put TransDirect section in
"Transdirect": {
"ApiKey": "your-api-key",
"BaseUrl": "https://www.transdirect.com.au/api",
"CouriersCacheDuration": "00:05:00"
}
}
Then in your application initialization:
// in your Startup.cs
using Transdirect.Extensions;
/* This should come with a standard ASP.NET Core / Owin startup */
public Startup (IHostingEnvironment env) {
_currentEnvironment = env;
var builder = new ConfigurationBuilder ()
.SetBasePath (env.ContentRootPath)
.AddJsonFile ("appsettings.json", optional : true, reloadOnChange : true)
.AddJsonFile ($"appsettings.{env.EnvironmentName}.json", optional : true)
.AddEnvironmentVariables ();
Configuration = builder.Build ();
}
/* Then register the PinPayments service */
public void ConfigureServices (IServiceCollection services) {
services.AddTransdirect(Configuration);
}
From here onward, simply inject in ITransdirectService
in your constructor.
Working examples for Transdirect are in the PinPayments.Test app, specifically under TransdirectTest.cs
file.
To run the Test project:
- Clone this repo.
- Copy
Transdirect.Test\config.sample.json
toTransdirect.Test\config.json
and set the correct API. - Perform a
dotnet restore
inside Transdirect.Test folder. - Run the sample console app:
dotnet run
.