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

esendex.sdk.java.service.resource.base.XmlRequesterResponderResource Maven / Gradle / Ivy

Go to download

The Esendex Java SDK is an easy to use client for our REST API that you can use to integrate SMS and Voice messaging into your Java application.

The newest version!

package esendex.sdk.java.service.resource.base;

import esendex.sdk.java.EsendexException;
import esendex.sdk.java.http.HttpQuery;
import esendex.sdk.java.model.transfer.Dto;
import esendex.sdk.java.service.auth.Authenticator;

/**
 * An XmlRequesterResponderResource is a resource that receives and sends 
 * XML data
 * 
 * @param  the Dto type expected in the request
 * @param  the Dto type expected in the response
 * @author Mike Whittaker
 */
public abstract class XmlRequesterResponderResource extends Resource {

	private XmlRequester requester;
	private XmlResponder responder;
	
	/**
	 * Instantiates a new xml requester responder resource.
	 * @param auth the authenticator
	 * @param account the account
	 * @param id the id
	 * @param query the query
	 */
	public XmlRequesterResponderResource(Authenticator auth, String account, String id, HttpQuery query) {
		super(auth, account, id, query);
	}

	/**
	 * Sets the request object.
	 * @param requestDto the new request object
	 */
	public void setRequestObject(Q requestDto) {
		this.requester = new XmlRequester(requestDto);
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	protected String getRequestData() {
		return requester.getRequestData();
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void execute() throws EsendexException {
		super.execute();
		responder = new XmlResponder(getResponse().getContent());
	}
	
	/**
	 * Gets the response object.
	 * @return the response object
	 */
	public S getResponseObject() {
		return responder.getResponseObject();
	}

}