SharpNyx 0.2.0

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

// Install SharpNyx as a Cake Tool
#tool nuget:?package=SharpNyx&version=0.2.0

SharpNyx

Telnyx API C# wrapper for .Net Core. Uses HttpClient.

Dependencies

  • .NETCoreApp 2.1
  • Newtonsoft.Json (>= 12.0.2)

It should work with .Net standard but you may have to manually import the Telnyx.dll.

Installation

Add the NuGet package or download and reference the Telnyx.dll issued in Releases. https://www.nuget.org/packages/SharpNyx

Usage

Send a message
//Import, reference, Use
using Telnyx.SharpNyx;

//Quick instantiation
MessagingAPIClient mac = new MessagingAPIClient("Q7EI8KGZJ3FrwBxMKq5zmID1");

//Make a new SMS message
SMS sms = new SMS("BUGSINC", "+16506003337", "Hello Telnyx");

//Call and wait for SendSMS to finish
mac.SendSMSAsync(sms).Wait();

//Check to see if it is queued
bool isq = sms.IsQueued;
The Messaging API Client (MAC)

MAC is the main broker for the HttpClient. MAC does the work of sending messages, and communicating with the Telnyx Rest API.

MAC implements a static HttpClient to use for the entire application. You can instantiate the MessagingAPIClient by directly adding the x-secret.

The MAC will add the secret to the header every time a new request is made. So you can change the secret for the same instance.

//Get the full Http response from the API call
string httpstatus = mac.HttpResponse.StatusCode.ToString(); //returns OK for 200

//Reponse Status returns the status. This field is used to determine the Message.IsQueued value.
string responsemessage = mac.ReponseStatus;

//Reponse Message returns "Queued" if successful, returns the message if unsuccessful delivery
string responsemessage = mac.ReponseMessage;
SMS
//Send a message with just the recipient and body
Message msg = new Message();
msg.ToPhoneNumber = "+16506003337";
msg.Body = "Hello Telnyx";
Send Quick MMS
//Quickly send one image without subject
MessagingAPIClient mac = new MessagingAPIClient("M7RI1KGBJ8FrwBxTKq3zmIN1");

string url = "https://nssdc.gsfc.nasa.gov/planetary/image/saturn.jpg";

MMS mms = new MMS("+BUGSINC", "+16508976777", new Dictionary<string, string> { { MediaUtype.Image, url } });

mac.SendMMSAsync(mms).Wait();

return mms.IsQueued;
MMS With Two Images
//Send two images with a subject
MessagingAPIClient mac = new MessagingAPIClient("M7RI1KGBJ8FrwBxTKq3zmIN1");

string url1 = "https://upload.wikimedia.org/wikipedia/commons/5/5f/HubbleDeepField.800px.jpg";
string url2 = "https://upload.wikimedia.org/wikipedia/commons/e/e1/M45map.jpg";

Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add(MediaUtype.Image, url1);

Dictionary<string, string> dic2 = new Dictionary<string, string>();
dic2.Add(MediaUtype.Image, url2);

MMS mms = new MMS()
{
    FromPhoneNumber = "+BUGSINC",
    Subject = "Alcyone",
    ToPhoneNumber = "+16508976777",
    MediaUrls = new List<Dictionary<string, string>>() { dic, dic2 }
};
mac.SendMMSAsync(mms).Wait();
return mms.IsQueued;
Accepted Response Payload
//Get the full response payload on an accepted outbound message request
AcceptedResponsePayload arp = AcceptedResponsePayload.FromJson(mac.ReponseString);
string smsid = arp.SMSId; //Generated message ID from Telnyx
Rejected Response Payload
//Get the response error details from the mac response string if message is not queued
RejectedResponsePayload rrp = RejectedResponsePayload.FromJson(mac.ReponseString);
string errormessage = err.Message;

MIT License 2019 Bharat Bhardwaj

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.1 is compatible.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Additional computed target framework(s)
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
0.2.4 685 6/8/2019
0.2.3 479 5/31/2019
0.2.2 464 5/30/2019
0.2.1 473 5/30/2019
0.2.0 466 5/29/2019
0.1.8 673 5/26/2019
0.1.7 471 5/25/2019
0.1.6 484 5/25/2019
0.1.5 449 5/24/2019
0.1.4 454 5/24/2019
0.1.2 457 5/24/2019
0.1.0 478 5/24/2019

SharpNyx v 0.2.0
-MessagingAPIClient
-MMS, and SMS
-JSON POST instead of FormDictionary

-Add secret to client header every time before sending.
-Code cleanup.

-Exposed HttpResponse.

-Code changes. No upstream changes required.

-From field made optional. But simple instantiator still requires From field, so no upstream changes required.

-Simpler client setup. Create messages using a different class instead of the client itself.

-Removed Http status code checks

Support for Telnyx messaging API.

-Supports all published functions for sending messages.
-Objects for error response, and successful payload response.

Rest connections via HttpClient.

Json parsing via Newtonsoft.