Coder Social home page Coder Social logo

plivo-dotnet's Introduction

plivo-dotnet

UnitTest

The Plivo .NET SDK makes it simpler to integrate communications into your .NET applications using the Plivo REST API. Using the SDK, you will be able to make voice calls, send SMS and generate Plivo XML to control your call flows.

Supported .NET versions: This SDK was written targeting at .NET Standard 1.3 & .NET Standard 2.0, and thus works with .NET Framework 4.6+ and .NET Core 1.0+. Check here to know about all the other supported platforms.

Installation

You can install this SDK either by referencing the .dll file or using NuGet.

Use the following line to install the latest SDK using the NuGet CLI.

PM> Install-Package Plivo -Version 5.47.1

You can also use the .NET CLI to install this package as follows

> dotnet add package Plivo --version 5.47.1

Getting started

Authentication

To make the API requests, you need to create a PlivoApi instance and provide it with authentication credentials (which can be found at https://manage.plivo.com/dashboard/).

var api = new PlivoApi("<auth_id>", "<auth_token>");

The Basics

The SDK uses consistent interfaces to create, retrieve, update, delete and list resources. The pattern followed is as follows:

api.Resource.Create(params);
api.Resource.Get(params);
api.Resource.Update(identifier, params);
api.Resource.Delete(identifier);
api.Resource.List();

Using api.Resource.List() would list the first 20 resources by default (which is the first page, with limit as 20, and offset as 0). To get more, you will have to use limit and offset to get the second page of resources.

Examples

Send a message

internal class Program
{
    public static void Main(string[] args)
    {
        var api = new PlivoApi("<auth_id>", "<auth_token>");
        var response = api.Message.Create(
            src:"14156667778",
            dst:"14156667777",
            text:"Hello, this is a sample text from Plivo"
        );
        Console.WriteLine(response);
    }
}

Make a call

internal class Program
{
    public static void Main(string[] args)
    {
        var api = new PlivoApi("<auth_id>", "<auth_token>");
        var response = api.Call.Create(
            to:new List<String>{"the_to_number"},
            from:"the_from_number",
            answerMethod:"GET",
            answerUrl:"https://answer.url"
        );
        Console.WriteLine(response);
    }
}

Lookup a number

internal class Program
{
    public static void Main(string[] args)
    {
        var api = new PlivoApi("<auth_id>", "<auth_token>");
        var response = api.Lookup.Get("phone_number_here");
        Console.WriteLine(response);
    }
}

Generate Plivo XML

class MainClass
{
    public static void Main(string[] args)
    {
        Plivo.XML.Response response = new Plivo.XML.Response();
        response.AddSpeak("Hello, world!",
                          new Dictionary<string, string>() { });
        Console.WriteLine(response.ToString());
    }
}

This generates the following XML:

<Response>
  <Speak>Hello, world!</Speak>
</Response>

WhatsApp Messaging

Plivo's WhatsApp API allows you to send different types of messages over WhatsApp, including templated messages, free form messages and interactive messages. Below are some examples on how to use the Plivo Go SDK to send these types of messages.

Templated Messages

Templated messages are a crucial to your WhatsApp messaging experience, as businesses can only initiate WhatsApp conversation with their customers using templated messages.

WhatsApp templates support 4 components: header , body, footer and button. At the point of sending messages, the template object you see in the code acts as a way to pass the dynamic values within these components. header can accomodate text or media (images, video, documents) content. body can accomodate text content. button can support dynamic values in a url button or to specify a developer-defined payload which will be returned when the WhatsApp user clicks on the quick_reply button. footer cannot have any dynamic variables.

Example 1:

using System;
using System.Collections.Generic;
using Plivo;

namespace PlivoExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var api = new PlivoApi("<auth_id>", "<auth_token>");

           string jsonString = "{\"name\":\"plivo_movieticket_confirmation\",\"language\":\"en_US\",\"components\":[{\"type\":\"header\",\"parameters\":[{\"type\":\"media\",\"media\":\"https://media.geeksforgeeks.org/wp-content/uploads/20190712220639/ybearoutput-300x225.png\"}]},{\"type\":\"body\",\"parameters\":[{\"type\":\"text\",\"text\":\"Harry Potter\"},{\"type\":\"text\",\"text\":\"06:00 PM\"},{\"type\":\"text\",\"text\":\"Bengaluru\"},{\"type\":\"text\",\"text\":\"2\"}]}]}";

            var response = api.Message.Create(
                src: "14156667778",
                dst: "14156667777",
                type: "whatsapp",
                template_json_string: jsonString);
            Console.WriteLine(response);
        }
    }
}

