PSinfoodservice 1.0.1.46

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

PS in foodservice API Client for C#

A comprehensive C# client library for the PS in foodservice Web API (v7). This package simplifies integration with PS in foodservice services by providing a clean, type-safe interface for all API endpoints.

Installation

Install the package via NuGet:

Install-Package PSinfoodservice 

Or via the .NET CLI:

dotnet add package PSinfoodservice 

Requirements

  • Supports multiple frameworks:
    • .NET 9.0, 8.0, 7.0, 6.0
    • .NET Standard 2.0
    • .NET Framework 4.6.2, 4.8.1
  • PS in foodservice account with API access

Quick Start

using PSinfoodservice;
using System;
using System.Threading.Tasks;

namespace YourApplication
{
    class Program
    {
        static async Task Main(string[] args)
        {
            // Initialize the client
            var client = new PSinfoodserviceClient(PSinfoodservice.Domain.PSEnvironment.Test);
            
            try {
                // Authenticate
                var loginResponse = await client.Authentication.Login("your-email@example.com", "your-password");
                if (loginResponse.IsSuccess && loginResponse?.Data == true) {
                    Console.WriteLine("Authentication successful!");
                    
                    // Get product information
                    var productSheetResponse = await client.WebApi.GetProductSheet(59, PSinfoodservice.Enum.OutputType.All);
                    if (productSheetResponse.IsSuccess) {
                        Console.WriteLine($"Product name: {productSheetResponse.Data.Summary.Name.FirstOrDefault(p => p.Language == PSinfoodservice.Dtos.Language.nl).Value}");
                    }
                }
            } catch (Exception ex) {
                Console.WriteLine($"Error: {ex.Message}");
            }
        }
    }
}

Key Features

  • Easy authentication with PS in foodservice API
  • Support for all API endpoints
  • Helper methods for common operations
  • Type-safe request and response handling
  • Error handling with detailed response information
  • Asynchronous API for improved performance

Documentation

For complete API documentation, visit the PS in foodservice API Documentation.

Modules

The client is organized into multiple modules, each handling a specific part of the API:

  • Authentication: Login and token management
  • Masters: Reference data
  • Assortment: Assortment list management
  • Brands: Brand information
  • Updates: Track product updates
  • WebApi: Core product data operations
  • ImpactScore: Environmental impact scoring
  • Image: Product image retrieval
  • Helper: Utility methods for data processing

Examples

Authentication

var client = new PSinfoodserviceClient(PSinfoodservice.Domain.PSEnvironment.Test);
var loginResponse = await client.Authentication.Login("your-email@example.com", "your-password");
if (loginResponse.IsSuccess && loginResponse?.Data == true) {
    Console.WriteLine("Successfully logged in!");
} else {
    Console.WriteLine($"Login failed! Error: {loginResponse.ErrorMessage}");
}

Retrieving Product Information

// Get product sheet
var productSheetResponse = await client.WebApi.GetProductSheet(59, PSinfoodservice.Enum.OutputType.All);
if (productSheetResponse.IsSuccess) {
    Console.WriteLine("Successfully retrieved product sheet!");
    Console.WriteLine($"Summary name: {productSheetResponse.Data.Summary.Name.FirstOrDefault(p => p.Language == PSinfoodservice.Dtos.Language.nl).Value}");
}

// Get ingredients information
var ingredientsResponse = client.Helper.GetIngredientsPreview(productSheetResponse.Data, PSinfoodservice.Dtos.Language.nl);
if (ingredientsResponse != null && ingredientsResponse.IsSuccess) {
    Console.WriteLine($"Ingredients declaration: {ingredientsResponse.Data.DeclarationPreview}");
}

Working with Allergens

// Get allergen information with bootstrap formatting
var allergenResponse = client.Helper.GetAllergensPreview(
    productSheetResponse.Data, 
    false,  // simplified information
    PSinfoodservice.Dtos.Language.nl, 
    PSNetPackage.Domain.Outputstyle.Bootstrap
);

if (allergenResponse.IsSuccess) {
    Console.WriteLine($"Allergens:");
    Console.Write(allergenResponse.Data);
}

// Get allergen information with table formatting
var extendedAllergenResponse = client.Helper.GetAllergensPreview(
    productSheetResponse.Data, 
    true,  // extended information
    PSinfoodservice.Dtos.Language.nl, 
    PSNetPackage.Domain.Outputstyle.Table
);

Retrieving Nutritional Information

var nutrientsResponse = client.Helper.GetNutrientsPreview(
    productSheetResponse.Data, 
    PSinfoodservice.Dtos.Language.nl, 
    PSNetPackage.Domain.Outputstyle.Table
);

if (nutrientsResponse.IsSuccess) {
    Console.WriteLine($"Nutrients:");
    Console.Write(nutrientsResponse.Data);
}

Working with Preparation Information

var preparationInformationResponse = client.Helper.GetPreparationInformationPreview(
    productSheetResponse.Data, 
    PSinfoodservice.Dtos.Language.nl
);

if (preparationInformationResponse != null && preparationInformationResponse.IsSuccess) {
    Console.WriteLine("Preparation Information:");
    foreach (var item in preparationInformationResponse.Data) {
        Console.WriteLine($"Type: {item.PreparationType}");
        Console.WriteLine($"Description: {item.Description}");
    }
}

Getting Impact Scores

