PunchoutUtils 2.0.4

dotnet add package PunchoutUtils --version 2.0.4
                    
NuGet\Install-Package PunchoutUtils -Version 2.0.4
                    
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="PunchoutUtils" Version="2.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PunchoutUtils" Version="2.0.4" />
                    
Directory.Packages.props
<PackageReference Include="PunchoutUtils" />
                    
Project file
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 PunchoutUtils --version 2.0.4
                    
#r "nuget: PunchoutUtils, 2.0.4"
                    
#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 PunchoutUtils@2.0.4
                    
#: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=PunchoutUtils&version=2.0.4
                    
Install as a Cake Addin
#tool nuget:?package=PunchoutUtils&version=2.0.4
                    
Install as a Cake Tool

PunchoutUtils

A nifty utility pack for SAP OCI Punch-outs for dotnet

Features

For now there is only one feature

  • Serialize and deserialize a punch-out

Constants

In this document, we will use the following string as a punch-out:

NEW_ITEM-DESCRIPTION%5B0%5D%3DRubber%20duck&NEW_ITEM-QUANTITY%5B0%5D%3D1&NEW_ITEM-DESCRIPTION%5B1%5D%3DData%20structures%20in%20PHP%20%28book%29&NEW_ITEM-QUANTITY%5B1%5D%3D1

Below is a neatly formatted version so you can read it:

NEW_ITEM-DESCRIPTION[0]=Rubber duck&
NEW_ITEM-QUANTITY[0]=1&
NEW_ITEM-DESCRIPTION[1]=Data structures in PHP (book)&
NEW_ITEM-QUANTITY[1]=1

Of course, there are many more fields as documented: https://punchoutcommerce.com/docs/sap-oci-5.pdf

Serialize / Deserialize

// Deserialize
var entries = PunchoutSerializer.Deserialize("NEW_ITEM-DESCRIPTION%5B0%5D%3DRubber%20duck&NEW_ITEM-QUANTITY%5B0%5D%3D1&NEW_ITEM-DESCRIPTION%5B1%5D%3DData%20structures%20in%20PHP%20%28book%29&NEW_ITEM-QUANTITY%5B1%5D%3D1");

// Serialize back to punch-out
var text = PunchoutSerializer.Serialize(entries);		

// Or a single item 
text = PunchoutSerialize.Serialize(entries.First());

You can also deserialize to your custom model you use for your webshop or your ERP system. Your model should implement the IPunchoutEntry interface. It is also possible to inherit the PunchoutEntry model, since this class implements IPunchoutEntry as well. Make sure you map the correct fields to your model:

using PunchoutUtils.Attributes;

public class MyCustomModel : IPunchoutEntry
{
	[FieldName("DESCRIPTION[n]")]
	public string Description { get; set; }

	[FieldName("QUANTITY[n]")]
	public int Quantity { get; set; }
}

A list of valid field names can be found here: https://punchoutcommerce.com/docs/sap-oci-5.pdf. The n will be replaced by the index of the item.

var entries = PunchoutSerializer.Deserialize<MyCustomModel>("NEW_ITEM-DESCRIPTION%5B0%5D%3DRubber%20duck&NEW_ITEM-QUANTITY%5B0%5D%3D1&NEW_ITEM-DESCRIPTION%5B1%5D%3DData%20structures%20in%20PHP%20%28book%29&NEW_ITEM-QUANTITY%5B1%5D%3D1");

Bugs

Please create an issue on the github repo if you find anything that doesn't seem right.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.0.4 293 6/6/2023
2.0.3 239 6/3/2023
2.0.2 263 6/1/2023
2.0.1 241 5/31/2023
2.0.0 261 4/29/2023
1.0.0 276 4/28/2023

Fixed float decimal point localization