UssdStateMachine 3.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package UssdStateMachine --version 3.0.5
NuGet\Install-Package UssdStateMachine -Version 3.0.5
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="UssdStateMachine" Version="3.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add UssdStateMachine --version 3.0.5
#r "nuget: UssdStateMachine, 3.0.5"
#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.
// Install UssdStateMachine as a Cake Addin
#addin nuget:?package=UssdStateMachine&version=3.0.5

// Install UssdStateMachine as a Cake Tool
#tool nuget:?package=UssdStateMachine&version=3.0.5

USSD State Machine

Introduction

This library provides a convenient way to integrate USSD functionality into your ASP.NET Core applications. Follow the steps below to get started.

Usage

  1. Configure Redis Connection:

    Ensure you have a Redis connection string named Redis in your appsettings.json file.

    {
      "Redis": "your_redis_connection_string"
    }
    
  2. Register USSD Dependencies:

    In your Startup.cs file, add the following code within the ConfigureServices method.

    builder.Services.AddUSSDMenus();
    
  3. Implement USSD in Controller:

    Inject the USSDService into your controller, and call the ProccessRequest<InitialMenu>() function in your controller action.

    [Route("api/ussd")]
    [ApiController]
    public class USSDController : ControllerBase
    {
        private readonly USSDService _ussdService;
    
        public USSDController(USSDService ussdService) =>
            _ussdService = ussdService;    
    
        [HttpGet]
        public async Task Index([FromQuery] USSDRequest request) => 
            await _ussdService.ProcessRequest<InitialMenu>(request);
    }
    

Creating Menus

To create menus, follow these steps:

  1. Define Menu Class:

    Create a class for your menu and decorate it with the [USSDMenu] attribute. Implement the IUSSDMenu interface.

    [USSDMenu]
    public class InitialMenu : IUSSDMenu
    {
        public async Task DisplayAsync(USSDRequest request)
        {
            // Implement logic for displaying menu
        }
    
        public async Task ProcessInputAsync(USSDRequest request)
        {
            // Implement logic for processing user input
        }
    }
    
  2. Utilize IUSSDMenuBuilder (Optional):

    Inject the IUSSDMenuBuilder into your menu class to use the builder for implementing the DisplayAsync and ProcessInputAsync methods.

    [USSDMenu]
    public class InitialMenu : IUSSDMenu
    {
        private readonly IUSSDMenuBuilder _builder;
    
        public InitialMenu(IUSSDMenuBuilder builder) => 
            _builder = builder;
    
        public async Task DisplayAsync(USSDRequest request)
        {
            // Implement logic using the IUSSDMenuBuilder
        }
    
        public async Task ProcessInputAsync(USSDRequest request)
        {
            // Implement logic using the IUSSDMenuBuilder
        }
    }
    

Feel free to customize the logic within the menu classes to suit your USSD application requirements.

Product Compatible and additional computed target framework versions.
.NET 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 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. 
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
5.4.0-alpha.1 51 5/23/2024
5.3.2 98 3/27/2024
5.3.1 72 3/27/2024
5.3.0 89 3/20/2024
5.2.0 106 1/17/2024
5.0.14 83 1/15/2024
5.0.13 78 1/15/2024
5.0.12 77 1/15/2024
5.0.11 85 1/15/2024
5.0.1 89 1/12/2024
5.0.0 82 1/12/2024
4.0.3-alpha.1 35 5/29/2024
4.0.2 1,403 12/14/2023
4.0.1 106 12/13/2023
4.0.0 110 12/13/2023
3.0.5 359 10/27/2023
3.0.4 115 10/27/2023
3.0.0 99 10/10/2023
1.0.0 200 9/19/2023