Example 2:

using System;
using System.Collections.Generic;
using Plivo;
using Plivo.Resource.Message;

namespace PlivoExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var api = new PlivoApi("<auth_id>", "<auth_token>");

           var template = new Template
            {
                Name = "plivo_movieticket_confirmation",
                Language = "en_US",
                Components = new List<Component>
                {
                    new Component
                    {
                        Type = "header",
                        Parameters = new List<Parameter>
                        {
                            new Parameter
                            {
                                Type = "media",
                                Media = "https://media.geeksforgeeks.org/wp-content/uploads/20190712220639/ybearoutput-300x225.png"
                            }
                        }
                    },
                    new Component
                    {
                        Type = "body",
                        Parameters = new List<Parameter>
                        {
                            new Parameter
                            {
                                Type = "text",
                                Text = "Harry Potter"
                            },
                            new Parameter
                            {
                                Type = "text",
                                Text = "06:00 PM"
                            },
                            new Parameter
                            {
                                Type = "text",
                                Text = "Bengaluru"
                            },
                            new Parameter
                            {
                                Type = "text",
                                Text = "2"
                            }
                        }
                    }
                }
            };

            var response = api.Message.Create(
                src: "14156667778",
                dst: "14156667777",
                type: "whatsapp",
                template: template);
            Console.WriteLine(response);
        }
    }
}

Free Form Messages

Non-templated or Free Form WhatsApp messages can be sent as a reply to a user-initiated conversation (Service conversation) or if there is an existing ongoing conversation created previously by sending a templated WhatsApp message.

Free Form Text Message

Example:

using System;
using System.Collections.Generic;
using Plivo;

namespace PlivoExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var api = new PlivoApi("<auth_id>","<auth_token>");
            var response = api.Message.Create(
                src: "+14151112221",
                dst: "+14151112222",
                type: "whatsapp",
                text: "Hello, this is sample text",
                url: "https://<yourdomain>.com/wa_status/");
            Console.WriteLine(response);
        }
    }
}

Free Form Media Message

Example:

using System;
using System.Collections.Generic;
using Plivo;

namespace PlivoExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var api = new PlivoApi("<auth_id>","<auth_token>");
            var response = api.Message.Create(
                src: "+14151112221",
                dst: "+14151112222",
                type: "whatsapp",
                text: "Hello, this is sample text",
                media_urls: new string[] { "https://sample-videos.com/img/Sample-png-image-1mb.png"},
                url: "https://<yourdomain>.com/wa_status/");
            Console.WriteLine(response);
        }
    }
}

Interactive Messages

This guide shows how to send non-templated interactive messages to recipients using Plivo’s APIs.

Quick Reply Buttons

Quick reply buttons allow customers to quickly respond to your message with predefined options.

Example:

using System;
using System.Collections.Generic;
using Plivo;
using Plivo.Resource.Message;

namespace PlivoExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var api = new PlivoApi("<auth_id>", "<auth_token>");

            var interactive = new Interactive
            {
                Type = "button",
                Header = new Header
                {
                    Type = "media",
                    Media = "https://media.geeksforgeeks.org/wp-content/uploads/20190712220639/ybearoutput-300x225.png"
                },
                Body = new Body
                {
                    Text = "Make your selection"
                },
                Action = new MessageAction
                {
                    Buttons = new List<Button>
                    {
                        new Button
                        {
                            Id = "bt1",
                            Title = "Click here"
                        },
                        new Button
                        {
                            Id = "bt2",
                            Title = "Know More"
                        },
                        new Button
                        {
                            Id = "bt3",
                            Title = "Request Callback"
                        }
                    }
                }
            };
            var response = api.Message.Create(
                src: "+14151112221",
                dst: "+14151112222",
                type: "whatsapp",
                interactive: interactive);
            Console.WriteLine(response);
        }
    }
}

