Skip to content

Commit 36211d2

Browse files
authored
Develop (#33)
* 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 * fix!: Unspecified type issue * release: Update version 1.0.3
1 parent 6799456 commit 36211d2

File tree

68 files changed

+630
-141
lines changed

Some content is hidden

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

68 files changed

+630
-141
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'idea'
22
apply plugin: 'eclipse'
33

44
group = 'mobi.appcent'
5-
version = '1.0.2'
5+
version = '1.0.3'
66

77
buildscript {
88
repositories {

pom.xml

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

55
<groupId>mobi.appcent</groupId>
66
<artifactId>medusa-java-sdk</artifactId>
7-
<version>1.0.2</version>
7+
<version>1.0.3</version>
88
<name>medusa-java-sdk</name>
99

1010
<repositories>

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
}

0 commit comments

Comments
 (0)