// Get all impact scores
var impactScoreResponse = await client.ImpactScore.AllScores();
if (impactScoreResponse.IsSuccess) {
    Console.WriteLine("Successfully retrieved impact scores!");
    foreach (var impactScore in impactScoreResponse.Data.ImpactScore) {
        Console.WriteLine($"Impact score (CradleToGate): {impactScore.CradleToGate}");
    }
}

// Get specific product impact score
var productImpactScoreResponse = await client.ImpactScore.GetScore(59);
if (productImpactScoreResponse.IsSuccess) {
    Console.WriteLine($"Product Impact Score: {productImpactScoreResponse.Data.Score}");
}

Retrieving Master Data

// Get all masters
var allMasterResponse = await client.Masters.GetAllMasters();
if (allMasterResponse.IsSuccess) {
    Console.WriteLine("Successfully retrieved masters!");
    
    // Access tax rates or other master data
    foreach (var taxRate in allMasterResponse.Data.masters.TaxRates) {
        var name = taxRate.Name.First(p => p.Language == PSinfoodservice.Dtos.Language.nl).Value;
        Console.WriteLine($"Tax Rate: {name}");
    }
}

// Get logistic masters
var logisticMasterResponse = await client.Masters.GetLogisticMasters();
if (logisticMasterResponse.IsSuccess) {
    Console.WriteLine("Successfully retrieved logistic masters!");
    foreach (var taxRate in logisticMasterResponse.Data.Masters.TaxRates) {
        Console.WriteLine($"Tax Rate: {taxRate.Name.First(p => p.Language == PSinfoodservice.Dtos.Language.nl).Value}");
    }
}

Retrieving Brand Information

// Get my brands
var brandsResponse = await client.Brands.MyBrands();
if (brandsResponse.IsSuccess) {
    Console.WriteLine("Successfully retrieved brands!");
    foreach (var brand in brandsResponse.Data.Brands) {
        Console.WriteLine($"Brand: {brand.Name}");
    }
}

Tracking Updates

// Get updates based on EAN codes
var updateResponse = await client.Updates.Ean(new PSinfoodservice.Dtos.Incoming.RequestUpdateEANDto {
    LastUpdatedAfter = DateTime.Now.AddDays(-30),
    SearchCriteria = new[] { "1236547892138", "12365478921381", "1236547892139" },
    TargetMarket = PSinfoodservice.Enum.TargetMarkets.All
});

if (updateResponse.IsSuccess) {
    Console.WriteLine("Successfully retrieved updates!");
    
    Console.WriteLine("Changed:");
    foreach (var item in updateResponse.Data.Changed) {
        Console.WriteLine($"- {item.GTIN}");
    }
    
    Console.WriteLine("Not Changed:");
    foreach (var item in updateResponse.Data.NotChanged) {
        Console.WriteLine($"- {item.GTIN}");
    }
    
    Console.WriteLine("Not Found:");
    foreach (var ean in updateResponse.Data.NotFound) {
        Console.WriteLine($"- {ean}");
    }
    
    Console.WriteLine("Deleted:");
    foreach (var item in updateResponse.Data.Deleted) {
        Console.WriteLine($"- {item.GTIN}");
    }
}

Working with Images

// Get product image
var imageResponse = await client.Image.GetImage(1, Guid.Empty, 500, 500);
if (imageResponse != null && imageResponse.IsSuccess) {
    Console.WriteLine($"Content Type: {imageResponse.Data.ContentType}");
    Console.WriteLine($"Image Size: {imageResponse.Data.Content.Length} bytes");
    
    // Save the image
    if (imageResponse.Data.Content.Length > 0) {
        string extension = GetExtensionFromContentType(imageResponse.Data.ContentType);
        string filePath = Path.Combine(Path.GetTempPath(), $"image_{Guid.NewGuid()}{extension}");
        
        await File.WriteAllBytesAsync(filePath, imageResponse.Data.Content);
        Console.WriteLine($"Image saved to: {filePath}");
    }
}

// Helper method to determine file extension
private static string GetExtensionFromContentType(string contentType) {
    return contentType.ToLower() switch {
        "image/jpeg" => ".jpg",
        "image/png" => ".png",
        "image/gif" => ".gif",
        "image/bmp" => ".bmp",
        "image/tiff" => ".tiff",
        "image/webp" => ".webp",
        _ => ".jpg"
    };
}

Error Handling

The package includes comprehensive error handling with response objects:

try {
    var loginResponse = await client.Authentication.Login("email@example.com", "password");
    if (loginResponse.IsSuccess) {
        // Use the API...
    } else {
        Console.WriteLine($"API Error: {loginResponse.ErrorMessage}");
        Console.WriteLine($"Error Code: {loginResponse.ErrorCode}");
    }
} catch (Exception ex) {
    Console.WriteLine($"Unexpected Error: {ex.Message}");
    Console.WriteLine($"Stack Trace: {ex.StackTrace}");
}

Response Structure

All API methods return a standardized response object with the following properties:

public class ApiResponse<T>
{
    public bool IsSuccess { get; set; }
    public T Data { get; set; }
    public string ErrorMessage { get; set; }
    public int? ErrorCode { get; set; }
}

License

You must have a PS in foodservice account to use this package. For more information, visit https://psinfoodservice.com

Support

For questions or support requests, please contact us at info@psinfoodservice.com.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  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 is compatible.  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 is compatible.  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 is compatible.  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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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.

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
1.0.1.46 247 4/7/2025