Interactive Lists

Interactive lists allow you to present customers with a list of options.

Example:

using System;
using System.Collections.Generic;
using Plivo;
using Plivo.Resource.Message;

namespace PlivoExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var api = new PlivoApi("<auth_id>", "<auth_token>");

            var interactive = new Interactive
            {
                Type = "list",
                Header = new Header
                {
                    Type = "text",
                    Text = "Welcome to Plivo"
                },
                Body = new Body
                {
                    Text = "You can review the list of rewards we offer"
                },
                Footer = new Footer
                {
                    Text = "Yours Truly"
                },
                Action = new MessageAction
                {
                    Buttons = new List<Button>
                    {
                        new Button
                        {
                            Title = "Click here"
                        }
                    },
                    Sections = new List<Section>
                    {
                        new Section
                        {
                            Title = "SECTION_1_TITLE",
                            Rows = new List<Row>
                            {
                                new Row
                                {
                                    Id = "SECTION_1_ROW_1_ID",
                                    Title = "SECTION_1_ROW_1_TITLE",
                                    Description = "SECTION_1_ROW_1_DESCRIPTION"
                                }
                            }
                        },
                        new Section
                        {
                            Title = "SECTION_2_TITLE",
                            Rows = new List<Row>
                            {
                                new Row
                                {
                                    Id = "SECTION_2_ROW_1_ID",
                                    Title = "SECTION_2_ROW_1_TITLE",
                                    Description = "SECTION_2_ROW_1_DESCRIPTION"
                                }
                            }
                        }
                    }
                }
            };

            var response = api.Message.Create(
                src: "+14151112221",
                dst: "+14151112222",
                type: "whatsapp",
                interactive: interactive);
            Console.WriteLine(response);
        }
    }
}

Interactive CTA URLs

CTA URL messages allow you to send links and call-to-action buttons.

Example:

using System;
using System.Collections.Generic;
using Plivo;

namespace PlivoExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var api = new PlivoApi("<auth_id>","<auth_token>");

           var interactive = new Interactive
            {
                Type = "cta_url",
                Header = new Header
                {
                    Type = "media",
                    Media = "https://media.geeksforgeeks.org/wp-content/uploads/20190712220639/ybearoutput-300x225.png"
                },
                Body = new Body
                {
                    Text = "Know More"
                },
                Action = new MessageAction
                {
                    Buttons = new List<Button>
                    {
                        new Button
                        {
                            Title = "Click here",
                            CtaUrl = "https://www.plivo.com"
                        }
                    }
                }
            };

            var response = api.Message.Create(
                src: "+14151112221",
                dst: "+14151112222",
                type: "whatsapp",
                interactive: interactive);
            Console.WriteLine(response);
        }
    }
}

Location Messages

This guide shows how to send templated and non-templated location messages to recipients using Plivo’s APIs.

Templated Location Messages

Example:

using System;
using System.Collections.Generic;
using Plivo;

namespace PlivoExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var api = new PlivoApi("<auth_id>","<auth_token>");

            var template = new Template
                {
                    Name = "plivo_order_pickup",
                    Language = "en_US",
                    Components = new List<Component>
                    {
                        new Component
                        {
                            Type = "header",
                            Parameters = new List<Parameter>
                            {
                                new Parameter
                                {
                                    Type = "location",
                                    Location = new Location
                                    {
                                        Longitude = "122.148981",
                                        Latitude = "37.483307",
                                        Name = "Pablo Morales",
                                        Address = "1 Hacker Way, Menlo Park, CA 94025"
                                    }
                                }
                            }
                        },
                        new Component
                        {
                            Type = "body",
                            Parameters = new List<Parameter>
                            {
                                new Parameter
                                {
                                    Type = "text",
                                    Text = "Harry"
                                }
                            }
                        }
                    }
                };

            var response = api.Message.Create(
                src: "+14151112221",
                dst: "+14151112222",
                type: "whatsapp",
                template: template);
            Console.WriteLine(response);
        }
    }
}

