Giter Site home page Giter Site logo

plivo-java's Introduction

plivo-java

UnitTests

The Plivo Java SDK makes it simpler to integrate communications into your Java 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 Java versions: This SDK works with Java 1.8 & 1.9 i.e., JDK 8 and JDK 9. While using the SDK with Java 1.9, you may have to use the --add-modules java.se.ee flag to include modules that are no longer present by default.

Installation

To Install Stable release

You can use this SDK by adding it as a dependency in your dependency management tool. Alternatively, you can use the JAR file.

If you are using Maven, use the following XML to include the Plivo SDK as a dependency.

<dependency>
  <groupId>com.plivo</groupId>
  <artifactId>plivo-java</artifactId>
  <version>5.39.0</version>
</dependency>

If you are using Gradle, use the following line in your dependencies.

compile 'com.plivo:plivo-java:5.39.0'

To Install Beta release

You can use this SDK by adding it as a dependency in your dependency management tool. Alternatively, you can use the JAR file.

If you are using Maven, use the following XML to include the Plivo SDK as a dependency.

<dependency>
  <groupId>com.plivo</groupId>
  <artifactId>plivo-java</artifactId>
  <version>4.3.0-beta-2</version>
</dependency>

If you are using Gradle, use the following line in your dependencies.

compile 'com.plivo:plivo-java:4.3.0-beta-2'

Note: if you are already using Retrofit, exclude this SDK's dependency so there is no version conflict.

Getting started

Authentication

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

We recommend that you store your credentials in the PLIVO_AUTH_ID and the PLIVO_AUTH_TOKEN environment variables, so as to avoid the possibility of accidentally committing them to source control. If you do this, you can initialise the client with no arguments and it will automatically fetch them from the environment variables:

class Example {
  public static void main(String [] args) {
    Plivo.init();
  }
}

Alternatively, you can provide these to Plivo.init()'s constructor yourself:

class Example {
  public static void main(String [] args) {
    Plivo.init("<auth_id>", "<auth_id>");
  }
}

To use multiple clients, you can create a PlivoClient instance yourself and set it on a request:

class Example {
  public static void main(String [] args) {
    PlivoClient client = new PlivoClient("<auth_id>", "<auth_id>");
    Message.creator("+14156667778", "+14156667777", "Hello, this is sample text from Plivo")
                    .client(client)
                    .create();
  }
}

The Basics

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

Resource.creator(parameters).create();
Resource.getter(parameters).get();
Resource.updater(identifier, parameters).update();
Resource.deleter(identifier).delete();
Resource.lister().list();

Using Resource.lister().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.

To list all objects of any resource, simply use the request object itself as an iterable:

class Example {
  public static void main(String [] args) {
    Plivo.init();
    for (Message message : Message.lister()) {
      System.out.println(message.getMessageUuid());
    }
  }
}

Please note that this makes several requests to the Plivo API, and hence will pause for a short duration at every 20 resources.

Examples

Send a message

class Example {
  public static void main(String [] args) {
    Plivo.init();
    Message.creator("+14156667778", Collections.singletonList("+14156667777"), "Hello, world!")
                    .create();
  }
}

Make a call

class Example {
  public static void main(String [] args) {
    Plivo.init();
    Call.creator("+14156667778", Collections.singletonList("+14156667777"), "https://answer.url")
                    .answerMethod("GET")
                    .create();
  }
}

Lookup a number

class Example {
  public static void main(String [] args) {
    Plivo.init("<auth_id>", "<auth_id>");
    System.out.println(com.plivo.api.models.lookup.Number
        .getter("<number-goes-here>")
        .get());
  }
}

Generate Plivo XML

class Example {
  public static void main(String [] args) {
    System.out.println(new Response()
                             .children(
                               new Speak("Hello, world!")
                             ).toXmlString());
  }
}

This generates the following XML:

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

Log Level

We’ve introduced a customizable logging mechanism in the Java SDK that enables you to choose the level of logging in your development/production environment.

Log-level Description
NONE No logs
BASIC Logs request and response line
HEADER Logs request and response line along with their headers
BODY Logs request and response line along with their headers and bodies

Example

package com.plivo.api.samples.call;

import com.plivo.api.Plivo;
import com.plivo.api.models.base.LogLevel;

