Skip to content

Commit 5076fc1

Browse files
authored
Merge pull request #10 from intuit/develop
merge changes to master
2 parents 529e78e + 0fbe85f commit 5076fc1

File tree

115 files changed

+2314
-505
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+2314
-505
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ V3-JAVA-SDK
66
<br/>
77
**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)
88
<br/>
9+
**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)
10+
[![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)
11+
<br/>
912
**License:** [![Apache 2](http://img.shields.io/badge/license-Apache%202-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0) <br/>
1013

1114

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

3539
## System Requirements
3640
The SDK works on JDK 1.6 and above.

ipp-java-qbapihelper/pom.xml

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Copyright (c) 2017 Intuit
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
19+
<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">
20+
<modelVersion>4.0.0</modelVersion>
21+
<parent>
22+
<artifactId>ipp-v3-java-devkit-pom</artifactId>
23+
<groupId>com.intuit.quickbooks-online</groupId>
24+
<version>2.9.1</version>
25+
</parent>
26+
<artifactId>ipp-java-qbapihelper</artifactId>
27+
<version>2.9.1</version>
28+
<packaging>jar</packaging>
29+
<name>Quickbooks API Helper for Oauth</name>
30+
<description>Quickbooks API Helper Project for OAuth, Disconnect and Reconnect</description>
31+
32+
<profiles>
33+
<profile>
34+
<properties>
35+
<test.suite>testng.xml</test.suite>
36+
</properties>
37+
</profile>
38+
</profiles>
39+
40+
<dependencies>
41+
<dependency>
42+
<groupId>oauth.signpost</groupId>
43+
<artifactId>signpost-core</artifactId>
44+
<version>1.2.1.1</version>
45+
</dependency>
46+
<dependency>
47+
<groupId>oauth.signpost</groupId>
48+
<artifactId>signpost-commonshttp4</artifactId>
49+
<version>1.2</version>
50+
</dependency>
51+
<dependency>
52+
<groupId>net.sf.kxml</groupId>
53+
<artifactId>kxml2</artifactId>
54+
<version>2.2.2</version>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.testng</groupId>
58+
<artifactId>testng</artifactId>
59+
<version>6.1.1</version>
60+
<scope>test</scope>
61+
</dependency>
62+
<dependency>
63+
<groupId>javax.servlet</groupId>
64+
<artifactId>servlet-api</artifactId>
65+
<version>2.4</version>
66+
<scope>provided</scope>
67+
</dependency>
68+
<dependency>
69+
<groupId>org.apache.httpcomponents</groupId>
70+
<artifactId>httpcore</artifactId>
71+
<version>4.4.5</version>
72+
</dependency>
73+
<dependency>
74+
<groupId>org.apache.httpcomponents</groupId>
75+
<artifactId>httpclient</artifactId>
76+
<version>4.5.2</version>
77+
</dependency>
78+
<dependency>
79+
<groupId>org.openid4java</groupId>
80+
<artifactId>openid4java</artifactId>
81+
<version>0.9.8</version>
82+
</dependency>
83+
<dependency>
84+
<groupId>org.slf4j</groupId>
85+
<artifactId>slf4j-api</artifactId>
86+
<version>1.6.4</version>
87+
</dependency>
88+
89+
</dependencies>
90+
91+
<build>
92+
<!--<finalName>ipp-java-qbhelper</finalName> -->
93+
<testResources>
94+
<testResource>
95+
<directory>${basedir}/src/test/resources</directory>
96+
</testResource>
97+
</testResources>
98+
<resources>
99+
<resource>
100+
<directory>${basedir}/src/main/resources</directory>
101+
</resource>
102+
</resources>
103+
104+
<plugins>
105+
<!-- This plug-in instructs to use the mentioned JDK for compilation Reference:-
106+
http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html -->
107+
<plugin>
108+
<groupId>org.apache.maven.plugins</groupId>
109+
<artifactId>maven-compiler-plugin</artifactId>
110+
<version>2.5.1</version>
111+
<configuration>
112+
<source>1.6</source>
113+
<target>1.6</target>
114+
</configuration>
115+
</plugin>
116+
<plugin>
117+
<artifactId>maven-jar-plugin</artifactId>
118+
<configuration>
119+
<archive>
120+
<manifest>
121+
<mainClass>fully.qualified.MainClass
122+
</mainClass>
123+
</manifest>
124+
</archive>
125+
</configuration>
126+
</plugin>
127+
<plugin>
128+
<artifactId>maven-assembly-plugin</artifactId>
129+
<configuration>
130+
<finalName>${project.artifactId}-${project.version}</finalName>
131+
<descriptorRefs>
132+
<descriptorRef>jar-with-dependencies</descriptorRef>
133+
</descriptorRefs>
134+
</configuration>
135+
<executions>
136+
<execution>
137+
<id>qb-helper</id>
138+
<phase>package</phase>
139+
<goals>
140+
<goal>single</goal>
141+
</goals>
142+
</execution>
143+
</executions>
144+
</plugin>
145+
</plugins>
146+
</build>
147+
</project>
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2017 Intuit
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*******************************************************************************/
16+
17+
package com.intuit.ia.connection;
18+
19+
/**
20+
*
21+
* This class exposes APIs for disconnect (disconnect) and fetching blue dot menu dropdown(getAppMenu)
22+
*/
23+
24+
import java.util.List;
25+
import java.util.Map;
26+
27+
import org.openid4java.discovery.Identifier;
28+
29+
import com.intuit.ia.exception.ConnectionException;
30+
import com.intuit.ia.exception.OAuthException;
31+
import com.intuit.ia.exception.OpenIdException;
32+
33+
public class IAPlatformClient {
34+
35+
private PlatformHttpClient httpClient;
36+
37+
private OAuthHelper oAuthHelper;
38+
private OpenIdHelper openIdHelper;
39+
40+
public IAPlatformClient() {
41+
openIdHelper = new OpenIdHelper();
42+
oAuthHelper = new OAuthHelper();
43+
}
44+
45+
/**
46+
* Disconnects the user from quickbooks
47+
*
48+
* @throws ConnectionException
49+
*/
50+
public PlatformResponse disconnect(String consumerKey, String consumerSecret,
51+
String accessToken, String accessTokenSecret)
52+
throws ConnectionException {
53+
httpClient = new PlatformHttpClient(consumerKey, consumerSecret,
54+
accessToken, accessTokenSecret);
55+
return this.httpClient.disconnect();
56+
}
57+
/**
58+
* getCurrentUser the user from quickbooks
59+
*
60+
* @throws ConnectionException
61+
*/
62+
public User getcurrentUser(String consumerKey, String consumerSecret,
63+
String accessToken, String accessTokenSecret)
64+
throws ConnectionException {
65+
httpClient = new PlatformHttpClient(consumerKey, consumerSecret,
66+
accessToken, accessTokenSecret);
67+
User user = null;;
68+
try {
69+
user = this.httpClient.getCurrentUser();
70+
} catch (Exception e) {
71+
e.printStackTrace();
72+
}
73+
return user;
74+
}
75+
76+
/**
77+
* Get App Menu returns list of all the applications that are linked with
78+
* the selected company
79+
*
80+
* @return List<String>: Returns HTML as a list of Strings
81+
* @throws ConnectionException
82+
*
83+
*/
84+
public List<String> getAppMenu(String consumerKey, String consumerSecret,
85+
String accessToken, String accessTokenSecret)
86+
throws ConnectionException {
87+
try {
88+
List<String> menulist;
89+
httpClient = new PlatformHttpClient(consumerKey, consumerSecret,
90+
accessToken, accessTokenSecret);
91+
menulist = this.httpClient.getAppMenu();
92+
return menulist;
93+
} catch (ConnectionException conEx) {
94+
throw conEx;
95+
} catch (Exception e) {
96+
throw new ConnectionException("Failed to fetch appmenu: "
97+
+ e.getMessage());
98+
}
99+
}
100+
101+
public Map<String, String> getRequestTokenAndSecret(String consumerKey,
102+
String consumerSecret) throws OAuthException {
103+
return oAuthHelper.getRequestToken(consumerKey, consumerSecret);
104+
}
105+
106+
/**
107+
*
108+
* @param requestToken
109+
* @return authorizeUrl
110+
* @throws OAuthException
111+
*
112+
* This API will prepare the authorization URL and return it back
113+
*/
114+
115+
public String getOauthAuthorizeUrl(String requestToken)
116+
throws OAuthException {
117+
118+
return oAuthHelper.getAuthorizeUrl(requestToken);
119+
120+
}
121+
122+
/**
123+
*
124+
* Gets the accesstoken and accesstokensecret
125+
*
126+
* @param verofierCode
127+
* @param requestToken
128+
* (After the user authorization)
129+
* @param requestTokensecret
130+
* @return Map<String> : where accesstoken will be in the key "accessToken"
131+
* and accesstokensecret will be in key "accessTokenSecret"
132+
*
133+
*/
134+
135+
public Map<String, String> getOAuthAccessToken(String verifierCode,
136+
String requestToken, String requestTokenSecret, String consumerKey,
137+
String consumerSecret) throws OAuthException {
138+
139+
return oAuthHelper.getAccessToken(verifierCode, requestToken,
140+
requestTokenSecret, consumerKey, consumerSecret);
141+
}
142+
143+
/**
144+
* Gets the authorization url for OpenId
145+
*
146+
* @throws
147+
*
148+
*
149+
*/
150+
151+
public String getOpenIdAuthorizeUrl() throws OpenIdException {
152+
153+
return openIdHelper.initOpenIdFlow();
154+
}
155+
156+
/**
157+
*
158+
* @param receivingUrl
159+
* @param parameterMap
160+
* @return Identifier : the OpenId Identifier
161+
* @throws OpenIdException
162+
*/
163+
public Identifier verifyOpenIdResponse(String receivingUrl,
164+
Map<String, String[]> parameterMap) throws OpenIdException {
165+
return openIdHelper.verifyResponse(receivingUrl, parameterMap);
166+
}
167+
168+
/**
169+
*
170+
* @param consumerKey
171+
* @param consumerSecret
172+
* @param accessToken
173+
* @param accessTokenSecret
174+
* @throws ConnectionException
175+
*/
176+
public PlatformResponse reConnect(String consumerKey, String consumerSecret,
177+
String accessToken, String accessTokenSecret)
178+
throws ConnectionException {
179+
180+
httpClient = new PlatformHttpClient(consumerKey, consumerSecret,
181+
accessToken, accessTokenSecret);
182+
return this.httpClient.reConnect();
183+
}
184+
}

0 commit comments

Comments
 (0)