Skip to content

Commit b41c2a9

Browse files
authored
Update README.md
1 parent 68e8771 commit b41c2a9

1 file changed

Lines changed: 43 additions & 1 deletion

File tree

README.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Project Source | Nuget_Package | Description |
6060
[OnixData.Standard.Net5Tests](https://github.com/jaerith/ONIX-Data/tree/master/OnixData.Standard.Net5Tests)| | This project uses the BaseTests project to run unit tests against the .NET 5 framework. |
6161
[OnixTestHarness](https://github.com/jaerith/ONIX-Data/tree/master/OnixTestHarness)| | This project is a simple test harness that provides some use cases on how to use the ONIX-Data parser. |
6262

63-
# Usage Examples
63+
# Common Usage Examples
6464

6565
// An example of using the ONIX parser for the contemporary ONIX standard (i.e., 3.0)
6666
int nOnixPrdIdx = 0;
@@ -171,3 +171,45 @@ Project Source | Nuget_Package | Description |
171171
}
172172
}
173173
}
174+
175+
# Extension Usage Examples (including OpenAI)
176+
177+
// An example of using the ONIX parser for the contemporary ONIX standard (i.e., 3.0)
178+
int onixPrdIdx = 0;
179+
string filepath = @"YourVer3OnixFilepath.xml";
180+
181+
OnixChatServiceSettings onixChatServiceSettings = new OnixChatServiceSettings();
182+
onixChatServiceSettings.ApiKey = "xxx";
183+
184+
FileInfo currentFileInfo = new FileInfo(filepath);
185+
using (OnixParser v3Parser = new OnixParser(currentFileInfo, true))
186+
{
187+
foreach (OnixProduct tmpProduct in v3Parser)
188+
{
189+
OnixData.Version3.Price.OnixPrice usdPrice = tmpProduct.USDRetailPrice;
190+
191+
if (tmpProduct.IsValid())
192+
{
193+
System.Console.WriteLine("Product [" + (onixPrdIdx++) + "] has EAN(" +
194+
tmpProduct.EAN + ") and USD Retail Price(" + tmpProduct.USDRetailPrice.PriceAmount +
195+
") - HasUSRights(" + tmpProduct.HasUSRights() + ").");
196+
197+
if (tmpProduct.CollateralDetail != null)
198+
{
199+
foreach (var onixTextContent in tmpProduct.CollateralDetail.OnixTextContentList)
200+
{
201+
// Function to be implemented by developer, contextually evaluating text based on needs of environment
202+
// (simple grammar check, thorough examination with Nu Html Validator, etc)
203+
if (!IsValid(onixTextContent))
204+
{
205+
onixTextContent.RepairHtmlText(onixChatServiceSettings);
206+
}
207+
}
208+
}
209+
}
210+
else
211+
{
212+
System.Console.WriteLine(tmpProduct.GetParsingError());
213+
}
214+
}
215+
}

0 commit comments

Comments
 (0)