-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Maven support and fix some incorrect pathing, naming, unnecessary…
… jars, etc.
- Loading branch information
Ben Conley
committed
Apr 19, 2017
1 parent
608c9cd
commit 311bbf6
Showing
16 changed files
with
241 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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* | ||
#### *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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.thinq.twilio</groupId> | ||
<artifactId>twilio-thinQLCR</artifactId> | ||
<version>1.0.0</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>twilio-thinQLCR</name> | ||
<description>Twilio Wrapper Java Library For thinQ LCR integration</description> | ||
<url>https://github.com/thinqinc/twilio-thinQLCR-java</url> | ||
|
||
<licenses> | ||
<license> | ||
<name>The Apache Software License, Version 2.0</name> | ||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> | ||
</license> | ||
</licenses> | ||
|
||
<developers> | ||
<developer> | ||
<name>thinQ, Inc.</name> | ||
<email>[email protected]</email> | ||
<organization>thinQ, Inc.</organization> | ||
<organizationUrl>http://www.thinq.com</organizationUrl> | ||
</developer> | ||
</developers> | ||
|
||
<scm> | ||
<connection>scm:git:git://github.com/thinqinc/twilio-thinQLCR-java.git</connection> | ||
<developerConnection>scm:git:ssh://github.com:thinqinc/twilio-thinQLCR-java.git</developerConnection> | ||
<url>https://github.com/thinqinc/twilio-thinQLCR-java</url> | ||
</scm> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.twilio.sdk</groupId> | ||
<artifactId>twilio-java-sdk</artifactId> | ||
<version>6.3.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpclient</artifactId> | ||
<version>4.5.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpcore</artifactId> | ||
<version>4.4.5</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-logging</groupId> | ||
<artifactId>commons-logging</artifactId> | ||
<version>1.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-core</artifactId> | ||
<version>2.8.8</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<NameValuePair> params) throws TwilioRestException { | ||
CallFactory callFactory = this.client.getAccount().getCallFactory(); | ||
Call call; | ||
|
||
// ensure the To field is properly formatted | ||
String to_number; | ||
ArrayList<NameValuePair> twilioparams = new ArrayList<NameValuePair>(); | ||
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; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/com/twilio/thinq/TwilioWrapperLibraryBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5"> | ||
<output url="file://$MODULE_DIR$/target/classes" /> | ||
<output-test url="file://$MODULE_DIR$/target/test-classes" /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> | ||
<excludeFolder url="file://$MODULE_DIR$/target" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="twilio-java-sdk-6.3.0" level="project" /> | ||
<orderEntry type="library" name="lib" level="project" /> | ||
<orderEntry type="library" name="Maven: com.twilio.sdk:twilio-java-sdk:6.3.0" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.3.2" level="project" /> | ||
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1" level="project" /> | ||
<orderEntry type="library" name="Maven: org.codehaus.jackson:jackson-core-asl:1.9.3" level="project" /> | ||
<orderEntry type="library" name="Maven: org.codehaus.jackson:jackson-mapper-asl:1.9.3" level="project" /> | ||
<orderEntry type="library" name="Maven: io.jsonwebtoken:jjwt:0.4" level="project" /> | ||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.6" level="project" /> | ||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.4.2" level="project" /> | ||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.4.0" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.2" level="project" /> | ||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.5" level="project" /> | ||
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" /> | ||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.8" level="project" /> | ||
</component> | ||
</module> |