class Example {
    public static void main(String [] args) {
        Plivo.init("<auth_id>","<auth_token>", LogLevel.NONE); // LogLevel.NONE is the default value.
//        Plivo.init("<auth_id>","<auth_token>", LogLevel.BASIC);
//        Plivo.init("<auth_id>","<auth_token>", LogLevel.BODY);
//        Plivo.init("<auth_id>","<auth_token>", LogLevel.HEADERS);
    }
}

More examples

More examples are available here. Also refer to the guides for configuring the Java Spring to run various scenarios & use it to test out your integration in under 5 minutes.

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 test code can be added to <sdk_dir_path>/java-sdk-test/Test.java in host
    (or /usr/src/app/java-sdk-test/Test.java 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.
  5. To run unit tests, run make test CONTAINER=<cont_id> in host.

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

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

plivo-java's People

Contributors

abhishekgupta-plivo avatar abrolnalin avatar ajay-kg avatar ajay-plivo avatar anindya-plivo avatar ashutoshkumar-plivo avatar dakshin-plivo avatar eniyavanm avatar harika245 avatar huzaif-plivo avatar kalyan-plivo avatar kanishka2104 avatar kartik-plivo avatar koushik-ayila avatar kowshik-plivo avatar kunal-plivo avatar lsaitharun avatar manas-plivo avatar manish-plivo avatar mohsin-plivo avatar najamsa avatar narayana-plivo avatar neel-plivo avatar nirmitijain avatar nixonsam avatar renoldthomas-plivo avatar saksham-plivo avatar saurabhnewatiya-plivo 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  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

plivo-java's Issues

Can't record ougoing call

I'm trying to record a call made from a browser. I used the example XML from this page (with my own number and action URL):

https://www.plivo.com/docs/xml/record/

<Response>
    <Record action="http://foo.com/get_recording/" startOnDialAnswer="true" redirect="false" />
    <Dial>
        <Number>15551234567</Number>
    </Dial>
</Response>

However, after beginning the call the Record action is called immediately before the call is even answered with duration = -1.

I tried changing the parameters and also using recordSession with no success.

Is the documentation wrong or I'm using <Record> incorrectly?

Maven Repo

Hi Any chance you could update the maven repository?

http://mvnrepository.com/artifact/com.plivo/plivo-java

The last change to master was 2 months ago, but the pom.xml was 5 months ago and says v3.0.4, so should that be 3.0.5 with the post 3.0.4 changes? The repo still says 3.0.1

The Changelog is also showing different details.

Thanks,
S.

NoClassDefFoundError: retrofit2/Converter$Factory

Hello,
I've downloaded the plivo-java-4.0.0.beta-1.jar and included it in my project.
when trying to run Plivo.init() the following exception is thrown.

SEVERE: Servlet.service() for servlet [p2p] in context with path [/p2p] threw exception [Handler processing failed; nested exception is java.lang.NoClassDefFoundError: retrofit2/Converter$Factory] with root cause java.lang.ClassNotFoundException: retrofit2.Converter$Factory at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1854) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1703) at com.plivo.api.Plivo.init(Plivo.java:11)

it seems like the jar doesn't have all the necessary dependencies included?
Am I missing something?

thanks,
brandon

Making single API request to send a bulk message with 198 or more numbers fails

A customer is reporting that when he uses the plivo-java helper library to make an api request to send a text message with a dst parameter that contains 250 numbers, he gets an error:

Premature end of Content-Length delimited message body

If he uses a dst parameter that contains only 100 numbers, the api request executes with no problems.

I am able to reproduce the issue and have discovered that the error occurs when the dst parameter is 198 or more numbers long. 197 numbers works fine, 198 or more produces:

