Skip to content

Commit 73f07d5

Browse files
committed
changes to pass debug logs boolean in constructor
1 parent b7b88f2 commit 73f07d5

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

kiteconnect/src/com/zerodhatech/kiteconnect/KiteConnect.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,22 @@ public class KiteConnect {
4444
* @param apiKey is the api key provided after creating new Kite Connect app on developers console.
4545
*/
4646
public KiteConnect(String apiKey){
47-
this(apiKey, null);
47+
this(apiKey, null, false);
48+
}
49+
50+
/** Initializes KiteSDK with the api key provided for your app.
51+
* @param apiKey is the api key provided after creating new Kite Connect app on developers console.
52+
* @param enableDebugLog is a boolean to enable debug logs
53+
*/
54+
public KiteConnect(String apiKey, boolean enableDebugLog){
55+
this(apiKey, null, enableDebugLog);
4856
}
4957

5058
/** Initializes KiteSDK with the api key provided for your app.
5159
* @param apiKey is the api key provided after creating new Kite Connect app on developers console.
5260
* @param userProxy is the user defined proxy. Can be used only if a user chose to use the proxy.
5361
*/
54-
public KiteConnect(String apiKey, Proxy userProxy) {
62+
public KiteConnect(String apiKey, Proxy userProxy, boolean enableDebugLog) {
5563
this.proxy = userProxy;
5664
this.apiKey = apiKey;
5765
GsonBuilder gsonBuilder = new GsonBuilder();
@@ -68,6 +76,7 @@ public Date deserialize(JsonElement jsonElement, Type type, JsonDeserializationC
6876
}
6977
});
7078
gson = gsonBuilder.setDateFormat("yyyy-MM-dd HH:mm:ss").create();
79+
ENABLE_LOGGING = enableDebugLog;
7180
kiteRequestHandler = new KiteRequestHandler(proxy);
7281
}
7382

@@ -78,18 +87,6 @@ public void setSessionExpiryHook(SessionExpiryHook hook){
7887
sessionExpiryHook = hook;
7988
}
8089

81-
/** Enables logging of requests and responses.
82-
* @param enable is set to true to enable logging. */
83-
public void setEnableLogging(boolean enable) {
84-
ENABLE_LOGGING = enable;
85-
}
86-
87-
/** Set proxy.
88-
* @param proxy defined by user for making requests. *//*
89-
public void setProxy(Proxy proxy){
90-
this.proxy = proxy;
91-
}*/
92-
9390
/**
9491
* Returns apiKey of the App.
9592
* @return String apiKey is returned.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.zerodhatech.kiteconnect</groupId>
88
<artifactId>kiteconnect</artifactId>
9-
<version>3.0.1</version>
9+
<version>3.0.2</version>
1010
<packaging>jar</packaging>
1111

1212
<distributionManagement>

sample/src/Test.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ public static void main(String[] args){
1919
try {
2020
// First you should get request_token, public_token using kitconnect login and then use request_token, public_token, api_secret to make any kiteConnect api call.
2121
// Initialize KiteSdk with your apiKey.
22+
KiteConnect kiteConnect = new KiteConnect("xxxxyyyyzzzz");
23+
24+
//If you wish to enable debug logs send true in the constructor, this will log request and response.
25+
//KiteConnect kiteConnect = new KiteConnect("xxxxyyyyzzzz", true);
26+
2227
// If you wish to set proxy then pass proxy as a second parameter in the constructor with api_key. syntax:- new KiteConnect("xxxxxxyyyyyzzz", proxy).
23-
KiteConnect kiteConnect = new KiteConnect("xxxxxxyyyyyzzz");
28+
//KiteConnect kiteConnect = new KiteConnect("xxxxyyyyzzzz", userProxy, false);
2429

2530
// Set userId
26-
kiteConnect.setUserId("xxxxyyy");
27-
28-
//Enable logs for debugging purpose. This will log request and response.
29-
kiteConnect.setEnableLogging(true);
31+
kiteConnect.setUserId("xxxyyy");
3032

3133
// Get login url
3234
String url = kiteConnect.getLoginURL();
@@ -124,7 +126,7 @@ public void sessionExpired() {
124126
examples.logout(kiteConnect);
125127

126128
ArrayList<Long> tokens = new ArrayList<>();
127-
tokens.add(Long.parseLong("265"));
129+
tokens.add(Long.parseLong("256265"));
128130
examples.tickerUsage(kiteConnect, tokens);
129131
} catch (KiteException e) {
130132
System.out.println(e.message+" "+e.code+" "+e.getClass().getName());

0 commit comments

Comments
 (0)