diff --git a/README.md b/README.md index e62094e..bad8f3a 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,15 @@ -# twilio-thinQLCR-java, Twilio Wrapper Java Library For thinQ LCR integration +### twilio-thinQLCR-java, Twilio Wrapper Java Library For thinQ LCR integration -##**Note that you will need a valid LCR Account with thinQ before using the libraries. For more information please contact your thinQ Sales representative at [http://www.thinq.com/library/](http://www.thinq.com/library/)** +**Note that you will need a valid LCR Account with thinQ before using the libraries. For more information please contact your thinQ Sales representative at [http://www.thinq.com/library/](http://www.thinq.com/library/)** -#### *Copyright (c) 2016 thinQ* \ No newline at end of file +#### *Copyright (c) 2016 thinQ* +--- +Download public key: +``` javascript +gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys F369A178F1C54CCB93F540EAC55F351BC8CCD7F4 +``` + +Verify signatures: +``` +gpg2 --verify pom.xml.asc +``` \ No newline at end of file diff --git a/demo/demo.iml b/demo/demo.iml index 66fe434..15e3917 100755 --- a/demo/demo.iml +++ b/demo/demo.iml @@ -7,7 +7,9 @@ - - + + + + \ No newline at end of file diff --git a/lib/commons-codec-1.6.jar b/lib/commons-codec-1.6.jar deleted file mode 100755 index ee1bc49..0000000 Binary files a/lib/commons-codec-1.6.jar and /dev/null differ diff --git a/lib/commons-lang3-3.3.2.jar b/lib/commons-lang3-3.3.2.jar deleted file mode 100755 index 2ce08ae..0000000 Binary files a/lib/commons-lang3-3.3.2.jar and /dev/null differ diff --git a/lib/commons-logging-1.1.1.jar b/lib/commons-logging-1.1.1.jar deleted file mode 100755 index 1deef14..0000000 Binary files a/lib/commons-logging-1.1.1.jar and /dev/null differ diff --git a/lib/httpclient-4.2.6.jar b/lib/httpclient-4.2.6.jar deleted file mode 100755 index 11331df..0000000 Binary files a/lib/httpclient-4.2.6.jar and /dev/null differ diff --git a/lib/httpcore-4.2.5.jar b/lib/httpcore-4.2.5.jar deleted file mode 100755 index 498144c..0000000 Binary files a/lib/httpcore-4.2.5.jar and /dev/null differ diff --git a/lib/jackson-core-asl-1.9.3.jar b/lib/jackson-core-asl-1.9.3.jar deleted file mode 100755 index d42972e..0000000 Binary files a/lib/jackson-core-asl-1.9.3.jar and /dev/null differ diff --git a/lib/jackson-mapper-asl-1.9.3.jar b/lib/jackson-mapper-asl-1.9.3.jar deleted file mode 100755 index 7b07842..0000000 Binary files a/lib/jackson-mapper-asl-1.9.3.jar and /dev/null differ diff --git a/lib/json-simple-1.1.jar b/lib/json-simple-1.1.jar deleted file mode 100755 index f395f41..0000000 Binary files a/lib/json-simple-1.1.jar and /dev/null differ diff --git a/lib/twilio-java-sdk-6.3.0.jar b/lib/twilio-java-sdk-6.3.0.jar deleted file mode 100755 index 2de888b..0000000 Binary files a/lib/twilio-java-sdk-6.3.0.jar and /dev/null differ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..a68423b --- /dev/null +++ b/pom.xml @@ -0,0 +1,65 @@ + + + 4.0.0 + + com.thinq.twilio + twilio-thinQLCR + 1.0.0 + jar + + twilio-thinQLCR + Twilio Wrapper Java Library For thinQ LCR integration + https://github.com/thinqinc/twilio-thinQLCR-java + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + + + + + + thinQ, Inc. + info@thinq.com + thinQ, Inc. + http://www.thinq.com + + + + + scm:git:git://github.com/thinqinc/twilio-thinQLCR-java.git + scm:git:ssh://github.com:thinqinc/twilio-thinQLCR-java.git + https://github.com/thinqinc/twilio-thinQLCR-java + + + + + com.twilio.sdk + twilio-java-sdk + 6.3.0 + + + org.apache.httpcomponents + httpclient + 4.5.2 + + + org.apache.httpcomponents + httpcore + 4.4.5 + + + commons-logging + commons-logging + 1.2 + + + com.fasterxml.jackson.core + jackson-core + 2.8.8 + + + diff --git a/pom.xml.asc b/pom.xml.asc new file mode 100644 index 0000000..29d9a6b --- /dev/null +++ b/pom.xml.asc @@ -0,0 +1,11 @@ +-----BEGIN PGP SIGNATURE----- + +iQEzBAABCAAdFiEE82mhePHFTMuT9UDqxV81G8jM1/QFAlj3eX4ACgkQxV81G8jM +1/SSHQgAhvg346bNcmLAM9PghQkM/TT39aWre8pC34WeI8S8dwGWK4CfSZcM/VQF +tuJt5y3HQEznk7TXd8CZjfRmEbSt4OFXR8b6FhZHi6/KZbUH/7fwJDxD8owY/poU +d7EyeOywIT6yZMuqFBFP0fY7FqfFaeSEY0pfGbvUsBNWg9HL7ZPQZ8wRyXjD1VO0 +uaibX7/CeU4bTH19F/pj5Q9Otkx+rOEpXMFw9flQPNA0ZvH//Vp43n/tFFATeKOo +1Ja31+GFkj0v23Hoc4DqHkUelcuvFYQPqWnu8X40UcSQw/XeEwduDy6CZ6dN0K18 +K4vmZWKT2fG9Qg5sHsJZChCZP0DCxQ== +=NXNA +-----END PGP SIGNATURE----- diff --git a/src/main/java/com/twilio/thinq/TwilioWrapperLibrary.java b/src/main/java/com/twilio/thinq/TwilioWrapperLibrary.java new file mode 100755 index 0000000..4788f37 --- /dev/null +++ b/src/main/java/com/twilio/thinq/TwilioWrapperLibrary.java @@ -0,0 +1,77 @@ +package com.twilio.thinq; + +import com.twilio.sdk.TwilioRestClient; +import com.twilio.sdk.TwilioRestException; +import com.twilio.sdk.resource.factory.CallFactory; +import com.twilio.sdk.resource.instance.Call; +import org.apache.http.NameValuePair; +import org.apache.http.message.BasicNameValuePair; + +import java.util.ArrayList; +import java.util.Objects; + +public class TwilioWrapperLibrary { + + private static final String THINQ_DOMAIN = "wap.thinq.com"; + + private TwilioRestClient client; + private String twilio_account_sid; + private String twilio_account_token; + private String thinQ_id; + private String thinQ_token; + + + public TwilioWrapperLibrary(){ + + } + + /** + * Initialize Twilio Wrapper Object + * @param twilio_account_sid twilio account sid + * @param twilio_account_token twilio account token + * @param thinQ_id thinQid received when signed up at thinQ website + * @param thinQ_token thinQtoken received when signed up at thinQ website + */ + + public TwilioWrapperLibrary(String twilio_account_sid, String twilio_account_token, String thinQ_id, String thinQ_token) { + + this.twilio_account_sid = twilio_account_sid; + this.twilio_account_token = twilio_account_token; + this.thinQ_id = thinQ_id; + this.thinQ_token = thinQ_token; + + this.client = new TwilioRestClient(this.twilio_account_sid, this.twilio_account_token); + } + + /** + * Check if the twilio client is initialized properly. + */ + public boolean isClientValid(){ + return this.client != null && this.client.getAccount() != null; + } + + /** + * Initiate a call to the customer + * pass through of ArrayList of NameValuePairs that Twilio object expects + */ + + public Call call(ArrayList params) throws TwilioRestException { + CallFactory callFactory = this.client.getAccount().getCallFactory(); + Call call; + + // ensure the To field is properly formatted + String to_number; + ArrayList twilioparams = new ArrayList(); + for (NameValuePair temp : params) { + if (Objects.equals(temp.getName(), "To")) { + to_number = temp.getValue().startsWith("sip:") ? temp.getValue() : "sip:" + temp.getValue() + "@" + THINQ_DOMAIN + "?thinQid=" + thinQ_id + "&thinQtoken=" + thinQ_token; + twilioparams.add(new BasicNameValuePair("To", to_number)); + } else { + twilioparams.add(new BasicNameValuePair(temp.getName(), temp.getValue())); + } + } + + call = callFactory.create(twilioparams); + return call; + } +} diff --git a/src/main/java/com/twilio/thinq/TwilioWrapperLibraryBuilder.java b/src/main/java/com/twilio/thinq/TwilioWrapperLibraryBuilder.java new file mode 100755 index 0000000..1c3003b --- /dev/null +++ b/src/main/java/com/twilio/thinq/TwilioWrapperLibraryBuilder.java @@ -0,0 +1,49 @@ +package com.twilio.thinq; + +public class TwilioWrapperLibraryBuilder { + private String twilio_account_sid; + private String twilio_account_token; + private String thinQ_id; + private String thinQ_token; + + + public TwilioWrapperLibraryBuilder() { } + + /** + * Wrap the library and return the library object. + * @return + */ + + public TwilioWrapperLibrary buildLibrary() + { + return new TwilioWrapperLibrary( this.twilio_account_sid, this.twilio_account_token, this.thinQ_id, this.thinQ_token); + } + + /** + * Set customer phone number + * @param _id thinQid received when signed up at thinQ website + * @param _token thinQtoken received when signed up at thinQ website + * @return + */ + + public TwilioWrapperLibraryBuilder thinQ(String _id, String _token) + { + this.thinQ_id = _id; + this.thinQ_token = _token; + return this; + } + + /** + * Set twilio acount details + * @param _sid twilio account sid + * @param _token twilio account token + * @return + */ + + public TwilioWrapperLibraryBuilder twilio(String _sid, String _token) + { + this.twilio_account_sid = _sid; + this.twilio_account_token = _token; + return this; + } +} diff --git a/twilio-thinQLCR-java.iml b/twilio-thinQLCR-java.iml index b58a995..3752d67 100755 --- a/twilio-thinQLCR-java.iml +++ b/twilio-thinQLCR-java.iml @@ -1,13 +1,29 @@ - - - + + + + - + + + + - - + + + + + + + + + + + + + + \ No newline at end of file