Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(order-edit-api): Refactor order edits api #9

Merged
merged 1 commit into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
363 changes: 10 additions & 353 deletions src/main/java/mobi/appcent/medusa/store/api/OrderEditApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import java.io.IOException;


import mobi.appcent.medusa.store.model.request.orderedit.CompletesOrderEditRequest;
import mobi.appcent.medusa.store.model.request.orderedit.DeclineOrderEditRequest;
import mobi.appcent.medusa.store.model.request.orderedit.RetrieveOrderEditRequest;
import mobi.appcent.medusa.store.model.response.StoreOrderEditsRes;
import mobi.appcent.medusa.store.model.response.StorePostOrderEditsOrderEditDecline;

Expand All @@ -42,72 +45,6 @@ public MedusaSdkClient getApiClient() {

public void setApiClient(MedusaSdkClient medusaSdkClient) {
this.medusaSdkClient = medusaSdkClient;
}

/**
* Build call for getOrderEditsOrderEdit
* @param id The ID of the OrderEdit. (required)
* @param progressListener Progress listener
* @param progressRequestListener Progress request listener
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
*/
public com.squareup.okhttp.Call getOrderEditsOrderEditCall(String id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;

// create path and map variables
String localVarPath = "/order-edits/{id}"
.replaceAll("\\{" + "id" + "\\}", medusaSdkClient.escapeString(id.toString()));

List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();

Map<String, String> localVarHeaderParams = new HashMap<String, String>();

Map<String, Object> localVarFormParams = new HashMap<String, Object>();

final String[] localVarAccepts = {
"application/json", "text/plain"
};
final String localVarAccept = medusaSdkClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

final String[] localVarContentTypes = {

};
final String localVarContentType = medusaSdkClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);

if(progressListener != null) {
medusaSdkClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
@Override
public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
return originalResponse.newBuilder()
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
.build();
}
});
}

String[] localVarAuthNames = new String[] { };
return medusaSdkClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}

@SuppressWarnings("rawtypes")
private com.squareup.okhttp.Call getOrderEditsOrderEditValidateBeforeCall(String id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'id' is set
if (id == null) {
throw new ApiException("Missing the required parameter 'id' when calling getOrderEditsOrderEdit(Async)");
}

com.squareup.okhttp.Call call = getOrderEditsOrderEditCall(id, progressListener, progressRequestListener);
return call;





}

/**
Expand All @@ -117,122 +54,8 @@ private com.squareup.okhttp.Call getOrderEditsOrderEditValidateBeforeCall(String
* @return StoreOrderEditsRes
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public StoreOrderEditsRes getOrderEditsOrderEdit(String id) throws ApiException {
ApiResponse<StoreOrderEditsRes> resp = getOrderEditsOrderEditWithHttpInfo(id);
return resp.getData();
}

/**
* Retrieve an OrderEdit
* Retrieves a OrderEdit.
* @param id The ID of the OrderEdit. (required)
* @return ApiResponse&lt;StoreOrderEditsRes&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<StoreOrderEditsRes> getOrderEditsOrderEditWithHttpInfo(String id) throws ApiException {
com.squareup.okhttp.Call call = getOrderEditsOrderEditValidateBeforeCall(id, null, null);
Type localVarReturnType = new TypeToken<StoreOrderEditsRes>(){}.getType();
return medusaSdkClient.execute(call, localVarReturnType);
}

/**
* Retrieve an OrderEdit (asynchronously)
* Retrieves a OrderEdit.
* @param id The ID of the OrderEdit. (required)
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public com.squareup.okhttp.Call getOrderEditsOrderEditAsync(String id, final ApiCallback<StoreOrderEditsRes> callback) throws ApiException {

ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};

progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}

com.squareup.okhttp.Call call = getOrderEditsOrderEditValidateBeforeCall(id, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<StoreOrderEditsRes>(){}.getType();
medusaSdkClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
* Build call for postOrderEditsOrderEditComplete
* @param id The ID of the Order Edit. (required)
* @param progressListener Progress listener
* @param progressRequestListener Progress request listener
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
*/
public com.squareup.okhttp.Call postOrderEditsOrderEditCompleteCall(String id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;

// create path and map variables
String localVarPath = "/order-edits/{id}/complete"
.replaceAll("\\{" + "id" + "\\}", medusaSdkClient.escapeString(id.toString()));

List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();

Map<String, String> localVarHeaderParams = new HashMap<String, String>();

Map<String, Object> localVarFormParams = new HashMap<String, Object>();

final String[] localVarAccepts = {
"application/json", "text/plain"
};
final String localVarAccept = medusaSdkClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

final String[] localVarContentTypes = {

};
final String localVarContentType = medusaSdkClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);

if(progressListener != null) {
medusaSdkClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
@Override
public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
return originalResponse.newBuilder()
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
.build();
}
});
}

String[] localVarAuthNames = new String[] { };
return medusaSdkClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}