Premature end of Content-Length delimited message body (expected: 90; received: 0

Here is the code used:

package sendMessage;
import java.util.LinkedHashMap;
import com.plivo.helper.api.client.*;
import com.plivo.helper.api.response.message.MessageResponse;

public class Send {
    public static void main(String[] args) {
        String authId = "my authId";
        String authToken = "my authToken";
        RestAPI api = new RestAPI(authId, authToken, "v1");
        LinkedHashMap<String, String> parameters = new LinkedHashMap<String,String>();
        parameters.put("src", "my phone number"); // Sender's phone number with country code
        parameters.put("dst", getDest(200)); // Receiver's phone number with country code
        parameters.put("text", "testing4"); // Your SMS text message
        parameters.put("url", "https://example.com/plivo"); // The URL to which with the status of the message is sent
        parameters.put("method", "GET"); // The method used to call the url

        MessageResponse msgResponse = null;
        try {
            // Send the message
            msgResponse = api.sendMessage(parameters);
            // Print the Date
            System.out.print(new java.util.Date().toString());
            // Print the Api ID
            System.out.println("Api ID : " + msgResponse.apiId);
            // Print the Response Message
            System.out.println("Message : " + msgResponse.message);
            // Print the Response Error
            System.out.println("Error : " + msgResponse.error);
        } catch (Exception e) {
            System.out.println(e.getLocalizedMessage());
            System.out.println("msgResponse is null: "+(msgResponse == null));
        }
    }

    private static String getDest(int howMany){
        StringBuffer sb = new StringBuffer();
        sb.append("recipient's phone number");
        for(int i=1; i<howMany; i++){
            sb.append("<recipient's phone number");
        }
        return sb.toString();
    }
}

Assuming the destination number is 14155551234, calling getDest(198) returns a string that has 198 numbers delimited by < and is 2375 characters long:

14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234<14155551234

Is there something about 198 numbers or 2375 characters/bytes that is limiting this? I've tested this with the plivo-node helper library and it had no problems processing 200+ numbers in one api call.

httpclient upgrade

Hi,
I am using plivo java library, but since it uses httpclient I am unable to do some stuff in my rest of the code, since plivo uses http-client version 4.2.1.

When I include the newer version of httpclient, it conflicts with the one in the plivo.

Why I need a newer version of httpclient? There is SNI support in the http-client 4.3.2.

So, is it possible to upgrade httpclient to at least 4.3.2 ?

Thank you.

Client instance is not reusable

Every instance creation includes generation of a Gson instance and an Apache HTTP client, which are costly (CPU-wise).
It is most preferable if one could re-use an existing instance.

Even if your client is not thread-safe you can indicate that in its documentation and still allow instance re-usability (via an instance pool) simply by not invoking the Apache HTTP connection manager's shutdown() method after each request, and exposing your own shutdown method which will eventually call the HTTP client's shutdown() method.

When LogLevel.NONE, api still logging...

For some reason in the API code there are two lines where System.out.println("New build"); is present in Plivo.java

Can these be removed or at least added to the logging level BASIC? If logging level is NONE, it would be my understanding that no logging should take place.

Caused by: java.lang.ClassNotFoundException: retrofit2.Converter$Factory

i am building a retrofit rest client with Jakarta web api with jstl, jsp with tomcat 10.1.16.

I get the following server error which I hope to get some resolutions here.

Feb 28, 2023 3:47:11 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Server version name: Apache Tomcat/10.1.6 Feb 28, 2023 3:47:11 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Server built: Feb 19 2023 13:23:52 UTC Feb 28, 2023 3:47:11 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Server version number: 10.1.6.0 Feb 28, 2023 3:47:11 PM org.apache.catalina.startup.VersionLoggerListener log INFO: OS Name: Windows 10 Feb 28, 2023 3:47:11 PM org.apache.catalina.startup.VersionLoggerListener log INFO: OS Version: 10.0 Feb 28, 2023 3:47:11 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Architecture: amd64 Feb 28, 2023 3:47:11 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Java Home: C:\Users\karen\.p2\pool\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.3.v20220515-1416\jre Feb 28, 2023 3:47:11 PM org.apache.catalina.startup.VersionLoggerListener log INFO: JVM Version: 17.0.3+7 Feb 28, 2023 3:47:11 PM org.apache.catalina.startup.VersionLoggerListener log INFO: JVM Vendor: Eclipse Adoptium Feb 28, 2023 3:47:11 PM org.apache.catalina.startup.VersionLoggerListener log INFO: CATALINA_BASE: C:\Users\karen\thales\thales-workSpace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0 Feb 28, 2023 3:47:11 PM org.apache.catalina.startup.VersionLoggerListener log INFO: CATALINA_HOME: C:\Program Files\Java\apache-tomcat-10.1.6 Feb 28, 2023 3:47:11 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcatalina.base=C:\Users\karen\thales\thales-workSpace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0 Feb 28, 2023 3:47:11 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcatalina.home=C:\Program Files\Java\apache-tomcat-10.1.6 Feb 28, 2023 3:47:11 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dwtp.deploy=C:\Users\karen\thales\thales-workSpace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps Feb 28, 2023 3:47:11 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED Feb 28, 2023 3:47:11 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED Feb 28, 2023 3:47:11 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED Feb 28, 2023 3:47:11 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED Feb 28, 2023 3:47:11 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED Feb 28, 2023 3:47:11 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dfile.encoding=UTF-8 Feb 28, 2023 3:47:11 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -XX:+ShowCodeDetailsInExceptionMessages Feb 28, 2023 3:47:11 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO: Loaded Apache Tomcat Native library [2.0.3] using APR version [1.7.2]. Feb 28, 2023 3:47:11 PM org.apache.catalina.core.AprLifecycleListener initializeSSL INFO: OpenSSL successfully initialized [OpenSSL 3.0.8 7 Feb 2023] Feb 28, 2023 3:47:12 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-nio-8080"] Feb 28, 2023 3:47:12 PM org.apache.catalina.startup.Catalina load INFO: Server initialization in [1325] milliseconds Feb 28, 2023 3:47:12 PM org.apache.catalina.core.StandardService startInternal INFO: Starting service [Catalina] Feb 28, 2023 3:47:12 PM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet engine: [Apache Tomcat/10.1.6] Feb 28, 2023 3:47:13 PM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom WARNING: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [243] milliseconds. Feb 28, 2023 3:47:14 PM org.apache.catalina.core.ContainerBase startInternal SEVERE: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/restPostMan]] at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:878) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:846) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:871) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:241) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:428) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:912) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.startup.Catalina.start(Catalina.java:795) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:347) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:478) Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/restPostMan]] at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:871) ... 21 more

tks.

mix parameter in CallPlayCreator is not working properly

  • mix parameter in CallPlayCreator is not working properly.
  • As per the Plivo documentation, if this is set to false then participants of the call would not be able to hear anyone speaking in the call until the Play is stopped.
  • But I am able to hear a voice on both legs if I set it as false.
  • It works when I set it as true.
  • Version 4.4.1

Uncaught Exception for error response in sendMessage

The error response is not properly handled.
The following exception is thrown.
Since my account was disabled, the API is probably returning an error response. However, this client code is not handling that gracefully. Instead, it throws an uncaught exception.

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 6
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:176)
at com.google.gson.Gson.fromJson(Gson.java:795)
at com.google.gson.Gson.fromJson(Gson.java:761)
at com.google.gson.Gson.fromJson(Gson.java:710)
at com.google.gson.Gson.fromJson(Gson.java:682)
at com.plivo.helper.api.client.RestAPI.sendMessage(RestAPI.java:530)
<>