Non-Templated Location Messages

Example:

using System;
using System.Collections.Generic;
using Plivo;

namespace PlivoExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var api = new PlivoApi("<auth_id>","<auth_token>");

           var location = new Location
            {
                Longitude = "122.148981",
                Latitude = "37.483307",
                Name = "Pablo Morales",
                Address = "1 Hacker Way, Menlo Park, CA 94025"
            };

            var response = api.Message.Create(
                src: "+14151112221",
                dst: "+14151112222",
                type: "whatsapp",
                location: location);
            Console.WriteLine(response);
        }
    }
}

More examples

Refer to the Plivo API Reference for more examples.

Reporting issues

Report any feedback or problems with this version by opening an issue on Github.

Local Development

Note: Requires latest versions of Docker & Docker-Compose. If you're on MacOS, ensure Docker Desktop is running.

  1. Export the following environment variables in your host machine:
export PLIVO_AUTH_ID=<your_auth_id>
export PLIVO_AUTH_TOKEN=<your_auth_token>
export PLIVO_API_DEV_HOST=<plivoapi_dev_endpoint>
export PLIVO_API_PROD_HOST=<plivoapi_public_endpoint>
  1. Run make build. This will create a docker container in which the sdk will be setup and dependencies will be installed.

The entrypoint of the docker container will be the setup_sdk.sh script. The script will handle all the necessary changes required for local development. It will also package the sdk and reinstall it as a dependecy for the test program.

  1. The above command will print the docker container id (and instructions to connect to it) to stdout.
  2. The testing code can be added to <sdk_dir_path>/dotnet-sdk-test/Program.cs in host
    (or /usr/src/app/dotnet-sdk-test/Program.cs in container)
  3. The sdk directory will be mounted as a volume in the container. So any changes in the sdk code will also be reflected inside the container. However, when any change is made, the dependencies for the test program need to be re-installed. To do that:
    • Either restart the docker container
    • Or Run the setup_sdk.sh script
  4. To run test code, run make run CONTAINER=<cont_id> in host.

<cont_id> is the docker container id created in 2. (The docker container should be running)

Test code can also be run within the container using make run. (CONTAINER argument should be omitted when running from the container)

plivo-dotnet's People

Contributors

abinaya-shunmugavel avatar abrolnalin avatar ajay-plivo avatar alexk01 avatar anindya-plivo avatar eniyavan-muruganantham-plivo avatar huzaif-plivo avatar kalyan-plivo avatar kanishka2104 avatar kapilp93 avatar koushik-ayila avatar kritarth-plivo avatar kunal-plivo avatar lsaitharun avatar manish-plivo avatar manjunath-plivo avatar mohsin-plivo avatar narayana-plivo avatar nikhil-plivo avatar nirmitijain avatar nixonsam avatar plivo-sdks avatar prashantp-plivo avatar rajneeshkatkam-plivo avatar renoldthomas-plivo avatar saurabhnewatiya-plivo avatar solidclouddev avatar solidcloudio avatar sreyantha-plivo avatar varshit97plivo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

plivo-dotnet's Issues

Error Handling Issues

When an invalid outbound from number is passed to the SendSms, error handling is not performed.

Assembly reference issue

I am doing the exact installation through NuGet as you described on your readme documentation but getting the error below:

Error CS0012 The type 'IRestResponse<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'RestSharp, Version=100.0.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75'.

Even if I add reference to web.config it is persistent.

Nuget install of v4.1 throws error on SMS create

System.IO.FileLoadException: Could not load file or assembly 'System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I was able to bypass this by installing Nuget Package System.Net.Http v4.3.1 manually.

Could not load file or assembly 'System.IO.FileSystem'

Hello,
I got this exception on calling
PlivoApi.Message.Create Method.

Exception:

Could not load file or assembly 'System.IO.FileSystem, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies

Plivo version: 4.1.0

Regards.

'RestSharp' support.

