All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.newegg.marketplace.sdk.rma.inner.RMAUpdateCaller Maven / Gradle / Ivy

Go to download

How to create, retrieve and update RMA (e.g. refund and replacement), as well as how to issue a courtesy refund.

There is a newer version: 2.0.0
Show newest version
package com.newegg.marketplace.sdk.rma.inner;

import com.newegg.marketplace.sdk.common.CallerFactory;
import com.newegg.marketplace.sdk.common.Content;
import com.newegg.marketplace.sdk.common.Content.MEDIA_TYPE;
import com.newegg.marketplace.sdk.rma.Variables;
import com.newegg.marketplace.sdk.rma.Variables.UpdateRMARequestType;
import com.newegg.marketplace.sdk.rma.model.EditRMARequest;
import com.newegg.marketplace.sdk.rma.model.EditRMAResponse;

import feign.Headers;
import feign.Param;
import feign.RequestLine;

/**
Copyright (c) 2000-present, Newegg Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
 */

/**
 * For openfeign used
 * 
 * @author Achilles.K.Lin
 *
 */
public interface RMAUpdateCaller {
	/*
	 * Command define from Order Confirmation API Guide JSON and XML format
	 */
	@Headers({ "Accept: application/json", "Content-Type: application/json" })
	@RequestLine("POST /servicemgmt/rma/updaterma?sellerid={sellerid}&version={version}")
	EditRMAResponse sendRMAUpdateRequestJSON(@Param("sellerid") String sellerID, @Param("version") String version,
			EditRMARequest body);

	@Headers({ "Accept: application/xml", "Content-Type: application/xml" })
	@RequestLine("POST /servicemgmt/rma/updaterma?sellerid={sellerid}&version={version}")
	EditRMAResponse sendRMAUpdateRequestXML(@Param("sellerid") String sellerID, @Param("version") String version,
			EditRMARequest body);

	// Implement default method of interface class that according to
	// Variables.MediaType to run at JSON or XML request.
	default EditRMAResponse sendRMAUpdateRequest(EditRMARequest body, String version) {
		switch (Variables.MediaType) {
		case JSON:
			if (Variables.SimulationEnabled)
				return sendRMAUpdateRequestJSON(Content.SellerID, "307", body);
			else
				return sendRMAUpdateRequestJSON(Content.SellerID, version, body);

		case XML:
			if (Variables.SimulationEnabled)
				return sendRMAUpdateRequestXML(Content.SellerID, "307", body);
			else
				return sendRMAUpdateRequestXML(Content.SellerID, version, body);

		default:
			throw new RuntimeException("Never Happened!");
		}

	}

	static RMAUpdateCaller buildJSON() {
		Variables.MediaType = MEDIA_TYPE.JSON;

		Variables.UpdateRequestType = UpdateRMARequestType.Update;

		return new CallerFactory().jsonBuild(RMAUpdateCaller.class, Variables.LogLevel,
				Variables.Retryer, RMAClient.genClient());
	}

	static RMAUpdateCaller buildXML() {
		Variables.MediaType = MEDIA_TYPE.XML;

		Variables.UpdateRequestType = UpdateRMARequestType.Update;

		return new CallerFactory().xmlBuild(RMAUpdateCaller.class, Variables.LogLevel,
				Variables.Retryer, RMAClient.genClient());
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy