-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(order-api): Refactor orders api (#7)
- Loading branch information
1 parent
2440e14
commit 7f5feaa
Showing
7 changed files
with
305 additions
and
502 deletions.
There are no files selected for viewing
516 changes: 18 additions & 498 deletions
516
src/main/java/mobi/appcent/medusa/store/api/OrderApi.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/main/java/mobi/appcent/medusa/store/model/request/order/GetOrderByCartIdRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package mobi.appcent.medusa.store.model.request.order; | ||
|
||
import com.squareup.okhttp.Call; | ||
import mobi.appcent.medusa.store.*; | ||
import mobi.appcent.medusa.store.common.HeaderConstant; | ||
import mobi.appcent.medusa.store.common.HttpMethod; | ||
import mobi.appcent.medusa.store.common.QueryParamConstant; | ||
import mobi.appcent.medusa.store.common.UrlConstant; | ||
import mobi.appcent.medusa.store.model.request.BaseRequest; | ||
import mobi.appcent.medusa.store.model.response.StoreOrdersRes; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Created by erenalpaslan on 9.03.2023 | ||
*/ | ||
public class GetOrderByCartIdRequest extends BaseRequest<StoreOrdersRes> { | ||
|
||
private final MedusaSdkClient client; | ||
private final String cartId; | ||
|
||
public GetOrderByCartIdRequest(MedusaSdkClient client, String cartId) { | ||
this.client = client; | ||
this.cartId = cartId; | ||
} | ||
|
||
@Override | ||
protected Call buildCall() throws ApiException { | ||
String path = UrlConstant.ORDER_PATH + "/cart/" + cartId; | ||
Map<String, String> headers = new HashMap<>(); | ||
|
||
final String[] localVarAccepts = { HeaderConstant.APPLICATION_JSON }; | ||
final String localVarAccept = client.selectHeaderAccept(localVarAccepts); | ||
|
||
if (localVarAccept != null) headers.put(HeaderConstant.ACCEPT, localVarAccept); | ||
headers.put(HeaderConstant.CONTENT_TYPE, HeaderConstant.APPLICATION_JSON); | ||
|
||
return client.buildCall(path, HttpMethod.GET, null, null, null, headers, null, null); | ||
} | ||
|
||
@Override | ||
public ApiResponse<StoreOrdersRes> execute() throws ApiException { | ||
Call call = buildCall(); | ||
return client.execute(call); | ||
} | ||
|
||
@Override | ||
public void executeAsync(ApiCallback<StoreOrdersRes> callback) throws ApiException { | ||
Call call = buildCall(); | ||
client.executeAsync(call, callback); | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
src/main/java/mobi/appcent/medusa/store/model/request/order/GetOrderRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package mobi.appcent.medusa.store.model.request.order; | ||
|
||
import com.squareup.okhttp.Call; | ||
import jdk.javadoc.internal.doclets.formats.html.markup.Head; | ||
import mobi.appcent.medusa.store.*; | ||
import mobi.appcent.medusa.store.common.HeaderConstant; | ||
import mobi.appcent.medusa.store.common.HttpMethod; | ||
import mobi.appcent.medusa.store.common.QueryParamConstant; | ||
import mobi.appcent.medusa.store.common.UrlConstant; | ||
import mobi.appcent.medusa.store.model.request.BaseRequest; | ||
import mobi.appcent.medusa.store.model.response.StoreOrdersRes; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Created by erenalpaslan on 9.03.2023 | ||
*/ | ||
public class GetOrderRequest extends BaseRequest<StoreOrdersRes> { | ||
|
||
private final MedusaSdkClient client; | ||
private final String id; | ||
private String fields; | ||
private String expand; | ||
|
||
public GetOrderRequest(MedusaSdkClient client, String id) { | ||
this.client = client; | ||
this.id = id; | ||
} | ||
|
||
public GetOrderRequest fields(String fields) { | ||
this.fields = fields; | ||
return this; | ||
} | ||
|
||
public GetOrderRequest expand(String expand) { | ||
this.expand = expand; | ||
return this; | ||
} | ||
|
||
@Override | ||
protected Call buildCall() throws ApiException { | ||
String path = UrlConstant.ORDER_PATH + "/" + id; | ||
Map<String, String> headers = new HashMap<>(); | ||
|
||
final String[] localVarAccepts = { HeaderConstant.APPLICATION_JSON }; | ||
final String localVarAccept = client.selectHeaderAccept(localVarAccepts); | ||
|
||
if (localVarAccept != null) headers.put(HeaderConstant.ACCEPT, localVarAccept); | ||
headers.put(HeaderConstant.CONTENT_TYPE, HeaderConstant.APPLICATION_JSON); | ||
|
||
List<Pair> localVarQueryParams = new ArrayList<Pair>(); | ||
if (fields != null) | ||
localVarQueryParams.addAll(client.parameterToPair(QueryParamConstant.FIELDS, fields)); | ||
if (expand != null) | ||
localVarQueryParams.addAll(client.parameterToPair(QueryParamConstant.EXPAND, expand)); | ||
|
||
|
||
return client.buildCall(path, HttpMethod.GET, localVarQueryParams, null, null, headers, null, null); | ||
} | ||
|
||
@Override | ||
public ApiResponse<StoreOrdersRes> execute() throws ApiException { | ||
Call call = buildCall(); | ||
return client.execute(call); | ||
} | ||
|
||
@Override | ||
public void executeAsync(ApiCallback<StoreOrdersRes> callback) throws ApiException { | ||
Call call = buildCall(); | ||
client.executeAsync(call, callback); | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
src/main/java/mobi/appcent/medusa/store/model/request/order/LookUpOrderByFiltersRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package mobi.appcent.medusa.store.model.request.order; | ||
|
||
import com.squareup.okhttp.Call; | ||
import mobi.appcent.medusa.store.*; | ||
import mobi.appcent.medusa.store.common.HeaderConstant; | ||
import mobi.appcent.medusa.store.common.HttpMethod; | ||
import mobi.appcent.medusa.store.common.QueryParamConstant; | ||
import mobi.appcent.medusa.store.common.UrlConstant; | ||
import mobi.appcent.medusa.store.model.request.BaseRequest; | ||
import mobi.appcent.medusa.store.model.response.ShippingAddress; | ||
import mobi.appcent.medusa.store.model.response.StoreOrdersRes; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Created by erenalpaslan on 9.03.2023 | ||
*/ | ||
public class LookUpOrderByFiltersRequest extends BaseRequest<StoreOrdersRes> { | ||
|
||
private final MedusaSdkClient client; | ||
private final BigDecimal displayId; | ||
private final String email; | ||
private String fields; | ||
private String expand; | ||
private ShippingAddress shippingAddress; | ||
|
||
public LookUpOrderByFiltersRequest(MedusaSdkClient client, BigDecimal displayId, String email) { | ||
this.client = client; | ||
this.displayId = displayId; | ||
this.email = email; | ||
} | ||
|
||
public LookUpOrderByFiltersRequest fields(String fields) { | ||
this.fields = fields; | ||
return this; | ||
} | ||
|
||
public LookUpOrderByFiltersRequest expand(String expand) { | ||
this.expand = expand; | ||
return this; | ||
} | ||
|
||
public LookUpOrderByFiltersRequest expand(ShippingAddress shippingAddress) { | ||
this.shippingAddress = shippingAddress; | ||
return this; | ||
} | ||
|
||
@Override | ||
protected Call buildCall() throws ApiException { | ||
String path = UrlConstant.ORDER_PATH; | ||
Map<String, String> headers = new HashMap<>(); | ||
|
||
final String[] localVarAccepts = { HeaderConstant.APPLICATION_JSON }; | ||
final String localVarAccept = client.selectHeaderAccept(localVarAccepts); | ||
|
||
if (localVarAccept != null) headers.put(HeaderConstant.ACCEPT, localVarAccept); | ||
headers.put(HeaderConstant.CONTENT_TYPE, HeaderConstant.APPLICATION_JSON); | ||
|
||
List<Pair> localVarQueryParams = new ArrayList<Pair>(); | ||
if (displayId != null) | ||
localVarQueryParams.addAll(client.parameterToPair(QueryParamConstant.DISPLAY_ID, displayId)); | ||
if (fields != null) | ||
localVarQueryParams.addAll(client.parameterToPair(QueryParamConstant.FIELDS, fields)); | ||
if (expand != null) | ||
localVarQueryParams.addAll(client.parameterToPair(QueryParamConstant.EXPAND, expand)); | ||
if (email != null) | ||
localVarQueryParams.addAll(client.parameterToPair(QueryParamConstant.EMAIL, email)); | ||
if (shippingAddress != null) | ||
localVarQueryParams.addAll(client.parameterToPair(QueryParamConstant.SHIPPING_ADDRESS, shippingAddress)); | ||
|
||
|
||
return client.buildCall(path, HttpMethod.GET, localVarQueryParams, null, null, headers, null, null); | ||
} | ||
|
||
@Override | ||
public ApiResponse<StoreOrdersRes> execute() throws ApiException { | ||
Call call = buildCall(); | ||
return client.execute(call); | ||
} | ||
|
||
@Override | ||
public void executeAsync(ApiCallback<StoreOrdersRes> callback) throws ApiException { | ||
Call call = buildCall(); | ||
client.executeAsync(call, callback); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
src/main/java/mobi/appcent/medusa/store/model/request/order/VerifyOrderClaimRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package mobi.appcent.medusa.store.model.request.order; | ||
|
||
import com.squareup.okhttp.Call; | ||
import mobi.appcent.medusa.store.*; | ||
import mobi.appcent.medusa.store.common.HeaderConstant; | ||
import mobi.appcent.medusa.store.common.HttpMethod; | ||
import mobi.appcent.medusa.store.common.UrlConstant; | ||
import mobi.appcent.medusa.store.model.request.BaseRequest; | ||
import mobi.appcent.medusa.store.model.response.StorePostCustomersCustomerAcceptClaimReq; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Created by erenalpaslan on 9.03.2023 | ||
*/ | ||
public class VerifyOrderClaimRequest extends BaseRequest<Void> { | ||
|
||
private final MedusaSdkClient client; | ||
private StorePostCustomersCustomerAcceptClaimReq body; | ||
|
||
public VerifyOrderClaimRequest(MedusaSdkClient client) { | ||
this.client = client; | ||
} | ||
|
||
public VerifyOrderClaimRequest body(StorePostCustomersCustomerAcceptClaimReq body) { | ||
this.body = body; | ||
return this; | ||
} | ||
|
||
@Override | ||
protected Call buildCall() throws ApiException { | ||
String path = UrlConstant.ORDER_PATH + "/customer/confirm"; | ||
Map<String, String> headers = new HashMap<>(); | ||
|
||
final String[] localVarAccepts = { HeaderConstant.APPLICATION_JSON, HeaderConstant.TEXT_PLAIN }; | ||
final String localVarAccept = client.selectHeaderAccept(localVarAccepts); | ||
|
||
if (localVarAccept != null) headers.put(HeaderConstant.ACCEPT, localVarAccept); | ||
headers.put(HeaderConstant.CONTENT_TYPE, HeaderConstant.APPLICATION_JSON); | ||
|
||
String[] localVarAuthNames = new String[] { "cookie_auth" }; | ||
return client.buildCall(path, HttpMethod.POST, null, null, body, headers, null, localVarAuthNames); | ||
} | ||
|
||
@Override | ||
public ApiResponse<Void> execute() throws ApiException { | ||
Call call = buildCall(); | ||
return client.execute(call); | ||
} | ||
|
||
@Override | ||
public void executeAsync(ApiCallback<Void> callback) throws ApiException { | ||
Call call = buildCall(); | ||
client.executeAsync(call, callback); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters