

package com.payu.sdk.payments.model;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import com.payu.sdk.constants.Resources;
import com.payu.sdk.constants.Resources.RequestMethod;

/**
 * Payment attempt request.
 *
 * @author PayU Latam
 * @since 1.2.7
 */
@XmlRootElement(name = "request")
@XmlAccessorType(XmlAccessType.FIELD)
public class PaymentAttemptRequest extends PaymentRequest {

	/** The class serial version. */
	private static final long serialVersionUID = 1L;

	/** The payment request id. */
	@XmlTransient
	private Integer paymentRequestId;

	/**
	 * Default constructor.
	 * Necessary for JAXB marshaler
	 */
	@SuppressWarnings("unused")
	private PaymentAttemptRequest() {

		// Mandatory constructor.
	}

	/**
	 * Class constructor.
	 * 
	 * @param paymentRequestId the payment request id.
	 */
	public PaymentAttemptRequest(final Integer paymentRequestId) {

		this.paymentRequestId = paymentRequestId;
	}

	/*
	 * (non-Javadoc)
	 * @see com.payu.sdk.model.request.Request#getBaseRequestUrl(java.lang.String,
	 * com.payu.sdk.constants.Resources.RequestMethod)
	 */
	@Override
	protected String getBaseRequestUrl(final String baseUrl, final RequestMethod requestMethod) {

		return String.format(Resources.DEPENDENT_ENTITY_API_URL_PATTERN, baseUrl, Resources.V4_3,
				Resources.URI_PAYMENT_REQUEST, getPaymentRequestId(), "transaction");
	}

	/**
	 * @return the paymentRequestId
	 */
	public Integer getPaymentRequestId() {

		return paymentRequestId;
	}

	/**
	 * @param paymentRequestId the paymentRequestId to set
	 */
	public void setPaymentRequestId(final Integer paymentRequestId) {

		this.paymentRequestId = paymentRequestId;
	}
}