Skip to content

Commit fd01e5d

Browse files
authored
Fix (#31)
* Feature/api-client (#1) * feat(api-client): Create medusa api class and refactor api classes * feat(api-client): Adds base request classes and updates AuthApi * feat(cart-api): Refactor carts api (#2) * feat(collection-api): Refactor collection api (#3) * feat(customer-api): Refactor customers api (#4) * feat(invite-api): Refactor invite api (#5) * Feature/gift card api (#6) * feat(gift-card-api): Refactor gift cards api * fix(gift-card-api): Corrects path * feat(order-api): Refactor orders api (#7) * Feature/order api (#8) * feat(order-api): Refactor orders api * fix(order-api): Optimize imports * feat(order-edit-api): Refactor order edits api (#9) * feat(payment-collection-api): Refactor payment collection api (#10) * feat(product-api): Refactor product api (#11) * feat(product-category-api): Refactor product category api (#12) * feat(product-tags-api): Refactor product tags api (#13) * feat(return-reason-api): Refactor return reason api (#14) * feat(shipping-options-api): Refactor shipping options api (#15) * feat(return-api): Refactor return api (#16) * feat(swap-api): Refactor swap api (#17) * feat(product-type-api): Refactor product type api (#18) * feat(product-variant-api): Refactor product variant api (#19) * feat(region-api): Refactor region api (#20) * feat(invite-api): Refactor invite api (#21) * feat(pipeline): Implement github actions flow and update pom (#22) * Feature/pipeline (#23) * feat(pipeline): Implement github actions flow and update pom * fix!(pipeline): Remove prerequisites from pom * Feature/pipeline (#24) * feat(pipeline): Implement github actions flow and update pom * fix!(pipeline): Remove prerequisites from pom * fix!: Test issues * Feature/pipeline (#25) * feat(pipeline): Implement github actions flow and update pom * fix!(pipeline): Remove prerequisites from pom * fix!: Test issues * -Fix javadoc * feat(medusa-api): Adds cookie session management * build: Updates version to 1.0.1 * fix!: TypeReference issue for generic type * fix!: Init client sdk for productCategoryApi
1 parent 8fea92b commit fd01e5d

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ private void initializeSdkClients() {
5050
returnReasonApi.setApiClient(defaultMedusaSdkClient);
5151
shippingOptionApi.setApiClient(defaultMedusaSdkClient);
5252
swapApi.setApiClient(defaultMedusaSdkClient);
53+
productCategoryApi.setApiClient(defaultMedusaSdkClient);
5354
}
5455

5556
/**

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212

1313
package mobi.appcent.medusa.store;
1414

15+
import com.google.gson.reflect.TypeToken;
1516
import com.squareup.okhttp.*;
1617
import com.squareup.okhttp.internal.http.HttpMethod;
1718
import com.squareup.okhttp.logging.HttpLoggingInterceptor;
1819
import com.squareup.okhttp.logging.HttpLoggingInterceptor.Level;
1920
import mobi.appcent.medusa.store.auth.*;
21+
import mobi.appcent.medusa.store.common.TypeReference;
2022
import okio.BufferedSink;
2123
import okio.Okio;
2224
import org.threeten.bp.LocalDate;
@@ -718,7 +720,8 @@ public File prepareDownloadFile(Response response) throws IOException {
718720
* @return ApiResponse<T>
719721
*/
720722
public <T> ApiResponse<T> execute(Call call) throws ApiException {
721-
return execute(call, null);
723+
TypeReference<T> typeReference = new TypeReference<T>() {};
724+
return execute(call, typeReference.getType());
722725
}
723726

724727
/**
@@ -732,7 +735,7 @@ public <T> ApiResponse<T> execute(Call call) throws ApiException {
732735
* when returnType is null.
733736
* @throws ApiException If fail to execute the call
734737
*/
735-
public <T> ApiResponse<T> execute(Call call, Type returnType) throws ApiException {
738+
private <T> ApiResponse<T> execute(Call call, Type returnType) throws ApiException {
736739
try {
737740
Response response = call.execute();
738741
T data = handleResponse(response, returnType);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package mobi.appcent.medusa.store.common;
2+
3+
import java.lang.reflect.ParameterizedType;
4+
import java.lang.reflect.Type;
5+
6+
public abstract class TypeReference<T> {
7+
8+
public TypeReference() {}
9+
10+
public Type getType() {
11+
Type mySuperclass = this.getClass().getGenericSuperclass();
12+
return ((ParameterizedType)mySuperclass).getActualTypeArguments()[0];
13+
}
14+
15+
}

0 commit comments

Comments
 (0)