Exception in thread "main" java.lang.NoSuchFieldError: SNAKE_CASE

Trying to run a very simple send using the example docs
When i try to run it i get the error

Exception in thread "main" java.lang.NoSuchFieldError: SNAKE_CASE at com.plivo.api.PlivoClient.<init>(PlivoClient.java:91) at com.plivo.api.PlivoClient.<init>(PlivoClient.java:182) at com.plivo.api.Plivo.init(Plivo.java:12) at com.unitnet.virtAssist.test.PLivoTest.main(PLivoTest.java:14)

From My pom.xml
<dependency> <groupId>com.plivo</groupId> <artifactId>plivo-java</artifactId> <version>4.4.1</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.9.9</version> </dependency>

Please advise

java.lang.NoSuchMethodError: okio.Buffer.readUtf8CodePoint()I while trying to send sms

Hello I get an exception while I try to send SMS from my Server.
The content of the message is "Bonsoir xxx" It's just for testing but it doesn't work.
The log looks like this :

2018-02-27 21:32:11.425 INFO 9548 --- [ XNIO-2 task-1] okhttp3.OkHttpClient : --> POST https://api.plivo.com/v1/Account/I_HIDE_MY_ACCOUNT_KEY/Message/ http/1.1
2018-02-27 21:32:11.427 INFO 9548 --- [ XNIO-2 task-1] okhttp3.OkHttpClient : Content-Type: application/json; charset=UTF-8
2018-02-27 21:32:11.432 INFO 9548 --- [ XNIO-2 task-1] okhttp3.OkHttpClient : Content-Length: 116
2018-02-27 21:32:11.432 INFO 9548 --- [ XNIO-2 task-1] okhttp3.OkHttpClient : Authorization: Basic I_HIDE_THE_BASIC_AUTHENTICATION==
2018-02-27 21:32:11.433 INFO 9548 --- [ XNIO-2 task-1] okhttp3.OkHttpClient : User-Agent: plivo-java/4.0.1 (Implementation: Oracle Corporation Java Runtime Environment 1.8.0_102, Specification:
Oracle Corporation Java Platform API Specification 1.8)
2018-02-27 21:32:11.434 INFO 9548 --- [ XNIO-2 task-1] okhttp3.OkHttpClient : Host: api.plivo.com
2018-02-27 21:32:11.434 INFO 9548 --- [ XNIO-2 task-1] okhttp3.OkHttpClient : Connection: Keep-Alive
2018-02-27 21:32:11.435 INFO 9548 --- [ XNIO-2 task-1] okhttp3.OkHttpClient : Accept-Encoding: gzip
2018-02-27 21:32:11.437 INFO 9548 --- [ XNIO-2 task-1] okhttp3.OkHttpClient :
2018-02-27 21:32:11.452 ERROR 9548 --- [ XNIO-2 task-1] com.josdavi.aop.logging.LoggingAspect : Exception in com.josdavi.service.InfosGroupeesService.envoyerInfosAdministration() with cause = 'NULL' and exception
= 'okio.Buffer.readUtf8CodePoint()I'

java.lang.NoSuchMethodError: okio.Buffer.readUtf8CodePoint()I
at okhttp3.logging.HttpLoggingInterceptor.isPlaintext(HttpLoggingInterceptor.java:277)
at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:197)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at com.plivo.api.PlivoClient.lambda$new$0(PlivoClient.java:130)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:179)
at okhttp3.RealCall.execute(RealCall.java:63)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:174)
at com.plivo.api.models.base.Creator.create(Creator.java:23)
at com.josdavi.notification.NotificationService.sendWithPlivo(NotificationService.java:117)
at com.josdavi.notification.NotificationService.notifierSMS(NotificationService.java:100)
at com.josdavi.service.InfosGroupeesService.envoyerInfosAdministration(InfosGroupeesService.java:185)
at com.josdavi.service.InfosGroupeesService$$FastClassBySpringCGLIB$$cba0812.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85)
at com.josdavi.aop.logging.LoggingAspect.logAround(LoggingAspect.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:62)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
at com.josdavi.service.InfosGroupeesService$$EnhancerBySpringCGLIB$$5494049a.envoyerInfosAdministration()
at com.josdavi.web.rest.InfoAdministrationResource.envoyerInfosGroupe(InfoAdministrationResource.java:46)
at com.josdavi.web.rest.InfoAdministrationResource$$FastClassBySpringCGLIB$$c5e61a9d.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85)
at com.josdavi.aop.logging.LoggingAspect.logAround(LoggingAspect.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:62)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at com.ryantenney.metrics.spring.TimedMethodInterceptor.invoke(TimedMethodInterceptor.java:48)
at com.ryantenney.metrics.spring.TimedMethodInterceptor.invoke(TimedMethodInterceptor.java:34)
at com.ryantenney.metrics.spring.AbstractMetricMethodInterceptor.invoke(AbstractMetricMethodInterceptor.java:59)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
at com.josdavi.web.rest.InfoAdministrationResource$$EnhancerBySpringCGLIB$$d5cca1b0.envoyerInfosGroupe()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
at com.codahale.metrics.servlet.AbstractInstrumentedFilter.doFilter(AbstractInstrumentedFilter.java:111)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:110)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter.doFilter(OAuth2AuthenticationProcessingFilter.java:176)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:211)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:809)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Play and Wait are not PreAnswer Nestable Elements

Version: 4 Beta 2
Description: When creating a PreAnswer XML Element you can only nest Speak Elements and not Play or Wait (which you are supposed to be able to). In the SDK, the Wait and Play elements are not marked with PreAnswerNestable interface like the Speak element is. They need to have the interface added in order to be nested.

Reported by Steve, via e-mail.

Provide easy way to override BASE_URL to allow functional application testing

It is a standard practice of modern software development to perform functional testing of any application by running it against mock servers which emulate the backend services with which the application interacts. This allows negative path (error) responses from the backend service to be introduced and test that the application handles them correctly

In order to do this the Base URL used to interact with the Plivo API needs to be overridden. Since the Retrofit instance is private and there is no way replacing it, modifying the protected BASE_URL is the only way to achieve this with the helper library.

Unfortunately protected access means that the application code to override the base URL ends up looking like this:

