SharpNyx 0.2.2

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

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

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
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;
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> dic1 = 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>>() { dic1, dic2 }
};

mac.SendMMSAsync(mms).Wait();

return mms.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;
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;
Master Detail Record
MessageDeliveryRecord mdr = await trc.GetMessageDeliveryRecord(msgid);
return mdr;

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.  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. 
.NET Core netcoreapp2.1 is compatible.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 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
0.2.4 809 6/8/2019
0.2.3 555 5/31/2019
0.2.2 545 5/30/2019
0.2.1 557 5/30/2019
0.2.0 557 5/29/2019
0.1.8 762 5/26/2019
0.1.7 545 5/25/2019
0.1.6 570 5/25/2019
0.1.5 531 5/24/2019
0.1.4 550 5/24/2019
0.1.2 540 5/24/2019
0.1.0 566 5/24/2019

SharpNyx v0.2.2
This release is a rename of MasterDetailRecord to MessageDeliveryRecord.

-MessageDeliveryRecord (MDR)
-InboundMessage

Async Task method GetMessageDeliveryRecord(string) takes in the sms_id and returns the Master Detail Record for that message.

Inbound message objects have been added so you can diretctly consume them via Json.