Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ V3-JAVA-SDK
<br/>
**Continuous Integration:** [![Build Status](https://travis-ci.org/intuit/QuickBooks-V3-Java-SDK.svg?branch=develop)](https://travis-ci.org/intuit/QuickBooks-V3-Java-SDK)
<br/>
**Maven:** [![Maven Central](https://img.shields.io/maven-central/v/com.intuit.quickbooks-online/ipp-v3-java-devkit.svg)](http://search.maven.org/#artifactdetails%7Ccom.intuit.quickbooks-online%7Cipp-v3-java-devkit%7C2.9.0%7C)
[![Maven Central](https://img.shields.io/maven-central/v/com.intuit.quickbooks-online/ipp-v3-java-data.svg)](http://search.maven.org/#artifactdetails%7Ccom.intuit.quickbooks-online%7Cipp-v3-java-data%7C2.9.0%7C)
<br/>
**License:** [![Apache 2](http://img.shields.io/badge/license-Apache%202-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0) <br/>


Expand All @@ -31,6 +34,7 @@ The QuickBooks Online Java SDK provides a set of Java class libraries that make
* ipp-v3-java-devkit-assembly - builds final deployment package (zip) which includes everything
* ipp-v3-java-devkit-shaded-assembly - builds lightweight version (some dependencies excluded)
* ipp-v3-java-devkit-javadoc - contains javadoc for data and devkit classes
* ipp-java-qbapihelper - contains Quickbooks API Helper methods for OAuth, Disconnect and Reconnect API

## System Requirements
The SDK works on JDK 1.6 and above.
Expand Down
147 changes: 147 additions & 0 deletions ipp-java-qbapihelper/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Copyright (c) 2017 Intuit

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<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>
<parent>
<artifactId>ipp-v3-java-devkit-pom</artifactId>
<groupId>com.intuit.quickbooks-online</groupId>
<version>2.9.1</version>
</parent>
<artifactId>ipp-java-qbapihelper</artifactId>
<version>2.9.1</version>
<packaging>jar</packaging>
<name>Quickbooks API Helper for Oauth</name>
<description>Quickbooks API Helper Project for OAuth, Disconnect and Reconnect</description>

<profiles>
<profile>
<properties>
<test.suite>testng.xml</test.suite>
</properties>
</profile>
</profiles>

<dependencies>
<dependency>
<groupId>oauth.signpost</groupId>
<artifactId>signpost-core</artifactId>
<version>1.2.1.1</version>
</dependency>
<dependency>
<groupId>oauth.signpost</groupId>
<artifactId>signpost-commonshttp4</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>net.sf.kxml</groupId>
<artifactId>kxml2</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.5</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>org.openid4java</groupId>
<artifactId>openid4java</artifactId>
<version>0.9.8</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.4</version>
</dependency>

</dependencies>

<build>
<!--<finalName>ipp-java-qbhelper</finalName> -->
<testResources>
<testResource>
<directory>${basedir}/src/test/resources</directory>
</testResource>
</testResources>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>

<plugins>
<!-- This plug-in instructs to use the mentioned JDK for compilation Reference:-
http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass
</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>${project.artifactId}-${project.version}</finalName>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>qb-helper</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
/*******************************************************************************
* Copyright (c) 2017 Intuit
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

package com.intuit.ia.connection;

/**
*
* This class exposes APIs for disconnect (disconnect) and fetching blue dot menu dropdown(getAppMenu)
*/

import java.util.List;
import java.util.Map;

import org.openid4java.discovery.Identifier;

import com.intuit.ia.exception.ConnectionException;
import com.intuit.ia.exception.OAuthException;
import com.intuit.ia.exception.OpenIdException;

public class IAPlatformClient {

private PlatformHttpClient httpClient;

private OAuthHelper oAuthHelper;
private OpenIdHelper openIdHelper;

public IAPlatformClient() {
openIdHelper = new OpenIdHelper();
oAuthHelper = new OAuthHelper();
}

/**
* Disconnects the user from quickbooks
*
* @throws ConnectionException
*/
public PlatformResponse disconnect(String consumerKey, String consumerSecret,
String accessToken, String accessTokenSecret)
throws ConnectionException {
httpClient = new PlatformHttpClient(consumerKey, consumerSecret,
accessToken, accessTokenSecret);
return this.httpClient.disconnect();
}
/**
* getCurrentUser the user from quickbooks
*
* @throws ConnectionException
*/
public User getcurrentUser(String consumerKey, String consumerSecret,
String accessToken, String accessTokenSecret)
throws ConnectionException {
httpClient = new PlatformHttpClient(consumerKey, consumerSecret,
accessToken, accessTokenSecret);
User user = null;;
try {
user = this.httpClient.getCurrentUser();
} catch (Exception e) {
e.printStackTrace();
}
return user;
}

/**
* Get App Menu returns list of all the applications that are linked with
* the selected company
*
* @return List<String>: Returns HTML as a list of Strings
* @throws ConnectionException
*
*/
public List<String> getAppMenu(String consumerKey, String consumerSecret,
String accessToken, String accessTokenSecret)
throws ConnectionException {
try {
List<String> menulist;
httpClient = new PlatformHttpClient(consumerKey, consumerSecret,
accessToken, accessTokenSecret);
menulist = this.httpClient.getAppMenu();
return menulist;
} catch (ConnectionException conEx) {
throw conEx;
} catch (Exception e) {
throw new ConnectionException("Failed to fetch appmenu: "
+ e.getMessage());
}
}

public Map<String, String> getRequestTokenAndSecret(String consumerKey,
String consumerSecret) throws OAuthException {
return oAuthHelper.getRequestToken(consumerKey, consumerSecret);
}

/**
*
* @param requestToken
* @return authorizeUrl
* @throws OAuthException
*
* This API will prepare the authorization URL and return it back
*/

public String getOauthAuthorizeUrl(String requestToken)
throws OAuthException {

return oAuthHelper.getAuthorizeUrl(requestToken);

}

/**
*
* Gets the accesstoken and accesstokensecret
*
* @param verofierCode
* @param requestToken
* (After the user authorization)
* @param requestTokensecret
* @return Map<String> : where accesstoken will be in the key "accessToken"
* and accesstokensecret will be in key "accessTokenSecret"
*
*/

public Map<String, String> getOAuthAccessToken(String verifierCode,
String requestToken, String requestTokenSecret, String consumerKey,
String consumerSecret) throws OAuthException {

return oAuthHelper.getAccessToken(verifierCode, requestToken,
requestTokenSecret, consumerKey, consumerSecret);
}

/**
* Gets the authorization url for OpenId
*
* @throws
*
*
*/

public String getOpenIdAuthorizeUrl() throws OpenIdException {

return openIdHelper.initOpenIdFlow();
}

/**
*
* @param receivingUrl
* @param parameterMap
* @return Identifier : the OpenId Identifier
* @throws OpenIdException
*/
public Identifier verifyOpenIdResponse(String receivingUrl,
Map<String, String[]> parameterMap) throws OpenIdException {
return openIdHelper.verifyResponse(receivingUrl, parameterMap);
}

/**
*
* @param consumerKey
* @param consumerSecret
* @param accessToken
* @param accessTokenSecret
* @throws ConnectionException
*/
public PlatformResponse reConnect(String consumerKey, String consumerSecret,
String accessToken, String accessTokenSecret)
throws ConnectionException {

httpClient = new PlatformHttpClient(consumerKey, consumerSecret,
accessToken, accessTokenSecret);
return this.httpClient.reConnect();
}
}
Loading