Skip to content

Commit 2b63102

Browse files
Rajabbala-github
authored andcommitted
Removing appId from API Client (#19)
* Removing appId dependency with api-client * Test spec updated after removing appId dependency * README updated after removing appId dependency * README updated * README.md updated as per review comment * Verison bumped to 3.0.0
1 parent 1fb6014 commit 2b63102

11 files changed

Lines changed: 55 additions & 68 deletions

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,17 @@ Add the following dependency to your pom file
1515
<dependency>
1616
<groupId>com.indix.api</groupId>
1717
<artifactId>indix-api-java</artifactId>
18-
<version>2.0.0</version>
18+
<version>3.0.0</version>
1919
</dependency>
2020
```
2121

2222
##Usage :
2323

24-
The client needs to be first instantiated with the appropriate application id and key to be able to use
25-
the different api endpoints. It can be done as follows:
24+
First, the client must be instantiated with the appropriate application key (appKey). It can be done as follows:
2625
```java
27-
String appId = "__app_id__";
2826
String appKey = "__app_key__";
2927
IndixApiClient indixApiClient = IndixApiClientFactory
30-
.newIndixApiClient(appId, appKey);
28+
.newIndixApiClient(appKey);
3129
```
3230

3331
This instance can then used to query the different endpoints and obtain responses. Different types
@@ -209,5 +207,5 @@ HttpClient client = HttpClientFactory.newHttpClient(HttpClients.custom()
209207
.setSslcontext(SSLTrustCA.trustLetsEncryptRootCA())
210208
.build());
211209
IndixApiClient indixApiClient = IndixApiClientFactory
212-
.newIndixApiClient(appId, appKey, client);
210+
.newIndixApiClient(appKey, client);
213211
```

pom.xml

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

1111
<groupId>com.indix.api</groupId>
1212
<artifactId>indix-api-java</artifactId>
13-
<version>2.0.0</version>
13+
<version>3.0.0</version>
1414
<packaging>jar</packaging>
1515
<name>Indix API-V2 Java Client</name>
1616
<description>Java client which is used to access API V2 endpoints</description>

src/main/java/com/indix/client/impl/IndixApiClientFactory.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,32 @@
99
public class IndixApiClientFactory {
1010

1111
/**
12-
* @param appId application id
1312
* @param appKey application key
1413
* @return {@link IndixApiClient}
1514
*/
16-
public static IndixApiClient newIndixApiClient(String appId, String appKey) {
17-
return new IndixApiClientImpl(appId, appKey);
15+
public static IndixApiClient newIndixApiClient(String appKey) {
16+
return new IndixApiClientImpl(appKey);
1817
}
1918

2019
/**
2120
* Used for mocking http client for testing purpose.
22-
* @param appId application id
2321
* @param appKey application key
2422
* @param httpClient mock http client
2523
* @return {@link IndixApiClient}
2624
*/
27-
public static IndixApiClient newIndixApiClient(String appId, String appKey, HttpClient httpClient) {
28-
return new IndixApiClientImpl(appId, appKey, httpClient);
25+
public static IndixApiClient newIndixApiClient(String appKey, HttpClient httpClient) {
26+
return new IndixApiClientImpl(appKey, httpClient);
2927
}
3028

3129

3230
/**
3331
* Used for setting server scheme and host for testing purpose.
34-
* @param appId application id
3532
* @param appKey application key
3633
* @param scheme http scheme
3734
* @param host api host to be queried
3835
* @return {@link IndixApiClient}
3936
*/
40-
public static IndixApiClient newIndixApiClient(String appId, String appKey, String scheme, String host) {
41-
return new IndixApiClientImpl(appId, appKey, scheme, host);
37+
public static IndixApiClient newIndixApiClient(String appKey, String scheme, String host) {
38+
return new IndixApiClientImpl(appKey, scheme, host);
4239
}
4340
}

src/main/java/com/indix/client/impl/IndixApiClientImpl.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,14 @@ class IndixApiClientImpl implements IndixApiClient {
5757

5858
// Authorization parameters
5959
//
60-
String appId;
6160
String appKey;
6261

6362
final static Logger logger = LoggerFactory.getLogger(IndixApiClientImpl.class);
6463

6564
// constructors
6665
//
67-
private IndixApiClientImpl(String appId, String appKey, HttpClient httpClient, ObjectMapper jsonMapper,
66+
private IndixApiClientImpl(String appKey, HttpClient httpClient, ObjectMapper jsonMapper,
6867
String scheme, String host) {
69-
this.appId = appId;
7068
this.appKey = appKey;
7169
this.httpClient = httpClient;
7270
this.jsonMapper = jsonMapper;
@@ -75,27 +73,24 @@ private IndixApiClientImpl(String appId, String appKey, HttpClient httpClient, O
7573
}
7674

7775
/**
78-
* @param appId application id
7976
* @param appKey application key
8077
*/
81-
public IndixApiClientImpl(String appId, String appKey) {
82-
this(appId, appKey, HttpClientFactory.newHttpClient(), getNewObjectMapper(), SCHEME, HOST);
78+
public IndixApiClientImpl(String appKey) {
79+
this(appKey, HttpClientFactory.newHttpClient(), getNewObjectMapper(), SCHEME, HOST);
8380
}
8481

8582
/**
86-
* @param appId application id
8783
* @param appKey application key
8884
*/
89-
public IndixApiClientImpl(String appId, String appKey, String scheme, String host) {
90-
this(appId, appKey, HttpClientFactory.newHttpClient(), getNewObjectMapper(), scheme, host);
85+
public IndixApiClientImpl(String appKey, String scheme, String host) {
86+
this(appKey, HttpClientFactory.newHttpClient(), getNewObjectMapper(), scheme, host);
9187
}
9288

9389
/**
94-
* @param appId application id
9590
* @param appKey application key
9691
*/
97-
public IndixApiClientImpl(String appId, String appKey, HttpClient httpClient) {
98-
this(appId, appKey, httpClient, getNewObjectMapper(), SCHEME, HOST);
92+
public IndixApiClientImpl(String appKey, HttpClient httpClient) {
93+
this(appKey, httpClient, getNewObjectMapper(), SCHEME, HOST);
9994
}
10095

10196
// getter methods
@@ -114,7 +109,6 @@ private URI buildURI(String resource, Query searchQuery) throws URISyntaxExcepti
114109
.setHost(host)
115110
.setPath(resource)
116111
.setParameters(searchQuery.getParameters())
117-
.addParameter(APP_ID, appId)
118112
.addParameter(APP_KEY, appKey)
119113
.build();
120114
}
@@ -148,7 +142,6 @@ private String executePOST(String resource, Query searchQuery, File file)
148142
// populate app_id and app_key
149143
//
150144
List<NameValuePair> params = searchQuery.getParameters();
151-
params.add(new BasicNameValuePair(APP_ID, appId));
152145
params.add(new BasicNameValuePair(APP_KEY, appKey));
153146

154147
return httpClient.POST(uri, params, file);

src/test/java/com/indix/client/IndixApiClientBulkQueryTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void getBulkJobId()
3535
MockResourceHttpClient mockHttpClientInstance = new MockResourceHttpClient();
3636
HttpClient mockHttpClient = mockHttpClientInstance.getMockClient("bulkQuery-json-responses0/bulkQueryResponse.json");
3737

38-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123", mockHttpClient);
38+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", mockHttpClient);
3939

4040
List<Integer> storeIdList = new ArrayList<Integer>();
4141
storeIdList.add(68);
@@ -64,7 +64,7 @@ public void getBulkLookupJobId()
6464
MockResourceHttpClient mockHttpClientInstance = new MockResourceHttpClient();
6565
HttpClient mockHttpClient = mockHttpClientInstance.getMockClient("bulkQuery-json-responses0/bulkQueryResponse.json");
6666

67-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123", mockHttpClient);
67+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", mockHttpClient);
6868

6969
try {
7070
for (ProductsViewType resource : ProductsViewType.values()) {
@@ -92,7 +92,7 @@ public void getBulkJobStatus()
9292
MockResourceHttpClient mockHttpClientInstance = new MockResourceHttpClient();
9393
HttpClient mockHttpClient = mockHttpClientInstance.getMockClient("bulkQuery-json-responses0/bulkQueryJobStatus.json");
9494

95-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123", mockHttpClient);
95+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", mockHttpClient);
9696

9797
try {
9898
JobQuery jobQuery = QueryFactory.newJobQuery()
@@ -116,7 +116,7 @@ public void getBulkJobFile()
116116
MockResourceHttpClient mockHttpClientInstance = new MockResourceHttpClient();
117117
HttpClient mockHttpClient = mockHttpClientInstance.getMockClient("bulkQuery-json-responses0/bulkQueryJobOutput.jsonl.tar.gz");
118118

119-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123", mockHttpClient);
119+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", mockHttpClient);
120120

121121
try {
122122
JobQuery jobQuery = QueryFactory.newJobQuery()

src/test/java/com/indix/client/IndixApiClientHandleExceptionsTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void handleUnauthorizedException()
2222
MockExceptionHttpClient mockClientInstance = new MockExceptionHttpClient();
2323
HttpClient mockHttpClient = mockClientInstance.getMockClient(MockExceptionHttpClient.ExceptionName.UNAUTHORIZED);
2424

25-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123", mockHttpClient);
25+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", mockHttpClient);
2626

2727
try {
2828
SearchQuery searchQuery = QueryFactory.newSearchQuery();
@@ -42,7 +42,7 @@ public void handleTooManyRequestsException()
4242
MockExceptionHttpClient mockClientInstance = new MockExceptionHttpClient();
4343
HttpClient mockHttpClient = mockClientInstance.getMockClient(MockExceptionHttpClient.ExceptionName.TOO_MANY_REQUESTS);
4444

45-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123", mockHttpClient);
45+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", mockHttpClient);
4646

4747
try {
4848
SearchQuery searchQuery = QueryFactory.newSearchQuery();
@@ -62,7 +62,7 @@ public void handlePaymentRequiredException()
6262
MockExceptionHttpClient mockClientInstance = new MockExceptionHttpClient();
6363
HttpClient mockHttpClient = mockClientInstance.getMockClient(MockExceptionHttpClient.ExceptionName.PAYMENT_REQUIRED);
6464

65-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123", mockHttpClient);
65+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", mockHttpClient);
6666

6767
try {
6868
SearchQuery searchQuery = QueryFactory.newSearchQuery();
@@ -82,7 +82,7 @@ public void handleIndixApiException()
8282
MockExceptionHttpClient mockClientInstance = new MockExceptionHttpClient();
8383
HttpClient mockHttpClient = mockClientInstance.getMockClient(MockExceptionHttpClient.ExceptionName.INDIX_API);
8484

85-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123", mockHttpClient);
85+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", mockHttpClient);
8686

8787
try {
8888
SearchQuery searchQuery = QueryFactory.newSearchQuery();
@@ -102,7 +102,7 @@ public void handleInternalServerException()
102102
MockExceptionHttpClient mockClientInstance = new MockExceptionHttpClient();
103103
HttpClient mockHttpClient = mockClientInstance.getMockClient(MockExceptionHttpClient.ExceptionName.INTERNAL_SERVER);
104104

105-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123", mockHttpClient);
105+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", mockHttpClient);
106106

107107
try {
108108
SearchQuery searchQuery = QueryFactory.newSearchQuery();
@@ -122,7 +122,7 @@ public void handleBadRequestException()
122122
MockExceptionHttpClient mockClientInstance = new MockExceptionHttpClient();
123123
HttpClient mockHttpClient = mockClientInstance.getMockClient(MockExceptionHttpClient.ExceptionName.BAD_REQUEST);
124124

125-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123", mockHttpClient);
125+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", mockHttpClient);
126126

127127
try {
128128
SearchQuery searchQuery = QueryFactory.newSearchQuery();

src/test/java/com/indix/client/IndixApiClientMetadataTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public HttpClient getMockHttpClient(String resource)
2828
public void getStores()
2929
throws IndixApiException, IOException, URISyntaxException {
3030

31-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123",
31+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123",
3232
getMockHttpClient("metadata-json-responses0/storesResponse.json"));
3333

3434
try {
@@ -48,7 +48,7 @@ public void getStores()
4848
public void getBrands()
4949
throws IndixApiException, IOException, URISyntaxException {
5050

51-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123",
51+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123",
5252
getMockHttpClient("metadata-json-responses0/brandsResponse.json"));
5353

5454
try {
@@ -67,7 +67,7 @@ public void getBrands()
6767
public void getCategories()
6868
throws IndixApiException, IOException, URISyntaxException {
6969

70-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123",
70+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123",
7171
getMockHttpClient("metadata-json-responses0/categoriesResponse.json"));
7272

7373
try {

src/test/java/com/indix/client/IndixApiClientProductDetailsTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public HttpClient getMockHttpClient(String resource)
2626
public void getProductDetailsSummary()
2727
throws IndixApiException, IOException, URISyntaxException {
2828

29-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123",
29+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123",
3030
getMockHttpClient("productDetails-json-responses0/summaryProductDetailsResponse.json"));
3131

3232
try {
@@ -46,7 +46,7 @@ public void getProductDetailsSummary()
4646
public void getProductDetailsOffersStandard()
4747
throws IndixApiException, IOException, URISyntaxException {
4848

49-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123",
49+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123",
5050
getMockHttpClient("productDetails-json-responses0/offersStandardProductDetailsResponse.json"));
5151

5252
try {
@@ -67,7 +67,7 @@ public void getProductDetailsOffersStandard()
6767
public void getProductDetailsOffersPremium()
6868
throws IndixApiException, IOException, URISyntaxException {
6969

70-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123",
70+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123",
7171
getMockHttpClient("productDetails-json-responses0/offersPremiumProductDetailsResponse.json"));
7272

7373
try {
@@ -87,7 +87,7 @@ public void getProductDetailsOffersPremium()
8787
public void getProductDetailsCatalogStandard()
8888
throws IndixApiException, IOException, URISyntaxException {
8989

90-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123",
90+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123",
9191
getMockHttpClient("productDetails-json-responses0/catalogStandardProductDetailsResponse.json"));
9292

9393
try {
@@ -107,7 +107,7 @@ public void getProductDetailsCatalogStandard()
107107
public void getProductDetailsCatalogPremium()
108108
throws IndixApiException, IOException, URISyntaxException {
109109

110-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123",
110+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123",
111111
getMockHttpClient("productDetails-json-responses0/catalogPremiumProductDetailsResponse.json"));
112112

113113
try {
@@ -129,7 +129,7 @@ public void getProductDetailsCatalogPremium()
129129
public void getProductDetailsUniversal()
130130
throws IndixApiException, IOException, URISyntaxException {
131131

132-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123",
132+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123",
133133
getMockHttpClient("productDetails-json-responses0/universalProductDetailsResponse.json"));
134134

135135
try {
@@ -151,7 +151,7 @@ public void getProductDetailsUniversal()
151151
public void getProductDetailsSummaryShouldNotFailIfInputHasAdditionalFields()
152152
throws IndixApiException, IOException, URISyntaxException {
153153

154-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123",
154+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123",
155155
getMockHttpClient("productDetails-json-responses0/universalProductDetailsResponse.json"));
156156

157157
try {
@@ -171,7 +171,7 @@ public void getProductDetailsSummaryShouldNotFailIfInputHasAdditionalFields()
171171
public void getProductDetailsOffersStandardShouldNotFailIfInputHasAdditionalFields()
172172
throws IndixApiException, IOException, URISyntaxException {
173173

174-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123",
174+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123",
175175
getMockHttpClient("productDetails-json-responses0/universalProductDetailsResponse.json"));
176176

177177
try {
@@ -192,7 +192,7 @@ public void getProductDetailsOffersStandardShouldNotFailIfInputHasAdditionalFiel
192192
public void getProductDetailsOffersPremiumShouldNotFailIfInputHasAdditionalFields()
193193
throws IndixApiException, IOException, URISyntaxException {
194194

195-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123",
195+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123",
196196
getMockHttpClient("productDetails-json-responses0/universalProductDetailsResponse.json"));
197197

198198
try {
@@ -212,7 +212,7 @@ public void getProductDetailsOffersPremiumShouldNotFailIfInputHasAdditionalField
212212
public void getProductDetailsCatalogStandardShouldNotFailIfInputHasAdditionalFields()
213213
throws IndixApiException, IOException, URISyntaxException {
214214

215-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123",
215+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123",
216216
getMockHttpClient("productDetails-json-responses0/universalProductDetailsResponse.json"));
217217

218218
try {
@@ -232,7 +232,7 @@ public void getProductDetailsCatalogStandardShouldNotFailIfInputHasAdditionalFie
232232
public void getProductDetailsCatalogPremiumShouldNotFailIfInputHasAdditionalFields()
233233
throws IndixApiException, IOException, URISyntaxException {
234234

235-
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123", "123",
235+
IndixApiClient indixApiClient = IndixApiClientFactory.newIndixApiClient("123",
236236
getMockHttpClient("productDetails-json-responses0/universalProductDetailsResponse.json"));
237237

238238
try {

0 commit comments

Comments
 (0)