<commit_before>
Plivo Java Helper Library
---------------------------

Description
~~~~~~~~~~~

The Plivo Java helper simplifies the process of making REST calls and generating RESTXML.

See `Plivo Documentation <http://www.plivo.org/docs/>`_ for more information.


Installation
~~~~~~~~~~~~~

**Download Maven2**
    TAR.GZ - http://www.apache.org/dyn/closer.cgi/maven/binaries/apache-maven-2.2.1-bin.tar.gz
    ZIP - http://www.apache.org/dyn/closer.cgi/maven/binaries/apache-maven-2.2.1-bin.zip


**Use maven "mvn install"**

(This currently only supports the Oracle (SUN) JDK 1.6+. We should have OpenJDK available shortly)

**Use the Library in your Java IDE**
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Create Stubs for Eclipse:**
    mvn eclipse:eclipse

**Create stubs for idea**
    mvn idea:idea


How to use
~~~~~~~~~~~~~
You can read the code inside src/test/java folder. We've implemented there all methods that are
currently available on PLIVO.

**Creating the plivo client bridge for java**
   PlivoClient client = PlivoClient.create("accountId",
				"accountToken",
				"url", debug);
  // there's another constructor if you want to override the PLIVO version

**Requesting a new CALL to PLIVO**
	Map<String, String> parameters = new HashMap<String, String>();
	parameters.put("From", "1001");
	parameters.put("To", "1002");
	parameters.put("Gateways", "user/");
	parameters.put("GatewayCodecs", "PCMA,PCMU");
	parameters.put("GatewayTimeouts", "60");
	parameters.put("GatewayRetries", "1");
	parameters.put("OriginateDialString", "originate_dial_string");
	parameters.put("AnswerUrl", "http://localhost:5151/answered");
	parameters.put("HangUpUrl", "http://localhost:5151/hangup");
	parameters.put("RingUrl", "http://localhost:5151/ringing");

	CallResponse result = client.call().single(parameters);

	Call response will contain RequestUUID of the call.
	Note that the AnswerUrl, HangUpUrl and RingUrl has to be a VALID URL. Your application must be
	listening on these urls and response properly. Example of a simple implementation of the answered URL:
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		AnsweredCallback callback = AnsweredCallback.create(req);
		
		ApplicationResponse r = new ApplicationResponse();
		GetDigits digits = new GetDigits();
		digits.setNumDigits(1);
		digits.setValidDigits("123");
		digits.setPlayBeep(true);
		digits.setRetries(2);
		r.setGetDigits(digits);
		<commit_msg>Fixing readme.<commit_after>
Plivo Java Helper Library
---------------------------

Description
~~~~~~~~~~~

The Plivo Java helper simplifies the process of making REST calls and generating RESTXML.

See `Plivo Documentation <http://www.plivo.org/docs/>`_ for more information.


Installation
~~~~~~~~~~~~~

**Download Maven2**
    TAR.GZ - http://www.apache.org/dyn/closer.cgi/maven/binaries/apache-maven-2.2.1-bin.tar.gz
    ZIP - http://www.apache.org/dyn/closer.cgi/maven/binaries/apache-maven-2.2.1-bin.zip


**Use maven "mvn install"**

(This currently only supports the Oracle (SUN) JDK 1.6+. We should have OpenJDK available shortly)

**Use the Library in your Java IDE**
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Create Stubs for Eclipse:**
    mvn eclipse:eclipse

**Create stubs for idea**
    mvn idea:idea


How to use
~~~~~~~~~~~~~
You can read the code inside src/test/java folder. We've implemented there all methods that are
currently available on PLIVO.

**Creating the plivo client bridge for java**
   PlivoClient client = PlivoClient.create("accountId",
				"accountToken",
				"url", debug);
  // there's another constructor if you want to override the PLIVO version

**Requesting a new CALL to PLIVO**
	Map<String, String> parameters = 
		new HashMap<String, String>();
	
	parameters.put("From", "1001");
	
	parameters.put("To", "1002");
	
	parameters.put("Gateways", "user/");
	
	parameters.put("GatewayCodecs", "PCMA,PCMU");
	
	parameters.put("GatewayTimeouts", "60");
	
	parameters.put("GatewayRetries", "1");
	
	parameters.put("OriginateDialString", "originate_dial_string");
	
	parameters.put("AnswerUrl", "http://localhost:5151/answered");
	
	parameters.put("HangUpUrl", "http://localhost:5151/hangup");
	
	parameters.put("RingUrl", "http://localhost:5151/ringing");

	CallResponse result = client.call().single(parameters);

	Call response will contain RequestUUID of the call.
	Note that the AnswerUrl, HangUpUrl and RingUrl has to be a VALID URL. Your application must be
	listening on these urls and response properly. 
	
	This helper already contains a simple web server implemented by Jetty, so you can check our servlet classes.
	
	Example of a simple implementation of the answered URL:
	
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		AnsweredCallback callback = AnsweredCallback.create(req);
		
		ApplicationResponse r = new ApplicationResponse();
		GetDigits digits = new GetDigits();
		digits.setNumDigits(1);
		digits.setValidDigits("123");
		digits.setPlayBeep(true);
		digits.setRetries(2);
		r.setGetDigits(digits);
		
{'fraction_non_alphanumeric': 0.150516669916163, 'fraction_numerical': 0.014427763696627023, 'mean_word_length': 4.563991323210412, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4345172', 'n_tokens_mistral': 1691, 'n_tokens_neox': 1519, 'n_words': 458}