I've Restsharp installed on my project but when I install plivo nuget package it installs RestsharpSigned with it.

When I try to remove RestsharpSigned from my project, it says,

Unable to uninstall 'RestSharpSigned.105.2.3' because 'Plivo.3.0.5' depends on it.

Sms Message Api not updated

Hi,

I'm using RestApi to send messages and get status of messages.
The get_message method returns an object of type IRestResponse

The Message object contains the following properties:

public string cloud_rate { get; set; }
public string carrier_rate { get; set; }
public string message_direction { get; set; }
public string to_number { get; set; }
public string message_state { get; set; }
public string total_amount { get; set; }
public string from_number { get; set; }
public string message_uuid { get; set; }
public string message_time { get; set; }
public string resource_uri { get; set; }
public string message_type { get; set; }
public string total_rate { get; set; }
public int units { get; set; }

While the response from the message api contains the following fields:

"api_id":
"error_code"
"from_number"
"message_direction"
"message_state"
"message_time"
"message_type"
"message_uuid"
"resource_uri"
"to_number"
"total_amount"
"total_rate"
"units"

I want to get the error code from the response.
is there a way to do it using this library?

Thanks

NullReferenceException when a resource object is used to delete or update the resource

A few resources seem to have Interface unintialized when obtained using Get(id) or List(), and thus a NullReferenceException is thrown as follows when a .Delete() or .Update() is being called:

 System.NullReferenceException: Object reference not set to an instance of an object

For example, when an Application is obtained by Get(Id), Application.Delete() works fine.

But when the Application object is obtained by List(), Application.Delete() throws a NullReferenceException.

Full stack trace:

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at Plivo.Resource.Application.Application.Delete () [0x00011] in <cd16b14fcca449d784a4f3515319918e>:0 
  at TestAddress.Program.Main (System.String[] args) [0x000c6] in <d32985e7cd7a4bfb9f536c4595226956>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
  at Plivo.Resource.Application.Application.Delete () [0x00011] in <cd16b14fcca449d784a4f3515319918e>:0 
  at TestAddress.Program.Main (System.String[] args) [0x000c6] in <d32985e7cd7a4bfb9f536c4595226956>:0 

SDK version: 4.0.0
Tested on .NET Standard 1.3+

Library breaks with latest version of RestSharp

Resharp updated to v106.3.1

and you get the error:
Could not load type 'RestSharp.HttpBasicAuthenticator' from assembly 'RestSharp,API' looks like RestSharp was updated and they moved some stuff around in 105.0.2+

Rollback back to < 105.0.1

What are the dependencies for this package?

In the documentation, it says to add RestSharpSigned (105.1.0) and Newtonsoft.Json (7.0.1). The package in NuGet only shows RestSharpSigned and says greater than or equal to 105.1.0. I've tried to upgrade RestSharpSigned to 105.2.3 and have had issues. Can you clarify which dependencies and which version of those dependencies are required?

Installing 2.0.1 via NuGet gives dependency errors for RestSharp

Error CS0012: The type RestSharp.IRestResponse1<Plivo.API.MessageResponse>' is defined in an assembly that is not referenced. Consider adding a reference to assembly `RestSharp, Version=105.1.0.0, Culture=neutral, PublicKeyToken=null' (CS0012) (pM.Api)

I can see the RestSharpSigned package has been included, but it looks like it still needs the RestSharp package to also be included.

If I manually add the RestSharp package it works, but we shouldn't have to add packages manually.

Library not strong named

We have to strong name our project DLLs which means that every reference also needs to be strong named. I get an error that this library requires a strong name assembly when building with it. For our projects to fix, we right click the project file and then go to signing and make a key. Is it possible for you to add this to the nuget version?

.NET Core support

Hello,

are you planning create a .NET Core version of this library?

Thank you.

No support for ASP.NET core

Any time I tried using this package on an .NET Core framework APP, I keep getting an error message that says, "Not Supported on this framework"

how to generate Signature, Nonce, & MA_V2 and compare with header signature and nonce

@apexapexapex You can access the Signature, Nonce, & MA_V2 like below

