diff --git a/assets/alstroemeria-sansa.jpg b/assets/alstroemeria-sansa.jpg new file mode 100644 index 0000000..63d5e7b Binary files /dev/null and b/assets/alstroemeria-sansa.jpg differ diff --git a/floriapp-webapi-examples.sln b/floriapp-webapi-examples.sln new file mode 100644 index 0000000..2172250 --- /dev/null +++ b/floriapp-webapi-examples.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30114.105 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FloriApp.ExampleApp", "src\FloriApp.ExampleApp\FloriApp.ExampleApp.csproj", "{4758FF02-FD17-4C8D-991E-F44F5745AB77}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4758FF02-FD17-4C8D-991E-F44F5745AB77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4758FF02-FD17-4C8D-991E-F44F5745AB77}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4758FF02-FD17-4C8D-991E-F44F5745AB77}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4758FF02-FD17-4C8D-991E-F44F5745AB77}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EA37B974-EBFE-483D-B93F-CE43FF46750F} + EndGlobalSection +EndGlobal diff --git a/src/FloriApp.ExampleApp/Extensions.cs b/src/FloriApp.ExampleApp/Extensions.cs new file mode 100644 index 0000000..273b803 --- /dev/null +++ b/src/FloriApp.ExampleApp/Extensions.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; +using FloriApp.WebApi.Models; + +namespace FloriApp.ExampleApp +{ + public static class Extensions + { + + public static void Add(this List features, string key, string value) + { + features.Add(new Feature() + { + Key = key, + Value = value + }); + } + } +} diff --git a/src/FloriApp.ExampleApp/FloriApp.ExampleApp.csproj b/src/FloriApp.ExampleApp/FloriApp.ExampleApp.csproj new file mode 100644 index 0000000..9c2f7ae --- /dev/null +++ b/src/FloriApp.ExampleApp/FloriApp.ExampleApp.csproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp3.1 + + + + + + + diff --git a/src/FloriApp.ExampleApp/Program.cs b/src/FloriApp.ExampleApp/Program.cs new file mode 100644 index 0000000..e6ae978 --- /dev/null +++ b/src/FloriApp.ExampleApp/Program.cs @@ -0,0 +1,83 @@ +using System; +using System.Linq; +using System.Net.Http; +using System.Threading.Tasks; +using FloriApp.WebApi; +using FloriApp.WebApi.Models; + +namespace FloriApp.ExampleApp +{ + class Program + { + static async Task Main(string[] args) + { + Console.WriteLine("Hello FloriApp!"); + Console.WriteLine(); + var client = new FloriAppApiClient(new FloriAppApiOptions() + { + ApiBaseUrl = "https://testflori.app/", + ApiKey = "xxx", + }); + + var allowedCompanies = await client.CompaniesGet(); + Console.WriteLine("The ApiKey has access to the following companies:"); + foreach (var allowedCompany in allowedCompanies) + Console.WriteLine($"- {allowedCompany.Name} ({allowedCompany.Id})"); + Console.WriteLine(); + + var company = allowedCompanies.First(); + Console.WriteLine($"Using {company.Name} to create example stock"); + var companyClient = client.AsCompany(company); + + var stock = new Stock() + { + Vbn = "124039", // Alstroemeria Sansa + Date = DateTime.Today, + //Description = // override article name + //AddText = "super!", // additional text + Manufacturer = "8713783295847", // kweker + //Supplier = "", + Amount = 2, + ApE = 50, + Packing = "998", // emballage + Price = 0.29m, // piece price + Foto = "https://raw.githubusercontent.com/floriapp/webapi-examples/master/assets/alstroemeria-sansa.jpg", + }; + stock.Features.Add("S20", "075"); // steellengte + stock.Features.Add("S21", "090"); // gewicht + stock.Features.Add("S05", "023"); // rijpheid + stock.Features.Add("L11", "010"); // stelen per bos + stock.Features.Add("S22", "005"); // aantal bloemknoppen + stock.Features.Add("S65", "008"); // voorbehandeling + stock.Features.Add("S97", "004"); // mps-a + stock.Features.Add("S62", "NL"); // country of origin + stock.Features.Add("S98", "A1"); // quality + stock.Features.Add("P02", "001"); // belicht + stock.Features.Add("V22", "005"); // exclusief + + + // send stock to server, and update local stock object + stock = await companyClient.StockPost(stock); + + Console.WriteLine($"Created new stock with the following information:"); + Console.WriteLine($"- Id: {stock.Id}"); + Console.WriteLine($"- Date: {stock.Date}"); + Console.WriteLine($"- Article: {stock.Description} / {stock.Article.Name}"); + Console.WriteLine($"- Article trade name: {stock.Article.TradeName}"); + Console.WriteLine($"- Vbn number: {stock.Vbn}"); + Console.WriteLine($"- Vbn group: {stock.VbnGroup}"); + Console.WriteLine($"- Additional text: {stock.AddText}"); + Console.WriteLine($"- Manufacturer GLN: {stock.Manufacturer}"); + Console.WriteLine($"- Supplier: {stock.Supplier}"); + Console.WriteLine($"- Available pieces: {stock.PiecesAvailable}"); + Console.WriteLine($"- Available: {stock.PiecesAvailable/stock.ApE} x {stock.ApE}"); + Console.WriteLine($"- Price: {stock.Price}"); + Console.WriteLine($"- Packing: {stock.Packing}"); + foreach (var feature in stock.Features) + Console.WriteLine($"- {feature.Key}: {feature.Value}"); + Console.WriteLine(); + + + } + } +}