// horrible hack using fake subclass to get around the lack of a formal method to override the base URL for testing
final String baseUrlOverride = System.getProperty("PLIVO_BASE_URL");
if( !Strings.isNullOrEmpty( baseUrlOverride)) {
   LOGGER.info( "Overriding Plivo BASE_URL with '{}'", baseUrlOverride);
   PlivoClient dummy = new PlivoClient( authId, authToken) {
      {
         PlivoClient.BASE_URL = baseUrlOverride;
      }
   };
}
plivoClient = Plivo.init( authId, authToken);

And worse, this is not test code, this is hack code inside the application itself.

Please extend PlivoClient to allow a cleaner way to override the BASE_URL for test environments.

Reduce logging levels (from INFO to DEBUG) for some non-essential entries (4.0.x)

The (4.0.X branch) INFO logging level seems extremely chatty. For example, for making a simple call, the following log entries are generated. Most of these log entries should be (IMHO) reduced to the at least the DEBUG level. Cleaning this up would make it much more readable.

Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: --> POST https://api.plivo.com/v1/Account/MAMJK4MZKWMZG4NWZJZD/Call/ http/1.1 Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: Content-Type: application/json; charset=UTF-8 Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: Content-Length: 242 Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: Authorization: Basic TUFNSks0TVpLV01aRzROV1pKWkQ6WWpRMU5XUmhNbVF6TVdVeFpXTTBNak0zTURVd01USTFPVGxtWW1NMg== Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: User-Agent: plivo-java/4.0.0-beta-1 (Implementation: Oracle Corporation Java Runtime Environment 1.8.0_144, Specification: Oracle Corporation Java Platform API Specification 1.8) Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: Host: api.plivo.com Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: Connection: Keep-Alive Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: Accept-Encoding: gzip Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: {"from":"+12142159615","to":["+12143925898"],"answer_url":"http://aframeonline.ngrok.io/afs/PlivoWebHook_answer.action","hangup_url":"http://aframeonline.ngrok.io/afs/PlivoWebHook_hangup.action","time_limit":2700,"machine_detection":"hangup"} Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: --> END POST (242-byte body) Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: <-- 201 CREATED https://api.plivo.com/v1/Account/MAMJK4MZKWMZG4NWZJZD/Call/ (246ms) Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: Date: Fri, 03 Nov 2017 10:13:23 GMT Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: Content-Type: application/json Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: Content-Length: 139 Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: Connection: keep-alive Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: Server: nginx/1.4.6 (Ubuntu) Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: X-Plivo-Signature: J/5LdG2QlzVjJXE7orhCI9zabCI= Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: X-Plivo-Signature-V2: FT/g7Vcq7DnV/dkgJeiDGtChEnBvu1DGIPvCf6oaYuI= Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: X-Plivo-Signature-V2-Nonce: 64143476356534929163 Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: { "api_id": "a01a4478-c07f-11e7-b886-067c5485c240", "message": "call fired", "request_uuid": "b054374d-33d5-41c0-a2ed-cb1bbb22486a" } Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: <-- END HTTP (139-byte body)

*** should be reduced to ***

Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: --> POST https://api.plivo.com/v1/Account/MAMJK4MZKWMZG4NWZJZD/Call/ http/1.1 Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: {"from":"+12142159615","to":["+12143925898"],"answer_url":"http://aframeonline.ngrok.io/afs/PlivoWebHook_answer.action","hangup_url":"http://aframeonline.ngrok.io/afs/PlivoWebHook_hangup.action","time_limit":2700,"machine_detection":"hangup"} Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: --> END POST (242-byte body) Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: <-- 201 CREATED https://api.plivo.com/v1/Account/MAMJK4MZKWMZG4NWZJZD/Call/ (246ms) Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: { "api_id": "a01a4478-c07f-11e7-b886-067c5485c240", "message": "call fired", "request_uuid": "b054374d-33d5-41c0-a2ed-cb1bbb22486a" } Nov 03, 2017 5:13:23 AM okhttp3.internal.platform.Platform log INFO: <-- END HTTP (139-byte body)

NoSuchFieldError: SNAKE_CASE

Hi,
All I did is:
Plivo.init("auth_id", "auth_token");
But it gives me this error:
Exception in thread "main" java.lang.NoSuchFieldError: SNAKE_CASE
at com.plivo.api.PlivoClient.(PlivoClient.java:68)
at com.plivo.api.Plivo.init(Plivo.java:11)
at com.plivo.api.Plivo.init(Plivo.java:20)
at message.PlivoSMSNew.main(PlivoSMSNew.java:12)
It is true that I can't find SNAKE_CASE in PliveClient.java file. wondering how to solve it.

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.