$signature_v2 = $_SERVER['HTTP_X_PLIVO_SIGNATURE_V2'];
$signature_v2_nonce = $_SERVER['HTTP_X_PLIVO_SIGNATURE_V2_NONCE'];
$signature_ma_v2 = $_SERVER['HTTP_X_PLIVO_SIGNATURE_MA_V2'];

Please feel free to create a support ticket if you need any further assistance or in case of any issues.
Thank you!

Originally posted by @nixonsam in plivo/plivo-php#130 (comment)

callback is a required parameter

I am getting "callBack is a required parameter" when trying to create a call. I had just updated the plivo nuget package and this parameter was not required before. There doesnt seem to be any indication of what exactly this parameter is or why its needed in any of the documentation.

This is the call that I am making:

var result = await api.Call.CreateAsync(
    to: new List<string> { to },
    from: from,
    answerMethod: "GET",
    answerUrl: answerUrl,
    hangupUrl: hangupUrl,
    hangupMethod: "GET",
    machineDetection: "hangup",
    machineDetectionTime: 2000
);

Using Plivo with .netframework4 and WebAPI 1

Hi

I'm new to Pilvo

I see from docs that Plivo should be supported with .netframework version 4 and up

I have a project with MS web API (version 1), with main page served as ASP MVC Page ,
I installed Pilvo using Nuget and build pass, but got exception when trying to lunch the main page

I installed the latest stable version - 3.0.8

screenshot:
capture

After some investigations, it seems related to Assembly Strong Name - I didn't face such issue before, it could be related to the project? or it is a general Pilvo Assemblies issue?

can you please help?
Thanks

Version 4.0 and up breaks will not install

Could not install package 'Plivo 4.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

Cannot install on project targeting .net 4.5.2

Hi, I am trying to install Plivo SDK to a asp.net MVC project (.net 4,5,2) using nuget packages but it show the below error. Any ideas on how to install the sdk?

Could not install package 'Plivo 4.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5.2', but the package does not contain any assembly references or content files that are compatible with that framework.

Beep not supported in Wait

Hello,

