Skip to content

Commit

Permalink
Add Maven support and fix some incorrect pathing, naming, unnecessary…
Browse files Browse the repository at this point in the history
… jars, etc.
  • Loading branch information
Ben Conley committed Apr 19, 2017
1 parent 608c9cd commit 311bbf6
Show file tree
Hide file tree
Showing 16 changed files with 241 additions and 11 deletions.
16 changes: 13 additions & 3 deletions README.md
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
```
6 changes: 4 additions & 2 deletions demo/demo.iml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="lib" level="project" />
<orderEntry type="module" module-name="twilio-thinQLCR-java" />
<orderEntry type="module" module-name="twilio-thinQLCR-java" exported="" />
<orderEntry type="library" exported="" name="Maven: com.twilio.sdk:twilio-java-sdk:6.3.0" level="project" />
<orderEntry type="library" exported="" name="Maven: org.apache.httpcomponents:httpclient:4.5.2" level="project" />
<orderEntry type="library" exported="" name="Maven: org.apache.httpcomponents:httpcore:4.4.5" level="project" />
</component>
</module>
Binary file removed lib/commons-codec-1.6.jar
Binary file not shown.
Binary file removed lib/commons-lang3-3.3.2.jar
Binary file not shown.
Binary file removed lib/commons-logging-1.1.1.jar
Binary file not shown.
Binary file removed lib/httpclient-4.2.6.jar
Binary file not shown.
Binary file removed lib/httpcore-4.2.5.jar
Binary file not shown.
Binary file removed lib/jackson-core-asl-1.9.3.jar
Binary file not shown.
Binary file removed lib/jackson-mapper-asl-1.9.3.jar
Binary file not shown.
Binary file removed lib/json-simple-1.1.jar
Binary file not shown.
Binary file removed lib/twilio-java-sdk-6.3.0.jar
Binary file not shown.
65 changes: 65 additions & 0 deletions pom.xml
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>
11 changes: 11 additions & 0 deletions pom.xml.asc
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-----
77 changes: 77 additions & 0 deletions src/main/java/com/twilio/thinq/TwilioWrapperLibrary.java
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 src/main/java/com/twilio/thinq/TwilioWrapperLibraryBuilder.java
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;
}
}
28 changes: 22 additions & 6 deletions twilio-thinQLCR-java.iml
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>

0 comments on commit 311bbf6

Please sign in to comment.