/SepidarApi

Sepidar e-commerce web service

Primary LanguageC#MIT LicenseMIT

SepidarApi

GitHub Actions status nuget

Http Client for Sepidar e-commerce web service

Install via NuGet

To install Honamic.SepidarApi, run the following command in the Package Manager Console:

PM> Install-Package Honamic.SepidarApi

Sepidar Documents

sepidar-e-commerce-web-service-v1.0.0.pdf
Sepidar Swagger

Usage

         services.PostConfigure<SepidarApiOptions>(options =>
        {
            options.GenerationVersion = "110";
            options.RegistrationCode = "1000d6fa";
            options.Username = "username";
            options.Password = "password";
            options.PublicKey = null;
            options.BaseUrl = "http://127.0.0.1:7373";
            options.Timeout = 100;
            options.AutoLogin = true;
        });

        services.AddSepidarApiServices();
        services.AddTransient<TestService>();
public class TestService 
{
    private readonly ILogger<TestService> _logger;
    private readonly IOptionsMonitor<SepidarApiOptions> options;
    private readonly UserApiService userService;
    private readonly ItemApiService itemService;
    private readonly CustomerApiService customerService;

    public TestService(ILogger<TestService> logger,
        IOptionsMonitor<SepidarApiOptions> sepidarOptions,
        UserApiService userService,
        ItemApiService itemService,
        CustomerApiService customerService)
    {
        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
        this.options = sepidarOptions;
        this.userService = userService;
        this.itemService = itemService;
        this.customerService = customerService;
    }

    public async void Run()
    {
        if (options.CurrentValue.AutoLogin)
        {
            _logger.LogWarning("Auto login is enabled");
        }
        else
        {
            var loginResult = await userService.Login(options.CurrentValue.Username, options.CurrentValue.Password);
            _logger.LogWarning($"login as {loginResult}");
        }

        var customers = await customerService.GetCustomers();      
    }
}