It looks like Wait now has beep detection. (https://www.plivo.com/docs/xml/wait/).
However, PlivoXml.cs still doesn't support the key.

    public class Wait : PlivoElement
{
    public Wait(dict attributes)
        : base(attributes)
    {
        Nestables = new list() { "" };
        ValidAttributes = new list()
        {   "length", "silence","minSilence"
        };
        addAttributes();
    }
}

Can someone add this? Otherwise the API just throws. :(

Thanks!

Koby

How to receive response sms with .aspx file ?

I have 100 plivo numbers , i want to configure like that i can receive response sms for all 100 numbers , Please guide me how to do that ? and i am using plivo api in my .aspx website how to achieve this is .aspx web site ?

Thanks

Newtonsoft.json warning still exists in 4.4.10

This was supposed to be fixed in this version, but it's still there:

Warning NU1603 Plivo 4.4.10 depends on Newtonsoft.Json (>= 10.0.0) but Newtonsoft.Json 10.0.0 was not found. An approximate best match of Newtonsoft.Json 10.0.1 was resolved.

A2P 10DLC - Campaign status parameter getting from campaign API is missing

I am getting an issue I encountered while integrating Plivo in my .NET application. I have been working on registering an a2p campaign, referring to the official documentation provided by Plivo at https://www.plivo.com/docs/sms/api/10dlc/campaign/.

  • Campaign Status Retrieval:
    As part of my integration, it is crucial for me to retrieve the campaign status of a profile. However, upon exploring the Plivo .NET package, it appears that there is no direct support for this functionality. I kindly request your assistance in checking and updating the .NET package to include support for obtaining the campaign status of a profile. This enhancement would greatly benefit developers like myself who are leveraging the Plivo API within their .NET applications.
    image

  • Error Details for Failed Campaigns:
    Is there a mechanism in place to push error details when a campaign fails? It would be immensely helpful if we could receive detailed information about why a campaign failed, enabling us to diagnose and address any underlying issues promptly. If such functionality doesn't exist yet, I would appreciate it if you could consider incorporating this feature into the Plivo .NET package.

I genuinely appreciate the effort and dedication you put into maintaining this public GitHub repo. Your prompt attention to these matters would significantly contribute to the overall usability and developer experience associated with Plivo's .NET integration. As an active user of Plivo, I believe that these enhancements will benefit the community as a whole.

My Plivo package integrated version: 5.31.0

Unrecognizable Error while sending SMS with new Library !

Hi we are seeing the following error , while sending SMS from ASP.Net MVC using the Plivo 4.0 Package.

 
Unexpected character encountered while parsing value: C. Path '', line 0, position 0.   at Newtonsoft.Json.JsonTextReader.ParseValue()
   at Newtonsoft.Json.JsonTextReader.Read()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Plivo.Client.SystemHttpClient.SendRequest[T](String method, String uri, Dictionary`2 data)
   at Plivo.Client.HttpClient.Update[T](String uri, Dictionary`2 data)
   at Plivo.Resource.Message.MessageInterface.Create(String src, List`1 dst, String text, String type, String url, String method, Nullable`1 log)

This happens while sending extra characters in your Plivo Auth id . While we expect an error , it shuld be Authentication denied , or incorrect Auth id , but the error is a Newtonsoft parsing error.

.Net Framework: 4.6.2
Plivo: 4.0.0
Newtonsoft: 10.0.3

Thread safe?

We are sending large numbers of SMS messages from multiple threads in our app and are experiencing port exhaustion. My guess is that this is happening due to the fact that PlivoApi creates a new HttpClient in each instance (in Plivo.Client.SystemHttpClient), rather than using HttpClientFactory. We are currently registering PlivoApi as a transient service, so each thread creates its own instance of this class, which by extension results in a new instance of HttpClient.

The question is whether the PlivoApi class is thread-safe, which would allow us to register it as a singleton and share it among our various threads. I could not find any documentation or discussion on this topic.

NuGet package does not indicate downstream dependencies

The Plivo code relies on RestSharp. Packages.config states:

<package id="RestSharp" version="104.4.0" targetFramework="net40" />

However the NuSpec file does not contain this dependency, so when including the Plivo NuGet package in my project it does not pull the downstream dependencies and as a result it fails to run.

NuSpec file needs something like the following, in order to correctly install in target projects:

<package>
  <metadata>
  <!-- Existing metadata here -->
    <dependencies>
      <group targetFramework="net40">
        <dependency id="RestSharp" version="104.4.0" />
      </group>
    </dependencies>
  </metadata>
  <!-- Other things here -->
</package>

RestSharp version too old

The version of RestSharp used by Plivo is from September 2012, the superseded version has a breaking change which means that in solutions that need the newer version of RestSharp for other code cannot use the Plivo NuGet package.

Either

  • Update the Plivo code to the newer RestSharp package and resolve the breaking change (RestClient.BaseUrl is now a Uri rather than a string), or;
  • To keep compatibility with both RestSharp 104.x and 105.x change the code to set the baseUrl in the constructor of RestClient rather than setting a property once the RestClient is instantiated.

Message.Create Does not work in Windows Forms Application

Tried out current package (v4.2.3), the sample code works well in Windows Console Application, try to run the same code in Windows Forms Application Message.Create never returns the control back to the application. SMS gets delivered to the phone though. Simple Forms Application, and sample code with valid auth_id and auth_token

Conflict with other lib

I am using Twilio and when i install Plivo there is conflict since you are using restsharpsigned.
For now i am using your clean API but still i would like to use lib instead

Newtonsoft version specification causes NU1603 warning

I have this warning whenever I compile a netcore 2.0 assembly that references the plivo library:

Plivo 4.2.5 depends on Newtonsoft.Json (>= 10.0.0) but Newtonsoft.Json 10.0.0 was not found. An approximate best match of Newtonsoft.Json 10.0.1 was resolved.

I think this is because the nuspec file specifies the dependency as [10,), which effectively means "greater than or equal to 10.0.0.0". However, it tries 10.0.0.0 first, and this version does not exist, hence the warning.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.