@SuppressWarnings("rawtypes")
private com.squareup.okhttp.Call postOrderEditsOrderEditCompleteValidateBeforeCall(String id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'id' is set
if (id == null) {
throw new ApiException("Missing the required parameter 'id' when calling postOrderEditsOrderEditComplete(Async)");
}

com.squareup.okhttp.Call call = postOrderEditsOrderEditCompleteCall(id, progressListener, progressRequestListener);
return call;





public RetrieveOrderEditRequest retrieveOrderEdit(String id) throws ApiException {
return new RetrieveOrderEditRequest(medusaSdkClient, id);
}

/**
Expand All @@ -242,185 +65,19 @@ private com.squareup.okhttp.Call postOrderEditsOrderEditCompleteValidateBeforeCa
* @return StoreOrderEditsRes
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public StoreOrderEditsRes postOrderEditsOrderEditComplete(String id) throws ApiException {
ApiResponse<StoreOrderEditsRes> resp = postOrderEditsOrderEditCompleteWithHttpInfo(id);
return resp.getData();
}

/**
* Completes an OrderEdit
* Completes an OrderEdit.
* @param id The ID of the Order Edit. (required)
* @return ApiResponse&lt;StoreOrderEditsRes&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<StoreOrderEditsRes> postOrderEditsOrderEditCompleteWithHttpInfo(String id) throws ApiException {
com.squareup.okhttp.Call call = postOrderEditsOrderEditCompleteValidateBeforeCall(id, null, null);
Type localVarReturnType = new TypeToken<StoreOrderEditsRes>(){}.getType();
return medusaSdkClient.execute(call, localVarReturnType);
}

/**
* Completes an OrderEdit (asynchronously)
* Completes an OrderEdit.
* @param id The ID of the Order Edit. (required)
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public com.squareup.okhttp.Call postOrderEditsOrderEditCompleteAsync(String id, final ApiCallback<StoreOrderEditsRes> callback) throws ApiException {

ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};

progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}

com.squareup.okhttp.Call call = postOrderEditsOrderEditCompleteValidateBeforeCall(id, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<StoreOrderEditsRes>(){}.getType();
medusaSdkClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
* Build call for postOrderEditsOrderEditDecline
* @param id The ID of the OrderEdit. (required)
* @param body (optional)
* @param progressListener Progress listener
* @param progressRequestListener Progress request listener
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
*/
public com.squareup.okhttp.Call postOrderEditsOrderEditDeclineCall(String id, StorePostOrderEditsOrderEditDecline body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = body;

// create path and map variables
String localVarPath = "/order-edits/{id}/decline"
.replaceAll("\\{" + "id" + "\\}", medusaSdkClient.escapeString(id.toString()));

List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();

Map<String, String> localVarHeaderParams = new HashMap<String, String>();

Map<String, Object> localVarFormParams = new HashMap<String, Object>();

final String[] localVarAccepts = {
"application/json", "text/plain"
};
final String localVarAccept = medusaSdkClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

final String[] localVarContentTypes = {
"application/json"
};
final String localVarContentType = medusaSdkClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);

if(progressListener != null) {
medusaSdkClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
@Override
public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
return originalResponse.newBuilder()
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
.build();
}
});
}

String[] localVarAuthNames = new String[] { };
return medusaSdkClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}

@SuppressWarnings("rawtypes")
private com.squareup.okhttp.Call postOrderEditsOrderEditDeclineValidateBeforeCall(String id, StorePostOrderEditsOrderEditDecline body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'id' is set
if (id == null) {
throw new ApiException("Missing the required parameter 'id' when calling postOrderEditsOrderEditDecline(Async)");
}

com.squareup.okhttp.Call call = postOrderEditsOrderEditDeclineCall(id, body, progressListener, progressRequestListener);
return call;





public CompletesOrderEditRequest completesOrderEdit(String id) throws ApiException {
return new CompletesOrderEditRequest(medusaSdkClient, id);
}

/**
* Decline an OrderEdit
* Declines an OrderEdit.
* @param id The ID of the OrderEdit. (required)
* @param body (optional)
* body (optional)
* @return StoreOrderEditsRes
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public StoreOrderEditsRes postOrderEditsOrderEditDecline(String id, StorePostOrderEditsOrderEditDecline body) throws ApiException {
ApiResponse<StoreOrderEditsRes> resp = postOrderEditsOrderEditDeclineWithHttpInfo(id, body);
return resp.getData();
}

/**
* Decline an OrderEdit
* Declines an OrderEdit.
* @param id The ID of the OrderEdit. (required)
* @param body (optional)
* @return ApiResponse&lt;StoreOrderEditsRes&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<StoreOrderEditsRes> postOrderEditsOrderEditDeclineWithHttpInfo(String id, StorePostOrderEditsOrderEditDecline body) throws ApiException {
com.squareup.okhttp.Call call = postOrderEditsOrderEditDeclineValidateBeforeCall(id, body, null, null);
Type localVarReturnType = new TypeToken<StoreOrderEditsRes>(){}.getType();
return medusaSdkClient.execute(call, localVarReturnType);
}

/**
* Decline an OrderEdit (asynchronously)
* Declines an OrderEdit.
* @param id The ID of the OrderEdit. (required)
* @param body (optional)
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public com.squareup.okhttp.Call postOrderEditsOrderEditDeclineAsync(String id, StorePostOrderEditsOrderEditDecline body, final ApiCallback<StoreOrderEditsRes> callback) throws ApiException {

ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};

progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}

com.squareup.okhttp.Call call = postOrderEditsOrderEditDeclineValidateBeforeCall(id, body, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<StoreOrderEditsRes>(){}.getType();
medusaSdkClient.executeAsync(call, localVarReturnType, callback);
return call;
public DeclineOrderEditRequest declineOrderEdit(String id) throws ApiException {
return new DeclineOrderEditRequest(medusaSdkClient, id);
}
}
Loading