Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/peymanr34/riviera-kavenegar
The Kavenegar API for dotnet.
https://github.com/peymanr34/riviera-kavenegar
api csharp dotnet kavenegar riviera sms text-message
Last synced: about 2 months ago
JSON representation
The Kavenegar API for dotnet.
- Host: GitHub
- URL: https://github.com/peymanr34/riviera-kavenegar
- Owner: peymanr34
- License: mit
- Created: 2021-07-24T20:06:24.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-12T12:11:59.000Z (5 months ago)
- Last Synced: 2024-07-12T13:51:11.915Z (5 months ago)
- Topics: api, csharp, dotnet, kavenegar, riviera, sms, text-message
- Language: C#
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Riviera.Kavenegar
Unofficial implementation of the Kavenegar API for .NET[![NuGet Version][nuget-badge]][nuget]
[![NuGet Downloads][nuget-badge-dl]][nuget]## Installation
You can install this package via the `Package Manager Console` in Visual Studio.```powershell
Install-Package Riviera.Kavenegar -PreRelease
```## Startup Configuration
To use the `KavenegarService` you need to register it in your `Startup.cs` class.```csharp
// using Riviera.Kavenegar;services.AddHttpClient();
services.Configure(o => o.ApiKey = "your-api-key");
```
*Note: Consider using [user secrets][user-secrets] to store the API key.*## Controller Configuration
After registering the service, you need to add it to your controller.```csharp
// using Riviera.Kavenegar;public class HomeController : Controller
{
private readonly KavenegarService _service;public HomeController(KavenegarService service)
{
_service = service;
}
}
```## Sending a text message
You can send a text message via the `SendMessageAsync` method.```csharp
[Route("send")]
public async Task Send()
{
var result = await _service.SendMessageAsync("recipient number", "message", "sender number");if (result.IsSuccess)
{
return Ok("Message has been successfully sent.");
}// Show an error message
return Content($"Code: {result.Return.Status}\nMessage: {result.Return.Message}");
}
```## Checking the status
You can check the text message status via the `GetStatusAsync` method.```csharp
[Route("status")]
public async Task Status()
{
var result = await _service.GetStatusAsync(1234567);if (result.IsSuccess)
{
return Ok(result.Entry.StatusText);
}// Show an error message
return Content($"Code: {result.Return.Status}\nMessage: {result.Return.Message}");
}
```## License
This project is licensed under the [MIT License](LICENSE).[nuget]: https://www.nuget.org/packages/Riviera.Kavenegar
[nuget-badge]: https://img.shields.io/nuget/v/Riviera.Kavenegar.svg?label=NuGet
[nuget-badge-dl]: https://img.shields.io/nuget/dt/Riviera.Kavenegar?label=Downloads&color=red[user-secrets]: https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets