Skip to content

Commit ca093bf

Browse files
committed
fix!: Unspecified type issue
1 parent 9cb73c3 commit ca093bf

File tree

66 files changed

+628
-139
lines changed

Some content is hidden

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

66 files changed

+628
-139
lines changed

src/main/java/mobi/appcent/medusa/store/MedusaSdkClient.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -712,16 +712,15 @@ public File prepareDownloadFile(Response response) throws IOException {
712712
}
713713

714714
/**
715-
* {@link #execute(Call, Type)}
715+
* {@link #executeCall(Call, Type)}
716716
*
717717
* @param <T> Type
718718
* @param call An instance of the Call object
719719
* @throws ApiException If fail to execute the call
720720
* @return ApiResponse&lt;T&gt;
721721
*/
722-
public <T> ApiResponse<T> execute(Call call) throws ApiException {
723-
TypeReference<T> typeReference = new TypeReference<T>() {};
724-
return execute(call, typeReference.getType());
722+
public <T> ApiResponse<T> execute(Call call, Type type) throws ApiException {
723+
return executeCall(call, type);
725724
}
726725

727726
/**
@@ -735,7 +734,7 @@ public <T> ApiResponse<T> execute(Call call) throws ApiException {
735734
* when returnType is null.
736735
* @throws ApiException If fail to execute the call
737736
*/
738-
private <T> ApiResponse<T> execute(Call call, Type returnType) throws ApiException {
737+
private <T> ApiResponse<T> executeCall(Call call, Type returnType) throws ApiException {
739738
try {
740739
Response response = call.execute();
741740
T data = handleResponse(response, returnType);
@@ -759,7 +758,7 @@ public <T> void executeAsync(Call call, ApiCallback<T> callback) {
759758
/**
760759
* Execute HTTP call asynchronously.
761760
*
762-
* @see #execute(Call, Type)
761+
* @see #executeCall(Call, Type)
763762
* @param <T> Type
764763
* @param call The callback to be executed when the API call finishes
765764
* @param returnType Return type

src/main/java/mobi/appcent/medusa/store/model/request/BaseRequest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package mobi.appcent.medusa.store.model.request;
22

3+
import com.google.gson.reflect.TypeToken;
34
import com.squareup.okhttp.Call;
45
import mobi.appcent.medusa.store.ApiCallback;
56
import mobi.appcent.medusa.store.ApiException;
67
import mobi.appcent.medusa.store.ApiResponse;
78
import mobi.appcent.medusa.store.MedusaSdkClient;
89

10+
import java.lang.reflect.Type;
11+
912
/**
1013
* Created by erenalpaslan on 4.03.2023
1114
*/
@@ -17,4 +20,6 @@ abstract public class BaseRequest <T> {
1720

1821
public abstract void executeAsync(final ApiCallback<T> callback) throws ApiException;
1922

23+
public abstract Type getType();
24+
2025
}

src/main/java/mobi/appcent/medusa/store/model/request/auth/DeleteAuthRequest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected Call buildCall() throws ApiException {
4040
@Override
4141
public ApiResponse<Void> execute() throws ApiException {
4242
Call call = buildCall();
43-
return client.execute(call);
43+
return client.execute(call, null);
4444
}
4545

4646
@Override
@@ -49,4 +49,9 @@ public void executeAsync(ApiCallback<Void> callback) throws ApiException {
4949
Type type = new TypeToken<ApiResponse<Void>>(){}.getType();
5050
client.executeAsync(call, type, callback);
5151
}
52+
53+
@Override
54+
public Type getType() {
55+
return new TypeToken<Void>(){}.getType();
56+
}
5257
}

src/main/java/mobi/appcent/medusa/store/model/request/auth/GetAuthEmailRequest.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package mobi.appcent.medusa.store.model.request.auth;
22

3+
import com.google.gson.reflect.TypeToken;
34
import com.squareup.okhttp.Call;
45
import mobi.appcent.medusa.store.*;
56
import mobi.appcent.medusa.store.common.HeaderConstant;
67
import mobi.appcent.medusa.store.common.HttpMethod;
78
import mobi.appcent.medusa.store.common.UrlConstant;
89
import mobi.appcent.medusa.store.model.request.BaseRequest;
910
import mobi.appcent.medusa.store.model.response.StoreGetAuthEmailRes;
11+
12+
import java.lang.reflect.Type;
1013
import java.util.HashMap;
1114
import java.util.Map;
1215

@@ -46,12 +49,18 @@ protected Call buildCall() throws ApiException {
4649
@Override
4750
public ApiResponse<StoreGetAuthEmailRes> execute() throws ApiException {
4851
Call call = buildCall();
49-
return client.execute(call);
52+
return client.execute(call, getType());
5053
}
5154

5255
@Override
5356
public void executeAsync(ApiCallback<StoreGetAuthEmailRes> callback) throws ApiException {
5457
Call call = buildCall();
55-
client.executeAsync(call, callback);
58+
client.executeAsync(call, getType(), callback);
5659
}
60+
61+
@Override
62+
public Type getType() {
63+
return new TypeToken<StoreGetAuthEmailRes>(){}.getType();
64+
}
65+
5766
}

src/main/java/mobi/appcent/medusa/store/model/request/auth/GetAuthRequest.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
package mobi.appcent.medusa.store.model.request.auth;
22

3+
import com.google.gson.reflect.TypeToken;
34
import com.squareup.okhttp.Call;
45
import mobi.appcent.medusa.store.*;
56
import mobi.appcent.medusa.store.common.HeaderConstant;
67
import mobi.appcent.medusa.store.common.HttpMethod;
78
import mobi.appcent.medusa.store.common.UrlConstant;
89
import mobi.appcent.medusa.store.model.request.BaseRequest;
910
import mobi.appcent.medusa.store.model.response.StoreAuthRes;
11+
import mobi.appcent.medusa.store.model.response.StoreGetAuthEmailRes;
1012

13+
import java.lang.reflect.Type;
1114
import java.util.HashMap;
1215
import java.util.Map;
1316

@@ -40,12 +43,17 @@ protected Call buildCall() throws ApiException {
4043
@Override
4144
public ApiResponse<StoreAuthRes> execute() throws ApiException {
4245
Call call = buildCall();
43-
return client.execute(call);
46+
return client.execute(call, getType());
4447
}
4548

4649
@Override
4750
public void executeAsync(ApiCallback<StoreAuthRes> callback) throws ApiException {
4851
Call call = buildCall();
49-
client.executeAsync(call, callback);
52+
client.executeAsync(call, getType(), callback);
53+
}
54+
55+
@Override
56+
public Type getType() {
57+
return new TypeToken<StoreAuthRes>(){}.getType();
5058
}
5159
}

src/main/java/mobi/appcent/medusa/store/model/request/auth/PostAuthRequest.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package mobi.appcent.medusa.store.model.request.auth;
22

3+
import com.google.gson.reflect.TypeToken;
34
import com.squareup.okhttp.Call;
45
import mobi.appcent.medusa.store.*;
56
import mobi.appcent.medusa.store.common.HeaderConstant;
@@ -8,6 +9,8 @@
89
import mobi.appcent.medusa.store.model.request.BaseRequest;
910
import mobi.appcent.medusa.store.model.response.StoreAuthRes;
1011
import mobi.appcent.medusa.store.model.response.StorePostAuthReq;
12+
13+
import java.lang.reflect.Type;
1114
import java.util.HashMap;
1215
import java.util.Map;
1316

@@ -57,12 +60,17 @@ protected Call buildCall() throws ApiException {
5760
@Override
5861
public ApiResponse<StoreAuthRes> execute() throws ApiException {
5962
Call call = buildCall();
60-
return client.execute(call);
63+
return client.execute(call, getType());
6164
}
6265

6366
@Override
6467
public void executeAsync(ApiCallback<StoreAuthRes> callback) throws ApiException {
6568
Call call = buildCall();
66-
client.executeAsync(call, callback);
69+
client.executeAsync(call, getType(), callback);
70+
}
71+
72+
@Override
73+
public Type getType() {
74+
return new TypeToken<StoreAuthRes>(){}.getType();
6775
}
6876
}

src/main/java/mobi/appcent/medusa/store/model/request/cart/AddLineItemRequest.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
package mobi.appcent.medusa.store.model.request.cart;
22

3+
import com.google.gson.reflect.TypeToken;
34
import com.squareup.okhttp.Call;
45
import mobi.appcent.medusa.store.*;
56
import mobi.appcent.medusa.store.common.HeaderConstant;
67
import mobi.appcent.medusa.store.common.HttpMethod;
78
import mobi.appcent.medusa.store.common.UrlConstant;
89
import mobi.appcent.medusa.store.model.request.BaseRequest;
10+
import mobi.appcent.medusa.store.model.response.StoreAuthRes;
911
import mobi.appcent.medusa.store.model.response.StoreCartsRes;
1012
import mobi.appcent.medusa.store.model.response.StorePostCartsCartLineItemsReq;
1113

1214
import java.io.IOException;
15+
import java.lang.reflect.Type;
1316
import java.util.ArrayList;
1417
import java.util.HashMap;
1518
import java.util.List;
@@ -52,12 +55,17 @@ protected Call buildCall() throws ApiException {
5255
@Override
5356
public ApiResponse<StoreCartsRes> execute() throws ApiException {
5457
Call call = buildCall();
55-
return client.execute(call);
58+
return client.execute(call, getType());
5659
}
5760

5861
@Override
5962
public void executeAsync(ApiCallback<StoreCartsRes> callback) throws ApiException {
6063
Call call = buildCall();
61-
client.executeAsync(call, callback);
64+
client.executeAsync(call, getType(), callback);
65+
}
66+
67+
@Override
68+
public Type getType() {
69+
return new TypeToken<StoreCartsRes>(){}.getType();
6270
}
6371
}

src/main/java/mobi/appcent/medusa/store/model/request/cart/AddShippingMethodRequest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package mobi.appcent.medusa.store.model.request.cart;
22

3+
import com.google.gson.reflect.TypeToken;
34
import com.squareup.okhttp.Call;
45
import mobi.appcent.medusa.store.*;
56
import mobi.appcent.medusa.store.common.HeaderConstant;
@@ -10,6 +11,7 @@
1011
import mobi.appcent.medusa.store.model.response.StorePostCartsCartShippingMethodReq;
1112

1213
import java.io.IOException;
14+
import java.lang.reflect.Type;
1315
import java.util.ArrayList;
1416
import java.util.HashMap;
1517
import java.util.List;
@@ -52,12 +54,17 @@ protected Call buildCall() throws ApiException {
5254
@Override
5355
public ApiResponse<StoreCartsRes> execute() throws ApiException {
5456
Call call = buildCall();
55-
return client.execute(call);
57+
return client.execute(call, getType());
5658
}
5759

5860
@Override
5961
public void executeAsync(ApiCallback<StoreCartsRes> callback) throws ApiException {
6062
Call call = buildCall();
61-
client.executeAsync(call, callback);
63+
client.executeAsync(call, getType(), callback);
64+
}
65+
66+
@Override
67+
public Type getType() {
68+
return new TypeToken<StoreCartsRes>(){}.getType();
6269
}
6370
}

src/main/java/mobi/appcent/medusa/store/model/request/cart/CalculateCartTaxesRequest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package mobi.appcent.medusa.store.model.request.cart;
22

3+
import com.google.gson.reflect.TypeToken;
34
import com.squareup.okhttp.Call;
45
import mobi.appcent.medusa.store.*;
56
import mobi.appcent.medusa.store.common.HeaderConstant;
@@ -9,6 +10,7 @@
910
import mobi.appcent.medusa.store.model.response.StoreCartsRes;
1011

1112
import java.io.IOException;
13+
import java.lang.reflect.Type;
1214
import java.util.ArrayList;
1315
import java.util.HashMap;
1416
import java.util.List;
@@ -45,12 +47,17 @@ protected Call buildCall() throws ApiException {
4547
@Override
4648
public ApiResponse<StoreCartsRes> execute() throws ApiException {
4749
Call call = buildCall();
48-
return client.execute(call);
50+
return client.execute(call, getType());
4951
}
5052

5153
@Override
5254
public void executeAsync(ApiCallback<StoreCartsRes> callback) throws ApiException {
5355
Call call = buildCall();
54-
client.executeAsync(call, callback);
56+
client.executeAsync(call, getType(), callback);
57+
}
58+
59+
@Override
60+
public Type getType() {
61+
return new TypeToken<StoreCartsRes>(){}.getType();
5562
}
5663
}

src/main/java/mobi/appcent/medusa/store/model/request/cart/CompleteCartRequest.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
package mobi.appcent.medusa.store.model.request.cart;
22

3+
import com.google.gson.reflect.TypeToken;
34
import com.squareup.okhttp.Call;
45
import mobi.appcent.medusa.store.*;
56
import mobi.appcent.medusa.store.common.HeaderConstant;
67
import mobi.appcent.medusa.store.common.HttpMethod;
78
import mobi.appcent.medusa.store.common.UrlConstant;
89
import mobi.appcent.medusa.store.model.request.BaseRequest;
10+
import mobi.appcent.medusa.store.model.response.StoreCartsRes;
911
import mobi.appcent.medusa.store.model.response.StoreCompleteCartRes;
1012

1113
import java.io.IOException;
14+
import java.lang.reflect.Type;
1215
import java.util.ArrayList;
1316
import java.util.HashMap;
1417
import java.util.List;
@@ -45,12 +48,17 @@ protected Call buildCall() throws ApiException {
4548
@Override
4649
public ApiResponse<StoreCompleteCartRes> execute() throws ApiException {
4750
Call call = buildCall();
48-
return client.execute(call);
51+
return client.execute(call, getType());
4952
}
5053

5154
@Override
5255
public void executeAsync(ApiCallback<StoreCompleteCartRes> callback) throws ApiException {
5356
Call call = buildCall();
54-
client.executeAsync(call, callback);
57+
client.executeAsync(call, getType(), callback);
58+
}
59+
60+
@Override
61+
public Type getType() {
62+
return new TypeToken<StoreCompleteCartRes>(){}.getType();
5563
}
5664
}

0 commit comments

Comments
 (0)