Skip to content

vassilis-panos/BudgetSms.AspNetCore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BudgetSms.AspNetCore NuGet

ASP.NET Core library for BudgetSMS gateway

Installation

.NET CLI

dotnet add package BudgetSms.AspNetCore

Package Manager

Install-Package BudgetSms.AspNetCore

Configuration

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddBudgetSms(options =>
        {
            options.UserName = "Vassilis";
            options.UserId = 21547;
            options.Handle = "1e756dc895456f";
            options.Sender = "Vassilis";
        });
    }
}

appsettings.json

{
  "BudgetSms": {
    "UserName": "Vassilis",
    "UserId": 21547,
    "Handle": "1e756dc895456f",
    "Sender": "Vassilis"
  }
}
public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.Configure<BudgetSmsOptions>(
            Configuration.GetSection("BudgetSms"));
        services.AddBudgetSms();
    }
}

Dependency injection

public class SmsController : ControllerBase
{
    private readonly BadgetSmsService _sms;

    public SmsController(BadgetSmsService sms)
    {
        _sms = sms;
    }

    [HttpPost("send")]
    public async Task<IActionResult> SendSmsAsync(CancellationToken ct)
    {
        try
        {
            var response = await _budgetSms.SendAsync(
                "306982004055", "Test Message", cancellationToken: ct);

            return Ok(response.Id);
        }
        catch (ApiException ex)
        {
            return BadRequest(ex.ErrorDescription);
        }
    }
}

About

ASP.NET Core library for Budget SMS gateway

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages