Jakamo.Api
0.0.1.3-dev
This is a prerelease version of Jakamo.Api.
dotnet add package Jakamo.Api --version 0.0.1.3-dev
NuGet\Install-Package Jakamo.Api -Version 0.0.1.3-dev
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Jakamo.Api" Version="0.0.1.3-dev" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Jakamo.Api" Version="0.0.1.3-dev" />
<PackageReference Include="Jakamo.Api" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Jakamo.Api --version 0.0.1.3-dev
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Jakamo.Api, 0.0.1.3-dev"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Jakamo.Api@0.0.1.3-dev
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Jakamo.Api&version=0.0.1.3-dev&prerelease
#tool nuget:?package=Jakamo.Api&version=0.0.1.3-dev&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Jakamo API
This is a library that can be used to simplify access to the Jakamo APIs. It is currently under development and has not been battle tested yet.
Currently supported:
- Sales orders
Work in progress:
- Purchase Orders
- Claims
Quickstart
- Construct a HTTP Client and set the default
Accept
andAuthorization
headers - Construct a logger or inject one using Dependency Injection
- Construct the Sales Order client, passing the HTTP Client and the Logger instance to it. This would be done with Dependency Injection in eg. an ASP.NET Core web app.
- Fetch sales orders
- Process them in some way (read and validate XML, generate internal representation and store in ERP, write to disk, etc)
- Tell Jakamo you have processed the Sales Order using the
RemoveSalesOrderFromQueueAsync
method - Repeat from 4 until there are no more sales orders in the queue
using System.Xml.Linq;
using Ardalis.Result;
using Jakamo.Api.Client;
using Serilog;
using Serilog.Extensions.Logging;
namespace Example;
// 1. Construct the HTTP Client
var httpClient = new HttpClient();
httpClient.BaseAddress = new Uri("https://demo.thejakamo.com");
httpClient.DefaultRequestHeaders.Add("Accept", "application/xml");
httpClient.DefaultRequestHeaders.Add("Authorization", "Basic <your token here>");
// 2. Construct the logger. This is using Serilog as an example
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.Enrich.FromLogContext()
.WriteTo.Console()
.CreateLogger();
var logger = new SerilogLoggerProvider(Log.Logger).CreateLogger(nameof(SalesOrderClient));
// 3. Construct the sales order client
var client = new SalesOrderClient(httpClient, logger);
while (true) {
// 4. Fetch sales order
var result = await client.GetSalesOrderAsync();
if (result.Status == ResultStatus.NotFound) break; // No more orders, break out of loop
var so = result.Value; // Returns a SalesOrderDto -object
Console.WriteLine($"Order number: {so.OrderNumber}");
Console.WriteLine($"Confirmation URI: {so.ConfirmationUri}");
Console.WriteLine($"Acknowledgement URI: {so.AcknowledgementUri}");
// 5. Process the sales order
if (so.XmlStream != null)
{
// Write the indented and formatted XML to a file
// Normally you'd write so.XmlStream directly to a FileStream
// or however you wish to process it. The formatting is only for
// example purposes
Console.WriteLine($"Writing {so.OrderNumber}.xml");
var doc = XDocument.Load(so.XmlStream);
await File.WriteAllTextAsync($"{so.OrderNumber}.xml", doc.ToString());
}
// 6. Remove the processed sales order from the queue
var removeSalesOrderFromQueueResult = await client.RemoveSalesOrderFromQueueAsync(so.AcknowledgementUri);
Console.WriteLine(removeSalesOrderFromQueueResult.Value
? $"Successfully removed {so.OrderNumber} from queue"
: $"Error removing the order: ${string.Join(" ", removeSalesOrderFromQueueResult.Errors)}");
}
The code is Copyright (c) 2021 Jakamo Osakeyhtiö and licensed under the BSD-3 license. See the LICENSE file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- Ardalis.Result (>= 3.1.2)
- Microsoft.Extensions.Logging.Abstractions (>= 5.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
0.0.1.3-dev | 260 | 11/3/2021 |