<|start_filename|>src/main/java/com/mangopay/core/enumerations/DisputeStatus.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Dispute status enumeration.
 */
public enum DisputeStatus {
    
    /**
     * CREATED dispute status.
     */
    CREATED, 
    
    /**
     * PENDING_CLIENT_ACTION dispute status.
     */
    PENDING_CLIENT_ACTION, 
    
    /**
     * SUBMITTED dispute status.
     */
    SUBMITTED, 
    
    /**
     * PENDING_BANK_ACTION dispute status.
     */
    PENDING_BANK_ACTION, 
    
    /**
     * REOPENED_PENDING_CLIENT_ACTION dispute status.
     */
    REOPENED_PENDING_CLIENT_ACTION,
    
    /**
     * CLOSED dispute status.
     */
    CLOSED
}


<|start_filename|>src/main/java/com/mangopay/entities/RecurringPaymentExtended.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;

import java.lang.reflect.Type;
import java.util.Map;

public class RecurringPaymentExtended extends RecurringPayment {

    @SerializedName("CurrentState")
    private CurrentState currentState;

    public CurrentState getCurrentState() {
        return currentState;
    }

    @Override
    public Map<String, Type> getSubObjects() {
        Map<String, Type> result = super.getSubObjects();

        result.put("CurrentState", CurrentState.class);

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/DisputeDocumentStatus.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Dispute document status enumeration.
 */
public enum DisputeDocumentStatus {
    
    /**
     * CREATED dispute document status.
     */
    CREATED,
    
    /**
     * VALIDATION_ASKED dispute document status.
     */
    VALIDATION_ASKED,
    
    /**
     * VALIDATED dispute document status.
     */
    VALIDATED,
    
    /**
     * REFUSED dispute document status.
     */
    REFUSED
}


<|start_filename|>src/test/java/com/mangopay/core/ConfigurationsTest.java<|end_filename|>
package com.mangopay.core;

import static org.junit.Assert.*;
import org.junit.Test;

/**
 * Tests for holding authentication token in instance
 */
public class ConfigurationsTest extends BaseTest {

    @Test(expected = ResponseException.class)
    public void confInConstruct() throws Exception {
        this.api.getConfig().setClientId("test_asd");
        this.api.getConfig().setClientPassword("<PASSWORD>");
        this.api.getUserApi().getAll();
    }
    
    @Test
    public void getVersionTest() {
        // First load from properties files
        assertNotNull(getApi().getConfig().getVersion());
        // Second load from memory
        assertNotNull(getApi().getConfig().getVersion());
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/SettlementTransfer.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;

/**
 * Settlement transfer entity.
 */
public class SettlementTransfer extends Transfer {
    
    /**
     * The repudiation id of the settlement
     */
    @SerializedName("RepudiationId")
    private String repudiationId;

    public String getRepudiationId() {
      return repudiationId;
    }

    public void setRepudiationId(String repudiationId) {
      this.repudiationId = repudiationId;
    }


}


<|start_filename|>src/main/java/com/mangopay/core/APIs/implementation/TransferApiImpl.java<|end_filename|>
package com.mangopay.core.APIs.implementation;

import com.google.gson.GsonBuilder;
import com.mangopay.MangoPayApi;
import com.mangopay.core.APIs.ApiBase;
import com.mangopay.core.APIs.TransferApi;
import com.mangopay.core.Pagination;
import com.mangopay.core.Sorting;
import com.mangopay.core.deserializer.TransferDeserializer;
import com.mangopay.core.serializer.TransferSerializer;
import com.mangopay.entities.Refund;
import com.mangopay.entities.Transfer;

import java.util.List;

/**
 * API for transfers.
 */
public class TransferApiImpl extends ApiBase implements TransferApi {

    /**
     * Instantiates new TransferApiImpl object.
     * @param root Root/parent instance that holds the OAuthToken and Configuration instance.
     */
    public TransferApiImpl(MangoPayApi root, GsonBuilder gsonBuilder) {
        super(root);
        gsonBuilder.registerTypeAdapter(Transfer.class, new TransferSerializer());
        gsonBuilder.registerTypeAdapter(Transfer.class, new TransferDeserializer());
    }

    @Override
    public Transfer create(Transfer transfer) throws Exception {
        return this.create(null, transfer);
    }

    @Override
    public Transfer create(String idempotencyKey, Transfer transfer) throws Exception {
        return this.createObject(Transfer.class, idempotencyKey, "transfers_create", transfer);
    }

    @Override
    public Transfer get(String transferId) throws Exception {
        return this.getObject(Transfer.class, "transfers_get", transferId);
    }

    @Override
    public Refund createRefund(String transferId, Refund refund) throws Exception {
        return this.createRefund(null, transferId, refund);
    }

    @Override
    public Refund createRefund(String idempotencyKey, String transferId, Refund refund) throws Exception {
        return this.createObject(Refund.class, idempotencyKey, "transfers_createrefunds", refund, transferId);
    }

    @Override
    public Refund getRefund(String transferId) throws Exception {
        return this.getObject(Refund.class, "transfers_getrefunds", transferId);
    }

    @Override
    public List<Refund> getRefunds(String transferId) throws Exception {
        return this.getRefunds(transferId,null,null);
    }

    @Override
    public List<Refund> getRefunds(String transferId, Pagination pagination, Sorting sorting) throws Exception {
        return this.getList(Refund[].class,Refund.class,"transfers_getrefunds",pagination,transferId,sorting);
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/subentities/PayInExecutionDetailsWeb.java<|end_filename|>
package com.mangopay.entities.subentities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Dto;
import com.mangopay.core.enumerations.CultureCode;
import com.mangopay.core.enumerations.SecureMode;
import com.mangopay.core.interfaces.PayInExecutionDetails;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Map;

/**
 * Class representing Web type for execution option in PayIn entity.
 */
public class PayInExecutionDetailsWeb extends Dto implements PayInExecutionDetails {

    /**
     * URL format expected.
     */
    @SerializedName("TemplateURL")
    private String templateUrl;

    /**
     * Culture.
     */
    @SerializedName("Culture")
    private CultureCode culture;

    /**
     * Secure mode.
     */
    @SerializedName("SecureMode")
    private SecureMode secureMode;

    /**
     * Redirect URL.
     */
    @SerializedName("RedirectURL")
    private String redirectUrl;

    /**
     * Return URL.
     */
    @SerializedName("ReturnURL")
    private String returnUrl;

    /**
     * The URL where you host the iFramed template.
     * For CB, Visa, MasterCard you need to specify PAYLINE: before your URL
     * with the iFramed template
     * ex: PAYLINE: https://www.maysite.com/payline_template/
     * Used for:
     * - direct debit web type pay-in.
     *
     * @deprecated Use {@link #getTemplateURLOptions()} and {@link #setTemplateURLOptions(PayInTemplateURLOptions)} instead.
     */
    @Deprecated
    public PayInTemplateURLOptions TemplateURLOptions;

    public PayInExecutionDetailsWeb(String templateUrl, CultureCode culture, SecureMode secureMode, String redirectUrl, String returnUrl) {
        this.templateUrl = templateUrl;
        this.culture = culture;
        this.secureMode = secureMode;
        this.redirectUrl = redirectUrl;
        this.returnUrl = returnUrl;
    }

    public PayInExecutionDetailsWeb() {
    }

    public String getTemplateUrl() {
        return templateUrl;
    }

    public void setTemplateUrl(String templateUrl) {
        this.templateUrl = templateUrl;
    }

    public CultureCode getCulture() {
        return culture;
    }

    public void setCulture(CultureCode culture) {
        this.culture = culture;
    }

    public SecureMode getSecureMode() {
        return secureMode;
    }

    public void setSecureMode(SecureMode secureMode) {
        this.secureMode = secureMode;
    }

    public String getRedirectUrl() {
        return redirectUrl;
    }

    public String getReturnUrl() {
        return returnUrl;
    }

    public void setReturnUrl(String returnUrl) {
        this.returnUrl = returnUrl;
    }

    public void setRedirectUrl(String redirectUrl) {
        this.redirectUrl = redirectUrl;
    }

    public PayInTemplateURLOptions getTemplateURLOptions() {
        return TemplateURLOptions;
    }

    public void setTemplateURLOptions(PayInTemplateURLOptions templateURLOptions) { this.TemplateURLOptions = templateURLOptions; }

    /**
     * Gets the collection of read-only fields names
     *
     * @return List of field names.
     */
    @Override
    public ArrayList<String> getReadOnlyProperties() {

        ArrayList<String> result = super.getReadOnlyProperties();

        result.add("RedirectURL");

        return result;
    }

    /**
     * Gets map which property is an object and what type of object.
     * To be overridden in child class if has any sub objects.
     *
     * @return Collection of field name-field type pairs.
     */
    @Override
    public Map<String, Type> getSubObjects() {

        Map<String, Type> result = super.getSubObjects();

        result.put("TemplateURLOptions", PayInTemplateURLOptions.class);

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/PlatformCategorization.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.enumerations.BusinessType;
import com.mangopay.core.enumerations.Sector;

public class PlatformCategorization {

    @SerializedName("BusinessType")
    private BusinessType businessType;
    @SerializedName("Sector")
    private Sector sector;
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/SecureMode.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Secure mode enumeration.
 */
public enum SecureMode {
    /**
     * Not specified.
     */
    NotSpecified,

    /**
     * Secured Mode is activated from €100.
     */
    DEFAULT,

    /**
     * Secured Mode is activated for any transaction's amount.
     */
    FORCE,

    /**
     * Secured Mode has no choice.
     */
    NO_CHOICE
}


<|start_filename|>src/main/java/com/mangopay/entities/Event.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.EntityBase;
import com.mangopay.core.enumerations.EventType;

import java.util.ArrayList;

/**
 * Event entity.
 */
public class Event extends EntityBase {

    /**
     * Resource identifier.
     */
    @SerializedName("ResourceId")
    private String resourceId;

    /**
     * Type of event.
     */
    @SerializedName("EventType")
    private EventType eventType;

    /**
     * Date as UNIX timestamp.
     */
    @SerializedName("Date")
    private long date;

    public String getResourceId() {
        return resourceId;
    }

    public void setResourceId(String resourceId) {
        this.resourceId = resourceId;
    }

    public EventType getEventType() {
        return eventType;
    }

    public void setEventType(EventType eventType) {
        this.eventType = eventType;
    }

    public long getDate() {
        return date;
    }

    public void setDate(long date) {
        this.date = date;
    }

    /**
     * Gets the collection of read-only fields names.
     *
     * @return List of field names.
     */
    @Override
    public ArrayList<String> getReadOnlyProperties() {

        ArrayList<String> result = super.getReadOnlyProperties();

        result.add("ResourceId");
        result.add("EventType");
        result.add("Date");

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/Validity.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Validity enumeration.
 */
public enum Validity {
    /**
    * Not specified.
    */ 
    NotSpecified,

    /**
    * UNKNOWN validity.
    */ 
    UNKNOWN,

    /**
    * VALID validity.
    */ 
    VALID,

    /**
    * INVALID validity.
    */ 
    INVALID
}


<|start_filename|>src/main/java/com/mangopay/core/DocumentPageConsult.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;

/**
 * Holds document page viewing data.
 */
public class DocumentPageConsult extends Dto {

    /**
     * URL where this document page can be viewed.
     */
    @SerializedName("Url")
    private String url;

    /**
     * Time in millis when the page consult will expire.
     */
    @SerializedName("ExpirationDate")
    private long expirationDate;

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public long getExpirationDate() {
        return expirationDate;
    }

    public void setExpirationDate(long expirationDate) {
        this.expirationDate = expirationDate;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/RefundReason.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.enumerations.RefundReasonType;

/**
 * Class represents refund's reason.
 */
public class RefundReason extends Dto {

    /**
     * Message.
     */
    @SerializedName("RefundReasonMessage")
    private String refundReasonMessage;

    /**
     * Type of refund reason.
     */
    @SerializedName("RefundReasonType")
    private RefundReasonType refundReasonType;

    public String getRefundReasonMessage() {
        return refundReasonMessage;
    }

    public void setRefundReasonMessage(String refundReasonMessage) {
        this.refundReasonMessage = refundReasonMessage;
    }

    public RefundReasonType getRefundReasonType() {
        return refundReasonType;
    }

    public void setRefundReasonType(RefundReasonType refundReasonType) {
        this.refundReasonType = refundReasonType;
    }
}


<|start_filename|>src/test/java/com/mangopay/core/DisputeApiImplTest.java<|end_filename|>
package com.mangopay.core;

import com.mangopay.core.enumerations.*;
import com.mangopay.entities.*;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

import java.io.File;
import java.net.URL;
import java.util.Calendar;
import java.util.List;

import static org.junit.Assert.*;


/* IMPORTANT NOTE!
 *
 * Due to the fact the disputes CANNOT be created on user's side,
 * a special approach in testing is needed.
 * In order to get the tests below pass, a bunch of disputes has
 * to be prepared on the API's side - if it's not, the tests won't pass.
 *
 * Comment out the @Ignore attribute of DisputeApiImplTest class to include
 * disputes unit tests into the testing queue.
 *
 */


/**
 * DisputeApiImpl test methods.
 */
@Ignore("Comment this line out to allow DisputeApi unit tests run")
public class DisputeApiImplTest extends BaseTest {

    private List<Dispute> clientDisputes = null;

    @Before
    public void initialize() throws Exception {

        Sorting sort = new Sorting();
        sort.addField("CreationDate", SortDirection.desc);

        clientDisputes = api.getDisputeApi().getAll(new Pagination(1, 100), null, sort);

        assertTrue("INITIALIZATION FAILURE - cannot test disputes", clientDisputes != null && !clientDisputes.isEmpty());

    }

    @Test
    public void getDispute() throws Exception {

        Dispute dispute = api.getDisputeApi().get(clientDisputes.get(0).getId());

        assertNotNull(dispute);
        assertEquals(dispute.getId(), clientDisputes.get(0).getId());

    }

    @Test
    public void getTransactions() throws Exception {
        Dispute dispute = null;

        for (Dispute d : clientDisputes) {
            if (d.getDisputeType() == DisputeType.NOT_CONTESTABLE) {
                dispute = d;
                break;
            }
        }

        assertNotNull("Cannot test getting dispute's transactions because there's no not contestable dispute in the disputes list.", dispute);

        List<Transaction> result = api.getDisputeApi().getTransactions(dispute.getId(), new Pagination(1, 10), null, null);

        assertNotNull(result);
        assertFalse(result.isEmpty());
    }

    @Test
    public void getDisputesForWallet() throws Exception {
        Dispute dispute = null;

        for (Dispute d : clientDisputes) {
            if (d.getInitialTransactionId() != null) {
                dispute = d;
                break;
            }
        }

        assertNotNull("Cannot test getting disputes for wallet because there's no disputes with transaction ID in the disputes list.", dispute);

        String walletId = api.getPayInApi().get(dispute.getInitialTransactionId()).getCreditedWalletId();
        List<Dispute> result = api.getDisputeApi().getDisputesForWallet(walletId, new Pagination(1, 10), null, null);

        assertNotNull(result);
    }

    @Test
    public void getDisputesForUser() throws Exception {
        Dispute dispute = null;

        for (Dispute d : clientDisputes) {
            if (d.getDisputeType() == DisputeType.NOT_CONTESTABLE) {
                dispute = d;
                break;
            }
        }

        assertNotNull("Cannot test getting disputes for user because there's no not contestable dispute in the disputes list.", dispute);

        List<Transaction> transactions = api.getDisputeApi().getTransactions(dispute.getId(), new Pagination(1, 1), null, null);
        String userId = transactions.get(0).getAuthorId();
        List<Dispute> result = api.getDisputeApi().getDisputesForUser(userId, new Pagination(1, 20), null, null);

        assertNotNull(result);
        assertFalse(result.isEmpty());
    }

    @Test
    public void createDisputeDocument() throws Exception {
        Dispute dispute = null;

        for (Dispute d : clientDisputes) {
            if (d.getStatus() == DisputeStatus.PENDING_CLIENT_ACTION || d.getStatus() == DisputeStatus.REOPENED_PENDING_CLIENT_ACTION) {
                dispute = d;
                break;
            }
        }

        assertNotNull("Cannot test creating dispute document because there's no dispute with expected status in the disputes list.", dispute);

        DisputeDocument result = null;

        DisputeDocument documentPost = new DisputeDocument();
        documentPost.setType(DisputeDocumentType.DELIVERY_PROOF);

        result = api.getDisputeApi().createDisputeDocument(documentPost, dispute.getId());

        assertNotNull(result);
        assertEquals(result.getType(), DisputeDocumentType.DELIVERY_PROOF);
    }

    @Test
    public void createDisputePage() throws Exception {
        Dispute dispute = null;

        for (Dispute d : clientDisputes) {
            if (d.getStatus() == DisputeStatus.PENDING_CLIENT_ACTION || d.getStatus() == DisputeStatus.REOPENED_PENDING_CLIENT_ACTION) {
                dispute = d;
                break;
            }
        }

        assertNotNull("Cannot test creating dispute document page because there's no dispute with expected status in the disputes list.", dispute);

        DisputeDocument result = null;

        DisputeDocument documentPost = new DisputeDocument();
        documentPost.setType(DisputeDocumentType.DELIVERY_PROOF);
        result = api.getDisputeApi().createDisputeDocument(documentPost, dispute.getId());

        URL url = getClass().getResource("/com/mangopay/core/TestKycPageFile.png");
        String filePath = new File(url.toURI()).getAbsolutePath();

        api.getDisputeApi().createDisputePage(dispute.getId(), result.getId(), filePath);

        assertNotNull(result);
        assertEquals(result.getType(), DisputeDocumentType.DELIVERY_PROOF);
    }

    @Test
    public void contestDispute() throws Exception {
        Dispute notContestedDispute = null;

        for (Dispute d : clientDisputes) {
            if ((d.getStatus() == DisputeStatus.PENDING_CLIENT_ACTION || d.getStatus() == DisputeStatus.REOPENED_PENDING_CLIENT_ACTION)
                    && (d.getDisputeType() == DisputeType.CONTESTABLE || d.getDisputeType() == DisputeType.RETRIEVAL)) {
                notContestedDispute = d;
                break;
            }
        }

        assertNotNull("Cannot test contesting dispute because there's no disputes that can be contested in the disputes list.", notContestedDispute);

        Dispute result = null;

        Money contestedFunds = null;
        if (notContestedDispute.getStatus() == DisputeStatus.PENDING_CLIENT_ACTION) {
            contestedFunds = new Money();
            contestedFunds.setAmount(100);
            contestedFunds.setCurrency(CurrencyIso.EUR);
        }

        result = api.getDisputeApi().contestDispute(contestedFunds, notContestedDispute.getId());

        assertNotNull(result);
        assertEquals(result.getId(), notContestedDispute.getId());
    }

    @Test
    public void saveTag() throws Exception {
        Dispute result = null;

        Calendar c = Calendar.getInstance();
        String newTag = "New tag: " + Long.toString(c.getTimeInMillis() / 1000);

        result = api.getDisputeApi().updateTag(newTag, clientDisputes.get(0).getId());

        assertNotNull(result);
        assertEquals(result.getTag(), newTag);
    }

    @Test
    public void closeDispute() throws Exception {
        Dispute dispute = null;

        for (Dispute d : clientDisputes) {
            if (d.getStatus() == DisputeStatus.PENDING_CLIENT_ACTION || d.getStatus() == DisputeStatus.REOPENED_PENDING_CLIENT_ACTION) {
                dispute = d;
                break;
            }
        }

        assertNotNull("Cannot test closing dispute because there's no available disputes with expected status in the disputes list.", dispute);

        Dispute result = null;

        result = api.getDisputeApi().closeDispute(dispute.getId());

        assertNotNull(result);
    }

    @Test
    public void getDocument() throws Exception {
        Dispute dispute = null;

        for (Dispute d : clientDisputes) {
            if (d.getStatus() == DisputeStatus.PENDING_CLIENT_ACTION || d.getStatus() == DisputeStatus.REOPENED_PENDING_CLIENT_ACTION) {
                dispute = d;
                break;
            }
        }

        assertNotNull("Cannot test getting dispute's document because there's no dispute with expected status in the disputes list.", dispute);

        DisputeDocument document = null;
        DisputeDocument result = null;

        DisputeDocument documentPost = new DisputeDocument();
        documentPost.setType(DisputeDocumentType.OTHER);
        document = api.getDisputeApi().createDisputeDocument(documentPost, dispute.getId());

        result = api.getDisputeApi().getDocument(document.getId());

        assertNotNull(result);
        assertEquals(result.getCreationDate(), document.getCreationDate());
        assertEquals(result.getId(), document.getId());
        assertEquals(result.getRefusedReasonMessage(), document.getRefusedReasonMessage());
        assertEquals(result.getRefusedReasonType(), document.getRefusedReasonType());
        assertEquals(result.getStatus(), document.getStatus());
        assertEquals(result.getTag(), document.getTag());
        assertEquals(result.getType(), document.getType());
        assertEquals(result.getDisputeId(), document.getDisputeId());
    }

    @Test
    public void createDisputeDocumentConsult() throws Exception {
        Dispute dispute = null;

        for (Dispute d : clientDisputes) {
            if (d.getStatus() == DisputeStatus.PENDING_CLIENT_ACTION || d.getStatus() == DisputeStatus.REOPENED_PENDING_CLIENT_ACTION) {
                dispute = d;
                break;
            }
        }

        assertNotNull("Cannot test creating dispute's document consult because there's no dispute with expected status in the disputes list.", dispute);

        DisputeDocument document = null;
        DisputeDocument documentPost = new DisputeDocument();
        documentPost.setType(DisputeDocumentType.OTHER);
        document = api.getDisputeApi().createDisputeDocument(documentPost, dispute.getId());

        List<DocumentPageConsult> consults = api.getDisputeApi().createDisputeDocumentConsult(document.getId());

        assertNotNull(consults);
    }

    @Test
    public void getDocumentsForDispute() throws Exception {
        Dispute dispute = null;

        for (Dispute d : clientDisputes) {
            if (d.getStatus() == DisputeStatus.SUBMITTED) {
                dispute = d;
                break;
            }
        }

        if (dispute == null) {
            contestDispute();
            initialize();

            for (Dispute d : clientDisputes) {
                if (d.getStatus() == DisputeStatus.SUBMITTED) {
                    dispute = d;
                    break;
                }
            }

            assertNotNull("Cannot test getting dispute's documents because there's no available disputes with SUBMITTED status in the disputes list.", dispute);
        }

        List<DisputeDocument> result = null;

        result = api.getDisputeApi().getDocumentsForDispute(dispute.getId(), new Pagination(1, 1), null, null);

        assertNotNull(result);
    }

    @Test
    public void getDocumentsForClient() throws Exception {
        List<DisputeDocument> result = null;

        result = api.getDisputeApi().getDocumentsForClient(new Pagination(1, 1), null, null);

        assertNotNull(result);
    }

    @Test
    public void submitDisputeDocument() throws Exception {
        Dispute dispute = null;
        DisputeDocument disputeDocument = null;

        FilterDisputeDocuments filter = new FilterDisputeDocuments();
        filter.setStatus(DisputeDocumentStatus.CREATED);

        // search for disputes having any documents created...
        for (Dispute d : clientDisputes) {
            if (d.getStatus() == DisputeStatus.PENDING_CLIENT_ACTION || d.getStatus() == DisputeStatus.REOPENED_PENDING_CLIENT_ACTION) {

                List<DisputeDocument> dd = this.api.getDisputeApi().getDocumentsForDispute(d.getId(), new Pagination(1, 1), filter, null);

                if (dd != null && dd.size() > 0) {
                    // ...found such
                    dispute = d;
                    disputeDocument = dd.get(0);
                    break;
                }
            }
        }

        if (dispute == null) {
            // try to create a dispute document
            for (Dispute d : clientDisputes) {
                if (d.getStatus() == DisputeStatus.PENDING_CLIENT_ACTION || d.getStatus() == DisputeStatus.REOPENED_PENDING_CLIENT_ACTION) {
                    dispute = d;
                    DisputeDocument documentPost = new DisputeDocument();
                    documentPost.setType(DisputeDocumentType.DELIVERY_PROOF);
                    disputeDocument = this.api.getDisputeApi().createDisputeDocument(documentPost, dispute.getId());
                    break;
                }
            }
        }

        assertNotNull("Cannot test submitting dispute's documents because there's no dispute with expected status in the disputes list.", dispute);

        assertNotNull("Cannot test submitting dispute's documents because there's no dispute document that can be updated.", disputeDocument);

        URL url = getClass().getResource("/com/mangopay/core/TestKycPageFile.png");
        String filePath = new File(url.toURI()).getAbsolutePath();
        api.getDisputeApi().createDisputePage(dispute.getId(), disputeDocument.getId(), filePath);

        DisputeDocument result = null;

        DisputeDocument disputeDocumentPut = new DisputeDocument();
        disputeDocumentPut.setId(disputeDocument.getId());
        disputeDocumentPut.setStatus(DisputeDocumentStatus.VALIDATION_ASKED);

        result = api.getDisputeApi().submitDisputeDocument(disputeDocumentPut, dispute.getId());

        assertNotNull(result);
        assertTrue(disputeDocument.getType() == result.getType());
        assertTrue(result.getStatus() == DisputeDocumentStatus.VALIDATION_ASKED);
    }

    @Test
    public void getRepudiation() throws Exception {
        Dispute dispute = null;

        for (Dispute d : clientDisputes) {
            if (d.getDisputeType() == DisputeType.NOT_CONTESTABLE && d.getInitialTransactionId() != null) {
                dispute = d;
                break;
            }
        }

        Repudiation result = null;

        assertNotNull("Cannot test getting repudiation because there's no not contestable dispute in the disputes list.", dispute);

        String repudiationId = api.getDisputeApi().getTransactions(dispute.getId(), new Pagination(1, 1), null, null).get(0).getId();

        result = api.getRepudiationApi().getRepudiation(repudiationId);

        assertNotNull(result);
    }

    @Test
    public void createSettlementTransfer() throws Exception {
        Dispute dispute = null;

        for (Dispute d : clientDisputes) {
            if (d.getStatus() == DisputeStatus.CLOSED && d.getDisputeType() == DisputeType.NOT_CONTESTABLE) {
                dispute = d;
                break;
            }
        }

        assertNotNull("Cannot test creating settlement transfer because there's no closed and not contestable disputes in the disputes list.", dispute);

        String repudiationId = api.getDisputeApi().getTransactions(dispute.getId(), new Pagination(1, 1), null, null).get(0).getId();

        Repudiation repudiation = null;

        repudiation = api.getRepudiationApi().getRepudiation(repudiationId);

        Money debitedFunds = new Money();
        Money fees = new Money();
        debitedFunds.setCurrency(CurrencyIso.EUR);
        debitedFunds.setAmount(1);
        fees.setCurrency(CurrencyIso.EUR);
        fees.setAmount(0);

        SettlementTransfer post = new SettlementTransfer();
        post.setAuthorId(repudiation.getAuthorId());
        post.setDebitedFunds(debitedFunds);
        post.setFees(fees);

        Transfer result = null;
        result = api.getDisputeApi().createSettlementTransfer(post, repudiationId);

        assertNotNull(result);
    }

    @Test
    public void getDisputesWithPendingSettlement() throws Exception {
        Pagination pagination = new Pagination(0, 1);
        Sorting sort = new Sorting();
        sort.addField("CreationDate", SortDirection.desc);
        List<Dispute> disputesWithPendingSettlement = this.api.getDisputeApi().getDisputesWithPendingSettlement(pagination, sort);
        assertNotNull(disputesWithPendingSettlement);
        assertFalse(disputesWithPendingSettlement.isEmpty());
        assertTrue(disputesWithPendingSettlement.size() == 1);
    }

    @Test
    public void getFilteredDisputes() throws Exception {
        List<Dispute> result1 = null;
        List<Dispute> result2 = null;

        Calendar c = Calendar.getInstance();
        long now = c.getTime().getTime() / 1000;
        FilterDisputes filterAfter = new FilterDisputes();
        FilterDisputes filterBefore = new FilterDisputes();
        filterAfter.setAfterDate(now);
        filterBefore.setBeforeDate(now);
        result1 = api.getDisputeApi().getAll(new Pagination(1, 100), filterAfter, null);
        result2 = api.getDisputeApi().getAll(new Pagination(1, 100), filterBefore, null);

        assertNotNull(result1);
        assertNotNull(result2);
        assertTrue(result1.isEmpty());
        assertFalse(result2.isEmpty());
    }

    @Test
    public void getFilteredDisputeDocuments() throws Exception {
        List<DisputeDocument> result1 = null;
        List<DisputeDocument> result2 = null;
        List<DisputeDocument> result3 = null;

        Calendar c = Calendar.getInstance();
        long now = c.getTime().getTime() / 1000;
        FilterDisputeDocuments filterAfter = new FilterDisputeDocuments();
        FilterDisputeDocuments filterBefore = new FilterDisputeDocuments();
        filterAfter.setAfterDate(now + 10000);
        filterBefore.setBeforeDate(now);

        result1 = api.getDisputeApi().getDocumentsForClient(new Pagination(1, 100), filterAfter, null);
        result2 = api.getDisputeApi().getDocumentsForClient(new Pagination(1, 100), filterBefore, null);

        assertNotNull(result1);
        assertNotNull(result2);
        assertTrue(result1.isEmpty());
        assertFalse(result2.isEmpty());

        FilterDisputeDocuments filterType = new FilterDisputeDocuments();
        filterType.setType(result2.get(0).getType());
        result3 = api.getDisputeApi().getDocumentsForClient(new Pagination(1, 100), filterType, null);

        assertNotNull(result3);
        assertFalse(result3.isEmpty());
        for (DisputeDocument dd : result3) {
            assertTrue(dd.getType() == result2.get(0).getType());
        }
    }

    @Test
    public void resubmitDispute() throws Exception {
        Dispute dispute = null;

        for (Dispute d : clientDisputes) {
            if (d.getStatus() == DisputeStatus.REOPENED_PENDING_CLIENT_ACTION) {
                dispute = d;
                break;
            }
        }

        Dispute result = null;

        assertNotNull("Cannot test resubmitting dispute because there's no re-opened disputes in the disputes list.", dispute);

        result = api.getDisputeApi().resubmitDispute(dispute.getId());

        assertNotNull(result);
        assertTrue(result.getStatus() == DisputeStatus.SUBMITTED);
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/NaturalUserCapacity.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Enumeration that differentiates natural users.
 */
public enum NaturalUserCapacity {

    /**
     * Real customer.
     */
    NORMAL,

    /**
     * User used only for declaration purpose.
     */
    DECLARATIVE
}


<|start_filename|>src/main/java/com/mangopay/core/UrlTool.java<|end_filename|>
package com.mangopay.core;

import com.mangopay.MangoPayApi;

import java.io.UnsupportedEncodingException;
import java.net.*;
import java.util.Map;
import java.util.Map.Entry;

/**
 * Helper class to manage URLs.
 */
class UrlTool {

    /**
     * Root/parent instance that holds the OAuthToken and Configuration instance.
     */
    private MangoPayApi root;

    /**
     * Instantiates new UrlTool object.
     *
     * @param root Root/parent instance that holds the OAuthToken and Configuration instance.
     */
    public UrlTool(MangoPayApi root) {
        this.root = root;
    }

    private String getHost() throws Exception {

        if (root.getConfig().getBaseUrl() == null || root.getConfig().getBaseUrl().length() == 0)
            throw new Exception("MangoPayApi.config.BaseUrl setting is not defined.");

        URL baseUrl = new URL(root.getConfig().getBaseUrl());

        return baseUrl.getHost();
    }

    /**
     * Gets REST url.
     *
     * @param urlKey Url key.
     * @return Final REST url.
     * @throws UnsupportedEncodingException
     */
    public String getRestUrl(String urlKey) throws UnsupportedEncodingException {
        return getRestUrl(urlKey, true, null, null);
    }

    /**
     * Gets REST url.
     *
     * @param urlKey      Url key.
     * @param addClientId Denotes whether client identifier should be composed into final url.
     * @return Final REST url.
     * @throws UnsupportedEncodingException
     */
    public String getRestUrl(String urlKey, Boolean addClientId) throws UnsupportedEncodingException {
        return getRestUrl(urlKey, addClientId, null, null);
    }

    /**
     * Gets REST url.
     *
     * @param urlKey      Url key.
     * @param addClientId Denotes whether client identifier should be composed into final url.
     * @param pagination  Pagination object.
     * @return Final REST url.
     * @throws UnsupportedEncodingException
     */
    public String getRestUrl(String urlKey, Boolean addClientId, Pagination pagination) throws UnsupportedEncodingException {
        return getRestUrl(urlKey, addClientId, pagination, null);
    }

    /**
     * Gets REST url.
     *
     * @param urlKey              Url key.
     * @param addClientId         Denotes whether client identifier should be composed into final url.
     * @param pagination          Pagination object.
     * @param additionalUrlParams Additional parameters.
     * @return Final REST url.
     * @throws UnsupportedEncodingException
     */
    public String getRestUrl(String urlKey, Boolean addClientId, Pagination pagination, Map<String, String> additionalUrlParams) throws UnsupportedEncodingException {

        String url;

        if (!addClientId) {
            url = "/v2.01" + urlKey;
        } else {
            url = "/v2.01/" + root.getConfig().getClientId() + urlKey;
        }

        Boolean paramsAdded = false;
        if (pagination != null) {
            url += "?page=" + pagination.getPage() + "&per_page=" + pagination.getItemsPerPage();
            paramsAdded = true;
        }

        if (additionalUrlParams != null) {
            for (Entry<String, String> entry : additionalUrlParams.entrySet()) {
                url += paramsAdded ? "&" : "?";
                url += entry.getKey() + "=" + URLEncoder.encode(entry.getValue(), "ISO-8859-1");
                paramsAdded = true;
            }
        }

        return url;
    }

    /**
     * Gets complete url.
     *
     * @param restUrl Rest url.
     * @return Complete url.
     */
    public String getFullUrl(String restUrl) {

        String result = "";

        try {
            int port = new URL(root.getConfig().getBaseUrl()).getPort();
            String protocol = new URL(root.getConfig().getBaseUrl()).getProtocol() + "://" + this.getHost();
            if (port > 0) {
                result = protocol + ":" + port + restUrl;
            } else {
                result = protocol + restUrl;
            }
        } catch (Exception ex) {
        }

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/RefundReasonType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Refund reason type enumeration.
 */
public enum RefundReasonType {
    
    /**
     * Not specified.
     */
    NotSpecified,

    /**
     * Incorrect bank account.
     */
    BANKACCOUNT_INCORRECT, 

    /**
     * Closed bank account.
     */
    BANKACCOUNT_HAS_BEEN_CLOSED, 

    /**
     * Owner-bank account mismatch.
     */
    OWNER_DOT_NOT_MATCH_BANKACCOUNT, 

    /**
     * Withdrawal impossible on savings accounts.
     */
    WITHDRAWAL_IMPOSSIBLE_ON_SAVINGS_ACCOUNTS, 

    /**
     * Initialized by client.
     */
    INITIALIZED_BY_CLIENT, 

    /**
     * Other.
     */
    OTHER
}


<|start_filename|>src/main/java/com/mangopay/entities/subentities/BankAccountDetailsIBAN.java<|end_filename|>
package com.mangopay.entities.subentities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Dto;
import com.mangopay.core.interfaces.BankAccountDetails;

/**
 * Class represents IBAN type of bank account.
 */
public class BankAccountDetailsIBAN extends Dto implements BankAccountDetails {

    /**
     * IBAN number.
     */
    @SerializedName("IBAN")
    private String iban;

    /**
     * BIC.
     */
    @SerializedName("BIC")
    private String bic;

    public String getIban() {
        return iban;
    }

    public void setIban(String iban) {
        this.iban = iban;
    }

    public String getBic() {
        return bic;
    }

    public void setBic(String bic) {
        this.bic = bic;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/implementation/HookApiImpl.java<|end_filename|>
package com.mangopay.core.APIs.implementation;

import com.mangopay.MangoPayApi;
import com.mangopay.core.APIs.ApiBase;
import com.mangopay.core.APIs.HookApi;
import com.mangopay.core.Pagination;
import com.mangopay.core.Sorting;
import com.mangopay.entities.Hook;

import java.util.List;

/**
 * API for hooks.
 */
public class HookApiImpl extends ApiBase implements HookApi {
    
    /**
     * Instantiates new HookApiImpl object.
     * @param root Root/parent instance that holds the OAuthToken and Configuration instance.
     */
    public HookApiImpl(MangoPayApi root) {
        super(root);
    }
    
    @Override
    public Hook create(Hook hook) throws Exception {
        return this.create(null, hook);
    }
    
    @Override
    public Hook create(String idempotencyKey, Hook hook) throws Exception {
        return this.createObject(Hook.class, idempotencyKey, "hooks_create", hook);
    }
    
    @Override
    public Hook get(String hookId) throws Exception {
        return this.getObject(Hook.class, "hooks_get", hookId);
    }
    
    @Override
    public Hook update(Hook hook) throws Exception {
        return this.updateObject(Hook.class, "hooks_save", hook);
    }
    
    @Override
    public List<Hook> getAll(Pagination pagination, Sorting sorting) throws Exception {
        return this.getList(Hook[].class, Hook.class, "hooks_all", pagination, sorting);
    }
    
    @Override
    public List<Hook> getAll() throws Exception {
        return this.getAll(null, null);
    }
    
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/BankAccountType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Bank account type enumeration.
 */
public enum BankAccountType {
    /**
     * Not specified.
     */
    NotSpecified,

    /**
     * IBAN bank account type.
     */
    IBAN,

    /**
     * GB bank account type.
     */
    GB,

    /**
     * US bank account type.
     */
    US,

    /**
     * CA bank account type.
     */
    CA,

    /**
     * OTHER bank account type.
     */
    OTHER
}


<|start_filename|>src/main/java/com/mangopay/core/EntityBase.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;

import java.util.ArrayList;

/**
 * Base abstract class for entities. Provides common properties.
 */
public abstract class EntityBase extends Dto {

    /**
     * Unique identifier.
     */
    @SerializedName("Id")
    private String id;

    /**
     * Custom data.
     */
    @SerializedName("Tag")
    private String tag;

    /**
     * Date of creation (UNIX timestamp).
     */
    @SerializedName("CreationDate")
    private long creationDate;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTag() {
        return tag;
    }

    public void setTag(String tag) {
        this.tag = tag;
    }

    public long getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(long creationDate) {
        this.creationDate = creationDate;
    }

    /**
     * Gets the collection of read-only fields names.
     *
     * @return List of field names.
     */
    @Override
    public ArrayList<String> getReadOnlyProperties() {

        ArrayList<String> result = new ArrayList<>();

        result.add("Id");
        result.add("CreationDate");

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/serializer/SerializedTransaction.java<|end_filename|>
package com.mangopay.core.serializer;

import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.mangopay.entities.Transaction;

class SerializedTransaction {

    static JsonObject getTransactionObject(Transaction source, JsonSerializationContext context) {
        JsonObject object = new JsonObject();
        object.add("Id", context.serialize(source.getId()));
        object.add("Tag", context.serialize(source.getTag()));
        object.add("CreationDate", context.serialize(source.getCreationDate()));

        object.add("AuthorId", context.serialize(source.getAuthorId()));
        object.add("CreditedUserId", context.serialize(source.getCreditedUserId()));
        object.add("DebitedFunds", context.serialize(source.getDebitedFunds()));
        object.add("CreditedFunds", context.serialize(source.getCreditedFunds()));
        object.add("Fees", context.serialize(source.getFees()));
        object.add("Status", context.serialize(source.getStatus()));
        object.add("ResultCode", context.serialize(source.getResultCode()));
        object.add("ResultMessage", context.serialize(source.getResultMessage()));
        object.add("ExecutionDate", context.serialize(source.getExecutionDate()));
        object.add("Type", context.serialize(source.getType()));
        object.add("Nature", context.serialize(source.getNature()));

        return object;
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/ClientLogo.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.EntityBase;

/**
 * Client logo container.
 */
public class ClientLogo extends EntityBase {

    /**
     * File content.
     */
    @SerializedName("File")
    private String file;

    public String getFile() {
        return file;
    }

    public void setFile(String file) {
        this.file = file;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/SettlementApi.java<|end_filename|>
package com.mangopay.core.APIs;

import com.mangopay.entities.SettlementTransfer;

public interface SettlementApi {

    /**
     * Get settlement transfer entity
     *
     * @param id settlement identifier
     * @return settlement entity returned from API
     * @throws Exception
     */
    SettlementTransfer get(String id) throws Exception;

}


<|start_filename|>src/main/java/com/mangopay/core/APIs/OAuthApi.java<|end_filename|>
package com.mangopay.core.APIs;

import com.mangopay.core.OAuthToken;

/**
 * Created by thepa on 18-Jan-17.
 */
public interface OAuthApi {

    /**
     * Gets the new token used for requests authentication.
     *
     * @return OAuth object with token information.
     */
    OAuthToken createToken() throws Exception;
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/implementation/CardRegistrationApiImpl.java<|end_filename|>
package com.mangopay.core.APIs.implementation;

import com.mangopay.MangoPayApi;
import com.mangopay.core.APIs.ApiBase;
import com.mangopay.core.APIs.CardRegistrationApi;
import com.mangopay.entities.CardRegistration;

/**
 * API for card registrations.
 */
public class CardRegistrationApiImpl extends ApiBase implements CardRegistrationApi {

    /**
     * Instantiates new ApiCardRegistration object.
     *
     * @param root Root/parent instance that holds the OAuthToken and Configuration instance
     */
    public CardRegistrationApiImpl(MangoPayApi root) {
        super(root);
    }

    @Override
    public CardRegistration create(CardRegistration cardRegistration) throws Exception {
        return this.create(null, cardRegistration);
    }

    @Override
    public CardRegistration create(String idempotencyKey, CardRegistration cardRegistration) throws Exception {
        return this.createObject(CardRegistration.class, idempotencyKey, "cardregistration_create", cardRegistration);
    }

    @Override
    public CardRegistration get(String cardRegistrationId) throws Exception {
        return this.getObject(CardRegistration.class, "cardregistration_get", cardRegistrationId);
    }

    @Override
    public CardRegistration update(CardRegistration cardRegistration) throws Exception {
        return this.updateObject(CardRegistration.class, "cardregistration_save", cardRegistration);
    }

}


<|start_filename|>src/main/java/com/mangopay/core/Configuration.java<|end_filename|>
package com.mangopay.core;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Configuration settings.
 */
public class Configuration {

    /**
     * Client identifier.
     */
    private String clientId = "";

    /**
     * Client password.
     */
    private String clientPassword = "";

    /**
     * Base URL to MangoPay API.
     */
    private String baseUrl = "https://api.sandbox.mangopay.com";

    /**
     * [INTERNAL USAGE ONLY] Switch debug mode: log all request and response data.
     */
    private boolean debugMode = false;

    /**
     * Connection Timeout.
     */
    private int connectTimeout = 60000;

    /**
     * Connection Read Timeout.
     */
    private int readTimeout = 60000;
    
    /**
     * Mangopay SDK Version
     */
    private String version;
    

    public String getClientId() {
        return clientId;
    }

    public void setClientId(String clientId) {
        this.clientId = clientId;
    }

    public String getClientPassword() {
        return clientPassword;
    }

    public void setClientPassword(String clientPassword) {
        this.clientPassword = <PASSWORD>;
    }

    public String getBaseUrl() {
        return baseUrl;
    }

    public void setBaseUrl(String baseUrl) {
        this.baseUrl = baseUrl;
    }

    public boolean isDebugMode() {
        return debugMode;
    }

    public void setDebugMode(boolean debugMode) {
        this.debugMode = debugMode;
    }

    /**
     * Get Connection Timeout
     *
     * @return int Connection Timeout in millis.
     */
    public int getConnectTimeout() {
        return connectTimeout;
    }

    /**
     * Set Connection Timeout
     *
     * @param connectTimeout connection timeout in millis.
     */
    public void setConnectTimeout(int connectTimeout) {
        this.connectTimeout = connectTimeout;
    }

    /**
     * Get Connection Read Timeout
     *
     * @return int Connection Timeout in millis.
     */
    public int getReadTimeout() {
        return readTimeout;
    }

    /**
     * Set Connection Read Timeout
     *
     * @param readTimeout connection read timeout in millis.
     */
    public void setReadTimeout(int readTimeout) {
        this.readTimeout = readTimeout;
    }

    
    /**
     * Get Mangopay SDK Version
     * @return String Mangopay Version
     */
    public String getVersion() {
        if (ObjectTool.isNull(version)) {
            version = readMangopayVersion();
        }
        return version;
    }

    /**
     * Read Mangopay version from mangopay properties
     * @return String Mangopay Version
     */
    private String readMangopayVersion() {
        try {
            Properties prop = new Properties();
            InputStream input = getClass().getResourceAsStream("mangopay.properties");
            prop.load(input);
            return prop.getProperty("version");
        } catch (IOException ex) {
            Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, null, ex);
        }
        return "unknown";
    }
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/implementation/BankingAliasApiImpl.java<|end_filename|>
package com.mangopay.core.APIs.implementation;

import com.google.gson.GsonBuilder;
import com.mangopay.MangoPayApi;
import com.mangopay.core.APIs.ApiBase;
import com.mangopay.core.APIs.BankingAliasApi;
import com.mangopay.core.FilterBankingAlias;
import com.mangopay.core.Pagination;
import com.mangopay.core.Sorting;
import com.mangopay.core.deserializer.BankingAliasDeserializer;
import com.mangopay.entities.BankingAlias;

import java.util.List;

/**
 * Created by thepa on 08-Feb-17.
 */
public class BankingAliasApiImpl extends ApiBase implements BankingAliasApi {

    /**
     * Creates new BankingAliasApiImpl instance.
     *
     * @param root Root/parent instance that holds the OAuthToken and Configuration instance.
     */
    public BankingAliasApiImpl(MangoPayApi root, GsonBuilder gsonBuilder) {
        super(root);
        gsonBuilder.registerTypeAdapter(BankingAlias.class, new BankingAliasDeserializer());
    }

    @Override
    public BankingAlias create(String walletId, BankingAlias bankingAlias) throws Exception {
        return this.create(null, walletId, bankingAlias);
    }

    @Override
    public BankingAlias create(String idempotencyKey, String walletId, BankingAlias bankingAlias) throws Exception {
        return this.createObject(BankingAlias.class, idempotencyKey, "banking_alias_create_iban", bankingAlias, walletId);
    }

    @Override
    public BankingAlias get(String bankingAliasId) throws Exception {
        return this.getObject(BankingAlias.class, "banking_alias_get", bankingAliasId);
    }

    @Override
    public List<BankingAlias> listForWallet(String walletId, Pagination pagination, FilterBankingAlias filter, Sorting sorting) throws Exception {
        return this.getList(BankingAlias[].class, BankingAlias.class, "banking_aliases_get_for_wallet", pagination, walletId, filter.getValues(), sorting);
    }

    @Override
    public List<BankingAlias> listForWallet(String walletId, Pagination pagination, FilterBankingAlias filter) throws Exception {
        return listForWallet(walletId, pagination, filter, null);
    }

    @Override
    public List<BankingAlias> listForWallet(String walletId, Pagination pagination) throws Exception {
        return listForWallet(walletId, pagination, new FilterBankingAlias());
    }

    @Override
    public List<BankingAlias> listForWallet(String walletId) throws Exception {
        return listForWallet(walletId, null, new FilterBankingAlias());
    }

    @Override
    public BankingAlias deactivate(String bankingAliasId, BankingAlias bankingAlias) throws Exception {
        return this.updateObject(BankingAlias.class, "banking_alias_deactivate", bankingAlias, bankingAliasId);
    }
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/KycDocumentApi.java<|end_filename|>
package com.mangopay.core.APIs;

import com.mangopay.core.DocumentPageConsult;
import com.mangopay.core.Pagination;
import com.mangopay.core.Sorting;
import com.mangopay.entities.KycDocument;

import java.util.List;

/**
 * Created by thepa on 18-Jan-17.
 */
public interface KycDocumentApi {
    /**
     * Gets all KYC documents.
     * @param pagination    Pagination object.
     * @param sorting       Sorting object.
     * @return              Collection of KycDocuments returned from API.
     * @throws Exception
     */
    List<KycDocument> getAll(Pagination pagination, Sorting sorting) throws Exception;

    /**
     * Gets KYC document.
     * @param kycDocumentId KYC document identifier.
     * @return              KYC document returned from API.
     * @throws Exception
     */
    KycDocument getKycDocument(String kycDocumentId) throws Exception;

    /**
     * Creates temporary URLs where each page of a KYC document can be viewed.
     *
     * @param kycDocumentId Identification of the document whose pages to view
     * @throws Exception
     */
    List<DocumentPageConsult> createKycDocumentConsult(String kycDocumentId) throws Exception;
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/MandateType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Type of mandate.
 */
public enum MandateType {
    
    /**
     * Nor specified.
     */
    NotSpecified,

    /**
     * Direct debit type.
     */
    DIRECT_DEBIT
    
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/ReportApi.java<|end_filename|>
package com.mangopay.core.APIs;

import com.mangopay.core.FilterReportsList;
import com.mangopay.core.Pagination;
import com.mangopay.core.Sorting;
import com.mangopay.entities.ReportRequest;

import java.util.List;

/**
 * Created by thepa on 18-Jan-17.
 */
public interface ReportApi {

    /**
     * Creates new report request.
     *
     * @param reportRequest Report request details for creation
     * @return Newly-created {@link ReportRequest}
     * @throws Exception
     */
    ReportRequest create(ReportRequest reportRequest) throws Exception;

    /**
     * Creates new report request.
     *
     * @param idempotencyKey Idempotency key
     * @param reportRequest  Report request details for creation
     * @return Newly-created {@link ReportRequest}
     * @throws Exception
     */
    ReportRequest create(String idempotencyKey, ReportRequest reportRequest) throws Exception;

    /**
     * Request creation of a report for wallets.
     *
     * @param reportRequest The report request details
     * @return Newly-created wallet report request
     * @throws Exception
     */
    ReportRequest createWalletReport(ReportRequest reportRequest) throws Exception;

    /**
     * Gets a report request by its unique identifier.
     *
     * @param reportId Unique report identifier
     * @return Corresponding {@link ReportRequest}
     * @throws Exception
     */
    ReportRequest get(String reportId) throws Exception;

    /**
     * Gets a list of all report requests.
     *
     * @param pagination Pagination object
     * @param filters    Filtering object
     * @param sort       Sorting object
     * @return List of matching {@link ReportRequest}s
     * @throws Exception
     */
    List<ReportRequest> getAll(Pagination pagination, FilterReportsList filters, Sorting sort) throws Exception;

    /**
     * Gets a list of all report requests.
     *
     * @return List of {@link ReportRequest}s
     * @throws Exception
     */
    List<ReportRequest> getAll() throws Exception;
}


<|start_filename|>src/main/java/com/mangopay/core/interfaces/BankingAliasDetails.java<|end_filename|>
package com.mangopay.core.interfaces;

/**
 * Marker interface for classes containing banking alias details.
 */
public interface BankingAliasDetails {
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/ReportType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Report type enumeration.
 */
public enum ReportType {

    /**
     * Not specified.
     */
    NotSpecified,
    
    /**
     * Transactions type.
     */
    TRANSACTIONS,
    
    /**
    * Wallets type.
    */
    WALLETS
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/HookStatus.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Hook status enumeration.
 */
public enum HookStatus {
    /**
     * Not specified.
     */
    NotSpecified,

    /*
     * DISABLED hook status.
     */
    DISABLED,

    /*
     * ENABLED hook status.
     */
    ENABLED
}


<|start_filename|>src/main/java/com/mangopay/core/FilterEvents.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.enumerations.EventType;

import java.util.HashMap;
import java.util.Map;

/**
 * Filter for events list.
 */
public class FilterEvents extends Dto {

    /**
     * Type of events.
     */
    @SerializedName("Type")
    private EventType type;

    /**
     * Start date in Unix format.
     */
    @SerializedName("BeforeDate")
    private Long beforeDate;

    /**
     * End date in Unix format.
     */
    @SerializedName("AfterDate")
    private Long afterDate;

    public EventType getType() {
        return type;
    }

    public void setType(EventType type) {
        this.type = type;
    }

    public Long getBeforeDate() {
        return beforeDate;
    }

    public void setBeforeDate(Long beforeDate) {
        this.beforeDate = beforeDate;
    }

    public Long getAfterDate() {
        return afterDate;
    }

    public void setAfterDate(Long afterDate) {
        this.afterDate = afterDate;
    }

    /**
     * Gets map of fields and values.
     *
     * @return Collection of field name-field value pairs.
     */
    @Override
    public Map<String, String> getValues() {
        HashMap<String, String> result = new HashMap<>();

        if (type != EventType.ALL) {
            result.put("eventtype", type.name());
        }

        if (beforeDate != null) result.put("beforeDate", Long.toString(beforeDate));
        if (afterDate != null) result.put("afterDate", Long.toString(afterDate));

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/implementation/WalletApiImpl.java<|end_filename|>
package com.mangopay.core.APIs.implementation;

import com.mangopay.MangoPayApi;
import com.mangopay.core.APIs.ApiBase;
import com.mangopay.core.APIs.WalletApi;
import com.mangopay.core.FilterTransactions;
import com.mangopay.core.Pagination;
import com.mangopay.core.Sorting;
import com.mangopay.entities.Transaction;
import com.mangopay.entities.Wallet;

import java.util.List;

/**
 * API for wallets.
 */
public class WalletApiImpl extends ApiBase implements WalletApi {

    /**
     * Instantiates new WalletApiImpl object.
     *
     * @param root Root/parent instance that holds the OAuthToken and Configuration instance
     */
    public WalletApiImpl(MangoPayApi root) {
        super(root);
    }

    @Override
    public Wallet create(Wallet wallet) throws Exception {
        return this.create(null, wallet);
    }

    @Override
    public Wallet create(String idempotencyKey, Wallet wallet) throws Exception {
        return this.createObject(Wallet.class, idempotencyKey, "wallets_create", wallet);
    }

    @Override
    public Wallet get(String walletId) throws Exception {
        return this.getObject(Wallet.class, "wallets_get", walletId);
    }

    @Override
    public Wallet update(Wallet wallet) throws Exception {
        return this.updateObject(Wallet.class, "wallets_save", wallet);
    }

    @Override
    public List<Transaction> getTransactions(String walletId, Pagination pagination, FilterTransactions filter, Sorting sorting) throws Exception {
        return this.getList(Transaction[].class, Transaction.class, "wallets_alltransactions", pagination, walletId, filter.getValues(), sorting);
    }

    @Override
    public List<Transaction> getTransactions(String walletId, Pagination pagination, FilterTransactions filter) throws Exception {
        return getTransactions(walletId, pagination, filter, null);
    }

    @Override
    public List<Transaction> getTransactions(String walletId, Pagination pagination) throws Exception {
        return getTransactions(walletId, pagination, new FilterTransactions());
    }

    @Override
    public List<Transaction> getTransactions(String walletId) throws Exception {
        return getTransactions(walletId, null, new FilterTransactions());
    }

}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/DisputeDocumentType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Dispute document type enumeration.
 */
public enum DisputeDocumentType {
    
    /**
     * DELIVERY_PROOF dispute document type.
     */
    DELIVERY_PROOF, 
    
    /**
     * INVOICE dispute document type.
     */
    INVOICE, 
    
    /**
     * REFUND_PROOF dispute document type.
     */
    REFUND_PROOF, 
    
    /**
     * USER_CORRESPONDANCE dispute document type.
     */
    USER_CORRESPONDANCE, 
    
    /**
     * USER_ACCEPTANCE_PROOF dispute document type.
     */
    USER_ACCEPTANCE_PROOF, 
    
    /**
     * PRODUCT_REPLACEMENT_PROOF dispute document type.
     */
    PRODUCT_REPLACEMENT_PROOF, 
    
    /**
     * OTHER dispute document type.
     */
    OTHER
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/CardPreAuthorizationApi.java<|end_filename|>
package com.mangopay.core.APIs;

import com.mangopay.core.Pagination;
import com.mangopay.entities.CardPreAuthorization;
import com.mangopay.entities.Transaction;

import java.util.List;

/**
 * Created by thepa on 18-Jan-17.
 */
public interface CardPreAuthorizationApi {

    /**
     * Creates new pre-authorization object.
     *
     * @param cardPreAuthorization PreAuthorization object to be created.
     * @return Card pre-authorization instance returned from API.
     * @throws Exception
     */
    CardPreAuthorization create(CardPreAuthorization cardPreAuthorization) throws Exception;

    /**
     * Creates new pre-authorization object.
     *
     * @param idempotencyKey       idempotency key for this request.
     * @param cardPreAuthorization PreAuthorization object to be created.
     * @return Card pre-authorization instance returned from API.
     * @throws Exception
     */
    CardPreAuthorization create(String idempotencyKey, CardPreAuthorization cardPreAuthorization) throws Exception;

    /**
     * Gets pre-authorization object.
     *
     * @param cardPreAuthorizationId PreAuthorization identifier.
     * @return Card pre-authorization instance returned from API.
     * @throws Exception
     */
    CardPreAuthorization get(String cardPreAuthorizationId) throws Exception;

    /**
     * Updates pre-authorization object.
     *
     * @param cardPreAuthorization PreAuthorization object to be updated.
     * @return Card pre-authorization instance returned from API.
     * @throws Exception
     */
    CardPreAuthorization update(CardPreAuthorization cardPreAuthorization) throws Exception;

    List<Transaction> getTransactions(String cardPreAuthorizationId, Pagination pagination) throws Exception;
}


<|start_filename|>src/main/java/com/mangopay/entities/Dispute.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.DisputeReason;
import com.mangopay.core.EntityBase;
import com.mangopay.core.Money;
import com.mangopay.core.enumerations.DisputeStatus;
import com.mangopay.core.enumerations.DisputeType;
import com.mangopay.core.enumerations.InitialTransactionType;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;

/**
 * Dispute entity.
 */
public class Dispute extends EntityBase {

    /**
     * Identifier of the transaction that was disputed.
     */
    @SerializedName("InitialTransactionId")
    private String initialTransactionId;

    /**
     * Most transaction type of the original trasaction.
     */
    @SerializedName("InitialTransactionType")
    private InitialTransactionType initialTransactionType;

    /**
     * Type of dispute.
     */
    @SerializedName("DisputeType")
    private DisputeType disputeType;

    /**
     * The date by which you must submit docs if they wish to contest the dispute.
     */
    @SerializedName("ContestDeadlineDate")
    private Long contestDeadlineDate;

    /**
     * Dispute's reason.
     */
    @SerializedName("DisputeReason")
    private DisputeReason disputeReason;

    /**
     * Disputed funds.
     */
    @SerializedName("DisputedFunds")
    private Money disputedFunds;

    /**
     * Contested funds.
     */
    @SerializedName("ContestedFunds")
    private Money contestedFunds;

    /**
     * Contested funds.
     */
    @SerializedName("Status")
    private DisputeStatus status;

    /**
     * Free text used when reopening the dispute.
     */
    @SerializedName("StatusMessage")
    private String statusMessage;

    /**
     * Result code.
     */
    @SerializedName("ResultCode")
    private String resultCode;

    /**
     * Free text that might be completed when the dispute is closed.
     */
    @SerializedName("ResultMessage")
    private String resultMessage;
    
    /**
     * The ID of the corresponding repudiation transaction
     */
    @SerializedName("RepudiationId")
    private String repudiationId;

    public String getInitialTransactionId() {
        return initialTransactionId;
    }

    public void setInitialTransactionId(String initialTransactionId) {
        this.initialTransactionId = initialTransactionId;
    }

    public com.mangopay.core.enumerations.InitialTransactionType getInitialTransactionType() {
        return initialTransactionType;
    }

    public void setInitialTransactionType(InitialTransactionType initialTransactionType) {
        this.initialTransactionType = initialTransactionType;
    }

    public DisputeType getDisputeType() {
        return disputeType;
    }

    public void setDisputeType(DisputeType disputeType) {
        this.disputeType = disputeType;
    }

    public Long getContestDeadlineDate() {
        return contestDeadlineDate;
    }

    public void setContestDeadlineDate(Long contestDeadlineDate) {
        this.contestDeadlineDate = contestDeadlineDate;
    }

    public DisputeReason getDisputeReason() {
        return disputeReason;
    }

    public void setDisputeReason(DisputeReason disputeReason) {
        this.disputeReason = disputeReason;
    }

    public Money getDisputedFunds() {
        return disputedFunds;
    }

    public void setDisputedFunds(Money disputedFunds) {
        this.disputedFunds = disputedFunds;
    }

    public Money getContestedFunds() {
        return contestedFunds;
    }

    public void setContestedFunds(Money contestedFunds) {
        this.contestedFunds = contestedFunds;
    }

    public DisputeStatus getStatus() {
        return status;
    }

    public void setStatus(DisputeStatus status) {
        this.status = status;
    }

    public String getStatusMessage() {
        return statusMessage;
    }

    public void setStatusMessage(String statusMessage) {
        this.statusMessage = statusMessage;
    }

    public String getResultCode() {
        return resultCode;
    }

    public void setResultCode(String resultCode) {
        this.resultCode = resultCode;
    }

    public String getResultMessage() {
        return resultMessage;
    }

    public void setResultMessage(String resultMessage) {
        this.resultMessage = resultMessage;
    }
    
    public String getRepudiationId() {
        return repudiationId;
    }

    public void setRepudiationId(String repudiationId) {
        this.repudiationId = repudiationId;
    }

    /**
     * Gets map which property is an object and what type of object.
     *
     * @return Collection of field name-field type pairs.
     */
    @Override
    public Map<String, Type> getSubObjects() {

        return new HashMap<String, Type>() {{
            put("DisputedFunds", Money.class);
            put("ContestedFunds", Money.class);
            put("DisputeReason", DisputeReason.class);
        }};
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/subentities/BrowserInfo.java<|end_filename|>
package com.mangopay.entities.subentities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Dto;

public class BrowserInfo extends Dto {
    @SerializedName("AcceptHeader")
    private String acceptHeader;

    @SerializedName("JavaEnabled")
    private Boolean javaEnabled;

    @SerializedName("JavascriptEnabled")
    private Boolean javascriptEnabled;

    @SerializedName("Language")
    private String language;

    @SerializedName("ColorDepth")
    private Integer colorDepth;

    @SerializedName("ScreenHeight")
    private Integer screenHeight;

    @SerializedName("ScreenWidth")
    private Integer screenWidth;

    @SerializedName("TimeZoneOffset")
    private String timeZoneOffset;

    @SerializedName("UserAgent")
    private String userAgent;

    public String getAcceptHeader() {
        return acceptHeader;
    }

    public BrowserInfo setAcceptHeader(String acceptHeader) {
        this.acceptHeader = acceptHeader;
        return this;
    }

    public Boolean getJavaEnabled() {
        return javaEnabled;
    }

    public BrowserInfo setJavaEnabled(Boolean javaEnabled) {
        this.javaEnabled = javaEnabled;
        return this;
    }

    public Boolean getJavascriptEnabled() {
        return javascriptEnabled;
    }

    public BrowserInfo setJavascriptEnabled(Boolean javascriptEnabled) {
        this.javascriptEnabled = javascriptEnabled;
        return this;
    }

    public String getLanguage() {
        return language;
    }

    public BrowserInfo setLanguage(String language) {
        this.language = language;
        return this;
    }

    public int getColorDepth() {
        return colorDepth;
    }

    public BrowserInfo setColorDepth(Integer colorDepth) {
        this.colorDepth = colorDepth;
        return this;
    }

    public int getScreenHeight() {
        return screenHeight;
    }

    public BrowserInfo setScreenHeight(Integer screenHeight) {
        this.screenHeight = screenHeight;
        return this;
    }

    public int getScreenWidth() {
        return screenWidth;
    }

    public BrowserInfo setScreenWidth(Integer screenWidth) {
        this.screenWidth = screenWidth;
        return this;
    }

    public String getTimeZoneOffset() {
        return timeZoneOffset;
    }

    public BrowserInfo setTimeZoneOffset(String timeZoneOffset) {
        this.timeZoneOffset = timeZoneOffset;
        return this;
    }

    public String getUserAgent() {
        return userAgent;
    }

    public BrowserInfo setUserAgent(String userAgent) {
        this.userAgent = userAgent;
        return this;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/DisputeType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Dispute types enumeration.
 */
public enum DisputeType {
    
    /**
     * CONTESTABLE dispute type.
     */
    CONTESTABLE,
    
    /**
     * NOT_CONTESTABLE dispute type.
     */
    NOT_CONTESTABLE,
    
    /**
     * RETRIEVAL dispute type.
     */
    RETRIEVAL
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/implementation/EventApiImpl.java<|end_filename|>
package com.mangopay.core.APIs.implementation;

import com.mangopay.MangoPayApi;
import com.mangopay.core.APIs.ApiBase;
import com.mangopay.core.APIs.EventApi;
import com.mangopay.core.FilterEvents;
import com.mangopay.core.Pagination;
import com.mangopay.core.Sorting;
import com.mangopay.entities.Event;

import java.util.List;

/**
 * API for events.
 */
public class EventApiImpl extends ApiBase implements EventApi {

    /**
     * Instantiates new EventApiImpl object.
     *
     * @param root Root/parent instance that holds the OAuthToken and Configuration instance.
     */
    public EventApiImpl(MangoPayApi root) {
        super(root);
    }

    @Override
    public List<Event> get(FilterEvents filter, Pagination pagination, Sorting sorting) throws Exception {
        return this.getList(Event[].class, Event.class, "events_all", pagination, "", filter.getValues(), sorting);
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/UserBlockStatus.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.EntityBase;
import com.mangopay.entities.subentities.ScopeBlocked;

public class UserBlockStatus extends EntityBase {
    @SerializedName("ScopeBlocked")
    private ScopeBlocked scopeBlocked;

    @SerializedName("ActionCode")
    private String actionCode;

    public ScopeBlocked getScopeBlocked() {
        return scopeBlocked;
    }

    public UserBlockStatus setScopeBlocked(ScopeBlocked scopeBlocked) {
        this.scopeBlocked = scopeBlocked;
        return this;
    }

    public String getActionCode() {
        return actionCode;
    }

    public UserBlockStatus setActionCode(String actionCode) {
        this.actionCode = actionCode;
        return this;
    }

}


<|start_filename|>src/main/java/com/mangopay/entities/RateLimit.java<|end_filename|>
package com.mangopay.entities;

/**
 * Holds information regarding API call limits.
 * <P>
 * Created by <NAME> on 27-Jul-17.
 */
public class RateLimit {

    private int intervalMinutes;
    private int callsMade;
    private int callsRemaining;
    private long resetTimeMillis;

    public RateLimit(int intervalMinutes) {
        this.intervalMinutes = intervalMinutes;
    }

    /**
     * Gets the maximum allowed number of calls in this time interval.
     *
     * @return
     */
    public int getAllowedCalls() {
        return callsMade + callsRemaining;
    }

    /**
     * Gets the number of minutes in this time interval.
     *
     * @return
     */
    public int getIntervalMinutes() {
        return intervalMinutes;
    }

    /**
     * Gets the number of API calls already made in this time interval.
     *
     * @return
     */
    public int getCallsMade() {
        return callsMade;
    }

    /**
     * Sets the number of API calls already made in this time interval.
     *
     * @param callsMade Number of calls
     */
    public void setCallsMade(int callsMade) {
        this.callsMade = callsMade;
    }

    /**
     * Gets the number of calls still allowed to be made in this time interval.
     *
     * @return
     */
    public int getCallsRemaining() {
        return callsRemaining;
    }

    /**
     * Sets the remaining allowed number of calls in this time interval.
     *
     * @param callsRemaining The remaining number of calls allowed
     */
    public void setCallsRemaining(int callsRemaining) {
        this.callsRemaining = callsRemaining;
    }

    /**
     * Gets the time in millis when the number of allowed calls in this time interval will be reset.
     *
     * @return
     */
    public long getResetTimeMillis() {
        return resetTimeMillis;
    }

    /**
     * Sets the time at which the number of allowed calls in this interval will be reset.
     *
     * @param resetTimeMillis The reset time in millis
     */
    public void setResetTimeMillis(long resetTimeMillis) {
        this.resetTimeMillis = resetTimeMillis;
    }
}


<|start_filename|>src/test/java/com/mangopay/entities/RateLimitTest.java<|end_filename|>
package com.mangopay.entities;

import com.mangopay.core.BaseTest;
import org.junit.Test;

import java.util.List;

import static org.junit.Assert.*;

/**
 * Tests concerning rate limit data storage and update.
 * <p>
 * Created by thepa on 28-Jul-17.
 */
public class RateLimitTest extends BaseTest {

    @Test
    public void rateLimitsUpdateTest() throws Exception {
        assertNull(this.api.getRateLimits());

        getJohnsCardPreAuthorization();

        List<RateLimit> rateLimits = this.api.getRateLimits();

        assertNotNull(rateLimits);
        assertTrue(rateLimits.size() == 4);
    }
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/WalletApi.java<|end_filename|>
package com.mangopay.core.APIs;

import com.mangopay.core.FilterTransactions;
import com.mangopay.core.Pagination;
import com.mangopay.core.Sorting;
import com.mangopay.entities.Transaction;
import com.mangopay.entities.Wallet;

import java.util.List;

/**
 * Created by thepa on 18-Jan-17.
 */
public interface WalletApi {

    /**
     * Creates a new wallet.
     * @param wallet        Wallet instance to be created.
     * @return              Wallet instance returned from API.
     * @throws Exception
     */
    Wallet create(Wallet wallet) throws Exception;

    /**
     * Creates a new wallet.
     * @param idempotencyKey    idempotency key for this request.
     * @param wallet            Wallet instance to be created.
     * @return                  Wallet instance returned from API.
     * @throws Exception
     */
    Wallet create(String idempotencyKey, Wallet wallet) throws Exception;

    /**
     * Gets the wallet.
     * @param walletId      Wallet identifier.
     * @return              Wallet instance returned from API.
     * @throws Exception
     */
    Wallet get(String walletId) throws Exception;

    /**
     * Updates the wallet.
     * @param wallet        Wallet object to save.
     * @return              Wallet instance returned from API.
     * @throws Exception
     */
    Wallet update(Wallet wallet) throws Exception;

    /**
     * Gets transactions for the wallet.
     * @param walletId      Wallet identifier.
     * @param pagination    Pagination object.
     * @param filter        Object to filter data.
     * @return              Transactions for wallet returned from API.
     * @throws Exception
     */
    List<Transaction> getTransactions(String walletId, Pagination pagination, FilterTransactions filter, Sorting sorting) throws Exception;

    /**
     * Gets transactions for the wallet.
     * @param walletId      Wallet identifier.
     * @param pagination    Pagination object.
     * @param filter        Object to filter data.
     * @return              Transactions for wallet returned from API.
     * @throws Exception
     */
    List<Transaction> getTransactions(String walletId, Pagination pagination, FilterTransactions filter) throws Exception;

    /**
     * Gets transactions for the wallet.
     * @param walletId      Wallet identifier.
     * @param pagination    Pagination object.
     * @return              Transactions for wallet returned from API.
     * @throws Exception
     */
    List<Transaction> getTransactions(String walletId, Pagination pagination) throws Exception;

    /**
     * Gets transactions for the wallet.
     * @param walletId      Wallet identifier.
     * @return              Transactions for wallet returned from API.
     * @throws Exception
     */
    List<Transaction> getTransactions(String walletId) throws Exception;
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/IdempotencyApi.java<|end_filename|>
package com.mangopay.core.APIs;

import com.mangopay.entities.IdempotencyResponse;

/**
 * Created by thepa on 18-Jan-17.
 */
public interface IdempotencyApi {
    /**
     * Gets idempotency response.
     *
     * @param idempotencyKey idempotency key.
     * @return idempotency response instance returned from API.
     * @throws Exception
     */
    IdempotencyResponse get(String idempotencyKey) throws Exception;
}


<|start_filename|>src/main/java/com/mangopay/core/deserializer/UserDeserializer.java<|end_filename|>
package com.mangopay.core.deserializer;

import com.google.gson.*;
import com.mangopay.core.enumerations.PersonType;
import com.mangopay.entities.User;
import com.mangopay.entities.UserLegal;
import com.mangopay.entities.UserNatural;

import java.lang.reflect.Type;

public class UserDeserializer implements JsonDeserializer<User> {
    @Override
    public User deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
        JsonObject jsonObject = json.getAsJsonObject();
        PersonType type = PersonType.valueOf(jsonObject.get("PersonType").getAsString());
        if (type.equals(PersonType.LEGAL)) {
            return context.deserialize(json, UserLegal.class);
        } else if (type.equals(PersonType.NATURAL)) {
            return context.deserialize(json, UserNatural.class);
        } else {
            throw new IllegalArgumentException("Invalid user JSON:" + json.getAsJsonObject().toString());
        }
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/RecurringPayInCIT.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Dto;
import com.mangopay.core.Money;
import com.mangopay.entities.subentities.BrowserInfo;

import java.lang.reflect.Type;
import java.util.Map;

public class RecurringPayInCIT extends Dto {

    @SerializedName("RecurringPayinRegistrationId")
    private String recurringPayInRegistrationId;

    @SerializedName("BrowserInfo")
    private BrowserInfo browserInfo;

    @SerializedName("IpAddress")
    private String ipAddress;

    @SerializedName("SecureModeReturnURL")
    private String secureModeReturnURL;

    @SerializedName("StatementDescriptor")
    private String statementDescriptor;

    @SerializedName("Tag")
    private String tag;

    @SerializedName("DebitedFunds")
    private Money debitedFunds;

    @SerializedName("Fees")
    private Money fees;

    public String getRecurringPayInRegistrationId() {
        return recurringPayInRegistrationId;
    }

    public void setRecurringPayInRegistrationId(String recurringPayInRegistrationId) {
        this.recurringPayInRegistrationId = recurringPayInRegistrationId;
    }

    public BrowserInfo getBrowserInfo() {
        return browserInfo;
    }

    public void setBrowserInfo(BrowserInfo browserInfo) {
        this.browserInfo = browserInfo;
    }

    public String getIpAddress() {
        return ipAddress;
    }

    public void setIpAddress(String ipAddress) {
        this.ipAddress = ipAddress;
    }

    public String getSecureModeReturnURL() {
        return secureModeReturnURL;
    }

    public void setSecureModeReturnURL(String secureModeReturnURL) {
        this.secureModeReturnURL = secureModeReturnURL;
    }

    public String getStatementDescriptor() {
        return statementDescriptor;
    }

    public void setStatementDescriptor(String statementDescriptor) {
        this.statementDescriptor = statementDescriptor;
    }

    public String getTag() {
        return tag;
    }

    public void setTag(String tag) {
        this.tag = tag;
    }

    public Money getDebitedFunds() { return debitedFunds; }

    public void setDebitedFunds(Money debitedFunds) { this.debitedFunds = debitedFunds; }

    public Money getFees() { return fees; }

    public void setFees(Money fees) { this.fees = fees; }

    @Override
    public Map<String, Type> getSubObjects() {

        Map<String, Type> result = super.getSubObjects();

        result.put("BrowserInfo", BrowserInfo.class);
        result.put("Money", Money.class);

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/deserializer/BankAccountDeserializer.java<|end_filename|>
package com.mangopay.core.deserializer;

import com.google.gson.*;
import com.mangopay.core.enumerations.BankAccountType;
import com.mangopay.core.enumerations.CountryIso;
import com.mangopay.core.enumerations.DepositAccountType;
import com.mangopay.entities.BankAccount;
import com.mangopay.entities.subentities.*;

import java.lang.reflect.Type;

public class BankAccountDeserializer implements JsonDeserializer<BankAccount> {
    @Override
    public BankAccount deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
        JsonObject jsonObject = json.getAsJsonObject();
        BankAccount bankAccount = new Gson().fromJson(jsonObject.toString(), BankAccount.class);
        BankAccountType accountType = bankAccount.getType();
        switch (accountType) {
            case GB:
                BankAccountDetailsGB bankAccountDetailsGB = new BankAccountDetailsGB();
                bankAccountDetailsGB.setAccountNumber(jsonObject.get("AccountNumber").getAsString());
                bankAccountDetailsGB.setSortCode(jsonObject.get("SortCode").getAsString());
                bankAccount.setDetails(bankAccountDetailsGB);
                break;
            case US:
                BankAccountDetailsUS bankAccountDetailsUS = new BankAccountDetailsUS();
                bankAccountDetailsUS.setAccountNumber(jsonObject.get("AccountNumber").getAsString());
                bankAccountDetailsUS.setAba(jsonObject.get("ABA").getAsString());
                bankAccountDetailsUS.setDepositAccountType(DepositAccountType.valueOf(jsonObject.get("DepositAccountType").getAsString()));
                bankAccount.setDetails(bankAccountDetailsUS);
                break;
            case CA:
                BankAccountDetailsCA bankAccountDetailsCA = new BankAccountDetailsCA();
                bankAccountDetailsCA.setBankName(jsonObject.get("BankName").getAsString());
                bankAccountDetailsCA.setInstitutionNumber(jsonObject.get("InstitutionNumber").getAsString());
                bankAccountDetailsCA.setBranchCode(jsonObject.get("BranchCode").getAsString());
                bankAccountDetailsCA.setAccountNumber(jsonObject.get("AccountNumber").getAsString());
                bankAccount.setDetails(bankAccountDetailsCA);
                break;
            case IBAN:
                BankAccountDetailsIBAN bankAccountDetailsIBAN = new BankAccountDetailsIBAN();
                bankAccountDetailsIBAN.setIban(jsonObject.get("IBAN").getAsString());
                bankAccountDetailsIBAN.setBic(jsonObject.get("BIC").getAsString());
                bankAccount.setDetails(bankAccountDetailsIBAN);
                break;
            case OTHER:
                BankAccountDetailsOTHER bankAccountDetailsOTHER = new BankAccountDetailsOTHER();
                bankAccountDetailsOTHER.setCountry(CountryIso.valueOf(jsonObject.get("Country").getAsString()));
                bankAccountDetailsOTHER.setBic(jsonObject.get("BIC").getAsString());
                bankAccountDetailsOTHER.setAccountNumber(jsonObject.get("AccountNumber").getAsString());
                bankAccount.setDetails(bankAccountDetailsOTHER);
                break;
            default:
                return null;
        }
        return bankAccount;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/deserializer/PayOutDeserializer.java<|end_filename|>
package com.mangopay.core.deserializer;

import com.google.gson.*;
import com.mangopay.core.Money;
import com.mangopay.core.enumerations.PayoutMode;
import com.mangopay.entities.PayOut;
import com.mangopay.entities.subentities.FallbackReason;
import com.mangopay.entities.subentities.PayOutPaymentDetailsBankWire;

import java.lang.reflect.Type;

public class PayOutDeserializer implements JsonDeserializer<PayOut> {
    @Override
    public PayOut deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
        JsonObject object = json.getAsJsonObject();
        PayOut payOut = new Gson().fromJson(object.toString(), PayOut.class);
        switch (payOut.getPaymentType()) {
            case BANK_WIRE:
                PayOutPaymentDetailsBankWire meanOfPaymentDetails = new PayOutPaymentDetailsBankWire();
                if (object.has("BankAccountId") && !object.get("BankAccountId").isJsonNull())
                    meanOfPaymentDetails.setBankAccountId(object.get("BankAccountId").getAsString());
                if (object.has("BankWireRef") && !object.get("BankWireRef").isJsonNull())
                    meanOfPaymentDetails.setBankWireRef(object.get("BankWireRef").getAsString());
                if (object.has("ModeRequested") && !object.get("ModeRequested").isJsonNull())
                    meanOfPaymentDetails.setPayoutModeRequested(PayoutMode.valueOf(object.get("ModeRequested").getAsString()));
                if (object.has("ModeApplied") && !object.get("ModeApplied").isJsonNull())
                    meanOfPaymentDetails.setPayoutModeApplied(object.get("ModeApplied").getAsString());
                if (object.has("FallbackReason")&& !object.get("FallbackReason").isJsonNull())
                    meanOfPaymentDetails.setFallbackReason((FallbackReason) context.deserialize(object.get("FallbackReason"), FallbackReason.class));
                if (object.has("Status") && !object.get("Status").isJsonNull())
                    meanOfPaymentDetails.setStatus(object.get("Status").getAsString());
                payOut.setMeanOfPaymentDetails(meanOfPaymentDetails);
                return payOut;
            default:
                return null;
        }
    }
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/DisputeApi.java<|end_filename|>
package com.mangopay.core.APIs;

import com.mangopay.core.*;
import com.mangopay.entities.*;

import java.io.IOException;
import java.util.List;

/**
 * Created by thepa on 18-Jan-17.
 */
public interface DisputeApi {
    /**
     * Gets dispute.
     *
     * @param disputeId Dispute identifier.
     * @return Dispute instance returned from API.
     * @throws Exception
     */
    Dispute get(String disputeId) throws Exception;

    /**
     * Gets all disputes.
     *
     * @param pagination Pagination.
     * @param filters    Filters.
     * @param sorting    Sorting.
     * @return List of Dispute instances returned from API.
     * @throws Exception
     */
    List<Dispute> getAll(Pagination pagination, FilterDisputes filters, Sorting sorting) throws Exception;

    /**
     * Gets all disputes.
     *
     * @return List of Dispute instances returned from API.
     * @throws Exception
     */
    List<Dispute> getAll() throws Exception;

    /**
     * Gets dispute's transactions.
     *
     * @param disputeId  Dispute identifier.
     * @param pagination Pagination.
     * @param filters    Filters.
     * @param sorting    Sorting.
     * @return List of Transaction instances returned from API.
     * @throws Exception
     */
    List<Transaction> getTransactions(String disputeId, Pagination pagination, FilterTransactions filters, Sorting sorting) throws Exception;

    /**
     * Gets dispute's documents for wallet.
     *
     * @param walletId   Wallet identifier.
     * @param pagination Pagination.
     * @param filters    Filters.
     * @param sorting    Sorting.
     * @return List of dispute instances returned from API.
     * @throws Exception
     */
    List<Dispute> getDisputesForWallet(String walletId, Pagination pagination, FilterDisputes filters, Sorting sorting) throws Exception;

    /**
     * Gets user's disputes.
     *
     * @param userId     User identifier.
     * @param pagination Pagination.
     * @param filters    Filters.
     * @param sorting    Sorting.
     * @return List of Dispute instances returned from API.
     * @throws Exception
     */
    List<Dispute> getDisputesForUser(String userId, Pagination pagination, FilterDisputes filters, Sorting sorting) throws Exception;

    /**
     * Gets dispute's document.
     *
     * @param documentId Dispute document identifier.
     * @return Dispute's document instance returned from API.
     * @throws Exception
     */
    DisputeDocument getDocument(String documentId) throws Exception;

    /**
     * Gets documents for dispute.
     *
     * @param disputeId  Dispute identifier.
     * @param pagination Pagination.
     * @param filters    Filters.
     * @param sorting    Sorting.
     * @return List of DisputeDocument instances returned from API.
     * @throws Exception
     */
    List<DisputeDocument> getDocumentsForDispute(String disputeId, Pagination pagination, FilterDisputeDocuments filters, Sorting sorting) throws Exception;

    /**
     * Gets dispute's documents for client.
     *
     * @param pagination Pagination.
     * @param filters    Filters.
     * @param sorting    Sorting.
     * @return List of dispute documents returned from API.
     * @throws Exception
     */
    List<DisputeDocument> getDocumentsForClient(Pagination pagination, FilterDisputeDocuments filters, Sorting sorting) throws Exception;

    /**
     * Gets repudiation.
     *
     * @param repudiationId Repudiation identifier.
     * @return Repudiation instance returned from API.
     * @throws Exception
     * @deprecated use {@link RepudiationApi#getRepudiation(String)} instead
     */
    @Deprecated
    Repudiation getRepudiation(String repudiationId) throws Exception;

    /**
     * Creates settlement transfer.
     *
     * @param settlementTransfer Settlement transfer.
     * @param repudiationId      Repudiation identifier.
     * @return Transfer instance returned from API.
     * @throws Exception
     */
    Transfer createSettlementTransfer(SettlementTransfer settlementTransfer, String repudiationId) throws Exception;

    /**
     * Creates settlement transfer.
     *
     * @param idempotencyKey     idempotency key for this request.
     * @param settlementTransfer Settlement transfer.
     * @param repudiationId      Repudiation identifier.
     * @return Transfer instance returned from API.
     * @throws Exception
     */
    Transfer createSettlementTransfer(String idempotencyKey, SettlementTransfer settlementTransfer, String repudiationId) throws Exception;

    /**
     * Get disputes that need settling
     *
     * @return a list of {@link Dispute}s
     * @throws Exception
     */
    List<Dispute> getDisputesWithPendingSettlement() throws Exception;

    /**
     * Get disputes that need settling
     *
     * @param pagination Pagination object
     * @param sorting    Sorting object
     * @return a list of {@link Dispute}s
     * @throws Exception
     */
    List<Dispute> getDisputesWithPendingSettlement(Pagination pagination, Sorting sorting) throws Exception;

    /**
     * Updates dispute's tag.
     *
     * @param tag       New tag text.
     * @param disputeId Dispute identifier.
     * @return Dispute instance returned from API.
     * @throws Exception
     */
    Dispute updateTag(String tag, String disputeId) throws Exception;

    /**
     * Submits dispute document.
     *
     * @param disputeDocument Dispute document to be submitted.
     * @param disputeId       Dispute identifier.
     * @return Dispute document instance returned from API.
     * @throws Exception
     */
    DisputeDocument submitDisputeDocument(DisputeDocument disputeDocument, String disputeId) throws Exception;

    /**
     * Contests dispute.
     *
     * @param contestedFunds Contested funds.
     * @param disputeId      Dispute identifier.
     * @return Dispute instance returned from API.
     * @throws Exception
     */
    Dispute contestDispute(Money contestedFunds, String disputeId) throws Exception;

    /**
     * Resubmits dispute.
     *
     * @param disputeId Dispute identifier.
     * @return Dispute instance returned from API.
     * @throws Exception
     */
    Dispute resubmitDispute(String disputeId) throws Exception;

    /**
     * Closes dispute.
     *
     * @param disputeId Dispute identifier.
     * @return Dispute instance returned from API.
     * @throws Exception
     */
    Dispute closeDispute(String disputeId) throws Exception;

    /**
     * Creates document for dispute.
     *
     * @param disputeDocument Dispute document to be created.
     * @param disputeId       Dispute identifier.
     * @return Dispute document returned from API.
     * @throws Exception
     */
    DisputeDocument createDisputeDocument(DisputeDocument disputeDocument, String disputeId) throws Exception;

    /**
     * Creates document for dispute.
     *
     * @param idempotencyKey  idempotency key for this request.
     * @param disputeDocument Dispute document to be created.
     * @param disputeId       Dispute identifier.
     * @return Dispute document returned from API.
     * @throws Exception
     */
    DisputeDocument createDisputeDocument(String idempotencyKey, DisputeDocument disputeDocument, String disputeId) throws Exception;

    /**
     * Creates document's page for dispute.
     *
     * @param disputeId  Dispute identifier.
     * @param documentId Dispute document identifier.
     * @param binaryData The byte array the DisputePage will be created from.
     * @throws Exception
     */
    void createDisputePage(String disputeId, String documentId, byte[] binaryData) throws Exception;

    /**
     * Creates document's page for dispute.
     *
     * @param idempotencyKey idempotency key for this request.
     * @param disputeId      Dispute identifier.
     * @param documentId     Dispute document identifier.
     * @param binaryData     The byte array the DisputePage will be created from.
     * @throws Exception
     */
    void createDisputePage(String idempotencyKey, String disputeId, String documentId, byte[] binaryData) throws Exception;

    /**
     * Creates document's page for dispute.
     *
     * @param disputeId  Dispute identifier.
     * @param documentId Dispute document identifier.
     * @param filePath   Path to the file the DisputePage will be created from.
     * @throws IOException
     * @throws Exception
     */
    void createDisputePage(String disputeId, String documentId, String filePath) throws Exception;

    /**
     * Creates document's page for dispute.
     *
     * @param idempotencyKey idempotency key for this request.
     * @param disputeId      Dispute identifier.
     * @param documentId     Dispute document identifier.
     * @param filePath       Path to the file the DisputePage will be created from.
     * @throws IOException
     * @throws Exception
     */
    void createDisputePage(String idempotencyKey, String disputeId, String documentId, String filePath) throws Exception;

    /**
     * Creates temporary URLs where each page of a dispute document can be viewed.
     *
     * @param documentId Identification of the document whose pages to view
     * @return List of consults for viewing the dispute document's pages
     * @throws Exception
     */
    List<DocumentPageConsult> createDisputeDocumentConsult(String documentId) throws Exception;
}


<|start_filename|>src/main/java/com/mangopay/core/ObjectTool.java<|end_filename|>
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mangopay.core;

/**
 *
 * @author <NAME> <EMAIL>
 */
public class ObjectTool {
    
    public static boolean nonNull(Object object) {
        return object != null;
    }
    
    public static boolean isNull(Object object) {
        return object == null;
    }
    
}


<|start_filename|>src/test/java/com/mangopay/core/TokensTest.java<|end_filename|>
package com.mangopay.core;

import com.mangopay.MangoPayApi;
import org.junit.Test;

import static org.junit.Assert.*;

/**
 * Tests for holding authentication token in instance
 */
public class TokensTest extends BaseTest {

    @Test
    public void forceToken() throws Exception {

        OAuthToken oldToken = this.api.getOAuthTokenManager().getToken();
        OAuthToken newToken = this.api.getAuthenticationManager().createToken();

        assertFalse(oldToken.getAccessToken().equals(newToken.getAccessToken()));

        this.api.getOAuthTokenManager().storeToken(newToken);
        OAuthToken storedToken = this.api.getOAuthTokenManager().getToken();

        assertEquals(newToken.getAccessToken(), storedToken.getAccessToken());
    }

    @Test
    public void standardUseOfToken() throws Exception {
        this.api.getUserApi().getAll();
        OAuthToken token = this.api.getOAuthTokenManager().getToken();
        this.api.getUserApi().getAll();

        assertEquals(token.getAccessToken(), this.api.getOAuthTokenManager().getToken().getAccessToken());
    }

    @Test
    public void shareTokenBetweenInstances() throws Exception {
        MangoPayApi api = this.buildNewMangoPayApi();

        OAuthToken token1 = this.api.getOAuthTokenManager().getToken();
        OAuthToken token2 = api.getOAuthTokenManager().getToken();

        assertEquals(token1.getAccessToken(), token2.getAccessToken());
    }

    @Test
    public void isolateTokensBetweenEnvironments() throws Exception {
        MangoPayApi api = new MangoPayApi();
        api.getConfig().setClientId("sdk-unit-tests");
        api.getConfig().setClientPassword("<PASSWORD>");
        api.getConfig().setBaseUrl("https://api.sandbox.mangopay.com");

        OAuthToken token1 = api.getOAuthTokenManager().getToken();

        api.getConfig().setClientId("sdk_example");
        api.getConfig().setClientPassword("<PASSWORD>");
        api.getConfig().setBaseUrl("https://api.sandbox.mangopay.com");

        OAuthToken token2 = api.getOAuthTokenManager().getToken();

        assertNotEquals(token1.getAccessToken(), token2.getAccessToken());

        api.getConfig().setClientId("sdk-unit-tests");
        api.getConfig().setClientPassword("<PASSWORD>");
        api.getConfig().setBaseUrl("https://api.sandbox.mangopay.com");

        OAuthToken token3 = api.getOAuthTokenManager().getToken();

        assertEquals(token1.getAccessToken(), token3.getAccessToken());
    }
}


<|start_filename|>src/main/java/com/mangopay/core/OAuthToken.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;

import java.io.Serializable;

/**
 * OAuth entity.
 */
public class OAuthToken extends Dto implements Serializable {

    /**
     * Creation time.
     */
    @SerializedName("create_time")
    private Long createTime;

    /**
     * Value of token.
     */
    @SerializedName("access_token")
    private String accessToken;

    /**
     * Token type.
     */
    @SerializedName("token_type")
    private String tokenType;

    /**
     * Denotes how long the token is valid, in seconds.
     */
    @SerializedName("expires_in")
    private int expiresIn;

    /**
     * Instantiates new OAuthToken object.
     */
    public OAuthToken() {
        this.createTime = System.currentTimeMillis() - 5000;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public String getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public String getTokenType() {
        return tokenType;
    }

    public void setTokenType(String tokenType) {
        this.tokenType = tokenType;
    }

    public int getExpiresIn() {
        return expiresIn;
    }

    public void setExpiresIn(int expiresIn) {
        this.expiresIn = expiresIn;
    }

    /**
     * Checks if current token is expired.
     *
     * @return Returns true if token has expired, or false if token is still valid.
     */
    public Boolean IsExpired() {
        return (System.currentTimeMillis() >= (createTime + (expiresIn * 1000)));
    }

    // for debug purposes
    @Override
    public String toString() {

        return "access_token = " + this.accessToken + ", token_type: " + this.tokenType + ", expires_in: " + this.expiresIn;

    }
}


<|start_filename|>src/main/java/com/mangopay/core/serializer/TransferSerializer.java<|end_filename|>
package com.mangopay.core.serializer;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.mangopay.entities.Transfer;

import java.lang.reflect.Type;

public class TransferSerializer implements JsonSerializer<Transfer> {
    @Override
    public JsonElement serialize(Transfer src, Type typeOfSrc, JsonSerializationContext context) {
        JsonObject object = SerializedTransaction.getTransactionObject(src, context);
        object.add("DebitedWalletId", context.serialize(src.getDebitedWalletId()));
        object.add("CreditedWalletId", context.serialize(src.getCreditedWalletId()));
        return object;
    }
}


<|start_filename|>src/test/java/com/mangopay/core/RefundApiImplTest.java<|end_filename|>
package com.mangopay.core;

import com.mangopay.core.enumerations.InitialTransactionType;
import com.mangopay.core.enumerations.RefundReasonType;
import com.mangopay.core.enumerations.TransactionType;
import com.mangopay.entities.PayIn;
import com.mangopay.entities.Refund;
import com.mangopay.entities.Transfer;
import com.mangopay.entities.UserNatural;
import org.junit.Test;

import static org.junit.Assert.*;

/**
 * API Refunds test methods.
 */
public class RefundApiImplTest extends BaseTest {

    @Test
    public void getRefundForTransfer() throws Exception {
        Transfer transfer = this.getNewTransfer();
        Refund refund = this.getNewRefundForTransfer(transfer);
        UserNatural user = this.getJohn();

        Refund getRefund = this.api.getRefundApi().get(refund.getId());

        assertEquals(getRefund.getId(), refund.getId());
        assertEquals(getRefund.getInitialTransactionId(), transfer.getId());
        assertEquals(getRefund.getAuthorId(), user.getId());
        assertTrue(getRefund.getType() == TransactionType.TRANSFER);
        assertTrue(getRefund.getInitialTransactionType() == InitialTransactionType.TRANSFER);
        assertNotNull(getRefund.getRefundReason());
        assertTrue(getRefund.getRefundReason().getRefundReasonType() == RefundReasonType.OTHER);
    }

    @Test
    public void getRefundForPayIn() throws Exception {
        PayIn payIn = this.getNewPayInCardDirect();
        Refund refund = this.getNewRefundForPayIn(payIn);
        UserNatural user = this.getJohn();

        Refund getRefund = this.api.getRefundApi().get(refund.getId());

        assertEquals(getRefund.getId(), refund.getId());
        assertEquals(getRefund.getInitialTransactionId(), payIn.getId());
        assertEquals(getRefund.getAuthorId(), user.getId());
        assertTrue(getRefund.getType() == TransactionType.PAYOUT);
        assertTrue(getRefund.getInitialTransactionType() == InitialTransactionType.PAYIN);
        assertNotNull(getRefund.getRefundReason());
        assertTrue(getRefund.getRefundReason().getRefundReasonType() == RefundReasonType.INITIALIZED_BY_CLIENT);
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/subentities/BankingAliasDetailsIBAN.java<|end_filename|>
package com.mangopay.entities.subentities;

import com.mangopay.core.Dto;
import com.mangopay.core.interfaces.BankingAliasDetails;

/**
 * Created by thepa on 08-Feb-17.
 */
public class BankingAliasDetailsIBAN extends Dto implements BankingAliasDetails {

    /**
     * The IBAN of the banking alias.
     */
    public String IBAN;
    /**
     * The BIC of the banking alias.
     */
    public String BIC;

    public String getIBAN() {
        return IBAN;
    }

    public void setIBAN(String IBAN) {
        this.IBAN = IBAN;
    }

    public String getBIC() {
        return BIC;
    }

    public void setBIC(String BIC) {
        this.BIC = BIC;
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/Client.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Address;
import com.mangopay.core.EntityBase;
import com.mangopay.core.PlatformCategorization;

import java.util.ArrayList;

/**
 * Client entity.
 */
public class Client extends EntityBase {

    /**
     * Client identifier.
     */
    @SerializedName("ClientId")
    private String clientId;

    /**
     * Name of this client.
     */
    @SerializedName("Name")
    private String name;

    /**
     * Your branding colour to use for theme pages.
     */
    @SerializedName("PrimaryThemeColour")
    private String primaryThemeColour;

    /**
     * Your branding colour to use for call to action buttons.
     */
    @SerializedName("PrimaryButtonColour")
    private String primaryButtonColour;

    /**
     * The URL of your MANGOPAY hosted logo.
     */
    @SerializedName("Logo")
    private String logo;

    /**
     * A list of email addresses to use when contacting you for technical issues/communications.
     */
    @SerializedName("TechEmails")
    private ArrayList<String> techEmails;

    /**
     * A list of email addresses to use when contacting you for admin/commercial issues/communications.
     */
    @SerializedName("AdminEmails")
    private ArrayList<String> adminEmails;

    /**
     * A list of email addresses to use when contacting you for fraud/compliance issues/communications.
     */
    @SerializedName("FraudEmails")
    private ArrayList<String> fraudEmails;

    /**
     * A list of email addresses to use when contacting you for billing issues/communications.
     */
    @SerializedName("BillingEmails")
    private ArrayList<String> billingEmails;

    /**
     * A description of what your platform does.
     */
    @SerializedName("PlatformDescription")
    private String platformDescription;

    /**
     * The categorization of the platform
     */
    @SerializedName("PlatformCategorization")
    private PlatformCategorization platformCategorization;
    /**
     * The URL for your website.
     */
    @SerializedName("PlatformURL")
    private String platformUrl;

    /**
     * The address of the company’s headquarters.
     */
    @SerializedName("HeadquartersAddress")
    private Address headquartersAddress;

    /**
     * The phone number of the client's headquarters
     */
    @SerializedName("HeadquartersPhoneNumber")
    private String headquartersPhoneNumber;

    /**
     * The tax (or VAT) number for your company.
     */
    @SerializedName("TaxNumber")
    private String taxNumber;

    public String getClientId() {
        return clientId;
    }

    public void setClientId(String clientId) {
        this.clientId = clientId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPrimaryThemeColour() {
        return primaryThemeColour;
    }

    public void setPrimaryThemeColour(String primaryThemeColour) {
        this.primaryThemeColour = primaryThemeColour;
    }

    public String getPrimaryButtonColour() {
        return primaryButtonColour;
    }

    public void setPrimaryButtonColour(String primaryButtonColour) {
        this.primaryButtonColour = primaryButtonColour;
    }

    public String getLogo() {
        return logo;
    }

    public void setLogo(String logo) {
        this.logo = logo;
    }

    public ArrayList<String> getTechEmails() {
        return techEmails;
    }

    public void setTechEmails(ArrayList<String> techEmails) {
        this.techEmails = techEmails;
    }

    public ArrayList<String> getAdminEmails() {
        return adminEmails;
    }

    public void setAdminEmails(ArrayList<String> adminEmails) {
        this.adminEmails = adminEmails;
    }

    public ArrayList<String> getFraudEmails() {
        return fraudEmails;
    }

    public void setFraudEmails(ArrayList<String> fraudEmails) {
        this.fraudEmails = fraudEmails;
    }

    public ArrayList<String> getBillingEmails() {
        return billingEmails;
    }

    public void setBillingEmails(ArrayList<String> billingEmails) {
        this.billingEmails = billingEmails;
    }

    public String getPlatformDescription() {
        return platformDescription;
    }

    public void setPlatformDescription(String platformDescription) {
        this.platformDescription = platformDescription;
    }

    public PlatformCategorization getPlatformCategorization() {
        return platformCategorization;
    }

    public void setPlatformCategorization(PlatformCategorization platformCategorization) {
        this.platformCategorization = platformCategorization;
    }

    public String getPlatformUrl() {
        return platformUrl;
    }

    public void setPlatformUrl(String platformUrl) {
        this.platformUrl = platformUrl;
    }

    public Address getHeadquartersAddress() {
        return headquartersAddress;
    }

    public void setHeadquartersAddress(Address headquartersAddress) {
        this.headquartersAddress = headquartersAddress;
    }

    public String getTaxNumber() {
        return taxNumber;
    }

    public void setTaxNumber(String taxNumber) {
        this.taxNumber = taxNumber;
    }

    public String getHeadquartersPhoneNumber() {
        return headquartersPhoneNumber;
    }

    public Client setHeadquartersPhoneNumber(String headquartersPhoneNumber) {
        this.headquartersPhoneNumber = headquartersPhoneNumber;
        return this;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/FilterTransactions.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.enumerations.TransactionNature;
import com.mangopay.core.enumerations.TransactionStatus;
import com.mangopay.core.enumerations.TransactionType;

import java.util.HashMap;
import java.util.Map;

/**
 * Filter for transaction list.
 */
public class FilterTransactions extends Dto {

    @SerializedName("Status")
    private TransactionStatus status;

    /**
     * Transaction type.
     */
    @SerializedName("Type")
    private TransactionType type;

    /**
     * Transaction nature.
     */
    @SerializedName("Nature")
    private TransactionNature nature;

    /**
     * Start date in Unix format: return only transactions that have CreationDate BEFORE this date.
     */
    @SerializedName("BeforeDate")
    private Long beforeDate;

    /**
     * End date in Unix format: return only transactions that have CreationDate AFTER this date.
     */
    @SerializedName("AfterDate")
    private Long afterDate;

    public TransactionStatus getStatus() {
        return status;
    }

    public void setStatus(TransactionStatus status) {
        this.status = status;
    }

    public TransactionType getType() {
        return type;
    }

    public void setType(TransactionType type) {
        this.type = type;
    }

    public TransactionNature getNature() {
        return nature;
    }

    public void setNature(TransactionNature nature) {
        this.nature = nature;
    }

    public Long getBeforeDate() {
        return beforeDate;
    }

    public void setBeforeDate(Long beforeDate) {
        this.beforeDate = beforeDate;
    }

    public Long getAfterDate() {
        return afterDate;
    }

    public void setAfterDate(Long afterDate) {
        this.afterDate = afterDate;
    }

    /**
     * Gets map of fields and values.
     *
     * @return Collection of field name-field value pairs.
     */
    @Override
    public Map<String, String> getValues() {
        HashMap<String, String> result = new HashMap<>();

        if (status != null && status != TransactionStatus.NotSpecified) result.put("Status", status.toString());
        if (type != null && type != TransactionType.NotSpecified) result.put("Type", type.toString());
        if (nature != null && nature != TransactionNature.NotSpecified) result.put("Nature", nature.toString());
        if (beforeDate != null) result.put("BeforeDate", Long.toString(beforeDate));
        if (afterDate != null) result.put("AfterDate", Long.toString(afterDate));

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/deserializer/BankingAliasDeserializer.java<|end_filename|>
package com.mangopay.core.deserializer;

import com.google.gson.*;
import com.mangopay.core.enumerations.BankingAliasType;
import com.mangopay.entities.BankingAlias;
import com.mangopay.entities.subentities.BankingAliasDetailsIBAN;

import java.lang.reflect.Type;

public class BankingAliasDeserializer implements JsonDeserializer<BankingAlias> {
    @Override
    public BankingAlias deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
        JsonObject jsonObject = json.getAsJsonObject();
        BankingAlias bankingAlias = new Gson().fromJson(jsonObject.toString(), BankingAlias.class);
        BankingAliasType type = bankingAlias.getType();
        switch (type){
            case IBAN:
                BankingAliasDetailsIBAN bankingAliasDetailsIBAN = new BankingAliasDetailsIBAN();
                bankingAliasDetailsIBAN.setBIC(jsonObject.get("BIC").getAsString());
                bankingAliasDetailsIBAN.setIBAN(jsonObject.get("IBAN").getAsString());
                bankingAlias.setDetails(bankingAliasDetailsIBAN);
                break;
        }
        return bankingAlias;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/PayInExecutionType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Execution type enumeration.
 */
public enum PayInExecutionType {
    /**
     * Not specified.
     */
    NotSpecified,

    /**
     * WEB execution type.
     */
    WEB, 

    /**
     * DIRECT execution type.
     */
    DIRECT, 

    /**
     * PREAUTHORIZED execution type.
     */
    PREAUTHORIZED,

    /**
     * EXTERNAL INSTRUCTION execution type.
     */
    EXTERNAL_INSTRUCTION
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/BankingAliasType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Banking alias type enumeration.
 */
public enum BankingAliasType {

    /**
     * IBAN banking alias type.
     */
    IBAN
}


<|start_filename|>src/main/java/com/mangopay/core/deserializer/RecurringPayInDeserializer.java<|end_filename|>
package com.mangopay.core.deserializer;

import com.google.gson.*;
import com.mangopay.core.Billing;
import com.mangopay.core.SecurityInfo;
import com.mangopay.core.enumerations.CardType;
import com.mangopay.core.enumerations.CultureCode;
import com.mangopay.core.enumerations.SecureMode;
import com.mangopay.entities.RecurringPayIn;
import com.mangopay.entities.subentities.*;

import java.lang.reflect.Type;

public class RecurringPayInDeserializer implements JsonDeserializer<RecurringPayIn> {

    @Override
    public RecurringPayIn deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
        JsonObject object = json.getAsJsonObject();
        RecurringPayIn payIn = new Gson().fromJson(object.toString(), RecurringPayIn.class);
        if (payIn.getPaymentType() == null)
            return null;
        switch (payIn.getPaymentType()) {
            case CARD:
                PayInPaymentDetailsCard payInPaymentDetailsCard = new PayInPaymentDetailsCard();
                if (object.has("CardType") && !object.get("CardType").isJsonNull())
                    payInPaymentDetailsCard.setCardType(CardType.valueOf(object.get("CardType").getAsString()));
                if (object.has("CardId") && !object.get("CardId").isJsonNull())
                    payInPaymentDetailsCard.setCardId(object.get("CardId").getAsString());
                if (object.has("StatementDescriptor") && !object.get("StatementDescriptor").isJsonNull())
                    payInPaymentDetailsCard.setStatementDescriptor(object.get("StatementDescriptor").getAsString());
                payIn.setPaymentDetails(payInPaymentDetailsCard);
                break;
            default:
                return null;
        }
        switch (payIn.getExecutionType()) {
            case DIRECT:
                PayInExecutionDetailsDirect payInExecutionDetailsDirect = new PayInExecutionDetailsDirect();
                if (object.has("CardId") && !object.get("CardId").isJsonNull())
                    payInExecutionDetailsDirect.setCardId(object.get("CardId").getAsString());
                if (object.has("SecureMode") && !object.get("SecureMode").isJsonNull())
                    payInExecutionDetailsDirect.setSecureMode(SecureMode.valueOf(object.get("SecureMode").getAsString()));
                if (object.has("SecureModeReturnURL") && !object.get("SecureModeReturnURL").isJsonNull())
                    payInExecutionDetailsDirect.setSecureModeReturnUrl(object.get("SecureModeReturnURL").getAsString());
                if (object.has("SecureModeRedirectURL") && !object.get("SecureModeRedirectURL").isJsonNull())
                    payInExecutionDetailsDirect.setSecureModeRedirectUrl(object.get("SecureModeRedirectURL").getAsString());
                if (object.has("SecureModeNeeded") && !object.get("SecureModeNeeded").isJsonNull())
                    payInExecutionDetailsDirect.setSecureModeNeeded(object.get("SecureModeNeeded").getAsString());
                if (object.has("Billing") && !object.get("Billing").isJsonNull())
                    payInExecutionDetailsDirect.setBilling((Billing) context.deserialize(object.get("Billing"), Billing.class));
                if (object.has("SecurityInfo") && !object.get("SecurityInfo").isJsonNull())
                    payInExecutionDetailsDirect.setSecurityInfo((SecurityInfo) context.deserialize(object.get("SecurityInfo"), SecurityInfo.class));
                if (object.has("Culture") && !object.get("Culture").isJsonNull())
                    payInExecutionDetailsDirect.setCulture(CultureCode.valueOf(object.get("Culture").getAsString()));
                if (object.has("Requested3DSVersion") && !object.get("Requested3DSVersion").isJsonNull())
                    payInExecutionDetailsDirect.setRequested3DSVersion(object.get("Requested3DSVersion").getAsString());
                if (object.has("Applied3DSVersion") && !object.get("Applied3DSVersion").isJsonNull())
                    payInExecutionDetailsDirect.setApplied3DSVersion(object.get("Applied3DSVersion").getAsString());
                payIn.setExecutionDetails(payInExecutionDetailsDirect);
                break;
        }

        return payIn;
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/Transaction.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.EntityBase;
import com.mangopay.core.Money;
import com.mangopay.core.enumerations.TransactionNature;
import com.mangopay.core.enumerations.TransactionStatus;
import com.mangopay.core.enumerations.TransactionType;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * Transaction entity. Base class for: PayIn, PayOut, Transfer.
 */
public class Transaction extends EntityBase {

    /**
     * Author identifier.
     */
    @SerializedName("AuthorId")
    private String authorId;

    /**
     * Credited user identifier.
     */
    @SerializedName("CreditedUserId")
    private String creditedUserId;

    /**
     * Debited funds.
     */
    @SerializedName("DebitedFunds")
    private Money debitedFunds;

    /**
     * Credited funds.
     */
    @SerializedName("CreditedFunds")
    private Money creditedFunds;

    /**
     * Fees.
     */
    @SerializedName("Fees")
    private Money fees;

    /**
     * Transaction status.
     */
    @SerializedName("Status")
    private TransactionStatus status;

    /**
     * Result code.
     */
    @SerializedName("ResultCode")
    private String resultCode;

    /**
     * The PreAuthorization result Message explaining the result code.
     */
    @SerializedName("ResultMessage")
    private String resultMessage;

    /**
     * ExecutionDate (UNIX timestamp).
     */
    @SerializedName("ExecutionDate")
    private Long executionDate;

    /**
     * Transaction type.
     */
    @SerializedName("Type")
    private TransactionType type;

    /**
     * Transaction nature.
     */
    @SerializedName("Nature")
    private TransactionNature nature;

    public String getAuthorId() {
        return authorId;
    }

    public void setAuthorId(String authorId) {
        this.authorId = authorId;
    }

    public String getCreditedUserId() {
        return creditedUserId;
    }

    public void setCreditedUserId(String creditedUserId) {
        this.creditedUserId = creditedUserId;
    }

    public Money getDebitedFunds() {
        return debitedFunds;
    }

    public void setDebitedFunds(Money debitedFunds) {
        this.debitedFunds = debitedFunds;
    }

    public Money getCreditedFunds() {
        return creditedFunds;
    }

    public void setCreditedFunds(Money creditedFunds) {
        this.creditedFunds = creditedFunds;
    }

    public Money getFees() {
        return fees;
    }

    public void setFees(Money fees) {
        this.fees = fees;
    }

    /**
     * Get Transaction Status
     *
     * @return {@link TransactionStatus }
     */
    public TransactionStatus getStatus() {
        if (status == null) {
            return TransactionStatus.NotSpecified;
        } else {
            return status;
        }
    }

    public void setStatus(TransactionStatus status) {
        this.status = status;
    }

    public String getResultCode() {
        return resultCode;
    }

    public void setResultCode(String resultCode) {
        this.resultCode = resultCode;
    }

    public String getResultMessage() {
        return resultMessage;
    }

    public void setResultMessage(String resultMessage) {
        this.resultMessage = resultMessage;
    }

    public Long getExecutionDate() {
        return executionDate;
    }

    public void setExecutionDate(Long executionDate) {
        this.executionDate = executionDate;
    }

    public TransactionType getType() {
        return type;
    }

    public void setType(TransactionType type) {
        this.type = type;
    }

    public TransactionNature getNature() {
        return nature;
    }

    public void setNature(TransactionNature nature) {
        this.nature = nature;
    }

    /**
     * Is Transaction Created Status
     *
     * @return True if transaction is created
     */
    public boolean isCreated() {
        return getStatus() == TransactionStatus.CREATED;
    }

    /**
     * Is Transaction Failed Status
     *
     * @return True if transaction is failed
     */
    public boolean isFailed() {
        return getStatus() == TransactionStatus.FAILED;
    }

    /**
     * Is Transaction Succeeded Status
     *
     * @return True if transaction is succeeded
     */
    public boolean isSucceeded() {
        return getStatus() == TransactionStatus.SUCCEEDED;
    }

    /**
     * Gets map which property is an object and what type of object.
     *
     * @return Collection of field name-field type pairs.
     */
    @Override
    public Map<String, Type> getSubObjects() {

        HashMap<String, Type> result = new HashMap<>();

        result.put("DebitedFunds", Money.class);
        result.put("CreditedFunds", Money.class);
        result.put("Fees", Money.class);

        return result;
    }

    /**
     * Gets the collection of read-only fields names.
     *
     * @return List of field names.
     */
    @Override
    public ArrayList<String> getReadOnlyProperties() {

        ArrayList<String> result = super.getReadOnlyProperties();

        result.add("Status");
        result.add("ResultCode");
        result.add("ExecutionDate");

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/TransactionNature.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Transaction nature enumeration.
 */
public enum TransactionNature {
    /**
     * Not specified.
     */
    NotSpecified,

    /**
     * REGULAR transaction nature.
     */
    REGULAR, 

    /**
     * REFUND transaction nature.
     */
    REFUND, 

    /**
     * REPUDIATION transaction nature.
     */
    REPUDIATION,
    
    /**
     * SETTLEMENT transaction nature.
     */
    SETTLEMENT
}


<|start_filename|>src/main/java/com/mangopay/entities/DebitedBankAccount.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Dto;
import com.mangopay.core.enumerations.BankAccountType;

/**
 * Debited bank account object.
 */
public class DebitedBankAccount extends Dto {

    /**
     * Name of the account's owner.
     */
    @SerializedName("OwnerName")
    private String ownerName;

    /**
     * Number of the account.
     */
    @SerializedName("AccountNumber")
    private String accountNumber;

    /**
     * IBAN
     */
    @SerializedName("IBAN")
    private String iban;

    /**
     * BIC
     */
    @SerializedName("BIC")
    private String bic;

    /**
     * Bank account type.
     */
    @SerializedName("Type")
    private BankAccountType type;

    /**
     * Country.
     */
    @SerializedName("Country")
    private String country;

    public DebitedBankAccount(String ownerName, String accountNumber, String iban, String bic, BankAccountType type, String country) {
        this.ownerName = ownerName;
        this.accountNumber = accountNumber;
        this.iban = iban;
        this.bic = bic;
        this.type = type;
        this.country = country;
    }

    public DebitedBankAccount() {
    }

    public String getOwnerName() {
        return ownerName;
    }

    public void setOwnerName(String ownerName) {
        this.ownerName = ownerName;
    }

    public String getAccountNumber() {
        return accountNumber;
    }

    public void setAccountNumber(String accountNumber) {
        this.accountNumber = accountNumber;
    }

    public String getIban() {
        return iban;
    }

    public void setIban(String iban) {
        this.iban = iban;
    }

    public String getBic() {
        return bic;
    }

    public void setBic(String bic) {
        this.bic = bic;
    }

    public BankAccountType getType() {
        return type;
    }

    public void setType(BankAccountType type) {
        this.type = type;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/PreAuthorizationExecutionType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Pre-authorization execution type enumeration.
 */
public enum PreAuthorizationExecutionType {
    /**
     * Not specified.
     */ 
    NotSpecified,

    /**
     * CARD execution type.
     */ 
    CARD,

    /**
     * DIRECT execution type.
     */ 
    DIRECT
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/BankingAliasApi.java<|end_filename|>
package com.mangopay.core.APIs;

import com.mangopay.core.FilterBankingAlias;
import com.mangopay.core.Pagination;
import com.mangopay.core.Sorting;
import com.mangopay.entities.BankingAlias;

import java.util.List;

/**
 * API declaration for banking aliases.
 */
public interface BankingAliasApi {

    /**
     * Creates a new banking alias.
     *
     * @param bankingAlias Banking alias instance to be created.
     * @param walletId     ID of the wallet for which the alias is being created.
     * @return Banking alias instance returned from API.
     */
    BankingAlias create(String walletId, BankingAlias bankingAlias) throws Exception;

    /**
     * Creates a new banking alias.
     *
     * @param idempotencyKey Idempotency key for this request.
     * @param walletId       ID of the wallet for which the alias is being created.
     * @param bankingAlias   Banking alias instance to be created.
     * @return Banking alias instance returned from API.
     */
    BankingAlias create(String idempotencyKey, String walletId, BankingAlias bankingAlias) throws Exception;

    /**
     * Gets the banking alias.
     *
     * @param bankingAliasId Banking alias identifier.
     * @return Banking alias instance returned from API.
     */
    BankingAlias get(String bankingAliasId) throws Exception;

    /**
     * Gets banking aliases for the wallet.
     *
     * @param walletId   Wallet identifier.
     * @param pagination Pagination object
     * @param filter     Object to filter data.
     * @param sorting    Object to sort data.
     * @return Banking aliases for wallet returned from API.
     */
    List<BankingAlias> listForWallet(String walletId, Pagination pagination, FilterBankingAlias filter, Sorting sorting) throws Exception;

    /**
     * Gets banking aliases for the wallet.
     *
     * @param walletId   Wallet identifier.
     * @param pagination Pagination object
     * @param filter     Object to filter data.
     * @return Banking aliases for wallet returned from API.
     */
    List<BankingAlias> listForWallet(String walletId, Pagination pagination, FilterBankingAlias filter) throws Exception;

    /**
     * Gets banking aliases for the wallet.
     *
     * @param walletId   Wallet identifier.
     * @param pagination Pagination object
     * @return Banking aliases for wallet returned from API.
     */
    List<BankingAlias> listForWallet(String walletId, Pagination pagination) throws Exception;

    /**
     * Gets banking aliases for the wallet.
     *
     * @param walletId Wallet identifier.
     * @return Banking aliases for wallet returned from API.
     */
    List<BankingAlias> listForWallet(String walletId) throws Exception;

    /**
     * Deactivates a banking alias.
     *
     * @param bankingAliasId ID of the banking alias to be deactivated.
     * @param bankingAlias   Banking alias locally marked as deactivated.
     * @return
     */
    BankingAlias deactivate(String bankingAliasId, BankingAlias bankingAlias) throws Exception;
}


<|start_filename|>src/main/java/com/mangopay/entities/subentities/PaymentData.java<|end_filename|>
package com.mangopay.entities.subentities;

import com.mangopay.core.Dto;

public class PaymentData extends Dto {

    private String transactionId;

    public String getNetwork() {
        return network;
    }

    public PaymentData setNetwork(String network) {
        this.network = network;
        return this;
    }

    public String getTokenData() {
        return tokenData;
    }

    public PaymentData setTokenData(String tokenData) {
        this.tokenData = tokenData;
        return this;
    }

    private String network;

    private String tokenData;

    public String getTransactionId() {
        return transactionId;
    }

    public PaymentData setTransactionId(String transactionId) {
        this.transactionId = transactionId;
        return this;
    }
}

<|start_filename|>src/main/java/com/mangopay/entities/subentities/BankAccountDetailsUS.java<|end_filename|>
package com.mangopay.entities.subentities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Dto;
import com.mangopay.core.enumerations.DepositAccountType;
import com.mangopay.core.interfaces.BankAccountDetails;

import static com.mangopay.core.enumerations.DepositAccountType.CHECKING;

/**
 * Class represents US type of bank account.
 */
public class BankAccountDetailsUS extends Dto implements BankAccountDetails {

    /**
     * Account number.
     */
    @SerializedName("AccountNumber")
    private String accountNumber;

    /**
     * ABA.
     */
    @SerializedName("ABA")
    private String aba;

    /**
     * Deposit account type.
     */
    @SerializedName("DepositAccountType")
    private DepositAccountType depositAccountType;

    /**
     * Instantiates new BankAccountDetailsUS object.
     */
    public BankAccountDetailsUS() {
        this.depositAccountType = CHECKING;
    }

    public String getAccountNumber() {
        return accountNumber;
    }

    public void setAccountNumber(String accountNumber) {
        this.accountNumber = accountNumber;
    }

    public String getAba() {
        return aba;
    }

    public void setAba(String aba) {
        this.aba = aba;
    }

    public com.mangopay.core.enumerations.DepositAccountType getDepositAccountType() {
        return depositAccountType;
    }

    public void setDepositAccountType(com.mangopay.core.enumerations.DepositAccountType depositAccountType) {
        this.depositAccountType = depositAccountType;
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/BankAccount.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Address;
import com.mangopay.core.EntityBase;
import com.mangopay.core.enumerations.BankAccountType;
import com.mangopay.core.interfaces.BankAccountDetails;
import com.mangopay.entities.subentities.*;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * Bank Account entity.
 */
public class BankAccount extends EntityBase {

    /**
     * User identifier.
     */
    @SerializedName("UserId")
    private String userId;

    /**
     * Type of bank account.
     */
    @SerializedName("Type")
    private BankAccountType type;

    /**
     * Owner name.
     */
    @SerializedName("OwnerName")
    private String ownerName;

    /**
     * Owner address.
     */
    @SerializedName("OwnerAddress")
    private Address ownerAddress;

    /**
     * Denotes whether bank account is active or not.
     */
    @SerializedName("Active")
    private Boolean active;

    /**
     * One of BankAccountDetails implementations, depending on Type.
     */
    @SerializedName("Details")
    private BankAccountDetails details;

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public BankAccountType getType() {
        return type;
    }

    public void setType(BankAccountType type) {
        this.type = type;
    }

    public String getOwnerName() {
        return ownerName;
    }

    public void setOwnerName(String ownerName) {
        this.ownerName = ownerName;
    }

    public Address getOwnerAddress() {
        return ownerAddress;
    }

    public void setOwnerAddress(Address ownerAddress) {
        this.ownerAddress = ownerAddress;
    }

    public Boolean isActive() {
        return active;
    }

    public void setActive(Boolean active) {
        this.active = active;
    }

    public BankAccountDetails getDetails() {
        return details;
    }

    public void setDetails(BankAccountDetails details) {
        this.details = details;
    }

    /**
     * Gets map which property is an object and what type of object.
     *
     * @return Collection of field name-field type pairs.
     */
    @Override
    public Map<String, Type> getSubObjects() {

        Map<String, Type> result = super.getSubObjects();

        result.put("OwnerAddress", Address.class);

        return result;
    }

    /**
     * Gets the structure that maps which property depends on other property.
     *
     * @return
     */
    @Override
    public Map<String, Map<String, Map<String, Class<?>>>> getDependentObjects() {

        return new HashMap<String, Map<String, Map<String, Class<?>>>>() {{
            put("Type", new HashMap<String, Map<String, Class<?>>>() {{
                        put("IBAN", new HashMap<String, Class<?>>() {{
                                    put("Details", BankAccountDetailsIBAN.class);
                                }}
                        );
                        put("GB", new HashMap<String, Class<?>>() {{
                                    put("Details", BankAccountDetailsGB.class);
                                }}
                        );
                        put("US", new HashMap<String, Class<?>>() {{
                                    put("Details", BankAccountDetailsUS.class);
                                }}
                        );
                        put("CA", new HashMap<String, Class<?>>() {{
                                    put("Details", BankAccountDetailsCA.class);
                                }}
                        );
                        put("OTHER", new HashMap<String, Class<?>>() {{
                                    put("Details", BankAccountDetailsOTHER.class);
                                }}
                        );
                        // ...and more in future...
                    }}
            );
        }};
    }

    /**
     * Gets the collection of read-only fields names
     *
     * @return List of field names.
     */
    @Override
    public ArrayList<String> getReadOnlyProperties() {

        ArrayList<String> result = super.getReadOnlyProperties();

        result.add("UserId");
        result.add("Type");
        result.add("Active");

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/PaymentStatus.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Payment status enumeration.
 */
public enum PaymentStatus {
    /**
     * Not specified.
     */ 
    NotSpecified,

    /**
     * WAITING payment status.
     */ 
    WAITING, 

    /**
     * CANCELED payment status.
     */ 
    CANCELED, 

    /**
     * EXPIRED payment status.
     */ 
    EXPIRED, 

    /**
     * VALIDATED payment status.
     */ 
    VALIDATED
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/LegalPersonType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Legal person type enumeration.
 */
public enum LegalPersonType {
    /**
     * Not specified.
     */
    NotSpecified,

    /**
     * BUSINESS legal person type.
     */
    BUSINESS,
    
    /**
     * ORGANIZATION legal person type.
     */
    ORGANIZATION,
    
    /**
     * SOLETRADER legal person type.
     */
    SOLETRADER
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/KycDocumentType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * KYC document type enumeration.
 */
public enum KycDocumentType {
    /**
     * Not specified.
     */ 
    NotSpecified,

    /**
     * Only for natural users. ID of the individual duly empowered to act on 
     * behalf of the legal entity.
     */ 
    IDENTITY_PROOF,

    /**
     * Only for legal users. Extract from the relevant register of commerce 
     * issued within the last three months.
     */ 
    REGISTRATION_PROOF,

    /**
     * Only for legal users. It’s the Statute. Formal memorandum stated by 
     * the entrepreuneurs, in which the following information is mentioned: 
     * business name, activity, registered address, shareholding.
     */ 
    ARTICLES_OF_ASSOCIATION,

    /**
     * Only for legal users (business company).
     */ 
    SHAREHOLDER_DECLARATION,

    /**
     * Only for natural users.
     */ 
    ADDRESS_PROOF
}


<|start_filename|>src/main/java/com/mangopay/entities/CurrentState.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Dto;
import com.mangopay.core.Money;

import java.lang.reflect.Type;
import java.util.Map;

public class CurrentState extends Dto {

    @SerializedName("PayinsLinked ")
    private int payinsLinked;

    @SerializedName("CumulatedDebitedAmount")
    private Money cumulatedDebitedAmount;

    @SerializedName("CumulatedFeesAmount")
    private Money cumulatedFeesAmount;

    @SerializedName("LastPayinId")
    private String lastPayinId;

    public int getPayinsLinked() {
        return payinsLinked;
    }

    public Money getCumulatedDebitedAmount() {
        return cumulatedDebitedAmount;
    }

    public Money getCumulatedFeesAmount() {
        return cumulatedFeesAmount;
    }

    public String getLastPayinId() {
        return lastPayinId;
    }

    @Override
    public Map<String, Type> getSubObjects() {
        Map<String, Type> result = super.getSubObjects();

        result.put("Money", Money.class);

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/AuthenticationHelper.java<|end_filename|>
package com.mangopay.core;

import com.mangopay.MangoPayApi;
import java.util.*;

/**
 * Authentication helper class.
 */
public class AuthenticationHelper {
    
    /**
     * Root/parent instance that holds the OAuthToken and Configuration instance.
     */
    private MangoPayApi root;
    
    /**
     * Instantiates new AuthenticationHelper object.
     * @param root Root/parent instance that holds the OAuthToken and Configuration instance.
     */
    public AuthenticationHelper(MangoPayApi root) throws Exception {
        this.root = root;
    }
    
    /**
     * Gets HTTP header value with authorization string.
     * @return
     * @throws Exception
     */
    public Map<String, String> getHttpHeaderKey() throws Exception {
        return getHttpHeaderStrong();
    }
    
    /**
     * Gets basic key for HTTP header.
     * @return  Authorization string.
     * @throws Exception
     */
    public String getHttpHeaderBasicKey() throws Exception {
        if (root.getConfig().getClientId() == null || root.getConfig().getClientId().length() == 0)
            throw new Exception ("MangoPay.config.ClientId is not set.");
        
        if (root.getConfig().getClientPassword() == null || root.getConfig().getClientPassword().length() == 0)
            throw new Exception ("MangoPay.config.ClientPassword is not set.");
        
        String signature = root.getConfig().getClientId() + ':' + root.getConfig().getClientPassword();
        
        return Base64Encoder.encode(signature);
    }
    
    // gets HTTP header value with authorization string for basic authentication
    private Map<String, String> getHttpHeaderBasic() throws Exception {
        
        return new HashMap<String, String>(){{
            put("Authorization", "Basic " + getHttpHeaderBasicKey());
        }};
    }
    
    // gets HTTP header value with authorization string for strong authentication
    private Map<String, String> getHttpHeaderStrong() throws Exception {
        
        final OAuthToken token = root.getOAuthTokenManager().getToken();
        
        if (token == null || token.getAccessToken().length() == 0 || token.getTokenType().length() == 0)
            throw new Exception ("OAuth token is not created (or is invalid) for strong authentication");
                
        return new HashMap<String, String>(){{
            put("Authorization", token.getTokenType() + " " + token.getAccessToken());
        }};
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/subentities/PayInPaymentDetailsCard.java<|end_filename|>
package com.mangopay.entities.subentities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Dto;
import com.mangopay.core.ObjectTool;
import com.mangopay.core.Shipping;
import com.mangopay.core.interfaces.PayInPaymentDetails;
import com.mangopay.core.enumerations.CardType;

/**
 * Class representing the Card type for mean of payment in PayIn entity.
 */
public class PayInPaymentDetailsCard extends Dto implements PayInPaymentDetails {

    /**
     * Card type.
     */
    @SerializedName("CardType")
    private CardType cardType;
    
    /**
     * Card identifier.
     */
    @SerializedName("CardId")
    private String cardId;
    
    /**
     * An optional value to be specified on the user's bank statement
     */
    @SerializedName("StatementDescriptor")
    private String statementDescriptor;

    @SerializedName("Shipping")
    private Shipping shipping;

    @SerializedName("BrowserInfo")
    private BrowserInfo browserInfo;

    @SerializedName("IpAddress")
    private String ipAddress;

    public PayInPaymentDetailsCard() {
    }

    public PayInPaymentDetailsCard(CardType cardType, String cardId) {
        this.cardType = cardType;
        this.cardId = cardId;
    }

    public CardType getCardType() {
        return cardType;
    }

    public void setCardType(CardType cardType) {
        this.cardType = cardType;
    }

    public String getCardId() {
        return cardId;
    }

    public void setCardId(String cardId) {
        this.cardId = cardId;
    }

    public String getStatementDescriptor() {
        return statementDescriptor;
    }

    public void setStatementDescriptor(String statementDescriptor) {
        this.statementDescriptor = statementDescriptor;
    }

    public Shipping getShipping() {
        return shipping;
    }

    public PayInPaymentDetailsCard setShipping(Shipping shipping) {
        this.shipping = shipping;
        return this;
    }

    public static PayInPaymentDetailsCard build(CardType cardType, String cardId) {
        return new PayInPaymentDetailsCard(cardType, cardId);
    }

    public BrowserInfo getBrowserInfo() {
        return browserInfo;
    }

    public PayInPaymentDetailsCard setBrowserInfo(BrowserInfo browserInfo) {
        this.browserInfo = browserInfo;
        return this;
    }

    public String getIpAddress() {
        return ipAddress;
    }

    public PayInPaymentDetailsCard setIpAddress(String ipAddress) {
        this.ipAddress = ipAddress;
        return this;
    }

    public PayInPaymentDetailsCard(CardType cardType, String cardId, String statementDescriptor, Shipping shipping) {
        this.cardType = cardType;
        this.cardId = cardId;
        this.statementDescriptor = statementDescriptor;
        this.shipping = shipping;
    }
    
    public static PayInPaymentDetailsCard build(CardType cardType, String cardId, String statementDescriptor, Shipping shipping) {
        return new PayInPaymentDetailsCard(cardType, cardId, statementDescriptor, shipping);
    }
    
    public static PayInPaymentDetailsCard convert(PayInPaymentDetails paymentDetails) throws Exception {
        if (ObjectTool.isNull(paymentDetails)) {
            throw new Exception("PayInPaymentDetails null value");
        } else if (paymentDetails  instanceof PayInPaymentDetailsCard) {
            return (PayInPaymentDetailsCard) paymentDetails;
        } else {
            throw new Exception("PayInPaymentDetails instance isn't PayInPaymentDetailsCard instance");
        }
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/BankingAlias.java<|end_filename|>
package com.mangopay.entities;

import com.mangopay.core.EntityBase;
import com.mangopay.core.enumerations.BankingAliasType;
import com.mangopay.core.enumerations.CountryIso;
import com.mangopay.core.interfaces.BankingAliasDetails;
import com.mangopay.entities.subentities.BankingAliasDetailsIBAN;

import java.util.HashMap;
import java.util.Map;

/**
 * Banking alias entity.
 */
public class BankingAlias extends EntityBase {

    /**
     * The user ID who was credited.
     */
    public String CreditedUserId;

    /**
     * The ID of the wallet.
     */
    public String WalletId;

    /**
     * The name of the owner of the bank account.
     */
    public String OwnerName;

    /**
     * The type of banking alias.
     */
    public BankingAliasType Type;

    /**
     * The country format for the banking alias.
     */
    public CountryIso Country;

    /**
     * Whether the banking alias is active or not.
     */
    public boolean Active;

    /**
     * Type-specific details of the banking alias.
     */
    public BankingAliasDetails Details;

    public String getCreditedUserId() {
        return CreditedUserId;
    }

    public void setCreditedUserId(String creditedUserId) {
        this.CreditedUserId = creditedUserId;
    }

    public String getWalletId() {
        return WalletId;
    }

    public void setWalletId(String walletId) {
        this.WalletId = walletId;
    }

    public String getOwnerName() {
        return OwnerName;
    }

    public void setOwnerName(String ownerName) {
        this.OwnerName = ownerName;
    }

    public BankingAliasType getType() {
        return Type;
    }

    public void setType(BankingAliasType type) {
        this.Type = type;
    }

    public CountryIso getCountry() {
        return Country;
    }

    public void setCountry(CountryIso country) {
        this.Country = country;
    }

    public boolean isActive() {
        return Active;
    }

    public void setActive(boolean active) {
        this.Active = active;
    }

    public BankingAliasDetails getDetails() {
        return Details;
    }

    public void setDetails(BankingAliasDetails details) {
        this.Details = details;
    }

    /**
     * Gets the structure that maps which property depends on other property.
     *
     * @return
     */
    @Override
    public Map<String, Map<String, Map<String, Class<?>>>> getDependentObjects() {
        return new HashMap<String, Map<String, Map<String, Class<?>>>>() {{
            put("Type", new HashMap<String, Map<String, Class<?>>>() {{
                        put("IBAN", new HashMap<String, Class<?>>() {{
                                    put("Details", BankingAliasDetailsIBAN.class);
                                }}
                        );
                        // ...and more in future...
                    }}
            );
        }};
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/CardType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Card type enumeration.
 */
public enum CardType {
    /**
    * Not specified.
    */ 
    NotSpecified,

    /**
    * CB VISA MASTERCARD card type.
    */ 
    CB_VISA_MASTERCARD,

    /**
    * AMEX card type.
    */ 
    AMEX,

    /**
    * DINERS card type.
    */ 
    DINERS,

    /**
    * MASTERPASS card type.
    */ 
    MASTERPASS,

    /**
    * MAESTRO card type.
    */ 
    MAESTRO,

    /**
    * P24 (Przelewy24) card type.
    */ 
    P24,

    /**
    * IDEAL card type.
    */ 
    IDEAL,

    /**
    * BCMC card type.
    */ 
    BCMC
    ,

    /**
    * PAYLIB card type.
    */ 
    PAYLIB
}


<|start_filename|>src/main/java/com/mangopay/core/FilterMandates.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.enumerations.MandateStatus;

import java.util.HashMap;
import java.util.Map;

/**
 * Filters for mandates list.
 */
public class FilterMandates extends Dto {

    /**
     * Status of mandates.
     */
    @SerializedName("Status")
    private MandateStatus status;

    /**
     * Start date in Unix format.
     */
    @SerializedName("BeforeDate")
    private Long beforeDate;

    /**
     * End date in Unix format.
     */
    @SerializedName("AfterDate")
    private Long afterDate;

    public MandateStatus getStatus() {
        return status;
    }

    public void setStatus(MandateStatus status) {
        this.status = status;
    }

    public Long getBeforeDate() {
        return beforeDate;
    }

    public void setBeforeDate(Long beforeDate) {
        this.beforeDate = beforeDate;
    }

    public Long getAfterDate() {
        return afterDate;
    }

    public void setAfterDate(Long afterDate) {
        this.afterDate = afterDate;
    }

    /**
     * Gets map of fields and values.
     *
     * @return Collection of field name-field value pairs.
     */
    @Override
    public Map<String, String> getValues() {
        HashMap<String, String> result = new HashMap<>();

        if (status != null && status != MandateStatus.NotSpecified) {
            result.put("status", status.name());
        }

        if (beforeDate != null) result.put("beforeDate", Long.toString(beforeDate));
        if (afterDate != null) result.put("afterDate", Long.toString(afterDate));

        return result;
    }

}


<|start_filename|>src/main/java/com/mangopay/core/APIs/implementation/MandateApiImpl.java<|end_filename|>
package com.mangopay.core.APIs.implementation;

import com.mangopay.MangoPayApi;
import com.mangopay.core.APIs.ApiBase;
import com.mangopay.core.APIs.MandateApi;
import com.mangopay.core.FilterMandates;
import com.mangopay.core.Pagination;
import com.mangopay.core.Sorting;
import com.mangopay.entities.Mandate;
import com.mangopay.entities.Transfer;

import java.util.List;
import java.util.logging.Filter;

/**
 * API for mandates.
 */
public class MandateApiImpl extends ApiBase implements MandateApi {

    /**
     * Instantiates new MandateApiImpl object.
     *
     * @param root Root/parent instance that holds the OAuthToken and Configuration instance.
     */
    public MandateApiImpl(MangoPayApi root) {
        super(root);
    }

    @Override
    public Mandate create(Mandate mandate) throws Exception {
        return create(null, mandate);
    }

    @Override
    public Mandate create(String idempotencyKey, Mandate mandate) throws Exception {
        return this.createObject(Mandate.class, idempotencyKey, "mandate_create", mandate);
    }

    @Override
    public Mandate get(String mandateId) throws Exception {
        return this.getObject(Mandate.class, "mandate_get", mandateId);
    }

    /// <summary>Gets all mandates.</summary>
    /// <param name="pagination">Pagination.</param>
    /// <param name="filters">Filters.</param>
    /// <param name="sort">Sort.</param>
    /// <returns>List of Mandate instances returned from API.</returns>

    @Override
    public List<Mandate> getAll(FilterMandates filters, Pagination pagination, Sorting sorting) throws Exception {
        if (filters == null) filters = new FilterMandates();

        return this.getList(Mandate[].class, Mandate.class, "mandates_get_all", pagination, "", filters.getValues(), sorting);
    }

    @Override
    public List<Mandate> getForUser(String userId, FilterMandates filters, Pagination pagination, Sorting sorting) throws Exception {
        if (filters == null) filters = new FilterMandates();

        return this.getList(Mandate[].class, Mandate.class, "mandates_get_for_user", pagination, userId, filters.getValues(), sorting);
    }

    @Override
    public List<Mandate> getForBankAccount(String userId, String bankAccountId, FilterMandates filters, Pagination pagination, Sorting sorting) throws Exception {
        if (filters == null) filters = new FilterMandates();

        return this.getList(Mandate[].class, Mandate.class, "mandates_get_for_bank_account", pagination, userId, bankAccountId, filters.getValues(), sorting);
    }

    @Override
    public Mandate cancel(String mandateId) throws Exception {
        return this.updateObject(Mandate.class, "mandate_cancel", new Mandate(), mandateId);
    }

    @Override
    public List<Transfer> getTransfers(String mandateId) throws Exception {
        return this.getTransfers(mandateId, null, null);
    }

    @Override
    public List<Transfer> getTransfers(String mandateId, Pagination pagination, Sorting sorting) throws Exception {
        return this.getList(Transfer[].class, Transfer.class, "mandate_get_transactions", pagination, mandateId, sorting);
    }

    @Override
    public List<Transfer> getTransfers(String mandateId, Pagination pagination, Sorting sorting, FilterMandates filters) throws Exception {
        if (filters == null) filters = new FilterMandates();
        return this.getList(Transfer[].class, Transfer.class, "mandate_get_transactions", pagination, mandateId, filters.getValues(), sorting);
    }
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/EventApi.java<|end_filename|>
package com.mangopay.core.APIs;

import com.mangopay.core.FilterEvents;
import com.mangopay.core.Pagination;
import com.mangopay.core.Sorting;
import com.mangopay.entities.Event;

import java.util.List;

/**
 * Created by thepa on 18-Jan-17.
 */
public interface EventApi {
    /**
     * Gets the events.
     * @param filter        Filters for events.
     * @param pagination    Pagination.
     * @return              List of events matching passed filter criteria.
     * @throws Exception
     */
    List<Event> get(FilterEvents filter, Pagination pagination, Sorting sorting) throws Exception;
}


<|start_filename|>src/main/java/com/mangopay/core/ShippingAddress.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;

import java.lang.reflect.Type;
import java.util.Map;

/**
 * Models shipping details
 */
public class ShippingAddress extends Dto {

    /**
     * Name of the shipping recipient
     */
    @SerializedName("RecipientName")
    private String recipientName;

    /**
     * The shipping address
     */
    @SerializedName("Address")
    private Address address;

    public String getRecipientName() {
        return recipientName;
    }

    public void setRecipientName(String recipientName) {
        this.recipientName = recipientName;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    @Override
    public Map<String, Type> getSubObjects() {
        Map<String, Type> subObjects = super.getSubObjects();

        subObjects.put("Address", Address.class);

        return subObjects;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/Sector.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Sector enumeration
 */
public enum Sector {

    RENTALS,
    STORES_FASHION_ACCESSORIES_OBJECTS,
    BEAUTY_COSMETICS_HEALTH,
    FOOD_WINE_RESTAURANTS,
    HOSPITALITY_TRAVEL_CORIDING,
    ART_MUSIC_ENTERTAINMENT,
    FURNITURE_GARDEN,
    SERVICES_JOBBING_EDUCATION,
    SPORT_RECREATION_ACTIVITIES,
    TICKETING
}


<|start_filename|>src/main/java/com/mangopay/entities/ClientBankWireDirect.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.EntityBase;
import com.mangopay.core.Money;

/**
 * Client bankwire direct entity.
 */
public class ClientBankWireDirect extends EntityBase {

    /**
     * Declared debited funds.
     */
    @SerializedName("DeclaredDebitedFunds")
    private Money declaredDebitedFunds;

    /**
     * Credited wallet alias.
     */
    @SerializedName("CreditedWalletId")
    private String creditedWalletId;

    public ClientBankWireDirect(String creditedWalletAlias, Money declaredDebitedFunds) {
        this.creditedWalletId = creditedWalletAlias;
        this.declaredDebitedFunds = declaredDebitedFunds;
    }

    public Money getDeclaredDebitedFunds() {
        return declaredDebitedFunds;
    }

    public void setDeclaredDebitedFunds(Money declaredDebitedFunds) {
        this.declaredDebitedFunds = declaredDebitedFunds;
    }

    public String getCreditedWalletId() {
        return creditedWalletId;
    }

    public void setCreditedWalletId(String creditedWalletId) {
        this.creditedWalletId = creditedWalletId;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/serializer/PayOutSerializer.java<|end_filename|>
package com.mangopay.core.serializer;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.mangopay.entities.PayOut;
import com.mangopay.entities.subentities.PayOutPaymentDetailsBankWire;

import java.lang.reflect.Type;

public class PayOutSerializer implements JsonSerializer<PayOut> {
    @Override
    public JsonElement serialize(PayOut src, Type typeOfSrc, JsonSerializationContext context) {
        JsonObject object = SerializedTransaction.getTransactionObject(src, context);
        object.add("DebitedWalletId", context.serialize(src.getDebitedWalletId()));
        object.add("PaymentType", context.serialize(src.getPaymentType()));
        switch (src.getMeanOfPaymentDetails().getClass().getSimpleName()) {
            case "PayOutPaymentDetailsBankWire":
                object.add("BankAccountId", context.serialize(((PayOutPaymentDetailsBankWire) src.getMeanOfPaymentDetails()).getBankAccountId()));
                object.add("BankWireRef", context.serialize(((PayOutPaymentDetailsBankWire) src.getMeanOfPaymentDetails()).getBankWireRef()));
                object.add("PayoutModeRequested", context.serialize(((PayOutPaymentDetailsBankWire) src.getMeanOfPaymentDetails()).getPayoutModeRequested()));
                return object;
            default:
                return null;
        }
    }
}


<|start_filename|>src/test/java/com/mangopay/entities/subentities/PayInPaymentDetailsCardTest.java<|end_filename|>
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mangopay.entities.subentities;

import com.mangopay.core.Address;
import com.mangopay.core.Shipping;
import com.mangopay.core.enumerations.CardType;
import com.mangopay.core.enumerations.CountryIso;
import com.mangopay.core.interfaces.PayInPaymentDetails;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author <NAME> <EMAIL>
 */
public class PayInPaymentDetailsCardTest {
    
    public PayInPaymentDetailsCardTest() {
    }
    
    @BeforeClass
    public static void setUpClass() {
    }
    
    @AfterClass
    public static void tearDownClass() {
    }
    
    @Before
    public void setUp() {
    }
    
    @After
    public void tearDown() {
    }

    /**
     * Test of build method, of class PayInPaymentDetailsCard.
     */
    @Test
    public void testBuild_CardType_String() {
        CardType cardType = CardType.CB_VISA_MASTERCARD;
        String cardId = "12345678";
        PayInPaymentDetailsCard paymentDetailsCard = PayInPaymentDetailsCard.build(cardType, cardId);
        assertNotNull(paymentDetailsCard);
        assertEquals(cardId, paymentDetailsCard.getCardId());
        assertEquals(cardType, paymentDetailsCard.getCardType());
    }

    /**
     * Test of build method, of class PayInPaymentDetailsCard.
     */
    @Test
    public void testBuild_3args() {
        String statementDescriptor = "statementDescriptor";
        CardType cardType = CardType.CB_VISA_MASTERCARD;
        String cardId = "12345678";
        Shipping shipping = new Shipping();
        Address result = new Address();

        result.setAddressLine1("Address line 1");
        result.setAddressLine2("Address line 2");
        result.setCity("City");
        result.setCountry(CountryIso.PL);
        result.setPostalCode("11222");
        result.setRegion("Region");
        shipping.setFirstName("John");
        shipping.setLastName("Doe");
        shipping.setAddress(result);


        PayInPaymentDetailsCard paymentDetailsCard = PayInPaymentDetailsCard.build(cardType, cardId, statementDescriptor, shipping);
        assertNotNull(paymentDetailsCard);
        assertEquals(cardId, paymentDetailsCard.getCardId());
        assertEquals(cardType, paymentDetailsCard.getCardType());
        assertEquals(statementDescriptor, paymentDetailsCard.getStatementDescriptor());
    }
    
    @Test
    public void testConvert() throws Exception {
        PayInPaymentDetailsCard payInPaymentDetailsCard = new PayInPaymentDetailsCard();
        assertNotNull(payInPaymentDetailsCard);
        PayInPaymentDetails payInPaymentDetails = payInPaymentDetailsCard;
        assertNotNull(payInPaymentDetails);
        payInPaymentDetailsCard = PayInPaymentDetailsCard.convert(payInPaymentDetails);
        assertNotNull(payInPaymentDetailsCard);
    }
    
}


<|start_filename|>src/main/java/com/mangopay/core/FilterBankingAlias.java<|end_filename|>
package com.mangopay.core;

import java.util.HashMap;
import java.util.Map;

/**
 * Filter for banking alias list.
 */
public class FilterBankingAlias extends Dto {

    /**
     * Return only banking aliases that have creation date BEFORE this date.
     */
    public Long BeforeDate;
    /**
     * Return only banking aliases that have creation date AFTER this date.
     */
    public Long AfterDate;

    public Long getBeforeDate() {
        return BeforeDate;
    }

    public void setBeforeDate(Long beforeDate) {
        this.BeforeDate = beforeDate;
    }

    public Long getAfterDate() {
        return AfterDate;
    }

    public void setAfterDate(Long afterDate) {
        this.AfterDate = afterDate;
    }

    /**
     * Gets map of fields and values.
     *
     * @return Collection of field name-field value pairs.
     */
    @Override
    public Map<String, String> getValues() {
        HashMap<String, String> result = new HashMap<>();

        if (BeforeDate != null) result.put("BeforeDate", Long.toString(BeforeDate));
        if (AfterDate != null) result.put("AfterDate", Long.toString(AfterDate));

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/implementation/SettlementApiImpl.java<|end_filename|>
package com.mangopay.core.APIs.implementation;

import com.mangopay.MangoPayApi;
import com.mangopay.core.APIs.ApiBase;
import com.mangopay.core.APIs.SettlementApi;
import com.mangopay.entities.SettlementTransfer;

/**
 * API for settlements
 */
public class SettlementApiImpl extends ApiBase implements SettlementApi {

    public SettlementApiImpl(MangoPayApi root) {
        super(root);
    }

    @Override
    public SettlementTransfer get(String id) throws Exception {
        return this.getObject(SettlementTransfer.class, "settlements_get", id);
    }
}


<|start_filename|>src/main/java/com/mangopay/core/serializer/BankAccountSerializer.java<|end_filename|>
package com.mangopay.core.serializer;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.mangopay.core.enumerations.BankAccountType;
import com.mangopay.entities.BankAccount;
import com.mangopay.entities.subentities.*;

import java.lang.reflect.Type;

public class BankAccountSerializer implements JsonSerializer<BankAccount> {
    @Override
    public JsonElement serialize(BankAccount src, Type typeOfSrc, JsonSerializationContext context) {
        JsonObject object = new JsonObject();
        object.addProperty("Id", src.getId());
        object.addProperty("Tag", src.getTag());
        object.addProperty("CreationDate", src.getCreationDate());
        object.addProperty("UserId", src.getUserId());
        object.addProperty("Type", String.valueOf(src.getType()));
        object.addProperty("OwnerName", src.getOwnerName());
        object.add("OwnerAddress", context.serialize(src.getOwnerAddress()));
        BankAccountType accountType = src.getType();
        switch (accountType) {
            case GB:
                BankAccountDetailsGB accountDetailsGB = (BankAccountDetailsGB) src.getDetails();
                object.addProperty("AccountNumber", accountDetailsGB.getAccountNumber());
                object.addProperty("SortCode", accountDetailsGB.getSortCode());
                break;
            case US:
                BankAccountDetailsUS bankAccountDetailsUS = (BankAccountDetailsUS) src.getDetails();
                object.addProperty("ABA", bankAccountDetailsUS.getAba());
                object.addProperty("AccountNumber", bankAccountDetailsUS.getAccountNumber());
                object.addProperty("DepositAccountType", bankAccountDetailsUS.getDepositAccountType().toString());
                break;
            case CA:
                BankAccountDetailsCA bankAccountDetailsCA = (BankAccountDetailsCA) src.getDetails();
                object.addProperty("AccountNumber", bankAccountDetailsCA.getAccountNumber());
                object.addProperty("BankName", bankAccountDetailsCA.getBankName());
                object.addProperty("BranchCode", bankAccountDetailsCA.getBranchCode());
                object.addProperty("InstitutionNumber", bankAccountDetailsCA.getInstitutionNumber());
                break;
            case IBAN:
                BankAccountDetailsIBAN bankAccountDetailsIBAN = (BankAccountDetailsIBAN) src.getDetails();
                object.addProperty("BIC", bankAccountDetailsIBAN.getBic());
                object.addProperty("IBAN", bankAccountDetailsIBAN.getIban());
                break;
            case OTHER:
                BankAccountDetailsOTHER bankAccountDetailsOTHER = (BankAccountDetailsOTHER) src.getDetails();
                object.addProperty("AccountNumber", bankAccountDetailsOTHER.getAccountNumber());
                object.addProperty("BIC", bankAccountDetailsOTHER.getBic());
                object.addProperty("Country", bankAccountDetailsOTHER.getCountry().toString());
                break;
            default:
                throw new IllegalArgumentException("Invalid BankAccountDetails JSON");
        }
        return object;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/FilterPreAuthorizations.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.enumerations.PaymentStatus;
import com.mangopay.core.enumerations.PreAuthorizationStatus;

import java.util.HashMap;
import java.util.Map;

/**
    Filter for PreAuthorizations
 */
public class FilterPreAuthorizations extends Dto {

    private static final String RESULT_CODE = "ResultCode";

    private static final String STATUS = "Status";

    private static final String PAYMENT_STATUS = "PaymentStatus";

    @SerializedName("ResultCode")
    private String resultCode;

    @SerializedName("Status")
    private PreAuthorizationStatus preAuthorizationStatus;

    @SerializedName("PaymentStatus")
    private PaymentStatus paymentStatus;

    public String getResultCode() {
        return resultCode;
    }

    public void setResultCode(String resultCode) {
        this.resultCode = resultCode;
    }

    public PreAuthorizationStatus getPreAuthorizationStatus() {
        return preAuthorizationStatus;
    }

    public void setPreAuthorizationStatus(PreAuthorizationStatus preAuthorizationStatus) {
        this.preAuthorizationStatus = preAuthorizationStatus;
    }

    public PaymentStatus getPaymentStatus() {
        return paymentStatus;
    }

    public void setPaymentStatus(PaymentStatus paymentStatus) {
        this.paymentStatus = paymentStatus;
    }

    @Override
    public Map<String, String> getValues() {
        HashMap<String, String> result = new HashMap<>();

        if (!resultCode.isEmpty()) { result.put(RESULT_CODE, resultCode.toString()); }
        if (preAuthorizationStatus != null && preAuthorizationStatus != PreAuthorizationStatus.NotSpecified) { result.put(STATUS, preAuthorizationStatus.toString()); }
        if (paymentStatus != null && paymentStatus != PaymentStatus.NotSpecified) { result.put(PAYMENT_STATUS, paymentStatus.toString()); }

        return result;
    }
}


<|start_filename|>src/test/java/com/mangopay/core/SettlementApiImplTest.java<|end_filename|>
package com.mangopay.core;

import com.mangopay.core.enumerations.CurrencyIso;
import com.mangopay.core.enumerations.DisputeStatus;
import com.mangopay.core.enumerations.DisputeType;
import com.mangopay.core.enumerations.SortDirection;
import com.mangopay.entities.Dispute;
import com.mangopay.entities.Repudiation;
import com.mangopay.entities.SettlementTransfer;
import com.mangopay.entities.Transfer;
import org.junit.Before;
import org.junit.Test;

import java.util.List;

import static org.junit.Assert.*;

public class SettlementApiImplTest extends BaseTest {
    private String settlementId = null;
    private List<Dispute> clientDisputes;

    @Before
    public void initialize() throws Exception {

        Sorting sort = new Sorting();
        sort.addField("CreationDate", SortDirection.desc);

        clientDisputes = api.getDisputeApi().getAll(new Pagination(1, 100), null, sort);
        assertTrue("INITIALIZATION FAILURE - cannot test disputes", clientDisputes != null && !clientDisputes.isEmpty());

        if (settlementId == null || settlementId.isEmpty()) {
            Dispute dispute = null;
            for (Dispute d : clientDisputes) {
                if (d.getStatus() == DisputeStatus.CLOSED && d.getDisputeType() == DisputeType.NOT_CONTESTABLE) {
                    dispute = d;
                    break;
                }
            }

            assertNotNull("Cannot initialize settlement api test class because " +
                    "there's no closed and not contestable disputes in the disputes list.", dispute);

            String repudiationId = api.getDisputeApi().getTransactions(
                    dispute.getId(), new Pagination(1, 1), null, null).get(0).getId();
            Repudiation repudiation = null;
            repudiation = api.getRepudiationApi().getRepudiation(repudiationId);

            Money debitedFunds = new Money();
            Money fees = new Money();
            debitedFunds.setCurrency(CurrencyIso.EUR);
            debitedFunds.setAmount(1);
            fees.setCurrency(CurrencyIso.EUR);
            fees.setAmount(0);

            SettlementTransfer post = new SettlementTransfer();
            post.setAuthorId(repudiation.getAuthorId());
            post.setDebitedFunds(debitedFunds);
            post.setFees(fees);
            post.setTag("abc");

            Transfer result = null;
            result = api.getDisputeApi().createSettlementTransfer(post, repudiationId);
            assertNotNull("Can't retrieve id from settlement transfer because it is null", result);
            settlementId = result.getId();
        }

    }


    /*
    * Test to be uncommented when testing account data are fixed
    @Test
    public void getSettlement() throws Exception {
        SettlementTransfer settlementTransfers = this.api.getSettlementApi().get(settlementId);
        assertNotNull("Settlement api return null settlement transfer", settlementTransfers);
        assertNotNull(settlementTransfers.getTag());
        assertEquals("abc",settlementTransfers.getTag());
    }
    */
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/ClientApi.java<|end_filename|>
package com.mangopay.core.APIs;

import com.mangopay.core.FilterKycDocuments;
import com.mangopay.core.FilterTransactions;
import com.mangopay.core.Pagination;
import com.mangopay.core.Sorting;
import com.mangopay.core.enumerations.CurrencyIso;
import com.mangopay.core.enumerations.FundsType;
import com.mangopay.entities.*;

import java.util.List;

/**
 * Created by thepa on 18-Jan-17.
 */
public interface ClientApi {

    List<KycDocument> getKycDocuments(Pagination pagination, FilterKycDocuments filter, Sorting sort) throws Exception;

    /**
     * Get client information.
     *
     * @return Client object returned from API
     * @throws Exception
     */
    Client get() throws Exception;

    /**
     * Save client
     *
     * @param client Updated client object to save
     * @return The updated Client from API
     * @throws Exception
     */
    Client save(Client client) throws Exception;

    /**
     * Upload a logo for client.
     * Only GIF, PNG, JPG, JPEG, BMP, PDF and DOC formats are accepted,
     * and file must be less than about 7MB.
     *
     * @param binaryData Bytes of the image file
     * @throws Exception
     */
    void uploadLogo(byte[] binaryData) throws Exception;

    /**
     * Upload a logo for client.
     * Only GIF, PNG, JPG, JPEG, BMP, PDF and DOC formats are accepted,
     * and file must be less than about 7MB.
     *
     * @param filePath File path of the image to upload
     * @throws Exception
     */
    void uploadLogo(String filePath) throws Exception;

    /**
     * View your client wallets. To see your fees or credit wallets
     * for each currency set the {@code fundsType} parameter.
     *
     * @param fundsType  One of {@link FundsType}s
     * @param pagination Pagination object
     * @return List of current user's wallets
     * @throws Exception
     */
    List<Wallet> getWallets(FundsType fundsType, Pagination pagination) throws Exception;

    /**
     * View one of your client wallets (fees or credit) with a particular currency.
     *
     * @param fundsType One of {@link FundsType}s
     * @param currency  The particular {@link CurrencyIso}
     * @return Wallet (fees or credit) in the specified currency
     * @throws Exception
     */
    Wallet getWallet(FundsType fundsType, CurrencyIso currency) throws Exception;

    /**
     * View the transactions linked to your client wallets (fees and credit)
     *
     * @param fundsType  One of {@link FundsType}s
     * @param currency   The {@link CurrencyIso} in which to convert results
     * @param pagination Pagination object
     * @param filter     Filtering object
     * @param sort       Sorting object
     * @return Matching transactions linked to your client wallets (fees and credit)
     * @throws Exception
     */
    List<Transaction> getWalletTransactions(FundsType fundsType, CurrencyIso currency, Pagination pagination, FilterTransactions filter, Sorting sort) throws Exception;

    /**
     * View all transactions linked to your client wallets.
     *
     * @param pagination Pagination object
     * @param filter     Filtering object
     * @param sort       Sorting object
     * @return Paginated response comprising current user's transactions
     * @throws Exception
     */
    List<Transaction> getTransactions(Pagination pagination, FilterTransactions filter, Sorting sort) throws Exception;

    /**
     * Request processing of a payment by bank wire. The workflow is the following:q
     * <ul><li>
     * Call the /payins/bankwire/direct object. You’ll receive MANGOPAY bank account details and a reference.
     * </li><li>
     * Display this information to your user
     * </li><li>
     * The user has to proceed a Bank wire to the display bank account with the reference
     * </li><li>
     * Once MANGOPAY receive the payment the e-money is created and the targeted e-wallet is credited
     * </li>
     * </ul>
     *
     * @param bankWireDirect The Bank Wire Direct details
     * @return PayIn generated for the Bank Wire payment.
     * @throws Exception
     */
    PayIn createBankWireDirect(ClientBankWireDirect bankWireDirect) throws Exception;

    /**
     * Request processing of a payment by bank wire. The workflow is the following:q
     * <ul><li>
     * Call the /payins/bankwire/direct object. You’ll receive MANGOPAY bank account details and a reference.
     * </li><li>
     * Display this information to your user
     * </li><li>
     * The user has to proceed a Bank wire to the display bank account with the reference
     * </li><li>
     * Once MANGOPAY receive the payment the e-money is created and the targeted e-wallet is credited
     * </li>
     * </ul>
     *
     * @param idempotencyKey Idempotency key
     * @param bankWireDirect The Bank Wire Direct details
     * @return PayIn generated for the Bank Wire payment.
     * @throws Exception
     */
    PayIn createBankWireDirect(String idempotencyKey, ClientBankWireDirect bankWireDirect) throws Exception;

    BankAccount createBankAccountIBAN(BankAccount bankAccountIBAN) throws Exception;

    BankAccount createBankAccountIBAN(String idempotencyKey, BankAccount bankAccountIBAN) throws Exception;

    PayOut createPayOut(String idempotencyKey, PayOut payOut) throws Exception;

    PayOut createPayOut(PayOut payOut) throws Exception;

}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/RequestType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Request type enumeration.
 */
public enum RequestType {    
    GET,
    POST,
    PUT,
    DELETE
}


<|start_filename|>src/main/java/com/mangopay/entities/CardRegistration.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.EntityBase;
import com.mangopay.core.enumerations.CardType;
import com.mangopay.core.enumerations.CurrencyIso;

import java.util.ArrayList;

/**
 * CardRegistration entity.
 */
public class CardRegistration extends EntityBase {

    /**
     * User Id.
     */
    @SerializedName("UserId")
    private String userId;

    /**
     * Access key.
     */
    @SerializedName("AccessKey")
    private String accessKey;

    /**
     * Pre-registration data.
     */
    @SerializedName("PreregistrationData")
    private String preregistrationData;

    /**
     * Card registration URL.
     */
    @SerializedName("CardRegistrationURL")
    private String cardRegistrationUrl;

    /**
     * Card identifier.
     */
    @SerializedName("CardId")
    private String cardId;

    /**
     * Card registration data.
     */
    @SerializedName("RegistrationData")
    private String registrationData;

    /**
     * Result code.
     */
    @SerializedName("ResultCode")
    private String resultCode;

    /**
     * Currency.
     */
    @SerializedName("Currency")
    private CurrencyIso currency;

    /**
     * Status.
     */
    @SerializedName("Status")
    private String status;

    /**
     * Card type.
     */
    @SerializedName("CardType")
    private CardType cardType;

    public CardRegistration() {
        this.cardType = CardType.CB_VISA_MASTERCARD;
    }

    public CardRegistration(CardType cardType) {
        this.cardType = cardType;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getAccessKey() {
        return accessKey;
    }

    public void setAccessKey(String accessKey) {
        this.accessKey = accessKey;
    }

    public String getPreregistrationData() {
        return preregistrationData;
    }

    public void setPreregistrationData(String preregistrationData) {
        this.preregistrationData = preregistrationData;
    }

    public String getCardRegistrationUrl() {
        return cardRegistrationUrl;
    }

    public void setCardRegistrationUrl(String cardRegistrationUrl) {
        this.cardRegistrationUrl = cardRegistrationUrl;
    }

    public String getCardId() {
        return cardId;
    }

    public void setCardId(String cardId) {
        this.cardId = cardId;
    }

    public String getRegistrationData() {
        return registrationData;
    }

    public void setRegistrationData(String registrationData) {
        this.registrationData = registrationData;
    }

    public String getResultCode() {
        return resultCode;
    }

    public void setResultCode(String resultCode) {
        this.resultCode = resultCode;
    }

    public CurrencyIso getCurrency() {
        return currency;
    }

    public void setCurrency(CurrencyIso currency) {
        this.currency = currency;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public CardType getCardType() {
        return cardType;
    }

    public void setCardType(CardType cardType) {
        this.cardType = cardType;
    }

    /**
     * Gets the collection of read-only fields names.
     *
     * @return List of field names.
     */
    @Override
    public ArrayList<String> getReadOnlyProperties() {

        ArrayList<String> result = super.getReadOnlyProperties();

        result.add("AccessKey");
        result.add("PreregistrationData");
        result.add("CardRegistrationURL");
        result.add("CardId");
        result.add("ResultCode");
        result.add("Status");

        return result;
    }

}


<|start_filename|>src/test/java/com/mangopay/core/UboDeclarationApiImplTest.java<|end_filename|>
package com.mangopay.core;

import com.mangopay.core.enumerations.CountryIso;
import com.mangopay.core.enumerations.UboDeclarationStatus;
import com.mangopay.entities.Ubo;
import com.mangopay.entities.UboDeclaration;
import com.mangopay.entities.UserLegal;
import org.junit.Test;

import java.util.Calendar;
import java.util.List;

import static org.junit.Assert.*;

/**
 * UboDeclarationApiImpl test methods.
 */
public class UboDeclarationApiImplTest extends BaseTest {

    @Test
    public void createUboDeclaration() throws Exception {
        UboDeclaration uboDeclaration=this.getMatrixUboDeclaration();

        assertNotNull(uboDeclaration);
        assertEquals(UboDeclarationStatus.CREATED,uboDeclaration.getStatus());
        assertNotNull(uboDeclaration.getId());
    }

    @Test
    public void getUboDeclarationList() throws Exception {
        UboDeclaration uboDeclaration=this.getMatrixUboDeclaration();
        UserLegal matrix=this.getMatrix();
        List<UboDeclaration> declarations=this.api.getUboDeclarationApi().getAll(matrix.getId(),null,null);

        assertNotNull(declarations);
        assertTrue(!declarations.isEmpty());
        assertEquals(1,declarations.size());
        assertEquals(uboDeclaration.getId(),declarations.get(0).getId());
    }

    @Test
    public void getUboDeclaration() throws Exception {
        UboDeclaration uboDeclaration=this.getMatrixUboDeclaration();
        UserLegal matrix=this.getMatrix();

        UboDeclaration declarationFromApi=this.api.getUboDeclarationApi().get(matrix.getId(),uboDeclaration.getId());

        assertNotNull(declarationFromApi);
        assertEquals(uboDeclaration.getId(),declarationFromApi.getId());
    }

    @Test
    public void createUbo() throws Exception {
        Ubo ubo=this.createNewUboForMatrix();
        UserLegal matrix = this.getMatrix();
        UboDeclaration uboDeclaration = this.getMatrixUboDeclaration();
        Ubo newUbo = api.getUboDeclarationApi().createUbo(matrix.getId(), uboDeclaration.getId(), ubo);

        assertNotNull(newUbo);
        assertNotNull(newUbo.getId());
        assertEquals(ubo.getFirstName(),newUbo.getFirstName());
        assertEquals(ubo.getLastName(), newUbo.getLastName());
        assertEquals(ubo.getAddress().getAddressLine1(), newUbo.getAddress().getAddressLine1());
        assertEquals(ubo.getNationality(), newUbo.getNationality());
        assertEquals(ubo.getBirthday(),newUbo.getBirthday());
        assertEquals(ubo.getBirthplace().getCity(), newUbo.getBirthplace().getCity());
    }

    @Test
    public void updateUbo() throws Exception {
        UserLegal matrix=this.getMatrix();
        UboDeclaration uboDeclaration=this.getMatrixUboDeclaration();
        Calendar calendar=Calendar.getInstance();
        calendar.set(1991,12,21,0,0,0);

        Ubo toBeUpdated = this.getMatrixUbo();
        toBeUpdated.setFirstName("UpdatedFirstName");
        toBeUpdated.setLastName("UpdatedLastName");
        toBeUpdated.getAddress().setAddressLine1("UpdatedLine1");
        toBeUpdated.setNationality(CountryIso.GB);
        toBeUpdated.setBirthday(calendar.getTimeInMillis()/1000);
        toBeUpdated.getBirthplace().setCountry(CountryIso.GB);
        toBeUpdated.setActive(true);

        Ubo ubo=this.api.getUboDeclarationApi().updateUbo(matrix.getId(),uboDeclaration.getId(),toBeUpdated);

        assertEquals(toBeUpdated.getFirstName(),ubo.getFirstName());
        assertEquals(toBeUpdated.getLastName(),ubo.getLastName());
        assertEquals(toBeUpdated.getAddress().getAddressLine1(), ubo.getAddress().getAddressLine1());
        assertEquals(toBeUpdated.getNationality(),ubo.getNationality());
        assertEquals(toBeUpdated.getBirthday(),ubo.getBirthday());
        assertEquals(toBeUpdated.getBirthplace().getCity(), ubo.getBirthplace().getCity());
        assertEquals(toBeUpdated.getActive(), ubo.getActive());
        assertTrue(ubo.getActive());
    }

    @Test
    public void getUbo() throws Exception {
        UserLegal matrix=this.getMatrix();
        UboDeclaration uboDeclaration=this.getMatrixUboDeclaration();
        Ubo existingUbo=this.getMatrixUbo();

        UboDeclaration declaration=this.api.getUboDeclarationApi().get(matrix.getId(),uboDeclaration.getId());

        Ubo fetchedUbo=this.api.getUboDeclarationApi().getUbo(matrix.getId(),uboDeclaration.getId(),existingUbo.getId());

        assertNotNull(fetchedUbo);
        assertEquals(existingUbo.getFirstName(),fetchedUbo.getFirstName());
        assertEquals(existingUbo.getLastName(),fetchedUbo.getLastName());
        assertEquals(existingUbo.getAddress().getAddressLine1(), fetchedUbo.getAddress().getAddressLine1());
        assertEquals(existingUbo.getNationality(),fetchedUbo.getNationality());
        assertEquals(existingUbo.getBirthday(), fetchedUbo.getBirthday());
        assertEquals(existingUbo.getBirthplace().getCity(), fetchedUbo.getBirthplace().getCity());
    }
    
    @Test
    public void submitUboDeclaration() throws Exception{
        UserLegal matrix=this.getMatrix();
        UboDeclaration uboDeclaration=this.getMatrixUboDeclaration();
        UboDeclaration declaration=this.api.getUboDeclarationApi().get(matrix.getId(),uboDeclaration.getId());
        
        UboDeclaration submittedUboDeclaration = this.api.getUboDeclarationApi().submitForValidation(matrix.getId(),uboDeclaration.getId());
        
        assertNotNull(submittedUboDeclaration);
        assertEquals(UboDeclarationStatus.VALIDATION_ASKED,submittedUboDeclaration.getStatus());
        assertNotNull(submittedUboDeclaration.getId());
    }

    @Test
    public void getUboDeclarationById() throws Exception{
        UboDeclaration createdUboDeclaration=this.getMatrixUboDeclaration();

        UboDeclaration uboDeclaration=this.api.getUboDeclarationApi().get(createdUboDeclaration.getId());

        assertNotNull(uboDeclaration);
        assertEquals(createdUboDeclaration.getId(),uboDeclaration.getId());
    }
}


<|start_filename|>src/test/java/com/mangopay/entities/subentities/PayOutPaymentDetailsBankWireTest.java<|end_filename|>
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mangopay.entities.subentities;

import com.mangopay.core.interfaces.PayOutPaymentDetails;
import org.junit.*;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

/**
 * @author <NAME> <EMAIL>
 */
public class PayOutPaymentDetailsBankWireTest {

    public PayOutPaymentDetailsBankWireTest() {
    }

    @BeforeClass
    public static void setUpClass() {
    }

    @AfterClass
    public static void tearDownClass() {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of build method, of class PayOutPaymentDetailsBankWire.
     */
    @Test
    public void testBuild_String() {
        String bankAccountId = "12345678";
        PayOutPaymentDetailsBankWire detailsBankWire = PayOutPaymentDetailsBankWire.build(bankAccountId);
        assertNotNull(detailsBankWire);
        assertEquals(bankAccountId, detailsBankWire.getBankAccountId());
    }

    /**
     * Test of build method, of class PayOutPaymentDetailsBankWire.
     */
    @Test
    public void testBuild_String_String() {
        String bankAccountId = "12345678";
        String bankWireRef = "WireRef";
        PayOutPaymentDetailsBankWire detailsBankWire = PayOutPaymentDetailsBankWire.build(bankAccountId, bankWireRef);
        assertNotNull(detailsBankWire);
        assertEquals(bankAccountId, detailsBankWire.getBankAccountId());
        assertEquals(bankWireRef, detailsBankWire.getBankWireRef());
    }


    @Test
    public void testConvert() throws Exception {
        PayOutPaymentDetailsBankWire payOutPaymentDetailsBankWire = new PayOutPaymentDetailsBankWire();
        assertNotNull(payOutPaymentDetailsBankWire);
        PayOutPaymentDetails payOutPaymentDetails = payOutPaymentDetailsBankWire;
        assertNotNull(payOutPaymentDetails);
        payOutPaymentDetailsBankWire = PayOutPaymentDetailsBankWire.convert(payOutPaymentDetails);
        assertNotNull(payOutPaymentDetailsBankWire);
    }

}


<|start_filename|>src/main/java/com/mangopay/entities/IdempotencyResponse.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.EntityBase;

/**
 * IdempotencyResponse entity.
 */
public class IdempotencyResponse extends EntityBase {

    @SerializedName("StatusCode")
    private String statusCode;

    @SerializedName("ContentLength")
    private String contentLength;

    @SerializedName("ContentType")
    private String contentType;

    @SerializedName("Date")
    private String date;

    @SerializedName("Resource")
    private Object resource;

    @SerializedName("RequestURL")
    private String requestUrl;

    public String getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(String statusCode) {
        this.statusCode = statusCode;
    }

    public String getContentLength() {
        return contentLength;
    }

    public void setContentLength(String contentLength) {
        this.contentLength = contentLength;
    }

    public String getContentType() {
        return contentType;
    }

    public void setContentType(String contentType) {
        this.contentType = contentType;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public Object getResource() {
        return resource;
    }

    public void setResource(Object resource) {
        this.resource = resource;
    }

    public String getRequestUrl() {
        return requestUrl;
    }

    public void setRequestUrl(String requestUrl) {
        this.requestUrl = requestUrl;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/implementation/PayInApiImpl.java<|end_filename|>
package com.mangopay.core.APIs.implementation;

import com.google.gson.GsonBuilder;
import com.mangopay.MangoPayApi;
import com.mangopay.core.APIs.ApiBase;
import com.mangopay.core.APIs.PayInApi;
import com.mangopay.core.Pagination;
import com.mangopay.core.Sorting;
import com.mangopay.core.deserializer.PayInDeserializer;
import com.mangopay.core.deserializer.RecurringPayInDeserializer;
import com.mangopay.core.serializer.PayInSerializer;
import com.mangopay.entities.*;

import java.util.List;

/**
 * API for payIns.
 */
public class PayInApiImpl extends ApiBase implements PayInApi {

    /**
     * Instantiates new PayInApiImpl object.
     *
     * @param root Root/parent instance that holds the OAuthToken and Configuration instance.
     */
    public PayInApiImpl(MangoPayApi root, GsonBuilder gsonBuilder) {
        super(root);

        gsonBuilder.registerTypeAdapter(PayIn.class, new PayInSerializer());
        gsonBuilder.registerTypeAdapter(PayIn.class, new PayInDeserializer());
        gsonBuilder.registerTypeAdapter(RecurringPayIn.class, new RecurringPayInDeserializer());
    }

    @Override
    public PayIn create(PayIn payIn) throws Exception {
        return this.create(null, payIn);
    }

    @Override
    public PayIn create(String idempotencyKey, PayIn payIn) throws Exception {
        String paymentKey = this.getPaymentKey(payIn);
        String executionKey = this.getExecutionKey(payIn);
        return this.createObject(PayIn.class, idempotencyKey, String.format("payins_%s-%s_create", paymentKey, executionKey), payIn);
    }

    @Override
    public RecurringPayment createRecurringPayment(String idempotencyKey, CreateRecurringPayment createRecurringPayment) throws Exception {
        return this.createObject(RecurringPayment.class, idempotencyKey, "payins_recurring_registration", createRecurringPayment);
    }

    @Override
    public RecurringPaymentExtended getRecurringPayment(String payInId) throws Exception {
        return this.getObject(RecurringPaymentExtended.class, "payins_recurring_registration_get", payInId);
    }

    @Override
    public RecurringPaymentExtended updateRecurringPayment(String payInId, RecurringPaymentUpdate payIn) throws Exception {
        return this.updateObject(RecurringPaymentExtended.class, "payins_recurring_registration_put", payIn, payInId);
    }

    @Override
    public RecurringPayIn createRecurringPayInCIT(String idempotencyKey, RecurringPayInCIT cit) throws Exception {
        return this.createObject(RecurringPayIn.class, idempotencyKey, "payins_recurring_card_direct", cit);
    }

    @Override
    public RecurringPayIn createRecurringPayInMIT(String idempotencyKey, RecurringPayInMIT mit) throws Exception {
        return this.createObject(RecurringPayIn.class, idempotencyKey, "payins_recurring_card_direct", mit);
    }

    @Override
    public PayIn get(String payInId) throws Exception {
        return this.getObject(PayIn.class, "payins_get", payInId);
    }

    @Override
    public Refund createRefund(String payInId, Refund refund) throws Exception {
        return this.createRefund(null, payInId, refund);
    }

    @Override
    public Refund createRefund(String idempotencyKey, String payInId, Refund refund) throws Exception {
        return this.createObject(Refund.class, idempotencyKey, "payins_createrefunds", refund, payInId);
    }

    @Override
    public Refund getRefund(String payInId) throws Exception {
        return this.getObject(Refund.class, "payins_getrefunds", payInId);
    }

    @Override
    public List<Refund> getRefunds(String payInId) throws Exception {
        return this.getRefunds(payInId, null, null);
    }

    @Override
    public List<Refund> getRefunds(String payInId, Pagination pagination, Sorting sorting) throws Exception {
        return this.getList(Refund[].class, Refund.class, "payin_get_refunds", pagination, payInId, sorting);
    }

    private String getPaymentKey(PayIn payIn) throws Exception {

        if (payIn.getPaymentDetails() == null)
            throw new Exception("Payment is not defined or it is not object type");

        String className = payIn.getPaymentDetails().getClass().getSimpleName().replace("PayInPaymentDetails", "");
        return className.toLowerCase();
    }

    private String getExecutionKey(PayIn payIn) throws Exception {

        if (payIn.getExecutionDetails() != null) {
            String className = payIn.getExecutionDetails().getClass().getSimpleName().replace("PayInExecutionDetails", "");
            return className.toLowerCase();
        }
        if (payIn.getExecutionType() != null) {
            return payIn.getExecutionType().toString().toLowerCase();
        }
        throw new Exception("Execution is not defined or it is not object type");
    }
}


<|start_filename|>src/test/java/com/mangopay/core/CardRegistrationApiImplTest.java<|end_filename|>
package com.mangopay.core;

import com.mangopay.core.enumerations.*;
import com.mangopay.entities.CardRegistration;
import com.mangopay.entities.UserNatural;
import org.junit.Test;

import static org.junit.Assert.*;

/**
 * CardRegistrationApiImpl test methods.
 */
public class CardRegistrationApiImplTest extends BaseTest {

    @Test
    public void createCardRegistration() throws Exception {
        CardRegistration cardRegistration_visa = this.getJohnsCardRegistration(CardType.CB_VISA_MASTERCARD);
        UserNatural user = this.getJohn();

        assertNotNull(cardRegistration_visa.getId());
        assertTrue(cardRegistration_visa.getId().length() > 0);

        assertNotNull(cardRegistration_visa.getAccessKey());
        assertNotNull(cardRegistration_visa.getPreregistrationData());
        assertNotNull(cardRegistration_visa.getCardRegistrationUrl());
        assertEquals(user.getId(), cardRegistration_visa.getUserId());
        assertTrue(cardRegistration_visa.getCurrency() == CurrencyIso.EUR);
        assertEquals("CREATED", cardRegistration_visa.getStatus());
        assertEquals(CardType.CB_VISA_MASTERCARD, cardRegistration_visa.getCardType());


        CardRegistration cardRegistration_maestro = this.getNewJohnsCardRegistration(CardType.MAESTRO);

        assertNotNull(cardRegistration_maestro.getId());
        assertTrue(cardRegistration_maestro.getId().length() > 0);

        assertNotNull(cardRegistration_maestro.getAccessKey());
        assertNotNull(cardRegistration_maestro.getPreregistrationData());
        assertNotNull(cardRegistration_maestro.getCardRegistrationUrl());
        assertEquals(user.getId(), cardRegistration_maestro.getUserId());
        assertTrue(cardRegistration_maestro.getCurrency() == CurrencyIso.EUR);
        assertEquals("CREATED", cardRegistration_maestro.getStatus());
        assertEquals(CardType.MAESTRO, cardRegistration_maestro.getCardType());
    }

    @Test
    public void getCardRegistration() throws Exception {
        CardRegistration cardRegistration = this.getJohnsCardRegistration();

        CardRegistration getCardRegistration = this.api.getCardRegistrationApi().get(cardRegistration.getId());

        assertTrue(getCardRegistration.getId().length() > 0);
        assertEquals(cardRegistration.getId(), getCardRegistration.getId());
    }

    @Test
    public void updateCardRegistration() throws Exception {
        CardRegistration cardRegistration = this.getJohnsCardRegistration();
        String registrationData = this.getPaylineCorrectRegistartionData(cardRegistration);
        cardRegistration.setRegistrationData(registrationData);

        CardRegistration getCardRegistration = this.api.getCardRegistrationApi().update(cardRegistration);

        assertEquals(registrationData, getCardRegistration.getRegistrationData());
        assertNotNull(getCardRegistration.getCardId());
        assertEquals("VALIDATED", getCardRegistration.getStatus());
        assertEquals("000000", getCardRegistration.getResultCode());
    }

}


<|start_filename|>src/main/java/com/mangopay/core/FilterReports.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.enumerations.CurrencyIso;
import com.mangopay.core.enumerations.TransactionNature;
import com.mangopay.core.enumerations.TransactionStatus;
import com.mangopay.core.enumerations.TransactionType;

import java.util.ArrayList;
import java.util.List;

/**
 * Filter for report.
 */
public class FilterReports extends Dto {

    public FilterReports() {
        resultCode = new ArrayList<>();
    }

    /*
     * Common
     */

    @SerializedName("BeforeDate")
    private Long beforeDate;

    @SerializedName("AfterDate")
    private Long afterDate;

    /*
     * Transactions Report
     */

    @SerializedName("Status")
    private List<TransactionStatus> status;

    @SerializedName("Type")
    private List<TransactionType> type;

    @SerializedName("Nature")
    private List<TransactionNature> nature;

    @SerializedName("ResultCode")
    private List<String> resultCode;

    @SerializedName("AuthorId")
    private String authorId;

    @SerializedName("WalletId")
    private String walletId;

    @SerializedName("MinDebitedFundsAmount")
    private Integer minDebitedFundsAmount;

    @SerializedName("MinDebitedFundsCurrency")
    private CurrencyIso minDebitedFundsCurrency;

    @SerializedName("MaxDebitedFundsAmount")
    private Integer maxDebitedFundsAmount;

    @SerializedName("MaxDebitedFundsCurrency")
    private CurrencyIso maxDebitedFundsCurrency;
  
    @SerializedName("MinFeesAmount")
    private Integer minFeesAmount;

    @SerializedName("MinFeesCurrency")
    private CurrencyIso minFeesCurrency;

    @SerializedName("MaxFeesAmount")
    private Integer maxFeesAmount;

    @SerializedName("MaxFeesCurrency")
    private CurrencyIso maxFeesCurrency;

    /*
    * Wallets Report
    */

    /**
     * The ID of the wallet owner requesting the report.
     */
    @SerializedName("OwnerId")
    private String ownerId;

    /**
     * The currency used in the report.
     */
    @SerializedName("Currency")
    private CurrencyIso currency;

    /**
     * The minimum balance amount of the wallets taken into consideration.
     */
    @SerializedName("MinBalanceAmount")
    private int minBalanceAmount;

    /**
     * The currency of the {@link #minBalanceAmount} filter.
     */
    @SerializedName("MinBalanceCurrency")
    private CurrencyIso minBalanceCurrency;

    /**
     * The maximum balance amount of the wallets taken into consideration.
     */
    @SerializedName("MaxBalanceAmount")
    private int maxBalanceAmount;

    /**
     * The currency of the {@link #maxBalanceAmount} filter.
     */
    @SerializedName("MaxBalanceCurrency")
    private CurrencyIso maxBalanceCurrency;


    public List<TransactionStatus> getStatus() {
        return status;
    }

    public void setStatus(List<TransactionStatus> status) {
        this.status = status;
    }

    public List<TransactionType> getType() {
        return type;
    }

    public void setType(List<TransactionType> type) {
        this.type = type;
    }

    public List<TransactionNature> getNature() {
        return nature;
    }

    public void setNature(List<TransactionNature> nature) {
        this.nature = nature;
    }

    public Long getBeforeDate() {
        return beforeDate;
    }

    public void setBeforeDate(Long beforeDate) {
        this.beforeDate = beforeDate;
    }

    public Long getAfterDate() {
        return afterDate;
    }

    public void setAfterDate(Long afterDate) {
        this.afterDate = afterDate;
    }

    public List<String> getResultCode() {
        return resultCode;
    }

    public void setResultCode(List<String> resultCode) {
        this.resultCode = resultCode;
    }

    public String getAuthorId() {
        return authorId;
    }

    public void setAuthorId(String authorId) {
        this.authorId = authorId;
    }

    public String getWalletId() {
        return walletId;
    }

    public void setWalletId(String walletId) {
        this.walletId = walletId;
    }

    public Integer getMinDebitedFundsAmount() {
        return minDebitedFundsAmount;
    }

    public void setMinDebitedFundsAmount(Integer minDebitedFundsAmount) {
        this.minDebitedFundsAmount = minDebitedFundsAmount;
    }

    public CurrencyIso getMinDebitedFundsCurrency() {
        return minDebitedFundsCurrency;
    }

    public void setMinDebitedFundsCurrency(CurrencyIso minDebitedFundsCurrency) {
        this.minDebitedFundsCurrency = minDebitedFundsCurrency;
    }

    public Integer getMaxDebitedFundsAmount() {
        return maxDebitedFundsAmount;
    }

    public void setMaxDebitedFundsAmount(Integer maxDebitedFundsAmount) {
        this.maxDebitedFundsAmount = maxDebitedFundsAmount;
    }

    public CurrencyIso getMaxDebitedFundsCurrency() {
        return maxDebitedFundsCurrency;
    }

    public void setMaxDebitedFundsCurrency(CurrencyIso maxDebitedFundsCurrency) {
        this.maxDebitedFundsCurrency = maxDebitedFundsCurrency;
    }

    public String getOwnerId() {
        return ownerId;
    }

    public void setOwnerId(String ownerId) {
        this.ownerId = ownerId;
    }

    public CurrencyIso getCurrency() {
        return currency;
    }

    public void setCurrency(CurrencyIso currency) {
        this.currency = currency;
    }

    public int getMinBalanceAmount() {
        return minBalanceAmount;
    }

    public void setMinBalanceAmount(int minBalanceAmount) {
        this.minBalanceAmount = minBalanceAmount;
    }

    public CurrencyIso getMinBalanceCurrency() {
        return minBalanceCurrency;
    }

    public void setMinBalanceCurrency(CurrencyIso minBalanceCurrency) {
        this.minBalanceCurrency = minBalanceCurrency;
    }

    public int getMaxBalanceAmount() {
        return maxBalanceAmount;
    }

    public void setMaxBalanceAmount(int maxBalanceAmount) {
        this.maxBalanceAmount = maxBalanceAmount;
    }

    public CurrencyIso getMaxBalanceCurrency() {
        return maxBalanceCurrency;
    }

    public void setMaxBalanceCurrency(CurrencyIso maxBalanceCurrency) {
        this.maxBalanceCurrency = maxBalanceCurrency;
    }
      
    public Integer getMinFeesAmount() {
        return minFeesAmount;
    }

    public void setMinFeesAmount(Integer minFeesAmount) {
        this.minFeesAmount = minFeesAmount;
    }

    public CurrencyIso getMinFeesCurrency() {
        return minFeesCurrency;
    }

    public void setMinFeesCurrency(CurrencyIso minFeesCurrency) {
        this.minFeesCurrency = minFeesCurrency;
    }

    public Integer getMaxFeesAmount() {
        return maxFeesAmount;
    }

    public void setMaxFeesAmount(Integer maxFeesAmount) {
        this.maxFeesAmount = maxFeesAmount;
    }

    public CurrencyIso getMaxFeesCurrency() {
        return maxFeesCurrency;
    }

    public void setMaxFeesCurrency(CurrencyIso maxFeesCurrency) {
        this.maxFeesCurrency = maxFeesCurrency;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/implementation/IdempotencyApiImpl.java<|end_filename|>
package com.mangopay.core.APIs.implementation;

import com.google.gson.GsonBuilder;
import com.mangopay.MangoPayApi;
import com.mangopay.core.APIs.ApiBase;
import com.mangopay.core.APIs.IdempotencyApi;
import com.mangopay.core.deserializer.PayOutDeserializer;
import com.mangopay.core.serializer.PayOutSerializer;
import com.mangopay.entities.*;

import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * API for idempotency.
 */
public class IdempotencyApiImpl extends ApiBase implements IdempotencyApi {
    /**
     * Instantiates new IdempotencyApiImpl object.
     *
     * @param root Root/parent instance that holds the OAuthToken and Configuration instance.
     */
    public IdempotencyApiImpl(MangoPayApi root, GsonBuilder gsonBuilder) {
        super(root);

        gsonBuilder.registerTypeAdapter(PayOut.class, new PayOutSerializer());
        gsonBuilder.registerTypeAdapter(PayOut.class, new PayOutDeserializer());
    }

    @Override
    public IdempotencyResponse get(String idempotencyKey) throws Exception {
        IdempotencyResponse response = this.getObject(IdempotencyResponse.class, "idempotency_response_get", idempotencyKey);

        instantiateResourceObject(response);

        return response;
    }

    private void instantiateResourceObject(IdempotencyResponse response) throws Exception {
        Class<?> targetType = null;
        Map<String, Class<?>> map = getMapForResource();

        for (Map.Entry<String, Class<?>> entry : map.entrySet()) {
            //Class<? extends Object> value = entry.getValue();

            String sourceUrl = super.getRequestUrl(entry.getKey());
            sourceUrl = String.format(sourceUrl, "[0-9a-zA-Z]+", "[0-9a-zA-Z]+");
            sourceUrl = sourceUrl.replace("/", "\\/");

            Pattern ex = Pattern.compile(sourceUrl);
            Matcher matcher = ex.matcher(response.getRequestUrl());
            if (matcher.find()) {
                targetType = entry.getValue();
                break;
            }
        }

        if (targetType == null)
            return;

        response.setResource(root.getGson().fromJson(root.getGson().toJson(response.getResource()), targetType));
    }

    private Map<String, Class<?>> getMapForResource() {
        return new HashMap<String, Class<?>>() {{
            put("preauthorization_create", CardPreAuthorization.class);
            put("hooks_create", Hook.class);
            put("cardregistration_create", CardRegistration.class);
            put("payins_card-web_create", PayIn.class);
            put("payins_card-direct_create", PayIn.class);
            put("payins_createrefunds", Refund.class);
            put("payins_preauthorized-direct_create", PayIn.class);
            put("payins_bankwire-direct_create", PayIn.class);
            put("payins_directdebit-web_create", PayIn.class);
            put("payins_directdebit-direct_create", PayIn.class);
            put("payouts_bankwire_create", PayOut.class);
            put("payouts_bankwire_get", PayOut.class);
            put("transfers_createrefunds", Refund.class);
            put("transfers_create", Transfer.class);
            put("users_createnaturals", UserNatural.class);
            put("users_createlegals", UserLegal.class);
            put("users_createkycdocument", KycDocument.class);
            put("users_createbankaccounts_iban", BankAccount.class);
            put("users_createbankaccounts_gb", BankAccount.class);
            put("users_createbankaccounts_us", BankAccount.class);
            put("users_createbankaccounts_ca", BankAccount.class);
            put("users_createbankaccounts_other", BankAccount.class);
            put("wallets_create", Wallet.class);
            put("disputes_document_create", DisputeDocument.class);
            put("disputes_repudiation_create_settlement", SettlementTransfer.class);
            put("mandate_create", Mandate.class);
            put("client_create_bankwire_direct", PayIn.class);
            put("banking_alias_create_iban", BankingAlias.class);
        }};
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/UboDeclarationStatus.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * UBO declaration status enumeration.
 */
public enum UboDeclarationStatus {

    /**
     * When the UBO declaration was created
     */
    CREATED,

    /**
     * When validation has been requested for the UBO declaration
     */
    VALIDATION_ASKED,

    /**
     * When the UBO declaration was validated
     */
    VALIDATED,

    /**
     * When the UBO declaration was refused
     */
    REFUSED,

    /**
     * When the UBO declaration was incomplete
     */
    INCOMPLETE
}


<|start_filename|>src/main/java/com/mangopay/entities/subentities/PayInPaymentDetailsBankWire.java<|end_filename|>
package com.mangopay.entities.subentities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Dto;
import com.mangopay.core.Money;
import com.mangopay.core.interfaces.PayInPaymentDetails;
import com.mangopay.entities.BankAccount;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;

/**
 * Class representing the BankWire type for mean of payment in PayIn entity.
 */
public class PayInPaymentDetailsBankWire extends Dto implements PayInPaymentDetails {

    /**
     * Declared debited funds.
     */
    @SerializedName("DeclaredDebitedFunds")
    private Money declaredDebitedFunds;

    /**
     * Declared fees.
     */
    @SerializedName("DeclaredFees")
    private Money declaredFees;

    /**
     * Bank account details.
     */
    @SerializedName("BankAccount")
    private BankAccount bankAccount;

    /**
     * Wire reference.
     */
    @SerializedName("WireReference")
    private String wireReference;

    public PayInPaymentDetailsBankWire(Money declaredDebitedFunds, Money declaredFees, BankAccount bankAccount, String wireReference) {
        this.declaredDebitedFunds = declaredDebitedFunds;
        this.declaredFees = declaredFees;
        this.bankAccount = bankAccount;
        this.wireReference = wireReference;
    }

    public PayInPaymentDetailsBankWire() {
    }

    public Money getDeclaredDebitedFunds() {
        return declaredDebitedFunds;
    }

    public void setDeclaredDebitedFunds(Money declaredDebitedFunds) {
        this.declaredDebitedFunds = declaredDebitedFunds;
    }

    public Money getDeclaredFees() {
        return declaredFees;
    }

    public void setDeclaredFees(Money declaredFees) {
        this.declaredFees = declaredFees;
    }

    public BankAccount getBankAccount() {
        return bankAccount;
    }

    public void setBankAccount(BankAccount bankAccount) {
        this.bankAccount = bankAccount;
    }

    public String getWireReference() {
        return wireReference;
    }

    public void setWireReference(String wireReference) {
        this.wireReference = wireReference;
    }

    /**
     * Gets map which property is an object and what type of object.
     *
     * @return Collection of field name-field type pairs.
     */
    @Override
    public Map<String, Type> getSubObjects() {

        HashMap<String, Type> result = new HashMap<>();

        result.put("DeclaredDebitedFunds", Money.class);
        result.put("DeclaredFees", Money.class);
        result.put("BankAccount", BankAccount.class);

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/DepositAccountType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Deposit account type enumeration.
 */
public enum DepositAccountType {
    /**
     * Not specified.
     */
    NotSpecified,
    
    /**
     * CHECKING deposit account type.
     */
    CHECKING,
    
    /**
     * SAVINGS deposit account type.
     */
    SAVINGS
}


<|start_filename|>src/test/java/com/mangopay/MangoPayApiTest.java<|end_filename|>
package com.mangopay;

import com.mangopay.core.*;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 */
public class MangoPayApiTest extends BaseTest {
    
    @Test
    public void ApiAndUsersConstructionTest() {
        MangoPayApi mangoPayApi = new MangoPayApi();
        assertNotNull(mangoPayApi);
        assertNotNull(mangoPayApi.getUserApi());
    }
}

<|start_filename|>src/main/java/com/mangopay/core/interfaces/PayOutPaymentDetails.java<|end_filename|>
package com.mangopay.core.interfaces;

/**
 * Marker interface for classes with details of means of payment in PayOut entity.
 */
public interface PayOutPaymentDetails { }


<|start_filename|>src/main/java/com/mangopay/core/APIs/implementation/RefundApiImpl.java<|end_filename|>
package com.mangopay.core.APIs.implementation;

import com.mangopay.MangoPayApi;
import com.mangopay.core.APIs.ApiBase;
import com.mangopay.core.APIs.RefundApi;
import com.mangopay.entities.Refund;

/**
 * API for refunds.
 */
public class RefundApiImpl extends ApiBase implements RefundApi {

    /**
     * Instantiates new RefundApiImpl object.
     *
     * @param root Root/parent instance that holds the OAuthToken and Configuration instance.
     */
    public RefundApiImpl(MangoPayApi root) {
        super(root);
    }

    @Override
    public Refund get(String refundId) throws Exception {
        return this.getObject(Refund.class, "refunds_get", refundId);
    }

}


<|start_filename|>src/main/java/com/mangopay/entities/subentities/BankAccountDetailsCA.java<|end_filename|>
package com.mangopay.entities.subentities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Dto;
import com.mangopay.core.interfaces.BankAccountDetails;

/**
 * Class represents CA type of bank account.
 */
public class BankAccountDetailsCA extends Dto implements BankAccountDetails {

    /**
     * Bank name.
     */
    @SerializedName("BankName")
    private String bankName;

    /**
     * Institution number.
     */
    @SerializedName("InstitutionNumber")
    private String institutionNumber;

    /**
     * Branch code.
     */
    @SerializedName("BranchCode")
    private String branchCode;

    /**
     * Account number.
     */
    @SerializedName("AccountNumber")
    private String accountNumber;

    public String getBankName() {
        return bankName;
    }

    public void setBankName(String bankName) {
        this.bankName = bankName;
    }

    public String getInstitutionNumber() {
        return institutionNumber;
    }

    public void setInstitutionNumber(String institutionNumber) {
        this.institutionNumber = institutionNumber;
    }

    public String getBranchCode() {
        return branchCode;
    }

    public void setBranchCode(String branchCode) {
        this.branchCode = branchCode;
    }

    public String getAccountNumber() {
        return accountNumber;
    }

    public void setAccountNumber(String accountNumber) {
        this.accountNumber = accountNumber;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/CardRegistrationApi.java<|end_filename|>
package com.mangopay.core.APIs;

import com.mangopay.entities.CardRegistration;

/**
 * Created by thepa on 18-Jan-17.
 */
public interface CardRegistrationApi {
    /**
     * Creates new card registration.
     * @param cardRegistration Card registration object to create.
     * @return Card registration instance returned from API.
     * @throws Exception
     */
    CardRegistration create(CardRegistration cardRegistration) throws Exception;

    /**
     * Creates new card registration.
     * @param idempotencyKey    idempotency key for this request.
     * @param cardRegistration Card registration object to create.
     * @return Card registration instance returned from API.
     * @throws Exception
     */
    CardRegistration create(String idempotencyKey, CardRegistration cardRegistration) throws Exception;

    /**
     * Gets card registration.
     * @param cardRegistrationId Card Registration identifier.
     * @return Card registration instance returned from API.
     * @throws Exception
     */
    CardRegistration get(String cardRegistrationId) throws Exception;

    /**
     * Updates card registration.
     * @param cardRegistration Card registration object to be updated.
     * @return Card registration instance returned from API.
     * @throws Exception
     */
    CardRegistration update(CardRegistration cardRegistration) throws Exception;
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/RefundApi.java<|end_filename|>
package com.mangopay.core.APIs;

import com.mangopay.entities.Refund;

/**
 * Created by thepa on 18-Jan-17.
 */
public interface RefundApi {
    /**
     * Gets refund entity.
     *
     * @param refundId Refund identifier.
     * @return Refund entity instance returned from API.
     * @throws Exception
     */
    Refund get(String refundId) throws Exception;
}


<|start_filename|>src/main/java/com/mangopay/core/FilterKycDocuments.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.enumerations.KycDocumentType;
import com.mangopay.core.enumerations.KycStatus;

import java.util.HashMap;
import java.util.Map;

/**
 * Filter for KYC documents list.
 */
public class FilterKycDocuments {

    @SerializedName("Status")
    private KycStatus status;

    @SerializedName("Type")
    private KycDocumentType type;

    @SerializedName("BeforeDate")
    private Long beforeDate;

    @SerializedName("AfterDate")
    public Long afterDate;

    public KycStatus getStatus() {
        return status;
    }

    public void setStatus(KycStatus status) {
        this.status = status;
    }

    public KycDocumentType getType() {
        return type;
    }

    public void setType(KycDocumentType type) {
        this.type = type;
    }

    public Long getBeforeDate() {
        return beforeDate;
    }

    public void setBeforeDate(Long beforeDate) {
        this.beforeDate = beforeDate;
    }

    public Long getAfterDate() {
        return afterDate;
    }

    public void setAfterDate(Long afterDate) {
        this.afterDate = afterDate;
    }

    public Map<String, String> getValues() {
        HashMap<String, String> result = new HashMap();

        if (status != null && status != KycStatus.NotSpecified) result.put("status", status.toString());
        if (type != null && type != KycDocumentType.NotSpecified) result.put("type", type.toString());
        if (beforeDate != null) result.put("beforedate", beforeDate.toString());
        if (afterDate != null) result.put("afterdate", afterDate.toString());

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/KycLevel.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * KYC document level enumeration.
 */
public enum KycLevel {
    /**
     * Not specified.
     */
    NotSpecified,
    
    /**
     * LIGHT KYC level.
     */
    LIGHT,
    
    /**
     * REGULAR KYC level.
     */
    REGULAR
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/PersonType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Person type enumeration.
 */
public enum PersonType {
    /**
     * Not specified.
     */
    NotSpecified,

    /**
     * NATURAL user type.
     */
    NATURAL,
    
    /**
     * LEGAL user type.
     */
    LEGAL
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/PreAuthorizationStatus.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * PreAuthorization status enumeration.
 */
public enum PreAuthorizationStatus {
    /**
     * Not specified.
     */ 
    NotSpecified,

    /**
     * CREATED preauthorization status.
     */ 
    CREATED,

    /**
     * SUCCEEDED preauthorization status.
     */ 
    SUCCEEDED, 

    /**
     * FAILED preauthorization status.
     */ 
    FAILED
}


<|start_filename|>src/main/java/com/mangopay/core/FilterDisputes.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;

import java.util.HashMap;
import java.util.Map;

/**
 * Filter for disputes list.
 */
public class FilterDisputes extends Dto {

    /**
     * Start date in Unix format: return only disputes that have CreationDate BEFORE this date.
     */
    @SerializedName("BeforeDate")
    private Long beforeDate;

    /**
     * End date in Unix format: return only disputes that have CreationDate AFTER this date.
     */
    @SerializedName("AfterDate")
    private Long afterDate;

    public Long getBeforeDate() {
        return beforeDate;
    }

    public void setBeforeDate(Long beforeDate) {
        this.beforeDate = beforeDate;
    }

    public Long getAfterDate() {
        return afterDate;
    }

    public void setAfterDate(Long afterDate) {
        this.afterDate = afterDate;
    }

    /**
     * Gets map of fields and values.
     *
     * @return Collection of field name-field value pairs.
     */
    @Override
    public Map<String, String> getValues() {
        HashMap<String, String> result = new HashMap<>();

        if (beforeDate != null) result.put("BeforeDate", Long.toString(beforeDate));
        if (afterDate != null) result.put("AfterDate", Long.toString(afterDate));

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/interfaces/PayInPaymentDetails.java<|end_filename|>
package com.mangopay.core.interfaces;

/**
 * Marker interface for classes with details of means of payment in PayIn entity.
 */
public interface PayInPaymentDetails { }


<|start_filename|>src/main/java/com/mangopay/entities/EMoney.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.EntityBase;
import com.mangopay.core.Money;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;

/**
 * Model of a user's e-money entity.
 */
public class EMoney extends EntityBase {

    /**
     * The object owner's UserId
     */
    @SerializedName("UserId")
    private String userId;

    /**
     * The amount of money that has been credited to this user
     */
    @SerializedName("CreditedEMoney")
    private Money creditedEMoney;

    /**
     * The amount of money that has been debited from this user
     */
    @SerializedName("DebitedEMoney")
    private Money debitedEMoney;

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public Money getCreditedEMoney() {
        return creditedEMoney;
    }

    public void setCreditedEMoney(Money creditedEMoney) {
        this.creditedEMoney = creditedEMoney;
    }

    public Money getDebitedEMoney() {
        return debitedEMoney;
    }

    public void setDebitedEMoney(Money debitedEMoney) {
        this.debitedEMoney = debitedEMoney;
    }

    /**
     * Gets map which property is an object and what type of object.
     *
     * @return Collection of field name-field type pairs.
     */
    @Override
    public Map<String, Type> getSubObjects() {
        HashMap<String, Type> result = new HashMap<>();

        result.put("DebitedEMoney", Money.class);
        result.put("CreditedEMoney", Money.class);

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/PayOut.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.enumerations.PayOutPaymentType;
import com.mangopay.core.interfaces.PayOutPaymentDetails;
import com.mangopay.entities.subentities.PayOutPaymentDetailsBankWire;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * PayOut entity.
 */
public class PayOut extends Transaction {

    /**
     * Debited wallet identifier.
     */
    @SerializedName("DebitedWalletId")
    private String debitedWalletId;

    /**
     * Payment type.
     */
    @SerializedName("PaymentType")
    private PayOutPaymentType paymentType;

    /**
     * One of PayOutPaymentDetails implementations, depending on PaymentType.
     */
    @SerializedName("MeanOfPaymentDetails")
    private PayOutPaymentDetails meanOfPaymentDetails;

    public String getDebitedWalletId() {
        return debitedWalletId;
    }

    public void setDebitedWalletId(String debitedWalletId) {
        this.debitedWalletId = debitedWalletId;
    }

    public PayOutPaymentType getPaymentType() {
        return paymentType;
    }

    public void setPaymentType(PayOutPaymentType paymentType) {
        this.paymentType = paymentType;
    }

    public PayOutPaymentDetails getMeanOfPaymentDetails() {
        return meanOfPaymentDetails;
    }

    public void setMeanOfPaymentDetails(PayOutPaymentDetails meanOfPaymentDetails) {
        this.meanOfPaymentDetails = meanOfPaymentDetails;
    }

    /**
     * Gets the structure that maps which property depends on other property.
     *
     * @return
     */
    @Override
    public Map<String, Map<String, Map<String, Class<?>>>> getDependentObjects() {

        return new HashMap<String, Map<String, Map<String, Class<?>>>>() {{
            put("PaymentType", new HashMap<String, Map<String, Class<?>>>() {{
                        put("BANK_WIRE", new HashMap<String, Class<?>>() {{
                                    put("MeanOfPaymentDetails", PayOutPaymentDetailsBankWire.class);
                                }}
                        );
                        // ...and more in future...
                    }}
            );
        }};
    }

    /**
     * Gets the collection of read-only fields names.
     *
     * @return List of field names.
     */
    @Override
    public ArrayList<String> getReadOnlyProperties() {

        ArrayList<String> result = super.getReadOnlyProperties();

        result.add("PaymentType");

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/DisputePage.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.EntityBase;

/**
 * Dispute page entity.
 */
public class DisputePage extends EntityBase {

    /**
     * File content.
     */
    @SerializedName("File")
    private String file;

    public String getFile() {
        return file;
    }

    public void setFile(String file) {
        this.file = file;
    }
}


<|start_filename|>src/test/java/com/mangopay/core/ReportApiImplTest.java<|end_filename|>
package com.mangopay.core;

import com.mangopay.core.enumerations.CurrencyIso;
import com.mangopay.core.enumerations.ReportType;
import com.mangopay.core.enumerations.SortDirection;
import com.mangopay.entities.ReportRequest;
import org.junit.Test;

import java.util.Calendar;
import java.util.List;

import static org.junit.Assert.*;

/**
 * API Reports test methods.
 */
public class ReportApiImplTest extends BaseTest {

    private static final int SMALL_AMOUNT = 100;
    private static final int LARGE_AMOUNT = 9999;
    private static final CurrencyIso CURRENCY = CurrencyIso.EUR;

    @Test
    public void createTransactionsReport() throws Exception {
        createReport(ReportType.TRANSACTIONS);
    }
  
    @Test
    public void createWalletsReport() throws Exception {
        createReport(ReportType.WALLETS);
    }
  
    private void createReport(ReportType type) throws Exception {
        ReportRequest reportPost = new ReportRequest();
        reportPost.setReportType(type);

        ReportRequest report = this.api.getReportApi().create(reportPost);
        assertNotNull(report);
        assertTrue(report.getId().length() > 0);
    }

    @Test
    public void createFilteredTransactionsReport() throws Exception {
        ReportRequest report = createFilteredTransactionsReport(ReportType.TRANSACTIONS);
        checkReport(report);
    }

    private ReportRequest createFilteredTransactionsReport(ReportType type) throws Exception {
        ReportRequest reportPost = new ReportRequest();
        reportPost.setReportType(type);

        int minFees = 10;
        CurrencyIso minCurrency = CurrencyIso.USD;
        int maxFees = 20;
        CurrencyIso maxCurrency = CurrencyIso.EUR;

        String johnsId = this.getJohn().getId();
        String walletId = this.getJohnsWallet().getId();
        reportPost.setFilters(new FilterReports());
      
        if (type.equals(ReportType.WALLETS)) {
            reportPost.getFilters().setOwnerId(johnsId);
            reportPost.getFilters().setMinBalanceAmount(SMALL_AMOUNT);
            reportPost.getFilters().setMinBalanceCurrency(CURRENCY);
            reportPost.getFilters().setMaxBalanceAmount(LARGE_AMOUNT);
            reportPost.getFilters().setMaxBalanceCurrency(CURRENCY);
        } else {
            reportPost.getFilters().setAuthorId(johnsId);
            reportPost.getFilters().setWalletId(walletId);
            reportPost.getFilters().setMinFeesAmount(minFees);
            reportPost.getFilters().setMinFeesCurrency(minCurrency);
            reportPost.getFilters().setMaxFeesAmount(maxFees);
            reportPost.getFilters().setMaxFeesCurrency(maxCurrency);
        }
        return this.api.getReportApi().create(reportPost);
    }

    private void checkReport(ReportRequest report) throws Exception {
        assertNotNull(report);
        assertTrue(report.getId().length() > 0);
        assertNotNull(report.getFilters());

        if (report.getReportType().equals(ReportType.WALLETS)) {
            assertNotNull(report.getFilters().getOwnerId());
            assertEquals(this.getJohn().getId(), report.getFilters().getOwnerId());
            assertEquals(report.getFilters().getMinBalanceAmount(), SMALL_AMOUNT);
            assertEquals(report.getFilters().getMinBalanceCurrency(), CURRENCY);
            assertEquals(report.getFilters().getMaxBalanceAmount(), LARGE_AMOUNT);
            assertEquals(report.getFilters().getMaxBalanceCurrency(), CURRENCY);
        } else {
            assertNotNull(report.getFilters().getAuthorId());
            assertEquals(this.getJohn().getId(), report.getFilters().getAuthorId());
            assertNotNull(report.getFilters().getWalletId());
            assertEquals(this.getJohnsWallet().getId(), report.getFilters().getWalletId());
        }
    }

    @Test
    public void createFilteredWalletsReport() throws Exception {
        ReportRequest report = createFilteredTransactionsReport(ReportType.WALLETS);
        checkReport(report);
    }

    @Test
    public void createWalletReport() throws Exception {
        ReportRequest reportRequest = new ReportRequest();

        ReportRequest report = this.api.getReportApi().createWalletReport(reportRequest);

        assertNotNull(report);
        assertEquals(report.getReportType(), ReportType.WALLETS);
    }

    @Test
    public void getReport() throws Exception {
        ReportRequest report = this.getJohnsReport();
        ReportRequest getReport = this.api.getReportApi().get(report.getId());

        assertEquals(getReport.getId(), report.getId());
    }

    @Test
    public void getReports() throws Exception {
        ReportRequest report = this.getNewJohnsReport();
        Pagination pagination = new Pagination(1, 10);
        Sorting sort = new Sorting();
        sort.addField("CreationDate", SortDirection.desc);

        List<ReportRequest> list = this.api.getReportApi().getAll(pagination, null, sort);

        /*
            Due to concurrent nature of how unit tests are launched, 
            it is not guaranteed that report created in this method
            will be the newest one in the reports list received from
            API. Therefore another solution is needed here, such as
            looking for the report among few the newest ones (here 10).
        */
        int j = -1;
        for (int i = 0; i < list.size(); i++) {
            if (report.getId().equals(list.get(i).getId())) {
                j = i;
                break;
            }
        }
        assertTrue(j > -1);

        assertEquals(report.getId(), list.get(j).getId());
        assertEquals(pagination.getPage(), 1);
        assertEquals(pagination.getItemsPerPage(), 10);

        FilterReportsList filters = new FilterReportsList();
        filters.setAfterDate(list.get(j).getCreationDate());
        Calendar c = Calendar.getInstance();
        c.set(Calendar.HOUR_OF_DAY, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MILLISECOND, 0);
        filters.setBeforeDate(c.getTimeInMillis() / 1000);

        list = this.api.getReportApi().getAll(pagination, filters, sort);

        assertNotNull(list);
        assertTrue(list.isEmpty());

        filters.setBeforeDate(filters.getAfterDate());
        c.set(Calendar.YEAR, c.get(Calendar.YEAR) - 10);
        filters.setAfterDate(c.getTimeInMillis() / 1000);

        list = this.api.getReportApi().getAll(pagination, filters, sort);

        assertNotNull(list);
        assertTrue(list.size() > 0);
    }

}


<|start_filename|>src/test/java/com/mangopay/core/IdempotencyApiImplTest.java<|end_filename|>
package com.mangopay.core;

import com.mangopay.core.enumerations.CurrencyIso;
import com.mangopay.core.enumerations.PayoutMode;
import com.mangopay.entities.*;
import com.mangopay.entities.subentities.PayOutPaymentDetailsBankWire;

import java.util.Calendar;

import org.junit.Assert;
import org.junit.Test;

import static org.junit.Assert.*;

/**
 * IdempotencyApiImpl test methods.
 */
public class IdempotencyApiImplTest extends BaseTest {

    @Test
    public void idempotentRequest() {

        Calendar c = Calendar.getInstance();
        String key = Long.toString(c.getTimeInMillis());
        key = key + "abcdef";   // <- to make the key string at least 16 characters long

        PayOut payOut = null;

        // create bankwire
        try {
            Wallet wallet = this.getJohnsWallet();
            UserNatural user = this.getJohn();
            BankAccount account = this.getJohnsAccount();

            PayOut payOutPost = new PayOut();
            payOutPost.setAuthorId(user.getId());
            payOutPost.setDebitedWalletId(wallet.getId());
            Money debitedFunds = new Money();
            debitedFunds.setAmount(10);
            debitedFunds.setCurrency(CurrencyIso.EUR);
            payOutPost.setDebitedFunds(debitedFunds);
            Money fees = new Money();
            fees.setAmount(5);
            fees.setCurrency(CurrencyIso.EUR);
            payOutPost.setFees(fees);
            PayOutPaymentDetailsBankWire paymentDetails = new PayOutPaymentDetailsBankWire();
            paymentDetails.setBankAccountId(account.getId());
            paymentDetails.setBankWireRef("Johns bank wire ref");
            paymentDetails.setPayoutModeRequested(PayoutMode.STANDARD);
            payOutPost.setMeanOfPaymentDetails(paymentDetails);

            payOutPost.setTag("DefaultTag");
            payOutPost.setCreditedUserId(user.getId());

            payOut = this.api.getPayOutApi().create(key, payOutPost);
        } catch (Exception ex) {
            Assert.fail(ex.getMessage());
        }

        assertNotNull(payOut);

        // test existing key
        IdempotencyResponse result = null;
        try {
            result = this.api.getIdempotencyApi().get(key);
        } catch (Exception ex) {
            Assert.fail(ex.getMessage());
        }

        assertNotNull(result);

        // test not existing key
        try {
            this.api.getIdempotencyApi().get(key + "_no");

            // expecting a ResponseException to be thrown
            Assert.fail();
        } catch (ResponseException rex) {
            assertTrue(rex.getResponseHttpCode() == 400);
            assertTrue(rex.getType().equals("correlationid_not_found"));
        } catch (Exception ex) {
            Assert.fail(ex.getMessage());
        }

    }

}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/PayOutPaymentType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Payment type enumeration.
 */
public enum PayOutPaymentType {
    /**
     * Not specified.
     */
    NotSpecified,

    /**
     * BANK WIRE payment type.
     */
    BANK_WIRE, 

    /**
     * MERCHANT EXPENSE payment type.
     */
    MERCHANT_EXPENSE, 

    /**
     * AMAZON GIFTCARD payment type.
     */
    AMAZON_GIFTCARD
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/CurrencyIso.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Currency ISO 4217 symbols enumeration.
 */
public enum CurrencyIso {
    /**
    * Not specified.
    */ 
    NotSpecified,

    /**
    * No currency
    */ 
    XXX,
    /**
    * United Arab Emirates dirham
    */ 
    AED,
    /**
    * Afghan afghani
    */ 
    AFN,
    /**
    * Albanian lek
    */ 
    ALL,
    /**
    * Armenian dram
    */ 
    AMD,
    /**
    * Netherlands Antillean guilder
    */ 
    ANG,
    /**
    * Angolan kwanza
    */ 
    AOA,
    /**
    * Argentine peso
    */ 
    ARS,
    /**
    * Australian dollar
    */ 
    AUD,
    /**
    * Aruban florin
    */ 
    AWG,
    /**
    * Azerbaijani manat
    */ 
    AZN,
    /**
    * Bosnia and Herzegovina convertible mark
    */ 
    BAM,
    /**
    * Barbados dollar
    */ 
    BBD,
    /**
    * Bangladeshi taka
    */ 
    BDT,
    /**
    * Bulgarian lev
    */ 
    BGN,
    /**
    * Bahraini dinar
    */ 
    BHD,
    /**
    * Burundian franc
    */ 
    BIF,
    /**
    * Bermudian dollar
    */ 
    BMD,
    /**
    * Brunei dollar
    */ 
    BND,
    /**
    * Boliviano
    */ 
    BOB,
    /**
    * Bolivian Mvdol (funds code)
    */ 
    BOV,
    /**
    * Brazilian real
    */ 
    BRL,
    /**
    * Bahamian dollar
    */ 
    BSD,
    /**
    * Bhutanese ngultrum
    */ 
    BTN,
    /**
    * Botswana pula
    */ 
    BWP,
    /**
    * Belarusian ruble
    */ 
    BYR,
    /**
    * Belize dollar
    */ 
    BZD,
    /**
    * Canadian dollar
    */ 
    CAD,
    /**
    * Congolese franc
    */ 
    CDF,
    /**
    * WIR Euro (complementary currency)
    */ 
    CHE,
    /**
    * Swiss franc
    */ 
    CHF,
    /**
    * WIR Franc (complementary currency)
    */ 
    CHW,
    /**
    * Unidad de Fomento (funds code)
    */ 
    CLF,
    /**
    * Chilean peso
    */ 
    CLP,
    /**
    * Chinese yuan
    */ 
    CNY,
    /**
    * Colombian peso
    */ 
    COP,
    /**
    * Unidad de Valor Real (UVR) (funds code)[7]
    */ 
    COU,
    /**
    * Costa Rican colon
    */ 
    CRC,
    /**
    * Cuban convertible peso
    */ 
    CUC,
    /**
    * Cuban peso
    */ 
    CUP,
    /**
    * Cape Verde escudo
    */ 
    CVE,
    /**
    * Czech koruna
    */ 
    CZK,
    /**
    * Djiboutian franc
    */ 
    DJF,
    /**
    * Danish krone
    */ 
    DKK,
    /**
    * Dominican peso
    */ 
    DOP,
    /**
    * Algerian dinar
    */ 
    DZD,
    /**
    * Egyptian pound
    */ 
    EGP,
    /**
    * Eritrean nakfa
    */ 
    ERN,
    /**
    * Ethiopian birr
    */ 
    ETB,
    /**
    * Euro
    */ 
    EUR,
    /**
    * Fiji dollar
    */ 
    FJD,
    /**
    * Falkland Islands pound
    */ 
    FKP,
    /**
    * Pound sterling
    */ 
    GBP,
    /**
    * Georgian lari
    */ 
    GEL,
    /**
    * Ghanaian cedi
    */ 
    GHS,
    /**
    * Gibraltar pound
    */ 
    GIP,
    /**
    * Gambian dalasi
    */ 
    GMD,
    /**
    * Guinean franc
    */ 
    GNF,
    /**
    * Guatemalan quetzal
    */ 
    GTQ,
    /**
    * Guyanese dollar
    */ 
    GYD,
    /**
    * Hong Kong dollar
    */ 
    HKD,
    /**
    * Honduran lempira
    */ 
    HNL,
    /**
    * Croatian kuna
    */ 
    HRK,
    /**
    * Haitian gourde
    */ 
    HTG,
    /**
    * Hungarian forint
    */ 
    HUF,
    /**
    * Indonesian rupiah
    */ 
    IDR,
    /**
    * Israeli new shekel
    */ 
    ILS,
    /**
    * Indian rupee
    */ 
    INR,
    /**
    * Iraqi dinar
    */ 
    IQD,
    /**
    * Iranian rial
    */ 
    IRR,
    /**
    * Icelandic króna
    */ 
    ISK,
    /**
    * Jamaican dollar
    */ 
    JMD,
    /**
    * Jordanian dinar
    */ 
    JOD,
    /**
    * Japanese yen
    */ 
    JPY,
    /**
    * Kenyan shilling
    */ 
    KES,
    /**
    * Kyrgyzstani som
    */ 
    KGS,
    /**
    * Cambodian riel
    */ 
    KHR,
    /**
    * Comoro franc
    */ 
    KMF,
    /**
    * North Korean won
    */ 
    KPW,
    /**
    * South Korean won
    */ 
    KRW,
    /**
    * Kuwaiti dinar
    */ 
    KWD,
    /**
    * Cayman Islands dollar
    */ 
    KYD,
    /**
    * Kazakhstani tenge
    */ 
    KZT,
    /**
    * Lao kip
    */ 
    LAK,
    /**
    * Lebanese pound
    */ 
    LBP,
    /**
    * Sri Lankan rupee
    */ 
    LKR,
    /**
    * Liberian dollar
    */ 
    LRD,
    /**
    * Lesotho loti
    */ 
    LSL,
    /**
    * Lithuanian litas
    */ 
    LTL,
    /**
    * Libyan dinar
    */ 
    LYD,
    /**
    * Moroccan dirham
    */ 
    MAD,
    /**
    * Moldovan leu
    */ 
    MDL,
    /**
    * Malagasy ariary
    */ 
    MGA,
    /**
    * Macedonian denar
    */ 
    MKD,
    /**
    * Myanmar kyat
    */ 
    MMK,
    /**
    * Mongolian tugrik
    */ 
    MNT,
    /**
    * Macanese pataca
    */ 
    MOP,
    /**
    * Mauritanian ouguiya
    */ 
    MRO,
    /**
    * Mauritian rupee
    */ 
    MUR,
    /**
    * Maldivian rufiyaa
    */ 
    MVR,
    /**
    * Malawian kwacha
    */ 
    MWK,
    /**
    * Mexican peso
    */ 
    MXN,
    /**
    * Mexican Unidad de Inversion(UDI) (funds code)
    */ 
    MXV,
    /**
    * Malaysian ringgit
    */ 
    MYR,
    /**
    * Mozambican metical
    */ 
    MZN,
    /**
    * Namibian dollar
    */ 
    NAD,
    /**
    * Nigerian naira
    */ 
    NGN,
    /**
    * Nicaraguan córdoba
    */ 
    NIO,
    /**
    * Norwegian krone
    */ 
    NOK,
    /**
    * Nepalese rupee
    */ 
    NPR,
    /**
    * New Zealand dollar
    */ 
    NZD,
    /**
    * Omani rial
    */ 
    OMR,
    /**
    * Panamanian balboa
    */ 
    PAB,
    /**
    * Peruvian nuevo sol
    */ 
    PEN,
    /**
    * Papua New Guinean kina
    */ 
    PGK,
    /**
    * Philippine peso
    */ 
    PHP,
    /**
    * Pakistani rupee
    */ 
    PKR,
    /**
    * Polish złoty
    */ 
    PLN,
    /**
    * Paraguayan guaraní
    */ 
    PYG,
    /**
    * Qatari riyal
    */ 
    QAR,
    /**
    * Romanian new leu
    */ 
    RON,
    /**
    * Serbian dinar
    */ 
    RSD,
    /**
    * Russian ruble
    */ 
    RUB,
    /**
    * Rwandan franc
    */ 
    RWF,
    /**
    * Saudi riyal
    */ 
    SAR,
    /**
    * Solomon Islands dollar
    */ 
    SBD,
    /**
    * Seychelles rupee
    */ 
    SCR,
    /**
    * Sudanese pound
    */ 
    SDG,
    /**
    * Swedish krona/kronor
    */ 
    SEK,
    /**
    * Singapore dollar
    */ 
    SGD,
    /**
    * Saint Helena pound
    */ 
    SHP,
    /**
    * Sierra Leonean leone
    */ 
    SLL,
    /**
    * Somali shilling
    */ 
    SOS,
    /**
    * Surinamese dollar
    */ 
    SRD,
    /**
    * South Sudanese pound
    */ 
    SSP,
    /**
    * Sao Tomé and Príncipe dobra
    */ 
    STD,
    /**
    * Syrian pound
    */ 
    SYP,
    /**
    * Swazi lilangeni
    */ 
    SZL,
    /**
    * Thai baht
    */ 
    THB,
    /**
    * Tajikistani somoni
    */ 
    TJS,
    /**
    * Turkmenistani manat
    */ 
    TMT,
    /**
    * Tunisian dinar
    */ 
    TND,
    /**
    * Tongan pa'anga
    */ 
    TOP,
    /**
    * Turkish lira
    */ 
    TRY,
    /**
    * Trinidad and Tobago dollar
    */ 
    TTD,
    /**
    * New Taiwan dollar
    */ 
    TWD,
    /**
    * Tanzanian shilling
    */ 
    TZS,
    /**
    * Ukrainian hryvnia
    */ 
    UAH,
    /**
    * Ugandan shilling
    */ 
    UGX,
    /**
    * United States dollar
    */ 
    USD,
    /**
    * United States dollar (next day) (funds code)
    */ 
    USN,
    /**
    * United States dollar (same day) (funds code)[10]
    */ 
    USS,
    /**
    * Uruguay Peso en Unidades Indexadas (URUIURUI) (funds code)
    */ 
    UYI,
    /**
    * Uruguayan peso
    */ 
    UYU,
    /**
    * Uzbekistan som
    */ 
    UZS,
    /**
    * Venezuelan bolívar
    */ 
    VEF,
    /**
    * Vietnamese dong
    */ 
    VND,
    /**
    * Vanuatu vatu
    */ 
    VUV,
    /**
    * Samoan tala
    */ 
    WST,
    /**
    * CFA franc BEAC
    */ 
    XAF,
    /**
    * Silver (one troy ounce)
    */ 
    XAG,
    /**
    * Gold (one troy ounce)
    */ 
    XAU,
    /**
    * European Composite Unit(EURCO) (bond market unit)
    */ 
    XBA,
    /**
    * European Monetary Unit(E.M.U.-6) (bond market unit)
    */ 
    XBB,
    /**
    * European Unit of Account 9(E.U.A.-9) (bond market unit)
    */ 
    XBC,
    /**
    * European Unit of Account 17(E.U.A.-17) (bond market unit)
    */ 
    XBD,
    /**
    * bitcoinInternational internet currency
    */ 
    XBT,
    /**
    * East Caribbean dollar
    */ 
    XCD,
    /**
    * Special drawing rights
    */ 
    XDR,
    /**
    * UIC franc(special settlement currency)
    */ 
    XFU,
    /**
    * CFA franc BCEAO
    */ 
    XOF,
    /**
    * Palladium (onetroy ounce)
    */ 
    XPD,
    /**
    * CFP franc(franc Pacifique)
    */ 
    XPF,
    /**
    * Platinum (onetroy ounce)
    */ 
    XPT,
    /**
    * SUCRE
    */ 
    XSU,
    /**
    * Code reserved for testing purposes
    */ 
    XTS,
    /**
    * ADB Unit of Account
    */ 
    XUA,
    /**
    * Yemeni rial
    */ 
    YER,
    /**
    * South African rand
    */ 
    ZAR,
    /**
    * Zambian kwacha
    */ 
    ZMW,
    /**
    * Zimbabwe dollar
    */ 
    ZWD
}


<|start_filename|>src/main/java/com/mangopay/core/ResponseException.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;

import java.util.HashMap;

/**
 * Response exception class.
 */
public class ResponseException extends Exception {

    /**
     * HTTP error code.
     */
    @SerializedName("ResponseHttpCode")
    private int responseHttpCode;

    /**
     * HTTP error description.
     */
    @SerializedName("ResponseHttpDescription")
    private String responseHttpDescription;

    /**
     * API error message.
     */
    @SerializedName("ApiMessage")
    private String apiMessage;

    /**
     * API error type.
     */
    @SerializedName("Type")
    private String type;

    /**
     * API error identifier.
     */
    @SerializedName("Id")
    private String id;

    /**
     * API error timestamp.
     */
    @SerializedName("Date")
    private int date;

    /**
     * List of detailed errors.
     */
    @SerializedName("Errors")
    private HashMap<String, String> errors;

    /**
     * Instantiates new ResponseException object.
     */
    public ResponseException() {
        this.errors = new HashMap<>();
    }

    /**
     * Instantiates new ResponseException object.
     *
     * @param message JSON data that came as a response from API.
     */
    public ResponseException(String message) {
        super(message);
        this.errors = new HashMap<>();
    }

    /**
     * Instantiates new ResponseException object.
     *
     * @param cause Throwable object.
     */
    public ResponseException(Throwable cause) {
        super(cause);
        this.errors = new HashMap<>();
    }

    /**
     * Instantiates new ResponseException object.
     *
     * @param message JSON data that came as a response from API.
     * @param cause   Throwable object.
     */
    public ResponseException(String message, Throwable cause) {
        super(message, cause);
        this.errors = new HashMap<>();
    }

    public int getResponseHttpCode() {
        return responseHttpCode;
    }

    public void setResponseHttpCode(int responseHttpCode) {
        this.responseHttpCode = responseHttpCode;
    }

    public String getResponseHttpDescription() {
        return responseHttpDescription;
    }

    public void setResponseHttpDescription(String responseHttpDescription) {
        this.responseHttpDescription = responseHttpDescription;
    }

    public String getApiMessage() {
        return apiMessage;
    }

    public void setApiMessage(String apiMessage) {
        this.apiMessage = apiMessage;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getDate() {
        return date;
    }

    public void setDate(int date) {
        this.date = date;
    }

    public HashMap<String, String> getErrors() {
        return errors;
    }

    public void setErrors(HashMap<String, String> errors) {
        this.errors = errors;
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/subentities/PayInPaymentDetailsPayPal.java<|end_filename|>
package com.mangopay.entities.subentities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Dto;
import com.mangopay.core.ShippingAddress;
import com.mangopay.core.interfaces.PayInPaymentDetails;

import java.lang.reflect.Type;
import java.util.Map;

/**
 * Class representing the PayPal type for mean of payment in PayIn entity.
 */
public class PayInPaymentDetailsPayPal extends Dto implements PayInPaymentDetails {

    /**
     * Address used instead of the user's PayPal account address.
     */
    @SerializedName("ShippingAddress")
    private ShippingAddress shippingAddress;

    @SerializedName("PaypalBuyerAccountEmail")
    private String paypalBuyerAccountEmail;

    public ShippingAddress getShippingAddress() {
        return shippingAddress;
    }

    public void setShippingAddress(ShippingAddress shippingAddress) {
        this.shippingAddress = shippingAddress;
    }

    @Override
    public Map<String, Type> getSubObjects() {
        Map<String, Type> subObjects = super.getSubObjects();

        subObjects.put("ShippingAddress", ShippingAddress.class);

        return subObjects;
    }

    public String getPaypalBuyerAccountEmail() {
        return paypalBuyerAccountEmail;
    }

    public PayInPaymentDetailsPayPal setPaypalBuyerAccountEmail(String paypalBuyerAccountEmail) {
        this.paypalBuyerAccountEmail = paypalBuyerAccountEmail;
        return this;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/Pagination.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;

/**
 * Pagination class.
 */
public class Pagination extends Dto {

    /**
     * Page number.
     */
    @SerializedName("Page")
    private int page;

    /**
     * Number of items per page.
     */
    @SerializedName("ItemsPerPage")
    private int itemsPerPage;

    /**
     * Number of total pages.
     */
    @SerializedName("TotalPages")
    private int totalPages;

    /**
     * Number of total items.
     */
    @SerializedName("TotalItems")
    private int totalItems;

    /**
     * Four-elements array with links to navigation.
     * All values are optional. Format:
     * Links[0] {@literal -> } first,
     * Links[1] {@literal -> } previous,
     * Links[2] {@literal -> } next,
     * Links[3] {@literal -> } last.
     */
    @SerializedName("Links")
    private String[] links;

    /**
     * Instantiates new Pagination object.
     */
    public Pagination() {
        this(1, 10);
    }

    /**
     * Instantiates new Pagination object.
     *
     * @param page Page number.
     */
    public Pagination(int page) {
        this(page, 10);
    }

    /**
     * Instantiates new Pagination object.
     *
     * @param page         Page number.
     * @param itemsPerPage Number of items per page.
     */
    public Pagination(int page, int itemsPerPage) {
        this.links = new String[4];
        this.page = page;
        this.itemsPerPage = itemsPerPage;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getItemsPerPage() {
        return itemsPerPage;
    }

    public void setItemsPerPage(int itemsPerPage) {
        this.itemsPerPage = itemsPerPage;
    }

    public int getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(int totalPages) {
        this.totalPages = totalPages;
    }

    public int getTotalItems() {
        return totalItems;
    }

    public void setTotalItems(int totalItems) {
        this.totalItems = totalItems;
    }

    public String[] getLinks() {
        return links;
    }

    public void setLinks(String[] links) {
        this.links = links;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/PayoutMode.java<|end_filename|>
package com.mangopay.core.enumerations;

public enum PayoutMode {
    STANDARD,
    INSTANT_PAYMENT
}


<|start_filename|>src/main/java/com/mangopay/entities/subentities/PayOutPaymentDetailsBankWire.java<|end_filename|>
package com.mangopay.entities.subentities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Dto;
import com.mangopay.core.ObjectTool;
import com.mangopay.core.enumerations.PayoutMode;
import com.mangopay.core.interfaces.PayOutPaymentDetails;

/**
 * Class representing the BankWire type for mean of payment in PayOut entity.
 */
public class PayOutPaymentDetailsBankWire extends Dto implements PayOutPaymentDetails {
    /**
     * Bank account identifier.
     */
    @SerializedName("BankAccountId")
    private String bankAccountId;

    /**
     * Bank wire reference.
     */
    @SerializedName("BankWireRef")
    private String bankWireRef;

    /**
     * The requested payout mode.
     */
    @SerializedName("PayoutModeRequested")
    private PayoutMode payoutModeRequested;

    private String payoutModeApplied;

    @SerializedName("Status")
    private String status;

    @SerializedName("FallbackReason")
    private FallbackReason fallbackReason;

    public PayOutPaymentDetailsBankWire() {
    }

    public PayOutPaymentDetailsBankWire(String bankAccountId) {
        this.bankAccountId = bankAccountId;
    }

    public PayOutPaymentDetailsBankWire(String bankAccountId, String bankWireRef) {
        this.bankAccountId = bankAccountId;
        this.bankWireRef = bankWireRef;
    }

    public PayOutPaymentDetailsBankWire(String bankAccountId, String bankWireRef, PayoutMode payoutModeRequested) {
        this.bankAccountId = bankAccountId;
        this.bankWireRef = bankWireRef;
        this.payoutModeRequested = payoutModeRequested;
    }

    public static PayOutPaymentDetailsBankWire build(String bankAccountId) {
        return new PayOutPaymentDetailsBankWire(bankAccountId);
    }

    public static PayOutPaymentDetailsBankWire build(String bankAccountId, String bankWireRef) {
        return new PayOutPaymentDetailsBankWire(bankAccountId, bankWireRef);
    }

    public static PayOutPaymentDetailsBankWire build(String bankAccountId, String bankWireRef, PayoutMode payoutModeRequested) {
        return new PayOutPaymentDetailsBankWire(bankAccountId, bankWireRef, payoutModeRequested);
    }

    public String getBankAccountId() {
        return bankAccountId;
    }

    public void setBankAccountId(String bankAccountId) {
        this.bankAccountId = bankAccountId;
    }

    public String getBankWireRef() {
        return bankWireRef;
    }

    public void setBankWireRef(String bankWireRef) {
        this.bankWireRef = bankWireRef;
    }

    public PayoutMode getPayoutModeRequested() {
        return payoutModeRequested;
    }

    public void setPayoutModeRequested(PayoutMode payoutModeRequested) {
        this.payoutModeRequested = payoutModeRequested;
    }

    public String getPayoutModeApplied() { return payoutModeApplied; }

    public void setPayoutModeApplied(String payoutModeApplied) {
        this.payoutModeApplied = payoutModeApplied;
    }

    public String getStatus() { return status; }

    public void setStatus(String status) {
        this.status = status;
    }

    public FallbackReason getFallbackReason() { return fallbackReason; }

    public void setFallbackReason(FallbackReason fallbackReason) {
        this.fallbackReason = fallbackReason;
    }

    public static PayOutPaymentDetailsBankWire convert(PayOutPaymentDetails payOutPaymentDetails) throws Exception {
        if (ObjectTool.isNull(payOutPaymentDetails)) {
            throw new Exception("PayOutPaymentDetails null value");
        } else if (payOutPaymentDetails instanceof PayOutPaymentDetailsBankWire) {
            return (PayOutPaymentDetailsBankWire) payOutPaymentDetails;
        } else {
            throw new Exception("PayOutPaymentDetails instance isn't PayOutPaymentDetailsBankWire instance");
        }
    }
}


<|start_filename|>src/test/java/com/mangopay/core/KycDocumentApiImplTest.java<|end_filename|>
package com.mangopay.core;

import com.mangopay.core.enumerations.SortDirection;
import com.mangopay.entities.KycDocument;
import org.junit.Test;

import java.util.List;

import static org.junit.Assert.*;

/**
 * KycDocumentApiImpl test methods
 */
public class KycDocumentApiImplTest extends BaseTest {

    @Test
    public void getKycDocuments() throws Exception {

        List<KycDocument> result = this.api.getKycDocumentApi().getAll(null, null);
        assertNotNull(result);
        assertTrue(result.size() > 0);

        Pagination pagination = new Pagination(1, 2);
        Sorting sort = new Sorting();
        sort.addField("CreationDate", SortDirection.asc);
        result = this.api.getKycDocumentApi().getAll(pagination, sort);
        assertNotNull(result);
        assertTrue(result.size() > 0);

        sort = new Sorting();
        sort.addField("CreationDate", SortDirection.desc);
        List<KycDocument> result2 = this.api.getKycDocumentApi().getAll(pagination, sort);
        assertNotNull(result2);
        assertTrue(result2.size() > 0);

        assertFalse(result.get(0).getId().equals(result2.get(0).getId()));
    }

    @Test
    public void getKycDocument() throws Exception {
        KycDocument kycDocument = this.getJohnsKycDocument();
        KycDocument result = this.api.getKycDocumentApi().getKycDocument(kycDocument.getId());

        assertNotNull(result);
        assertTrue(result.getId().equals(kycDocument.getId()));
        assertTrue(result.getStatus() == kycDocument.getStatus());
        assertTrue(result.getType() == kycDocument.getType());
    }

    @Test
    public void createKycDocumentConsult() throws Exception {
        KycDocument document = getJohnsKycDocument();
        List<DocumentPageConsult> pageConsults = api.getKycDocumentApi().createKycDocumentConsult(document.getId());

        assertNotNull(pageConsults);
    }
}


<|start_filename|>src/main/java/com/mangopay/core/interfaces/PayInExecutionDetails.java<|end_filename|>
package com.mangopay.core.interfaces;

/**
 * Marker interface for classes with details of execution option in PayIn entity.
 */
public interface PayInExecutionDetails { }


<|start_filename|>src/main/java/com/mangopay/core/deserializer/TransferDeserializer.java<|end_filename|>
package com.mangopay.core.deserializer;

import com.google.gson.*;
import com.mangopay.entities.Transfer;

import java.lang.reflect.Type;

public class TransferDeserializer implements JsonDeserializer<Transfer> {
    @Override
    public Transfer deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
        JsonObject jsonObject = json.getAsJsonObject();
        Transfer transfer = new Gson().fromJson(jsonObject.toString(), Transfer.class);
        if (jsonObject.has("DebitedWalletId") && !jsonObject.get("DebitedWalletId").isJsonNull())
            transfer.setDebitedWalletId(jsonObject.get("DebitedWalletId").getAsString());
        if (jsonObject.has("CreditedWalletId") && !jsonObject.get("CreditedWalletId").isJsonNull())
            transfer.setCreditedWalletId(jsonObject.get("CreditedWalletId").getAsString());
        return transfer;
    }
}


<|start_filename|>src/test/java/com/mangopay/core/HookApiImplTest.java<|end_filename|>
package com.mangopay.core;

import com.mangopay.core.enumerations.EventType;
import com.mangopay.entities.*;

import java.util.ArrayList;
import java.util.List;

import org.junit.Assert;
import org.junit.Test;

import static org.junit.Assert.*;

/**
 * HookApiImpl test methods.
 */
public class HookApiImplTest extends BaseTest {

    @Test
    public void createHook() {
        try {
            Hook hook = this.getJohnsHook();
            assertTrue(hook.getId().length() > 0);
        } catch (Exception ex) {
            Assert.fail(ex.getMessage());
        }
    }

    @Test
    public void getHook() {
        try {
            Hook hook = this.getJohnsHook();
            Hook getHook = this.api.getHookApi().get(hook.getId());

            assertEquals(getHook.getEventType(), hook.getEventType());
            assertEquals(getHook.getId(), hook.getId());
        } catch (Exception ex) {
            Assert.fail(ex.getMessage());
        }
    }

    @Test
    public void updateHook() {
        try {
            Hook hook = this.getJohnsHook();
            hook.setUrl("http://test123.com");

            Hook saveHook = this.api.getHookApi().update(hook);

            assertEquals(saveHook.getId(), hook.getId());
            assertEquals(saveHook.getUrl(), "http://test123.com");
        } catch (Exception ex) {
            Assert.fail(ex.getMessage());
        }
    }

    @Test
    public void getHooks() {
        try {
            Hook hook = this.getJohnsHook();
            Pagination pagination = new Pagination(1, 1);

            List<Hook> list = this.api.getHookApi().getAll(pagination, null);

            assertTrue(list.get(0) instanceof Hook);
            assertEquals(hook.getId(), list.get(0).getId());
            assertEquals(pagination.getPage(), 1);
            assertEquals(pagination.getItemsPerPage(), 1);
        } catch (Exception ex) {
            Assert.fail(ex.getMessage());
        }
    }

    @Test
    public void createUserInflowHooks() {
        try {
            List<Hook> allHooks = this.api.getHookApi().getAll(new Pagination(1, 100), null);
            Hook inflowBlockedHook = null;
            Hook inflowUnblockedHook = null;
            for (Hook hook : allHooks) {
                if (hook.getEventType() == EventType.USER_INFLOWS_BLOCKED) {
                    inflowBlockedHook = hook;
                }
                if (hook.getEventType() == EventType.USER_INFLOWS_UNBLOCKED) {
                    inflowUnblockedHook = hook;
                }
            }

            if (inflowBlockedHook == null) {
                Hook hook = new Hook();
                hook.setEventType(EventType.USER_INFLOWS_BLOCKED);
                hook.setUrl("http://test.com");
                inflowBlockedHook = this.api.getHookApi().create(hook);
            }

            if (inflowUnblockedHook == null) {
                Hook hook = new Hook();
                hook.setEventType(EventType.USER_INFLOWS_UNBLOCKED);
                hook.setUrl("http://test.com");
                inflowUnblockedHook = this.api.getHookApi().create(hook);
            }

            assertNotNull(inflowBlockedHook);
            assertNotNull(inflowUnblockedHook);
        } catch (Exception ex) {
            Assert.fail(ex.getMessage());
        }
    }

    @Test
    public void createUserOutflowHooks() {
        try {
            List<Hook> allHooks = this.api.getHookApi().getAll(new Pagination(1, 100), null);
            Hook outflowBlockedHook = null;
            Hook outlowUnblockedHook = null;
            for (Hook hook : allHooks) {
                if (hook.getEventType() == EventType.USER_OUTFLOWS_BLOCKED) {
                    outflowBlockedHook = hook;
                }
                if (hook.getEventType() == EventType.USER_OUTFLOWS_UNBLOCKED) {
                    outlowUnblockedHook = hook;
                }
            }

            if (outflowBlockedHook == null) {
                Hook hook = new Hook();
                hook.setEventType(EventType.USER_OUTFLOWS_BLOCKED);
                hook.setUrl("http://test.com");
                outflowBlockedHook = this.api.getHookApi().create(hook);
            }

            if (outlowUnblockedHook == null) {
                Hook hook = new Hook();
                hook.setEventType(EventType.USER_OUTFLOWS_UNBLOCKED);
                hook.setUrl("http://test.com");
                outlowUnblockedHook = this.api.getHookApi().create(hook);
            }

            assertNotNull(outflowBlockedHook);
            assertNotNull(outlowUnblockedHook);
        } catch (Exception ex) {
            Assert.fail(ex.getMessage());
        }
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/RecurringPayInMIT.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Dto;
import com.mangopay.core.Money;

import java.lang.reflect.Type;
import java.util.Map;

public class RecurringPayInMIT extends Dto {

    @SerializedName("RecurringPayinRegistrationId")
    private String recurringPayInRegistrationId;

    @SerializedName("DebitedFunds")
    private Money debitedFunds;

    @SerializedName("Fees")
    private Money fees;

    @SerializedName("StatementDescriptor")
    private String statementDescriptor;

    @SerializedName("Tag")
    private String tag;

    public String getRecurringPayInRegistrationId() {
        return recurringPayInRegistrationId;
    }

    public void setRecurringPayInRegistrationId(String recurringPayInRegistrationId) {
        this.recurringPayInRegistrationId = recurringPayInRegistrationId;
    }

    public String getStatementDescriptor() {
        return statementDescriptor;
    }

    public void setStatementDescriptor(String statementDescriptor) {
        this.statementDescriptor = statementDescriptor;
    }

    public String getTag() {
        return tag;
    }

    public void setTag(String tag) {
        this.tag = tag;
    }

    @Override
    public Map<String, Type> getSubObjects() {

        Map<String, Type> result = super.getSubObjects();

        result.put("Money", Money.class);

        return result;
    }
}


<|start_filename|>src/test/java/com/mangopay/core/UserApiImplTest.java<|end_filename|>
package com.mangopay.core;

import com.mangopay.core.enumerations.*;
import com.mangopay.entities.*;
import com.mangopay.entities.subentities.*;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;

import java.io.File;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Calendar;
import java.util.List;

import static org.junit.Assert.*;

/**
 * UserApiImpl test methods
 */
public class UserApiImplTest extends BaseTest {

    @Test
    public void createNatural() throws Exception {
        UserNatural john = this.getJohn();
        assertTrue(john.getId().length() > 0);
        assertTrue(john.getPersonType().equals(PersonType.NATURAL));
    }

    @Test
    public void createLegal() throws Exception {
        UserLegal matrix = this.getMatrix();
        assertTrue(matrix.getId().length() > 0);
        assertEquals(matrix.getPersonType(), PersonType.LEGAL);
        assertEquals("LU12345678", matrix.getCompanyNumber());
    }

    @Test
    public void createLegalFailsIfRequiredPropsNotProvided() throws Exception {
        UserLegal user = new UserLegal();

        User ret = null;

        try {
            ret = this.api.getUserApi().create(user);

            Assert.fail("CreateLegal() should throw an exception when required props are not provided");
        } catch (ResponseException ex) {
            assertNull(ret);
        }
    }

    @Test
    public void createLegalPassesIfRequiredPropsProvided() throws Exception {
        UserLegal user = new UserLegal();
        user.setHeadquartersAddress(new Address());
        user.getHeadquartersAddress().setAddressLine1("AddressLine1");
        user.getHeadquartersAddress().setAddressLine2("AddressLine2");
        user.getHeadquartersAddress().setCity("City");
        user.getHeadquartersAddress().setCountry(CountryIso.FR);
        user.getHeadquartersAddress().setPostalCode("11222");
        user.getHeadquartersAddress().setRegion("Region");
        user.setName("SomeOtherSampleOrg");
        user.setLegalPersonType(LegalPersonType.BUSINESS);
        user.setLegalRepresentativeFirstName("RepFName");
        user.setLegalRepresentativeLastName("RepLName");
        Calendar c = Calendar.getInstance();
        c.set(1975, 12, 21, 0, 0, 0);
        user.setLegalRepresentativeBirthday(c.getTimeInMillis() / 1000);
        user.setLegalRepresentativeNationality(CountryIso.FR);
        user.setLegalRepresentativeCountryOfResidence(CountryIso.FR);
        user.setEmail("<EMAIL>");
        user.setCompanyNumber("LU12345678");

        User ret = null;

        ret = this.api.getUserApi().create(user);

        assertTrue("Created successfully after required props set", ret.getId().length() > 0);

        assertEqualInputProps(user, ret);
    }

    @Test
    public void getAllUsers() throws Exception {
        Sorting sort = new Sorting();
        sort.addField("CreationDate", SortDirection.desc);
        List<User> users = this.api.getUserApi().getAll(null, sort);

        assertTrue(users.get(0).getCreationDate() > users.get(users.size() - 1).getCreationDate());

        sort = new Sorting();
        sort.addField("CreationDate", SortDirection.asc);
        users = this.api.getUserApi().getAll(null, sort);

        assertTrue(users.get(0).getCreationDate() < users.get(users.size() - 1).getCreationDate());
    }

    @Test
    public void getNatural() throws Exception {
        UserNatural john = this.getJohn();

        User user1 = this.api.getUserApi().get(john.getId());
        UserNatural user2 = this.api.getUserApi().getNatural(john.getId());

        assertTrue(user1.getPersonType().equals(PersonType.NATURAL));
        assertTrue(user1.getId().equals(john.getId()));
        assertTrue(user2.getPersonType().equals(PersonType.NATURAL));
        assertTrue(user2.getId().equals(john.getId()));

        assertEqualInputProps(user1, john);
    }

    @Test
    public void getNaturalFailsForLegalUser() throws Exception {
        UserLegal matrix = this.getMatrix();

        UserNatural user = null;
        try {
            user = this.api.getUserApi().getNatural(matrix.getId());

            Assert.fail("GetUser() should throw an exception when called with legal user id");
        } catch (ResponseException ex) {
            assertNull(user);
        }
    }

    @Test
    public void getLegalFailsForNaturalUser() throws Exception {
        UserNatural john = this.getJohn();

        User user = null;
        try {
            user = this.api.getUserApi().getLegal(john.getId());

            Assert.fail("GetLegal() should throw an exception when called with natural user id");
        } catch (ResponseException ex) {
            assertNull(user);
        }
    }

    @Test
    public void getLegal() throws Exception {
        UserLegal matrix = this.getMatrix();

        User user1 = this.api.getUserApi().get(matrix.getId());
        User user2 = this.api.getUserApi().getLegal(matrix.getId());

        assertEqualInputProps(user1, matrix);
        assertEqualInputProps(user2, matrix);
    }

    @Test
    public void updateNatural() throws Exception {
        UserNatural john = this.getJohn();
        john.setLastName(john.getLastName() + " - CHANGED");

        User userSaved = this.api.getUserApi().update(john);
        User userFetched = this.api.getUserApi().get(john.getId());

        assertEqualInputProps(john, userSaved);
        assertEqualInputProps(john, userFetched);
    }

    @Test
    public void updateNaturalNonASCII() throws Exception {
        UserNatural john = this.getJohn();
        john.setLastName(john.getLastName() + " - CHANGED");

        User userSaved = this.api.getUserApi().update(john);
        User userFetched = this.api.getUserApi().get(john.getId());

        assertEqualInputProps(john, userSaved);
        assertEqualInputProps(john, userFetched);
    }

    @Test
    public void updateLegal() throws Exception {
        UserLegal matrix = this.getMatrix();
        matrix.setLegalRepresentativeLastName(matrix.getLegalRepresentativeLastName() + " - CHANGED");

        User userSaved = this.api.getUserApi().update(matrix);
        User userFetched = this.api.getUserApi().get(matrix.getId());

        assertEqualInputProps(userSaved, matrix);
        assertEqualInputProps(userFetched, matrix);
    }

    @Test
    public void updateLegalWithoutAddresses() throws Exception {
        UserLegal matrix = this.getMatrixWithoutOptionalFields();
        matrix.setLegalRepresentativeLastName(matrix.getLegalRepresentativeLastName() + " - CHANGED");

        User userSaved = this.api.getUserApi().update(matrix);
        User userFetched = this.api.getUserApi().get(matrix.getId());

        assertEqualInputProps(userSaved, matrix);
        assertEqualInputProps(userFetched, matrix);
    }

    @Test
    public void createBankAccountIBAN() {
        try {
            UserNatural john = this.getJohn();
            BankAccount account = this.getJohnsAccount();

            assertTrue(account.getId().length() > 0);
            assertEquals(account.getUserId(), john.getId());
        } catch (Exception ex) {
            Assert.fail(ex.getMessage());
        }
    }

    @Test
    public void createBankAccountGB() throws Exception {
        UserNatural john = this.getJohn();
        BankAccount account = new BankAccount();
        account.setType(BankAccountType.GB);
        account.setOwnerName(john.getFirstName() + " " + john.getLastName());
        account.setOwnerAddress(john.getAddress());
        account.setDetails(new BankAccountDetailsGB());
        ((BankAccountDetailsGB) account.getDetails()).setAccountNumber("63956474");
        ((BankAccountDetailsGB) account.getDetails()).setSortCode("200000");
        account.setType(BankAccountType.GB);
        BankAccount createAccount = this.api.getUserApi().createBankAccount(john.getId(), account);

        assertTrue(createAccount.getId().length() > 0);
        assertEquals(createAccount.getUserId(), john.getId());
        assertSame(createAccount.getType(), BankAccountType.GB);
        assertEquals("63956474", ((BankAccountDetailsGB) createAccount.getDetails()).getAccountNumber());
        assertEquals("200000", ((BankAccountDetailsGB) createAccount.getDetails()).getSortCode());
    }

    @Test
    public void createBankAccountUS() throws Exception {
        UserNatural john = this.getJohn();
        BankAccount account = new BankAccount();
        account.setType(BankAccountType.US);
        account.setOwnerName(john.getFirstName() + " " + john.getLastName());
        account.setOwnerAddress(john.getAddress());
        account.setDetails(new BankAccountDetailsUS());
        ((BankAccountDetailsUS) account.getDetails()).setAccountNumber("234234234234");
        ((BankAccountDetailsUS) account.getDetails()).setAba("234334789");

        BankAccount createAccount = this.api.getUserApi().createBankAccount(john.getId(), account);

        assertTrue(createAccount.getId().length() > 0);
        assertEquals(createAccount.getUserId(), john.getId());
        assertSame(createAccount.getType(), BankAccountType.US);
        assertEquals("234234234234", ((BankAccountDetailsUS) createAccount.getDetails()).getAccountNumber());
        assertEquals("234334789", ((BankAccountDetailsUS) createAccount.getDetails()).getAba());
        assertEquals(((BankAccountDetailsUS) createAccount.getDetails()).getDepositAccountType(), DepositAccountType.CHECKING);

        ((BankAccountDetailsUS) account.getDetails()).setDepositAccountType(DepositAccountType.SAVINGS);
        BankAccount createAccountSavings = this.api.getUserApi().createBankAccount(john.getId(), account);

        assertTrue(createAccountSavings.getId().length() > 0);
        assertEquals(createAccountSavings.getUserId(), john.getId());
        assertSame(createAccountSavings.getType(), BankAccountType.US);
        assertEquals("234234234234", ((BankAccountDetailsUS) createAccountSavings.getDetails()).getAccountNumber());
        assertEquals("234334789", ((BankAccountDetailsUS) createAccountSavings.getDetails()).getAba());
        assertEquals(((BankAccountDetailsUS) createAccountSavings.getDetails()).getDepositAccountType(), DepositAccountType.SAVINGS);
    }

    @Test
    public void createBankAccountCA() throws Exception {
        UserNatural john = this.getJohn();
        BankAccount account = new BankAccount();
        account.setType(BankAccountType.CA);
        account.setOwnerName(john.getFirstName() + " " + john.getLastName());
        account.setOwnerAddress(john.getAddress());
        account.setDetails(new BankAccountDetailsCA());
        ((BankAccountDetailsCA) account.getDetails()).setBankName("TestBankName");
        ((BankAccountDetailsCA) account.getDetails()).setBranchCode("12345");
        ((BankAccountDetailsCA) account.getDetails()).setAccountNumber("234234234234");
        ((BankAccountDetailsCA) account.getDetails()).setInstitutionNumber("123");

        BankAccount createAccount = this.api.getUserApi().createBankAccount(john.getId(), account);

        assertTrue(createAccount.getId().length() > 0);
        assertEquals(createAccount.getUserId(), john.getId());
        assertSame(createAccount.getType(), BankAccountType.CA);
        assertEquals("234234234234", ((BankAccountDetailsCA) createAccount.getDetails()).getAccountNumber());
        assertEquals("TestBankName", ((BankAccountDetailsCA) createAccount.getDetails()).getBankName());
        assertEquals("12345", ((BankAccountDetailsCA) createAccount.getDetails()).getBranchCode());
        assertEquals("123", ((BankAccountDetailsCA) createAccount.getDetails()).getInstitutionNumber());
    }

    @Test
    public void createBankAccountOTHER() {
        try {
            UserNatural john = this.getJohn();
            BankAccount account = new BankAccount();
            account.setOwnerName(john.getFirstName() + " " + john.getLastName());
            account.setOwnerAddress(john.getAddress());
            account.setDetails(new BankAccountDetailsOTHER());
            account.setType(BankAccountType.OTHER);
            ((BankAccountDetailsOTHER) account.getDetails()).setCountry(CountryIso.FR);
            ((BankAccountDetailsOTHER) account.getDetails()).setAccountNumber("234234234234");
            ((BankAccountDetailsOTHER) account.getDetails()).setBic("BINAADADXXX");

            BankAccount createAccount = this.api.getUserApi().createBankAccount(john.getId(), account);

            assertTrue(createAccount.getId().length() > 0);
            assertTrue(createAccount.getUserId().equals(john.getId()));
            assertTrue(createAccount.getType() == BankAccountType.OTHER);
            assertTrue(((BankAccountDetailsOTHER) createAccount.getDetails()).getCountry().equals(CountryIso.FR));
            assertTrue(((BankAccountDetailsOTHER) createAccount.getDetails()).getAccountNumber().equals("234234234234"));
            assertTrue(((BankAccountDetailsOTHER) createAccount.getDetails()).getBic().equals("BINAADADXXX"));
        } catch (Exception ex) {
            Assert.fail(ex.getMessage());
        }
    }

    @Test
    public void createBankAccount() throws Exception {
        UserNatural john = this.getJohn();
        BankAccount account = this.getJohnsAccount();

        assertTrue(account.getId().length() > 0);
        assertTrue(account.getUserId().equals(john.getId()));
    }

    @Test
    public void updateBankAccount() throws Exception {
        UserNatural john = this.getJohn();
        BankAccount account = this.getJohnsAccount();

        assertTrue(account.getId().length() > 0);
        assertTrue(account.getUserId().equals(john.getId()));

        // disactivate bank account
        BankAccount disactivateBankAccount = new BankAccount();
        disactivateBankAccount.setActive(false);
        disactivateBankAccount.setType(BankAccountType.IBAN);
        BankAccountDetailsIBAN bankAccountDetails = new BankAccountDetailsIBAN();
        bankAccountDetails.setIban("FR7630004000031234567890143");
        bankAccountDetails.setBic("BNPAFRPP");
        disactivateBankAccount.setDetails(bankAccountDetails);
        BankAccount result = this.api.getUserApi().updateBankAccount(john.getId(), disactivateBankAccount, account.getId());

        assertNotNull(result);
        assertEquals(account.getId(), result.getId());
        assertFalse(result.isActive());
    }

    @Test
    public void getBankAccount() throws Exception {
        UserNatural john = this.getJohn();
        BankAccount account = this.getJohnsAccount();

        BankAccount accountFetched = this.api.getUserApi().getBankAccount(john.getId(), account.getId());

        assertEqualInputProps(account, accountFetched);
    }

    @Test
    public void getBankAccounts() throws Exception {
        UserNatural john = this.getJohn();
        BankAccount account = this.getJohnsAccount();
        Pagination pagination = new Pagination(1, 12);

        List<BankAccount> list = this.api.getUserApi().getBankAccounts(john.getId(), pagination, null);

        int index = -1;
        for (int i = 0; i < list.size(); i++) {
            if (account.getId().equals(list.get(i).getId())) {
                index = i;
                break;
            }
        }

        assertTrue(list.get(0) instanceof BankAccount);
        assertTrue(index > -1);
        assertEqualInputProps(account, list.get(index));
        assertTrue(pagination.getPage() == 1);
        assertTrue(pagination.getItemsPerPage() == 12);
    }

    @Test
    public void getActiveBankAccounts() {
        try {
            UserNatural john = this.getJohn();
            BankAccount account = this.getJohnsAccount();
            List<BankAccount> list = this.api.getUserApi().getActiveBankAccounts(john.getId(), true, null, null);
        } catch (Exception e) {
            Assert.fail(e.getMessage());
        }
    }

    @Test
    public void getBankAccountsAndSortByCreationDate() throws Exception {
        UserNatural john = this.getJohn();
        this.getJohnsAccount();
        this.holdOn(2);
        this.getNewBankAccount();
        Pagination pagination = new Pagination(1, 12);
        Sorting sorting = new Sorting();
        sorting.addField("CreationDate", SortDirection.desc);

        List<BankAccount> list = this.api.getUserApi().getBankAccounts(john.getId(), pagination, sorting);

        assertNotNull(list);
        assertTrue(list.get(0) instanceof BankAccount);
        assertTrue(list.size() > 1);
        assertTrue(list.get(0).getCreationDate() > list.get(1).getCreationDate());
    }


    @Test
    public void createKycDocument() throws Exception {
        KycDocument kycDocument = this.getJohnsKycDocument();

        assertNotNull(kycDocument);
        assertTrue(kycDocument.getStatus() == KycStatus.CREATED);
    }

    @Test
    public void updateKycDocument() throws Exception {
        UserNatural john = this.getJohn();
        KycDocument kycDocument = this.getJohnsKycDocument();

        URL url = getClass().getResource("/com/mangopay/core/TestKycPageFile.png");
        String filePath = new File(url.toURI()).getAbsolutePath();

        this.api.getUserApi().createKycPage(john.getId(), kycDocument.getId(), filePath);

        kycDocument.setStatus(KycStatus.VALIDATION_ASKED);

        KycDocument result = this.api.getUserApi().updateKycDocument(john.getId(), kycDocument);

        assertNotNull(result);
        assertTrue(kycDocument.getType().equals(result.getType()));
        assertTrue(kycDocument.getStatus() == KycStatus.VALIDATION_ASKED);
    }

    @Test
    public void getKycDocument() throws Exception {
        UserNatural john = this.getJohn();
        KycDocument kycDocument = this.getJohnsKycDocument();

        KycDocument result = this.api.getUserApi().getKycDocument(john.getId(), kycDocument.getId());

        assertNotNull(result);
        assertTrue(kycDocument.getId().equals(result.getId()));
        assertTrue(kycDocument.getType().equals(result.getType()));
        //there might be a problem with the JUnit. if you run the test separately, it works, if it's in the bunch, it doesn't.
        //assertTrue(kycDocument.getStatus().equals(result.getStatus()));
        assertTrue(kycDocument.getCreationDate() == result.getCreationDate());
    }

    @Test
    public void createKycPage() throws Exception {
        UserNatural john = this.getJohn();
        KycDocument kycDocument = this.getNewKycDocument();

        URL url = getClass().getResource("/com/mangopay/core/TestKycPageFile.png");
        String filePath = new File(url.toURI()).getAbsolutePath();

        this.api.getUserApi().createKycPage(john.getId(), kycDocument.getId(), filePath);

        kycDocument = this.getNewKycDocument();
        this.api.getUserApi().createKycPage(john.getId(), kycDocument.getId(), Files.readAllBytes(Paths.get(filePath)));
    }

    @Ignore("Can't be tested at this moment")
    @Test
    public void getCards() throws Exception {
        UserNatural john = this.getJohn();
        Pagination pagination = new Pagination(1, 20);
        List<Card> cardsBefore = this.api.getUserApi().getCards(john.getId(), pagination, null);
        PayIn payIn = this.getNewPayInCardDirect();
        Card card = this.api.getCardApi().get(((PayInPaymentDetailsCard) payIn.getPaymentDetails()).getCardId());
        List<Card> cardsAfter = this.api.getUserApi().getCards(john.getId(), pagination, null);

        assertNotNull(cardsBefore);
        assertTrue(cardsAfter.size() > cardsBefore.size());
    }

    @Test
    public void getCardsAndSortByCreationDate() throws Exception {
        UserNatural john = this.getJohn();
        this.getNewPayInCardDirect();
        this.holdOn(2);
        this.getNewPayInCardDirect();
        Pagination pagination = new Pagination(1, 20);
        Sorting sorting = new Sorting();
        sorting.addField("CreationDate", SortDirection.desc);
        List<Card> cards = this.api.getUserApi().getCards(john.getId(), pagination, sorting);

        assertNotNull(cards);
        assertTrue(cards.size() > 1);
        assertTrue(cards.get(0).getCreationDate() > cards.get(1).getCreationDate());
    }

    @Test
    public void getTransactions() throws Exception {
        UserNatural john = this.getJohn();
        Transfer transfer = this.getNewTransfer();
        Pagination pagination = new Pagination(1, 20);

        List<Transaction> transactions = this.api.getUserApi().getTransactions(john.getId(), pagination, new FilterTransactions(), null);

        assertTrue(transactions.size() > 0);
        assertTrue(transactions.get(0).getType() != null);
        assertTrue(transactions.get(0).getStatus() != null);
    }

    @Test
    public void getTransactionsAndSortByCreationDate() throws Exception {
        UserNatural john = this.getJohn();
        this.getNewTransfer();
        this.holdOn(2);
        this.getNewTransfer();
        Pagination pagination = new Pagination(1, 20);
        Sorting sorting = new Sorting();
        sorting.addField("CreationDate", SortDirection.desc);

        List<Transaction> transactions = this.api.getUserApi().getTransactions(john.getId(), pagination, new FilterTransactions(), sorting);

        assertNotNull(transactions);
        assertTrue(transactions.size() > 1);
        assertTrue(transactions.get(0).getCreationDate() > transactions.get(1).getCreationDate());
    }

    @Test
    public void getKycDocuments() throws Exception {
        KycDocument kycDocument = this.getJohnsKycDocument();
        UserNatural user = this.getJohn();
        Pagination pagination = new Pagination(1, 20);

        List<KycDocument> getKycDocuments = this.api.getUserApi().getKycDocuments(user.getId(), pagination, null);

        assertTrue(getKycDocuments.get(0) instanceof KycDocument);
        KycDocument kycFromList = null;
        for (KycDocument item : getKycDocuments) {
            if (item.getId().equals(kycDocument.getId())) {
                kycFromList = item;
                break;
            }
        }
        assertNotNull(kycFromList);
        assertEquals(kycDocument.getId(), kycFromList.getId());
        assertEqualInputProps(kycDocument, kycFromList);
    }

    @Test
    public void getKycDocumentsAndSortByCreationDate() throws Exception {
        this.getJohnsKycDocument();
        this.holdOn(2);
        this.getNewKycDocument();
        UserNatural user = this.getJohn();
        Pagination pagination = new Pagination(1, 20);
        Sorting sorting = new Sorting();
        sorting.addField("CreationDate", SortDirection.desc);

        List<KycDocument> getKycDocuments = this.api.getUserApi().getKycDocuments(user.getId(), pagination, sorting);

        assertNotNull(getKycDocuments);
        assertTrue(getKycDocuments.get(0) instanceof KycDocument);
        assertTrue(getKycDocuments.size() > 1);
        assertTrue(getKycDocuments.get(0).getCreationDate() > getKycDocuments.get(1).getCreationDate());
    }

    @Test
    public void getUserEMoney() throws Exception {
        User john = getJohn();
        String year = "2019";
        String month = "04";
        EMoney eMoney = this.api.getUserApi().getEMoney(john.getId(), year);

        assertNotNull(eMoney);
        assertEquals(eMoney.getUserId(), john.getId());

        eMoney = this.api.getUserApi().getEMoney(john.getId(), year, month);

        assertNotNull(eMoney);
        assertEquals(eMoney.getUserId(), john.getId());
    }

    @Test
    public void getUserEMoneyChf() throws Exception {
        getUserEMoney(CurrencyIso.CHF);
    }

    @Test
    public void getUserEMoneyUsd() throws Exception {
        getUserEMoney(CurrencyIso.USD);
    }

    @Test
    public void testUserEMoneyNullCurrency() throws Exception {
        getUserEMoney(null, CurrencyIso.EUR);
    }

    private void getUserEMoney(CurrencyIso currencySentInRequest) throws Exception {
        getUserEMoney(currencySentInRequest, currencySentInRequest);
    }

    private void getUserEMoney(CurrencyIso currencySentInRequest, CurrencyIso currencyExpected) throws Exception {
        User john = getJohn();
        String year = "2019";
        String month = "04";
        EMoney eMoney = this.api.getUserApi().getEMoney(john.getId(), year, currencySentInRequest);

        assertNotNull(eMoney);
        assertEquals(john.getId(), eMoney.getUserId());
        assertEquals(currencyExpected, eMoney.getCreditedEMoney().getCurrency());

        eMoney = this.api.getUserApi().getEMoney(john.getId(), year, month, currencySentInRequest);

        assertNotNull(eMoney);
        assertEquals(john.getId(), eMoney.getUserId());
        assertEquals(currencyExpected, eMoney.getCreditedEMoney().getCurrency());
    }

    @Test
    @Ignore
    public void getBankAccountTransactions() throws Exception {
        BankAccount johnsAccount = getJohnsAccount();
        PayOut johnsPayOutBankWire = getJohnsPayOutBankWire();
        Pagination pagination = new Pagination(1, 1);
        List<Transaction> bankAccountTransactions = this.api.getUserApi().getBankAccountTransactions(johnsAccount.getId(), pagination, null);

        assertNotNull("List of bank account transactions is null", bankAccountTransactions);
        assertFalse("List of bank account transactions is empty", bankAccountTransactions.isEmpty());
        assertTrue("List of bank account transactions size  does not match pagination", bankAccountTransactions.size() == 1);
        assertEquals("Returned transaction is not the expected one", bankAccountTransactions.get(0).getId(), johnsPayOutBankWire.getId());
    }

    @Test
    public void getUserPreAuthorizations() throws Exception {
        CardPreAuthorization johnsCardPreAuthorization = getJohnsCardPreAuthorization();

        assertNotNull(johnsCardPreAuthorization);
        List<CardPreAuthorization> preAuthorizations = this.api.getUserApi().getPreAuthorizations(johnsCardPreAuthorization.getAuthorId());

        assertNotNull(preAuthorizations);
        assertFalse(preAuthorizations.isEmpty());
        assertNotNull(preAuthorizations.get(0));
        assertTrue(preAuthorizations.get(0).getAuthorId().equals(johnsCardPreAuthorization.getAuthorId()));
    }

    @Test
    public void getUserPreAuthorizationsWithPagination() throws Exception {
        CardPreAuthorization johnsCardPreAuthorization = getJohnsCardPreAuthorization();

        assertNotNull(johnsCardPreAuthorization);

        Pagination pagination = new Pagination(1, 20);

        List<CardPreAuthorization> preAuthorizations = this.api.getUserApi().getPreAuthorizations(johnsCardPreAuthorization.getAuthorId(), pagination, null);

        assertNotNull(preAuthorizations);
        assertFalse(preAuthorizations.isEmpty());
        assertNotNull(preAuthorizations.get(0));
        assertTrue(preAuthorizations.get(0).getAuthorId().equals(johnsCardPreAuthorization.getAuthorId()));
    }

    @Test
    public void getUserPreAuthorizationsWithNullPaginationObject() throws Exception {
        CardPreAuthorization johnsCardPreAuthorization = getJohnsCardPreAuthorization();

        assertNotNull(johnsCardPreAuthorization);

        Pagination pagination = null;

        List<CardPreAuthorization> preAuthorizations = this.api.getUserApi().getPreAuthorizations(johnsCardPreAuthorization.getAuthorId(), null, null);

        assertNotNull(preAuthorizations);
        assertFalse(preAuthorizations.isEmpty());
        assertNotNull(preAuthorizations.get(0));
        assertTrue(preAuthorizations.get(0).getAuthorId().equals(johnsCardPreAuthorization.getAuthorId()));
    }

    @Test
    public void getUserPreAuthorizationsWithPaginationAndFilterReturnsValue() throws Exception {
        CardPreAuthorization johnsCardPreAuthorization = getJohnsCardPreAuthorization();

        assertNotNull(johnsCardPreAuthorization);

        Pagination pagination = new Pagination(1, 20);
        FilterPreAuthorizations fpa = new FilterPreAuthorizations();
        fpa.setPreAuthorizationStatus(PreAuthorizationStatus.SUCCEEDED);
        fpa.setResultCode("000000");

        List<CardPreAuthorization> preAuthorizations = this.api.getUserApi().getPreAuthorizations(johnsCardPreAuthorization.getAuthorId(), pagination, fpa, null);

        assertNotNull(preAuthorizations);
        assertFalse(preAuthorizations.isEmpty());
        assertNotNull(preAuthorizations.get(0));
        assertTrue(preAuthorizations.get(0).getAuthorId().equals(johnsCardPreAuthorization.getAuthorId()));
    }

    @Test
    public void getUserPreAuthorizationsWithPaginationAndFilterDoesNotReturnValue() throws Exception {
        CardPreAuthorization johnsCardPreAuthorization = getJohnsCardPreAuthorization();

        assertNotNull(johnsCardPreAuthorization);

        Pagination pagination = new Pagination(1, 20);
        FilterPreAuthorizations fpa = new FilterPreAuthorizations();
        fpa.setResultCode("000001");

        List<CardPreAuthorization> preAuthorizations = this.api.getUserApi().getPreAuthorizations(johnsCardPreAuthorization.getAuthorId(), pagination, fpa, null);

        assertNotNull(preAuthorizations);
        assertTrue(preAuthorizations.isEmpty());
    }

    @Test
    @Ignore
    // this endpoind isn't on the api just yet
    public void getBlockStatus() throws Exception{
        UserNatural user = this.getJohn();
        UserBlockStatus blockStatus = this.api.getUserApi().getBlockStatus(user.getId());

        assertNotNull(blockStatus);
    }

    @Test
    @Ignore
    // this endpoind isn't on the api just yet
    public void getRegulatory() throws Exception{
        UserNatural user = this.getJohn();
        UserBlockStatus blockStatus = this.api.getUserApi().getRegulatory(user.getId());

        assertNotNull(blockStatus);
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/subentities/PayInPaymentDetailsPreAuthorized.java<|end_filename|>
package com.mangopay.entities.subentities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Dto;
import com.mangopay.core.Shipping;
import com.mangopay.core.enumerations.CultureCode;
import com.mangopay.core.interfaces.PayInPaymentDetails;

/**
 * Class representing the PreAuthorized type for execution option in PayIn entity.
 */
public class PayInPaymentDetailsPreAuthorized extends Dto implements PayInPaymentDetails {

    /**
     * Pre-authorization identifier.
     */
    @SerializedName("PreauthorizationId")
    private String preauthorizationId;

    /**
     * The language to use for the payment page - needs to be the ISO code of the language
     */
    @SerializedName("Culture")
    private CultureCode culture;

    @SerializedName("Shipping")
    private Shipping shipping;

    public String getPreauthorizationId() {
        return preauthorizationId;
    }

    public Shipping getShipping() {
        return shipping;
    }

    public PayInPaymentDetailsPreAuthorized setShipping(Shipping shipping) {
        this.shipping = shipping;
        return this;
    }

    public void setPreauthorizationId(String preauthorizationId) {
        this.preauthorizationId = preauthorizationId;
    }

    public CultureCode getCulture() {
        return culture;
    }

    public PayInPaymentDetailsPreAuthorized setCulture(CultureCode culture) {
        this.culture = culture;
        return this;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/DisputeReason.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.enumerations.DisputeReasonType;

/**
 * Class represents dispute's reason.
 */
public class DisputeReason extends Dto {

    /**
     * Dispute's reason type.
     */
    @SerializedName("DisputeReasonType")
    private DisputeReasonType disputeReasonType;

    /**
     * Dispute's reason message.
     */
    @SerializedName("DisputeReasonMessage")
    private String disputeReasonMessage;

    public DisputeReasonType getDisputeReasonType() {
        return disputeReasonType;
    }

    public void setDisputeReasonType(DisputeReasonType disputeReasonType) {
        this.disputeReasonType = disputeReasonType;
    }

    public String getDisputeReasonMessage() {
        return disputeReasonMessage;
    }

    public void setDisputeReasonMessage(String disputeReasonMessage) {
        this.disputeReasonMessage = disputeReasonMessage;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/implementation/RepudiationApiImpl.java<|end_filename|>
package com.mangopay.core.APIs.implementation;

import com.mangopay.MangoPayApi;
import com.mangopay.core.APIs.ApiBase;
import com.mangopay.core.APIs.RepudiationApi;
import com.mangopay.core.Pagination;
import com.mangopay.core.Sorting;
import com.mangopay.entities.Refund;
import com.mangopay.entities.Repudiation;

import java.util.List;

/**
 * Created by cosmin on 17-11-2017.
 */
public class RepudiationApiImpl extends ApiBase implements RepudiationApi {

    /**
     * Creates new API instance.
     *
     * @param root Root/parent instance that holds the OAuthToken and Configuration instance.
     */
    public RepudiationApiImpl(MangoPayApi root) {
        super(root);
    }

    @Override
    public Repudiation getRepudiation(String repudiationId) throws Exception {
        return this.getObject(Repudiation.class, "disputes_repudiation_get", repudiationId);
    }

    @Override
    public List<Refund> getRefunds(String repudiationId) throws Exception {
        return this.getRefunds(repudiationId, null, null);
    }

    @Override
    public List<Refund> getRefunds(String repudiationId, Pagination pagination, Sorting sorting) throws Exception {
        return this.getList(Refund[].class, Refund.class, "repudiation_get_refunds", pagination, repudiationId, sorting);
    }
}


<|start_filename|>src/test/java/com/mangopay/entities/subentities/PayInExecutionDetailsDirectTest.java<|end_filename|>
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mangopay.entities.subentities;

import com.mangopay.core.enumerations.SecureMode;
import com.mangopay.core.interfaces.PayInExecutionDetails;
import org.junit.*;

import static org.junit.Assert.*;

/**
 * @author <NAME> <EMAIL>
 */
public class PayInExecutionDetailsDirectTest {

    @BeforeClass
    public static void setUpClass() {
    }

    @AfterClass
    public static void tearDownClass() {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of build method, of class PayInExecutionDetailsDirect.
     */
    @Test
    public void testBuild_String_String() {
        String cardId = "CARDID";
        String secureModeReturnURL = "RETURNURL";
        PayInExecutionDetailsDirect executionDetailsDirect = PayInExecutionDetailsDirect.build(cardId, secureModeReturnURL);
        assertNotNull(executionDetailsDirect);
        assertEquals(cardId, executionDetailsDirect.getCardId());
        assertEquals(secureModeReturnURL, executionDetailsDirect.getSecureModeReturnUrl());
    }

    /**
     * Test of build method, of class PayInExecutionDetailsDirect.
     */
    @Test
    public void testBuild_3args() {
        String cardId = "CARDID";
        SecureMode secureMode = SecureMode.DEFAULT;
        String secureModeReturnURL = "RETURNURL";
        PayInExecutionDetailsDirect executionDetailsDirect = PayInExecutionDetailsDirect.build(cardId, secureMode, secureModeReturnURL);
        assertNotNull(executionDetailsDirect);
        assertEquals(cardId, executionDetailsDirect.getCardId());
        assertEquals(secureMode, executionDetailsDirect.getSecureMode());
        assertEquals(secureModeReturnURL, executionDetailsDirect.getSecureModeReturnUrl());
    }

    @Test
    public void testIsSecureModeNeeded() {
        PayInExecutionDetailsDirect executionDetailsDirect = new PayInExecutionDetailsDirect();
        assertFalse(executionDetailsDirect.isSecureModeNeeded());
        executionDetailsDirect.setSecureModeNeeded("False");
        assertFalse(executionDetailsDirect.isSecureModeNeeded());
        executionDetailsDirect.setSecureModeNeeded("True");
        assertTrue(executionDetailsDirect.isSecureModeNeeded());
    }


    @Test
    public void testConvert() throws Exception {
        PayInExecutionDetailsDirect executionDetailsDirect = new PayInExecutionDetailsDirect();
        assertNotNull(executionDetailsDirect);
        PayInExecutionDetails payInExecutionDetails = executionDetailsDirect;
        assertNotNull(payInExecutionDetails);
        executionDetailsDirect = PayInExecutionDetailsDirect.convert(payInExecutionDetails);
        assertNotNull(executionDetailsDirect);
    }

}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/CultureCode.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Culture codes enumeration.
 */
public enum CultureCode {
    /**
    * Not specified.
    */ 
    NotSpecified,

    DE,
    EN,
    DA,
    ES,
    ET,
    FI,
    FR,
    EL,
    HU,
    IT,
    NL,
    NO,
    PL,
    PT,
    SK,
    SV,
    CS,
    
    /*
    * Temporary values to be removed in the future
    */
    de,
    en,
    da,
    es,
    et,
    fi,
    fr,
    el,
    hu,
    it,
    nl,
    no,
    pl,
    pt,
    sk,
    sv,
    cs
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/InitialTransactionType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Initial transaction type enumeration.
 */
public enum InitialTransactionType {
    /**
     * Not specified.
     */
    NotSpecified,

    /**
     * PAYIN transaction type.
     */
    PAYIN,

    /**
     * TRANSFER transaction type.
     */
    TRANSFER,

    /**
     * PAYOUT transaction type.
     */
    PAYOUT
}


<|start_filename|>src/main/java/com/mangopay/core/AuthorizationTokenManager.java<|end_filename|>
package com.mangopay.core;

import com.mangopay.core.interfaces.StorageStrategy;
import com.mangopay.core.APIs.ApiBase;
import com.mangopay.MangoPayApi;

import java.security.*;
import java.math.*;

/**
 * Authorization token manager. This class cannot be inherited.
 */
public final class AuthorizationTokenManager extends ApiBase {
    
    private StorageStrategy storageStrategy;
    
    /**
     * Instantiates new AuthorizationTokenManager object.
     * @param root Root/parent instance that holds the OAuthToken and Configuration instances.
     */
    public AuthorizationTokenManager(MangoPayApi root) {
        super(root);
        
        this.registerCustomStorageStrategy(new DefaultStorageStrategy());
    }
    
    /**
     * Gets the current authorization token.
     * <p>
     * In the very first call, this method creates a new token before returning.
     * If currently stored token is expired, this method creates a new one.
     * @return Valid OAuthToken instance.
     * @throws Exception
     */
    public OAuthToken getToken() throws Exception {
        OAuthToken token = storageStrategy.get(getEnvKey());
        
        if (token == null || token.IsExpired()) {
            storeToken(this.root.getAuthenticationManager().createToken());
        }
        
        return storageStrategy.get(getEnvKey());
    }
    
    /**
     * Stores authorization token passed as an argument in the underlying storage strategy implementation.
     * @param token Token instance to be stored.
     */
    public void storeToken(OAuthToken token) {
        storageStrategy.store(token, getEnvKey());
    }
    
    /**
     * Registers custom storage strategy implementation.
     * <p>
     * By default, the <code>DefaultStorageStrategy</code> instance is used. 
     * There is no need to explicitly call this method until some more complex 
     * storage implementation is needed.
     * @param customStorageStrategy StorageStrategy interface implementation.
     */
    public void registerCustomStorageStrategy(StorageStrategy customStorageStrategy) {
        storageStrategy = customStorageStrategy;
    }
    
    private String getEnvKey() {
        
        String input = root.getConfig().getBaseUrl() + root.getConfig().getClientId() + root.getConfig().getClientPassword();
        String md5 = "";
        
        try {
            MessageDigest m = MessageDigest.getInstance("MD5");
            m.update(input.getBytes(), 0, input.length());
            md5 = new BigInteger(1,m.digest()).toString(16);
        }
        catch (NoSuchAlgorithmException nsaex) {
            /* Intentionally suppress exception here, as MD5 algorithm for sure exists. */
        }
        return md5;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/SecurityInfo.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.enumerations.AVSResult;

public class SecurityInfo extends Dto {

    @SerializedName("AVSResult")
    private AVSResult avsResult;

    public AVSResult getAvsResult() {
        return avsResult;
    }

    public void setAvsResult(AVSResult avsResult) {
        this.avsResult = avsResult;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/DirectDebitType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Direct debit type enumeration.
 */
public enum DirectDebitType {
    /**
     * Not specified.
     */
    NotSpecified,

    /**
     * SOFORT direct debit type.
     */
    SOFORT,

    /**
     * ELV direct debit type.
     */
    ELV,

    /**
     * GIROPAY direct debit type.
     */
    GIROPAY
}


<|start_filename|>src/main/java/com/mangopay/core/interfaces/BankAccountDetails.java<|end_filename|>
package com.mangopay.core.interfaces;

/**
 * Marker interface for classes with bank account details.
 */
public interface BankAccountDetails { }


<|start_filename|>src/main/java/com/mangopay/core/Billing.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;

import java.lang.reflect.Type;
import java.util.Map;

public class Billing extends Dto {

    @SerializedName("FirstName")
    private String firstName;

    @SerializedName("LastName")
    private String lastName;

    @SerializedName("Address")
    private Address address;

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    @Override
    public Map<String, Type> getSubObjects() {

        Map<String, Type> result = super.getSubObjects();

        result.put("Address", Address.class);

        return result;
    }
}


<|start_filename|>src/test/java/com/mangopay/core/BankingAliasApiImplTest.java<|end_filename|>
package com.mangopay.core;

import com.mangopay.core.enumerations.CountryIso;
import com.mangopay.entities.BankingAlias;
import com.mangopay.entities.Wallet;
import org.junit.Test;

import java.util.List;

import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.*;

/**
 * Tests concerning the banking alias API.
 */
public class BankingAliasApiImplTest extends BaseTest {

    @Test
    public void createBankingAlias() throws Exception {
        BankingAlias bankingAlias = getJohnsBankingAlias();

        assertTrue(bankingAlias.getId().length() > 0);
        assertNotNull(bankingAlias.getDetails());
    }

    @Test
    public void getBankingAlias() throws Exception {
        BankingAlias bankingAlias = getJohnsBankingAlias();
        BankingAlias getBankingAlias = this.api.getBankingAliases().get(bankingAlias.getId());

        assertEquals(bankingAlias.getId(), getBankingAlias.getId());
        assertNotNull(bankingAlias.getDetails());
        assertNotNull(getBankingAlias.getDetails());
    }

    @Test
    public void getWalletBankingAliases() throws Exception {
        Wallet wallet = getJohnsWallet();
        BankingAlias bankingAlias = getJohnsBankingAlias();
        List<BankingAlias> bankingAliases = this.api.getBankingAliases().listForWallet(wallet.getId());

        assertEquals(bankingAlias.getId(), bankingAliases.get(0).getId());
    }

    @Test
    public void deactivateBankingAlias() throws Exception {
        BankingAlias bankingAlias = getJohnsBankingAlias();
        bankingAlias.setActive(false);
        BankingAlias deactivatedBankingAlias = this.api.getBankingAliases().deactivate(bankingAlias.getId(), bankingAlias);

        assertFalse(deactivatedBankingAlias.isActive());
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/subentities/ScopeBlocked.java<|end_filename|>
package com.mangopay.entities.subentities;

import com.google.gson.annotations.SerializedName;

public class ScopeBlocked {
    @SerializedName("Inflows")
    private Boolean inflows;

    @SerializedName("Outflows")
    private Boolean outflows;

    public Boolean getInflows() {
        return inflows;
    }

    public ScopeBlocked setInflows(Boolean inflows) {
        this.inflows = inflows;
        return this;
    }

    public Boolean getOutflows() {
        return outflows;
    }

    public ScopeBlocked setOutflows(Boolean outflows) {
        this.outflows = outflows;
        return this;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/implementation/ReportApiImpl.java<|end_filename|>
package com.mangopay.core.APIs.implementation;

import com.mangopay.MangoPayApi;
import com.mangopay.core.APIs.ApiBase;
import com.mangopay.core.APIs.ReportApi;
import com.mangopay.core.FilterReportsList;
import com.mangopay.core.Pagination;
import com.mangopay.core.Sorting;
import com.mangopay.core.enumerations.ReportType;
import com.mangopay.entities.ReportRequest;

import java.util.List;

/**
 * API for reports.
 */
public class ReportApiImpl extends ApiBase implements ReportApi {

    /**
     * Instantiates new ReportApiImpl object.
     *
     * @param root Root/parent instance that holds the OAuthToken and Configuration instance.
     */
    public ReportApiImpl(MangoPayApi root) {
        super(root);
    }

    @Override
    public ReportRequest create(ReportRequest reportRequest) throws Exception {
        if (reportRequest.getReportType() == ReportType.NotSpecified)
            reportRequest.setReportType(ReportType.TRANSACTIONS);

        return create(null, reportRequest);
    }

    @Override
    public ReportRequest create(String idempotencyKey, ReportRequest reportRequest) throws Exception {
        if (reportRequest.getReportType() == ReportType.NotSpecified)
            reportRequest.setReportType(ReportType.TRANSACTIONS);

        //ReportRequestTransport reportRequestTransport = ReportRequestTransport.CreateFromBusinessObject(reportRequest);
        //return this.createObject(ReportRequestTransport.class, idempotencyKey, "MethodKey.ReportRequest", reportRequestTransport, reportRequestTransport.ReportType.ToString()).GetBusinessObject();
        return this.createObject(ReportRequest.class, idempotencyKey, "reports_request", reportRequest, reportRequest.getReportType().toString());
    }

    @Override
    public ReportRequest createWalletReport(ReportRequest reportRequest) throws Exception {
        return this.createObject(ReportRequest.class, null, "reports_wallets_create", reportRequest);
    }

    @Override
    public ReportRequest get(String reportId) throws Exception {
        return this.getObject(ReportRequest.class, "reports_get", reportId);
    }

    @Override
    public List<ReportRequest> getAll(Pagination pagination, FilterReportsList filters, Sorting sort) throws Exception {
        if (filters == null) filters = new FilterReportsList();

        List<ReportRequest> result = this.getList(ReportRequest[].class, ReportRequest.class, "reports_get_all", pagination, null, filters.getValues(), sort);

        return result;
    }

    @Override
    public List<ReportRequest> getAll() throws Exception {
        return this.getAll(null, null, null);
    }
}


<|start_filename|>src/main/java/com/mangopay/core/Address.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.enumerations.CountryIso;

/**
 * Class represents an address.
 */
public class Address extends Dto {

    /**
     * Address line 1.
     */
    @SerializedName("AddressLine1")
    private String addressLine1;

    /**
     * Address line 2.
     */
    @SerializedName("AddressLine2")
    private String addressLine2;

    /**
     * City.
     */
    @SerializedName("City")
    private String city;

    /**
     * Region.
     */
    @SerializedName("Region")
    private String region;

    /**
     * Postal code.
     */
    @SerializedName("PostalCode")
    private String postalCode;

    /**
     * Country.
     */
    @SerializedName("Country")
    private CountryIso country;

    public String getAddressLine1() {
        return addressLine1;
    }

    public void setAddressLine1(String addressLine1) {
        this.addressLine1 = addressLine1;
    }

    public String getAddressLine2() {
        return addressLine2;
    }

    public void setAddressLine2(String addressLine2) {
        this.addressLine2 = addressLine2;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getRegion() {
        return region;
    }

    public void setRegion(String region) {
        this.region = region;
    }

    public String getPostalCode() {
        return postalCode;
    }

    public void setPostalCode(String postalCode) {
        this.postalCode = postalCode;
    }

    public CountryIso getCountry() {
        return country;
    }

    public void setCountry(CountryIso country) {
        this.country = country;
    }

    /**
     * Helper method used internally.
     *
     * @return True if the {@link Address} details are valid.
     */
    public Boolean isValid() {

        return addressLine1 != null ||
                addressLine2 != null ||
                city != null ||
                region != null ||
                postalCode != null ||
                (country != null && country != CountryIso.NotSpecified);

    }

    public Boolean allFieldsNull(){
        return addressLine1 == null &&
                addressLine2 == null &&
                city == null &&
                region == null &&
                postalCode == null &&
                country == null;
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/Mandate.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.EntityBase;
import com.mangopay.core.enumerations.*;

import java.util.ArrayList;

/**
 * Mandate entity.
 */
public class Mandate extends EntityBase {

    /**
     * The bank account ID to associate this mandate against (and hence from where the payins will come from).
     */
    @SerializedName("BankAccountId")
    private String bankAccountId;

    /**
     * The type of mandate – it will be SEPA or BACS but will only be completed once the mandate has been submitted.
     */
    @SerializedName("Scheme")
    private MandateScheme scheme;

    /**
     * The language to use for the confirmation web page presented to your user.
     */
    @SerializedName("Culture")
    private CultureCode culture;

    /**
     * The URL to view/download the mandate document.
     */
    @SerializedName("DocumentURL")
    private String documentUrl;

    /**
     * The URL where you must redirect the user for them to confirm the setup of their mandate and then he will be redirected to the ReturnURL.
     */
    @SerializedName("RedirectURL")
    private String redirectUrl;

    /**
     * URL format expected.
     */
    @SerializedName("ReturnURL")
    private String returnUrl;

    /**
     * ID of the user to which this mandate belongs.
     */
    @SerializedName("UserId")
    private String userId;

    /**
     * The status of the mandate:
     * CREATED (the mandate has been created),
     * SUBMITTED (the mandate has been submitted to the banks and you can now do payments with this mandate),
     * ACTIVE (the mandate is active and has been accepted by the banks and/or successfully used in a payment),
     * FAILED (the mandate has failed for a variety of reasons and is no longer available for payments).
     */
    @SerializedName("Status")
    private MandateStatus status;

    /**
     * Mandate result code.
     */
    @SerializedName("ResultCode")
    private String resultCode;

    /**
     * Mandate result message.
     */
    @SerializedName("ResultMessage")
    private String resultMessage;

    /**
     * Type of mandate.
     */
    @SerializedName("MandateType")
    private MandateType mandateType;

    /**
     * How the mandate has been created.
     */
    @SerializedName("ExecutionType")
    private MandateExecutionType executionType;

    @SerializedName("BankReference")
    private String bankReference;

    public String getBankAccountId() {
        return bankAccountId;
    }

    public void setBankAccountId(String bankAccountId) {
        this.bankAccountId = bankAccountId;
    }

    public MandateScheme getScheme() {
        return scheme;
    }

    public void setScheme(MandateScheme scheme) {
        this.scheme = scheme;
    }

    public CultureCode getCulture() {
        return culture;
    }

    public void setCulture(CultureCode culture) {
        this.culture = culture;
    }

    public String getDocumentUrl() {
        return documentUrl;
    }

    public void setDocumentUrl(String documentUrl) {
        this.documentUrl = documentUrl;
    }

    public String getRedirectUrl() {
        return redirectUrl;
    }

    public void setRedirectUrl(String redirectUrl) {
        this.redirectUrl = redirectUrl;
    }

    public String getReturnUrl() {
        return returnUrl;
    }

    public void setReturnUrl(String returnUrl) {
        this.returnUrl = returnUrl;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public MandateStatus getStatus() {
        return status;
    }

    public void setStatus(MandateStatus status) {
        this.status = status;
    }

    public String getResultCode() {
        return resultCode;
    }

    public void setResultCode(String resultCode) {
        this.resultCode = resultCode;
    }

    public String getResultMessage() {
        return resultMessage;
    }

    public void setResultMessage(String resultMessage) {
        this.resultMessage = resultMessage;
    }

    public MandateType getMandateType() {
        return mandateType;
    }

    public void setMandateType(MandateType mandateType) {
        this.mandateType = mandateType;
    }

    public MandateExecutionType getExecutionType() {
        return executionType;
    }

    public void setExecutionType(MandateExecutionType executionType) {
        this.executionType = executionType;
    }

    public String getBankReference() {
        return bankReference;
    }

    public void setBankReference(String bankReference) {
        this.bankReference = bankReference;
    }

    @Override
    public ArrayList<String> getReadOnlyProperties() {
        ArrayList<String> result = super.getReadOnlyProperties();

        result.add("BankReference");

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/subentities/FallbackReason.java<|end_filename|>
package com.mangopay.entities.subentities;

import com.google.gson.annotations.SerializedName;

public class FallbackReason  {
    @SerializedName("Code")
    private String code;

    @SerializedName("Message")
    private String message;

    public String getCode() {
        return code;
    }

    public FallbackReason setCode(String code) {
        this.code = code;
        return this;
    }

    public String getMessage() {
        return message;
    }

    public FallbackReason setMessage(String message) {
        this.message = message;
        return this;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/implementation/CardPreAuthorizationApiImpl.java<|end_filename|>
package com.mangopay.core.APIs.implementation;

import com.mangopay.MangoPayApi;
import com.mangopay.core.APIs.ApiBase;
import com.mangopay.core.APIs.CardPreAuthorizationApi;
import com.mangopay.core.Pagination;
import com.mangopay.entities.CardPreAuthorization;
import com.mangopay.entities.Transaction;

import java.util.List;

/**
 * API for card pre-authorizations.
 */
public class CardPreAuthorizationApiImpl extends ApiBase implements CardPreAuthorizationApi {

    /**
     * Instantiates new CardPreAuthorizationApiImpl object.
     *
     * @param root Root/parent instance that holds the OAuthToken and Configuration instance.
     */
    public CardPreAuthorizationApiImpl(MangoPayApi root) {
        super(root);
    }

    @Override
    public CardPreAuthorization create(CardPreAuthorization cardPreAuthorization) throws Exception {
        return this.create(null, cardPreAuthorization);
    }

    @Override
    public CardPreAuthorization create(String idempotencyKey, CardPreAuthorization cardPreAuthorization) throws Exception {
        return this.createObject(CardPreAuthorization.class, idempotencyKey, "preauthorization_create", cardPreAuthorization);
    }

    @Override
    public CardPreAuthorization get(String cardPreAuthorizationId) throws Exception {
        return this.getObject(CardPreAuthorization.class, "preauthorization_get", cardPreAuthorizationId);
    }

    @Override
    public CardPreAuthorization update(CardPreAuthorization cardPreAuthorization) throws Exception {
        return this.updateObject(CardPreAuthorization.class, "preauthorization_save", cardPreAuthorization);
    }

    @Override
    public List<Transaction> getTransactions(String cardPreAuthorizationId, Pagination pagination) throws Exception {
        return this.getList(Transaction[].class, Transaction.class,"preauthorization_transactions_get", pagination, cardPreAuthorizationId);
    }
}


<|start_filename|>src/main/java/com/mangopay/core/serializer/UserSerializer.java<|end_filename|>
package com.mangopay.core.serializer;

import com.google.gson.*;
import com.mangopay.core.enumerations.PersonType;
import com.mangopay.entities.User;
import com.mangopay.entities.UserLegal;
import com.mangopay.entities.UserNatural;

import java.lang.reflect.Type;

public class UserSerializer implements JsonSerializer<User> {
    @Override
    public JsonElement serialize(User src, Type typeOfSrc, JsonSerializationContext context) {
        PersonType personType = src.getPersonType();
        JsonObject object = new Gson().toJsonTree(src, typeOfSrc).getAsJsonObject();
        if (personType.equals(PersonType.LEGAL)) {
            if (((UserLegal)src).getHeadquartersAddress() != null && ((UserLegal)src).getHeadquartersAddress().allFieldsNull())
                object.add("HeadquartersAddress", null);
            if (((UserLegal)src).getLegalRepresentativeAddress() != null &&((UserLegal)src).getLegalRepresentativeAddress().allFieldsNull())
                object.add("LegalRepresentativeAddress", null);
            return object;
        } else {
            if (personType.equals(PersonType.NATURAL)) {
                if (((UserNatural)src).getAddress() != null && ((UserNatural)src).getAddress().allFieldsNull())
                    object.add("Address", null);
                return object;
            } else {
                throw new IllegalArgumentException("Invalid user JSON:" + context.toString());
            }
        }
    }
}


<|start_filename|>src/test/java/com/mangopay/core/PayOutApiImplTest.java<|end_filename|>
package com.mangopay.core;

import com.mangopay.core.enumerations.PayOutPaymentType;
import com.mangopay.entities.PayIn;
import com.mangopay.entities.PayOut;
import com.mangopay.entities.Refund;
import com.mangopay.entities.subentities.PayOutPaymentDetailsBankWire;
import org.junit.Test;

import java.util.List;

import static org.junit.Assert.*;

/**
 * PayOutApiImpl test methods
 */
public class PayOutApiImplTest extends BaseTest {

    @Test
    public void createBankWire() throws Exception {
            PayIn payIn = this.getJohnsPayInCardWeb();
            PayOut payOut = this.getJohnsPayOutBankWire();

            assertTrue(payOut.getId().length() > 0);
            assertTrue(payOut.getPaymentType() == PayOutPaymentType.BANK_WIRE);
            assertTrue(payOut.getMeanOfPaymentDetails() instanceof PayOutPaymentDetailsBankWire);
    }

    @Test
    public void createAndGetBankWire() throws Exception {
        PayIn payIn = this.getJohnsPayInCardWeb();
        PayOut payOut = this.getJohnsPayOutBankWire();

        PayOut getPayOut = this.api.getPayOutApi().getBankwire(payOut.getId());

        assertTrue(payOut.getId().length() > 0);
        assertTrue(payOut.getPaymentType() == PayOutPaymentType.BANK_WIRE);
        assertTrue(payOut.getMeanOfPaymentDetails() instanceof PayOutPaymentDetailsBankWire);

        assertTrue(getPayOut.getId().length() > 0);
        assertTrue(getPayOut.getPaymentType() == PayOutPaymentType.BANK_WIRE);
        assertTrue(getPayOut.getMeanOfPaymentDetails() instanceof PayOutPaymentDetailsBankWire);
    }

    @Test
    public void getPayOutRefunds() throws Exception {
        String payOutId = "38233499";//hardcoded and in sync with mangopay test database
        String expectedRefundId = "38239297";//hardcoded and in sync with mangopay test database
        PayOut payOut = this.api.getPayOutApi().get(payOutId);
        assertNotNull("PayOut object is null", payOut);

        List<Refund> refunds = this.api.getPayOutApi().getRefunds(payOutId);
        assertNotNull("Payout refunds api returns null", refunds);
        assertFalse("Payout refunds api returns empty list", refunds.isEmpty());
        assertTrue("Api returns more than 1 refund", refunds.size() == 1);
        assertTrue("Expected refund not found!", refunds.get(0).getId().equals(expectedRefundId));
    }

}


<|start_filename|>src/main/java/com/mangopay/entities/RecurringPayIn.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;

public class RecurringPayIn extends PayIn {

    @SerializedName("RecurringPayinRegistrationId")
    private String recurringPayinRegistrationId;

    public String getRecurringPayinRegistrationId() {
        return recurringPayinRegistrationId;
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/UboDeclaration.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.EntityBase;
import com.mangopay.core.enumerations.UboDeclarationStatus;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Map;

/**
 * UBO declaration entity.
 */
public class UboDeclaration extends EntityBase {

    /**
     * Date of process.
     */
    @SerializedName("ProcessedDate")
    private long processedDate;

    /**
     * Declaration status.
     */
    @SerializedName("Status")
    private UboDeclarationStatus status;

    /**
     * Reason why the declaration was refused.
     */
    @SerializedName("Reason")
    private String reason;

    /**
     * Explanation of why the declaration was refused.
     */
    @SerializedName("Message")
    private String message;

    /**
    * The User Id
     */
    @SerializedName("UserId")
    private String userId;

    /**
     * Listed representations of natural users declared as UBOs.
     * When transmitting a UBO declaration (POST / PUT), must be an array of
     * IDs (string) of the users to be declared as UBOs.
     * In a received UBO declaration (GET), will be an array of representations
     * of the natural users declared as UBOs.
     */
    @SerializedName("Ubos")
    private ArrayList<Ubo> ubos = new ArrayList<>();

    public Long getProcessedDate() {
        return processedDate;
    }

    public UboDeclarationStatus getStatus() {
        return status;
    }

    public void setStatus(UboDeclarationStatus status) {
        this.status = status;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public ArrayList<Ubo> getUbos() {
        return ubos;
    }

    public void setUbos(ArrayList<Ubo> ubos) {
        this.ubos = ubos;
    }

    public String getUserId() { return userId; }

    public void setUserId(String userId) { this.userId = userId; }

    @Override
    public ArrayList<String> getReadOnlyProperties() {
        ArrayList<String> props = super.getReadOnlyProperties();

        props.add("ProcessedDate");
        props.add("Reason");
        props.add("Message");

        return props;
    }

    @Override
    public Map<String, Type> getSubObjects() {

        Map<String, Type> result = super.getSubObjects();

        result.put("Ubos", Ubo.class);

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/DeclaredUboStatus.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Enumeration of possible statuses of a declared UBO.
 */
public enum DeclaredUboStatus {

    /**
     * When declaration of a UBO was created
     */
    CREATED,

    /**
     * When declaration of a UBO was validated
     */
    VALIDATED,

    /**
     * When declaration of a UBO was refused
     */
    REFUSED
}


<|start_filename|>src/main/java/com/mangopay/entities/Refund.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.RefundReason;
import com.mangopay.core.enumerations.InitialTransactionType;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Map;

/**
 * Refund entity.
 */
public class Refund extends Transaction {

    /**
     * Initial transaction identifier.
     */
    @SerializedName("InitialTransactionId")
    private String initialTransactionId;

    /**
     * Initial transaction type.
     */
    @SerializedName("InitialTransactionType")
    private InitialTransactionType initialTransactionType;

    /**
     * Debited wallet identifier.
     */
    @SerializedName("DebitedWalletId")
    private String debitedWalletId;

    /**
     * Credited wallet identifier.
     */
    @SerializedName("CreditedWalletId")
    private String creditedWalletId;

    /**
     * Contains info about the reason for refund.
     */
    @SerializedName("RefundReason")
    private RefundReason refundReason;

    public String getInitialTransactionId() {
        return initialTransactionId;
    }

    public void setInitialTransactionId(String initialTransactionId) {
        this.initialTransactionId = initialTransactionId;
    }

    public InitialTransactionType getInitialTransactionType() {
        return initialTransactionType;
    }

    public void setInitialTransactionType(InitialTransactionType initialTransactionType) {
        this.initialTransactionType = initialTransactionType;
    }

    public String getDebitedWalletId() {
        return debitedWalletId;
    }

    public void setDebitedWalletId(String debitedWalletId) {
        this.debitedWalletId = debitedWalletId;
    }

    public String getCreditedWalletId() {
        return creditedWalletId;
    }

    public void setCreditedWalletId(String creditedWalletId) {
        this.creditedWalletId = creditedWalletId;
    }

    public com.mangopay.core.RefundReason getRefundReason() {
        return refundReason;
    }

    public void setRefundReason(com.mangopay.core.RefundReason refundReason) {
        this.refundReason = refundReason;
    }

    /**
     * Gets map which property is an object and what type of object.
     *
     * @return Collection of field name-field type pairs.
     */
    @Override
    public Map<String, Type> getSubObjects() {

        Map<String, Type> result = super.getSubObjects();

        result.put("RefundReason", RefundReason.class);

        return result;
    }

    /**
     * Gets the collection of read-only fields names.
     *
     * @return List of field names.
     */
    @Override
    public ArrayList<String> getReadOnlyProperties() {

        ArrayList<String> result = super.getReadOnlyProperties();

        result.add("InitialTransactionType");
        result.add("RefundReason");

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/BusinessType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Business type enumeration
 */
public enum BusinessType {

    /**
     * Marketplace business type
     */
    MARKETPLACE,
    /**
     * Crowdfunding business type
     */
    CROWDFUNDING,

    /**
     * Franchise business type
     */
    FRANCHISE,

    /**
     * Other business type
     */
    OTHER

}


<|start_filename|>src/main/java/com/mangopay/entities/Birthplace.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Dto;
import com.mangopay.core.enumerations.CountryIso;

public class Birthplace extends Dto {

    /**
     * City.
     */
    @SerializedName("City")
    private String city;

    /**
     * Country.
     */
    @SerializedName("Country")
    private CountryIso country;

    public Birthplace() {
    }

    public Birthplace(String city, CountryIso country) {
        this.city=city;
        this.country=country;
    }

    public String getCity() { return city; }

    public void setCity(String city) { this.city = city; }

    public CountryIso getCountry() { return country; }

    public void setCountry(CountryIso country) { this.country = country; }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/DownloadReportFormat.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Format of downloaded report.
 */
public enum DownloadReportFormat {
    
    /**
     * Not specified.
     */
    NotSpecified,
    
    /**
     * Comma-separated values.
     */
    CSV
}


<|start_filename|>src/main/java/com/mangopay/core/FilterReportsList.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;

import java.util.HashMap;
import java.util.Map;

/**
 * Filter for reports list.
 */
public class FilterReportsList {

    @SerializedName("BeforeDate")
    private Long beforeDate;

    @SerializedName("AfterDate")
    private Long afterDate;

    public Long getBeforeDate() {
        return beforeDate;
    }

    public void setBeforeDate(Long beforeDate) {
        this.beforeDate = beforeDate;
    }

    public Long getAfterDate() {
        return afterDate;
    }

    public void setAfterDate(Long afterDate) {
        this.afterDate = afterDate;
    }

    public Map<String, String> getValues() {
        Map<String, String> result = new HashMap<>();

        if (beforeDate != null) result.put("BeforeDate", beforeDate.toString());
        if (afterDate != null) result.put("AfterDate", afterDate.toString());

        return result;
    }
    
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/MandateApi.java<|end_filename|>
package com.mangopay.core.APIs;

import com.mangopay.core.FilterMandates;
import com.mangopay.core.Pagination;
import com.mangopay.core.Sorting;
import com.mangopay.entities.Mandate;
import com.mangopay.entities.Transfer;

import java.util.List;

/**
 * Created by thepa on 18-Jan-17.
 */
public interface MandateApi {
    /**
     * Creates new mandate.
     * @param mandate   Mandate instance to be created.
     * @return          Mandate instance returned from API.
     * @throws Exception
     */
    Mandate create(Mandate mandate) throws Exception;

    /**
     * Creates new mandate.
     * @param idempotencyKey    idempotency key for this request.
     * @param mandate           Mandate instance to be created.
     * @return                  Mandate instance returned from API.
     * @throws Exception
     */
    Mandate create(String idempotencyKey, Mandate mandate) throws Exception;

    /**
     * Gets mandate.
     * @param mandateId     Mandate identifier.
     * @return              Mandate instance returned from API.
     * @throws Exception
     */
    Mandate get(String mandateId) throws Exception;

    /**
     * Gets all mandates.
     * @param filters       Filters.
     * @param pagination    Pagination.
     * @param sorting       Sorting.
     * @return              List of Mandate instances returned from API.
     * @throws Exception
     */
    List<Mandate> getAll(FilterMandates filters, Pagination pagination, Sorting sorting) throws Exception;

    /**
     * Gets mandates for user.
     * @param userId        User identifier.
     * @param filters       Filters.
     * @param pagination    Pagination.
     * @param sorting       Sorting.
     * @return              List of Mandate instances returned from API.
     * @throws Exception
     */
    List<Mandate> getForUser(String userId, FilterMandates filters, Pagination pagination, Sorting sorting) throws Exception;

    /**
     * Gets mandates for bank account.
     * @param userId            User identifier.
     * @param bankAccountId     Bank account identifier.
     * @param filters           Filters.
     * @param pagination        Pagination.
     * @param sorting           Sorting.
     * @return                  List of Mandate instances returned from API.
     * @throws Exception
     */
    List<Mandate> getForBankAccount(String userId, String bankAccountId, FilterMandates filters, Pagination pagination, Sorting sorting) throws Exception;

    /**
     * Cancels mandate.
     * @param mandateId     Mandate identifier.
     * @return              Mandate instance returned from API.
     * @throws Exception
     */
    Mandate cancel(String mandateId) throws Exception;


    /**
     * Get first page of mandate's transfers
     * @param mandateId Mandate indentifier
     * @return Collection of transfers
     * @throws Exception
     */
    List<Transfer> getTransfers(String mandateId) throws Exception;

    /**
     * Get page of mandate's transfers
     * @param mandateId Mandate identifier
     * @param pagination Pagination object
     * @param sorting Sorting object
     * @return Collection of transfers
     * @throws Exception
     */
    List<Transfer> getTransfers(String mandateId,Pagination pagination,Sorting sorting) throws Exception;

    /**
     * Get page of mandate's transfers
     * @param mandateId Mandate identifier
     * @param pagination Pagination object
     * @param sorting Sorting object
     * @param filters Status and/or ResultCode filters
     * @return Collection of transfers
     * @throws Exception
     */
    List<Transfer> getTransfers(String mandateId, Pagination pagination, Sorting sorting, FilterMandates filters) throws Exception;
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/TransactionType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Transaction type enumeration.
 */
public enum TransactionType {
    /**
     * Not specified.
     */
    NotSpecified,

    /**
     * PAYIN transaction type.
     */
    PAYIN, 

    /**
     * PAYOUT transaction type.
     */
    PAYOUT, 

    /**
     * TRANSFER transaction type.
     */
    TRANSFER
}


<|start_filename|>src/main/java/com/mangopay/entities/Repudiation.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.EntityBase;
import com.mangopay.core.Money;
import com.mangopay.core.enumerations.TransactionStatus;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;

/**
 * Repudiation entity.
 */
public class Repudiation extends EntityBase {

    /**
     * The Id of the origin payin author.
     */
    @SerializedName("AuthorId")
    private String authorId;

    /**
     * The funds repudiated from the wallet.
     */
    @SerializedName("DebitedFunds")
    private Money debitedFunds;

    /**
     * The fees taken on the repudiation – will always be 0 at this stage.
     */
    @SerializedName("Fees")
    private Money fees;

    /**
     * The amount of credited funds – since there are currently no fees,
     * this will be equal to the DebitedFunds.
     */
    @SerializedName("CreditedFunds")
    private Money creditedFunds;

    /**
     * The wallet from where the repudiation was taken.
     */
    @SerializedName("DebitedWalletId")
    private String debitedWalletId;

    /**
     * The status of the transfer.
     */
    @SerializedName("Status")
    private TransactionStatus status;

    /**
     * The transaction result code.
     */
    @SerializedName("ResultCode")
    private String resultCode;

    /**
     * The transaction result message.
     */
    @SerializedName("ResultMessage")
    private String resultMessage;

    /**
     * The execution date of the repudiation.
     */
    @SerializedName("ExecutionDate")
    private Long executionDate;

    /**
     * The Id of the dispute to which this repudiation corresponds.
     * Note that this value may be null (if it was created before the Dispute
     * objects started to be used – October 2015).
     */
    @SerializedName("DisputeId")
    private String disputeId;

    /**
     * The Id of the transaction that was repudiated.
     */
    @SerializedName("InitialTransactionId")
    private String initialTransactionId;

    /**
     * The initial transaction type.
     */
    @SerializedName("InitialTransactionType")
    private String initialTransactionType;

    public String getAuthorId() {
        return authorId;
    }

    public void setAuthorId(String authorId) {
        this.authorId = authorId;
    }

    public Money getDebitedFunds() {
        return debitedFunds;
    }

    public void setDebitedFunds(Money debitedFunds) {
        this.debitedFunds = debitedFunds;
    }

    public Money getFees() {
        return fees;
    }

    public void setFees(Money fees) {
        this.fees = fees;
    }

    public Money getCreditedFunds() {
        return creditedFunds;
    }

    public void setCreditedFunds(Money creditedFunds) {
        this.creditedFunds = creditedFunds;
    }

    public String getDebitedWalletId() {
        return debitedWalletId;
    }

    public void setDebitedWalletId(String debitedWalletId) {
        this.debitedWalletId = debitedWalletId;
    }

    public TransactionStatus getStatus() {
        return status;
    }

    public void setStatus(TransactionStatus status) {
        this.status = status;
    }

    public String getResultCode() {
        return resultCode;
    }

    public void setResultCode(String resultCode) {
        this.resultCode = resultCode;
    }

    public String getResultMessage() {
        return resultMessage;
    }

    public void setResultMessage(String resultMessage) {
        this.resultMessage = resultMessage;
    }

    public Long getExecutionDate() {
        return executionDate;
    }

    public void setExecutionDate(Long executionDate) {
        this.executionDate = executionDate;
    }

    public String getDisputeId() {
        return disputeId;
    }

    public void setDisputeId(String disputeId) {
        this.disputeId = disputeId;
    }

    public String getInitialTransactionId() {
        return initialTransactionId;
    }

    public void setInitialTransactionId(String initialTransactionId) {
        this.initialTransactionId = initialTransactionId;
    }

    public String getInitialTransactionType() {
        return initialTransactionType;
    }

    public void setInitialTransactionType(String initialTransactionType) {
        this.initialTransactionType = initialTransactionType;
    }

    /**
     * Gets map which property is an object and what type of object.
     *
     * @return Collection of field name-field type pairs.
     */
    @Override
    public Map<String, Type> getSubObjects() {

        return new HashMap<String, Type>() {{
            put("DebitedFunds", Money.class);
            put("Fees", Money.class);
            put("CreditedFunds", Money.class);
        }};
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/subentities/PayInTemplateURLOptions.java<|end_filename|>
package com.mangopay.entities.subentities;

import com.mangopay.core.Dto;

/**
 * Class represents template URL options.
 */
public class PayInTemplateURLOptions extends Dto {
    
    /**
     * PAYLINE options.
     */
    public String PAYLINE;
    
        /**
     * PAYLINEV2 options.
     */
    public String PAYLINEV2;
}


<|start_filename|>src/main/java/com/mangopay/entities/DisputeDocument.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.EntityBase;
import com.mangopay.core.enumerations.DisputeDocumentStatus;
import com.mangopay.core.enumerations.DisputeDocumentType;

/**
 * Dispute document entity.
 */
public class DisputeDocument extends EntityBase {

    /**
     * Type of dispute document.
     */
    @SerializedName("Type")
    private DisputeDocumentType type;

    /**
     * Status of dispute document.
     */
    @SerializedName("Status")
    private DisputeDocumentStatus status;

    /**
     * The Dispute that this document belongs to.
     */
    @SerializedName("DisputeId")
    private String disputeId;

    /**
     * Refused reason type.
     */
    @SerializedName("RefusedReasonType")
    private String refusedReasonType;

    /**
     * Refused reason message.
     */
    @SerializedName("RefusedReasonMessage")
    private String refusedReasonMessage;

    /**
     * Date when this document was processed (UNIX timestamp).
     */
    @SerializedName("ProcessedDate")
    private Long processedDate;

    public DisputeDocumentType getType() {
        return type;
    }

    public void setType(DisputeDocumentType type) {
        this.type = type;
    }

    public DisputeDocumentStatus getStatus() {
        return status;
    }

    public void setStatus(DisputeDocumentStatus status) {
        this.status = status;
    }

    public String getDisputeId() {
        return disputeId;
    }

    public void setDisputeId(String disputeId) {
        this.disputeId = disputeId;
    }

    public String getRefusedReasonType() {
        return refusedReasonType;
    }

    public void setRefusedReasonType(String refusedReasonType) {
        this.refusedReasonType = refusedReasonType;
    }

    public String getRefusedReasonMessage() {
        return refusedReasonMessage;
    }

    public void setRefusedReasonMessage(String refusedReasonMessage) {
        this.refusedReasonMessage = refusedReasonMessage;
    }

    public Long getProcessedDate() {
        return processedDate;
    }
}


<|start_filename|>src/test/java/com/mangopay/core/EventApiImplTest.java<|end_filename|>
package com.mangopay.core;

import com.mangopay.core.enumerations.EventType;
import com.mangopay.entities.Event;
import org.junit.Test;

import java.util.List;

import static org.junit.Assert.assertNotNull;

/**
 * EventApiImpl test methods
 */
public class EventApiImplTest extends BaseTest {

    @Test
    public void getEvents() throws Exception {

        FilterEvents eventsFilter = new FilterEvents();
        eventsFilter.setType(EventType.PAYIN_NORMAL_CREATED);

        List<Event> getEvents = this.api.getEventApi().get(eventsFilter, null, null);

        eventsFilter.setType(EventType.ALL);
        List<Event> getAllEvents = this.api.getEventApi().get(eventsFilter, null, null);

        assertNotNull(getEvents);
        assertNotNull(getAllEvents);
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/MandateExecutionType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Mandate execution type.
 */
public enum MandateExecutionType {
    
    /**
     * Not specified.
     */
    NotSpecified,
    
    /**
     * Web execution type.
     */
    WEB
    
}


<|start_filename|>src/main/java/com/mangopay/core/FilterDisputeDocuments.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.enumerations.DisputeDocumentStatus;
import com.mangopay.core.enumerations.DisputeDocumentType;

import java.util.HashMap;
import java.util.Map;

/**
 * Filter for dispute documents list.
 */
public class FilterDisputeDocuments extends Dto {

    /**
     * Dispute document status.
     */
    @SerializedName("Status")
    private DisputeDocumentStatus status;

    /**
     * Dispute document type.
     */
    @SerializedName("Type")
    private DisputeDocumentType type;

    /**
     * Start date in Unix format: return only dispute documents that have CreationDate BEFORE this date.
     */
    @SerializedName("BeforeDate")
    private Long beforeDate;

    /**
     * End date in Unix format: return only dispute documents that have CreationDate AFTER this date.
     */
    @SerializedName("AfterDate")
    private Long afterDate;

    public DisputeDocumentStatus getStatus() {
        return status;
    }

    public void setStatus(DisputeDocumentStatus status) {
        this.status = status;
    }

    public DisputeDocumentType getType() {
        return type;
    }

    public void setType(DisputeDocumentType type) {
        this.type = type;
    }

    public Long getBeforeDate() {
        return beforeDate;
    }

    public void setBeforeDate(Long beforeDate) {
        this.beforeDate = beforeDate;
    }

    public Long getAfterDate() {
        return afterDate;
    }

    public void setAfterDate(Long afterDate) {
        this.afterDate = afterDate;
    }

    /**
     * Gets map of fields and values.
     *
     * @return Collection of field name-field value pairs.
     */
    @Override
    public Map<String, String> getValues() {
        HashMap<String, String> result = new HashMap<>();

        if (status != null) result.put("Status", status.toString());
        if (type != null) result.put("Type", type.toString());
        if (beforeDate != null) result.put("BeforeDate", Long.toString(beforeDate));
        if (afterDate != null) result.put("AfterDate", Long.toString(afterDate));

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/TransactionStatus.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Transaction status enumeration.
 */
public enum TransactionStatus {
    /**
     * Not specified.
     */
    NotSpecified,

    /**
     * CREATED transaction status.
     */
    CREATED, 

    /**
     * SUCCEEDED transaction status.
     */
    SUCCEEDED, 

    /**
     * FAILED transaction status.
     */
    FAILED
}


<|start_filename|>src/main/java/com/mangopay/core/DefaultStorageStrategy.java<|end_filename|>
package com.mangopay.core;

import com.mangopay.core.interfaces.StorageStrategy;
import java.util.HashMap;
import java.util.Map;

/**
 * Default token storage strategy implementation.
 */
public class DefaultStorageStrategy implements StorageStrategy {

    private static Map<String, OAuthToken> oAuthToken = new HashMap<>();
    
    /**
     * Gets the currently stored token.
     * @param envKey Environment key for token.
     * @return Currently stored token instance or null.
     */
    @Override
    public OAuthToken get(String envKey) {
        if (!oAuthToken.containsKey(envKey)) return null;
        
        return oAuthToken.get(envKey);
    }

    /**
     * Stores authorization token passed as an argument.
     * @param token Token instance to be stored.
     * @param envKey Environment key for token.
     */
    @Override
    public void store(OAuthToken token, String envKey) {
        oAuthToken.put(envKey, token);
    }
    
}


<|start_filename|>src/main/java/com/mangopay/entities/CreateRecurringPayment.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.*;

import java.lang.reflect.Type;
import java.util.Map;

public class CreateRecurringPayment extends Dto {

    @SerializedName("AuthorId")
    private String authorId;

    @SerializedName("CardId")
    private String cardId;

    @SerializedName("CreditedUserId")
    private String creditedUserId;

    @SerializedName("CreditedWalletId")
    private String creditedWalletId;

    @SerializedName("FirstTransactionDebitedFunds")
    private Money firstTransactionDebitedFunds;

    @SerializedName("FirstTransactionFees")
    private Money firstTransactionFees;

    @SerializedName("Billing")
    private Billing billing;

    @SerializedName("Shipping")
    private Shipping shipping;

    @SerializedName("EndDate")
    private Long endDate;

    @SerializedName("Frequency")
    private String frequency;

    @SerializedName("FixedNextAmount")
    private Boolean fixedNextAmount;

    @SerializedName("FractionedPayment")
    private Boolean fractionedPayment;

    @SerializedName("Migration")
    private Boolean migration;

    @SerializedName("NextTransactionDebitedFunds")
    private Money nextTransactionDebitedFunds;

    @SerializedName("NextTransactionFees")
    private Money nextTransactionFees;

    public String getAuthorId() {
        return authorId;
    }

    public void setAuthorId(String authorId) {
        this.authorId = authorId;
    }

    public String getCardId() {
        return cardId;
    }

    public void setCardId(String cardId) {
        this.cardId = cardId;
    }

    public String getCreditedUserId() {
        return creditedUserId;
    }

    public void setCreditedUserId(String creditedUserId) {
        this.creditedUserId = creditedUserId;
    }

    public String getCreditedWalletId() {
        return creditedWalletId;
    }

    public void setCreditedWalletId(String creditedWalletId) {
        this.creditedWalletId = creditedWalletId;
    }

    public Money getFirstTransactionDebitedFunds() {
        return firstTransactionDebitedFunds;
    }

    public void setFirstTransactionDebitedFunds(Money firstTransactionDebitedFunds) {
        this.firstTransactionDebitedFunds = firstTransactionDebitedFunds;
    }

    public Money getFirstTransactionFees() {
        return firstTransactionFees;
    }

    public void setFirstTransactionFees(Money firstTransactionFees) {
        this.firstTransactionFees = firstTransactionFees;
    }

    public Billing getBilling() {
        return billing;
    }

    public void setBilling(Billing billing) {
        this.billing = billing;
    }

    public Shipping getShipping() {
        return shipping;
    }

    public void setShipping(Shipping shipping) {
        this.shipping = shipping;
    }

    public Long getEndDate() {
        return endDate;
    }

    public void setEndDate(Long endDate) {
        this.endDate = endDate;
    }

    public String getFrequency() {
        return frequency;
    }

    public void setFrequency(String frequency) {
        this.frequency = frequency;
    }

    public Boolean isFixedNextAmount() {
        return fixedNextAmount;
    }

    public void setFixedNextAmount(Boolean fixedNextAmount) {
        this.fixedNextAmount = fixedNextAmount;
    }

    public Boolean isFractionedPayment() {
        return fractionedPayment;
    }

    public void setFractionedPayment(Boolean fractionedPayment) {
        this.fractionedPayment = fractionedPayment;
    }

    public Boolean isMigration() {
        return migration;
    }

    public void setMigration(Boolean migration) {
        this.migration = migration;
    }

    public Money getNextTransactionDebitedFunds() {
        return nextTransactionDebitedFunds;
    }

    public void setNextTransactionDebitedFunds(Money nextTransactionDebitedFunds) {
        this.nextTransactionDebitedFunds = nextTransactionDebitedFunds;
    }

    public Money getNextTransactionFees() {
        return nextTransactionFees;
    }

    public void setNextTransactionFees(Money nextTransactionFees) {
        this.nextTransactionFees = nextTransactionFees;
    }

    @Override
    public Map<String, Type> getSubObjects() {

        Map<String, Type> result = super.getSubObjects();

        result.put("Money", Money.class);
        result.put("Billing", Billing.class);
        result.put("Shipping", Shipping.class);

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/RepudiationApi.java<|end_filename|>
package com.mangopay.core.APIs;

import com.mangopay.core.Pagination;
import com.mangopay.core.Sorting;
import com.mangopay.entities.Refund;
import com.mangopay.entities.Repudiation;

import java.util.List;

/**
 * Created by cosmin on 17-11-2017.
 */
public interface RepudiationApi {
    /**
     * Gets repudiation.
     *
     * @param repudiationId Repudiation identifier.
     * @return Repudiation instance returned from API.
     * @throws Exception
     */
    Repudiation getRepudiation(String repudiationId) throws Exception;

    /**
     * Get first page of repudiation's refunds
     *
     * @param repudiationId Repudiation identifier.
     * @return Collection of repudiation refunds
     * @throws Exception
     */
    List<Refund> getRefunds(String repudiationId) throws Exception;

    /**
     * Get a page of repudiation's refunds
     *
     * @param repudiationId Repudiation identifier.
     * @param pagination    Pagination object
     * @param sorting       Sorting object
     * @return Collection of repudiation refunds
     * @throws Exception
     */
    List<Refund> getRefunds(String repudiationId, Pagination pagination, Sorting sorting) throws Exception;
}


<|start_filename|>src/test/java/com/mangopay/entities/TransactionTest.java<|end_filename|>
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mangopay.entities;

import com.mangopay.core.enumerations.TransactionStatus;
import org.junit.*;

import static org.junit.Assert.*;

/**
 * @author <NAME> <EMAIL>
 */
public class TransactionTest {

    @BeforeClass
    public static void setUpClass() {
    }

    @AfterClass
    public static void tearDownClass() {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of getStatus method, of class Transaction.
     */
    @Test
    public void testGetStatus() {
        Transaction transaction = new Transaction();
        assertEquals(TransactionStatus.NotSpecified, transaction.getStatus());
        transaction.setStatus(TransactionStatus.SUCCEEDED);
        assertEquals(TransactionStatus.SUCCEEDED, transaction.getStatus());
    }


    @Test
    public void testIsCreated() {
        Transaction transaction = new Transaction();
        assertFalse(transaction.isCreated());
        transaction.setStatus(TransactionStatus.NotSpecified);
        assertFalse(transaction.isCreated());
        transaction.setStatus(TransactionStatus.CREATED);
        assertTrue(transaction.isCreated());
    }

    @Test
    public void testIsFailed() {
        Transaction transaction = new Transaction();
        assertFalse(transaction.isFailed());
        transaction.setStatus(TransactionStatus.CREATED);
        assertFalse(transaction.isFailed());
        transaction.setStatus(TransactionStatus.FAILED);
        assertTrue(transaction.isFailed());
    }

    @Test
    public void testIsSucceeded() {
        Transaction transaction = new Transaction();
        assertFalse(transaction.isSucceeded());
        transaction.setStatus(TransactionStatus.CREATED);
        assertFalse(transaction.isSucceeded());
        transaction.setStatus(TransactionStatus.SUCCEEDED);
        assertTrue(transaction.isSucceeded());
    }

}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/UboDeclarationRefusedReasonType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Enumeration of reasons why a UBO declaration could be refused.
 */
public enum UboDeclarationRefusedReasonType {

    /**
     * When at least one natural user is missing on the declaration
     */
    MISSING_UBO,

    /**
     * When at least one natural user should not be declared as UBO
     */
    DECLARATION_DO_NOT_MATCH_UBO_INFORMATION,

    /**
     * When at least one natural user declared as UBO has been created
     * with wrong details (i.e. date of birth, country of residence)
     */
    INVALID_UBO_DETAILS
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/implementation/UboDeclarationApiImpl.java<|end_filename|>
package com.mangopay.core.APIs.implementation;

import com.mangopay.MangoPayApi;
import com.mangopay.core.APIs.ApiBase;
import com.mangopay.core.APIs.UboDeclarationApi;
import com.mangopay.core.Pagination;
import com.mangopay.core.Sorting;
import com.mangopay.core.enumerations.UboDeclarationStatus;
import com.mangopay.entities.Ubo;
import com.mangopay.entities.UboDeclaration;

import java.util.List;

/**
 * Implementation for the UboDeclarationApi.
 */
public class UboDeclarationApiImpl extends ApiBase implements UboDeclarationApi {

    /**
     * Creates new UboDeclarationApiImpl instance.
     *
     * @param root Root/parent instance that holds the OAuthToken and Configuration instance.
     */
    public UboDeclarationApiImpl(MangoPayApi root) {
        super(root);
    }

    @Override
    public UboDeclaration create(String userId) throws Exception {
        return this.createObject(UboDeclaration.class,null,"ubo_declaration_create",null,userId);
    }

    @Override
    public List<UboDeclaration> getAll(String userId, Pagination pagination, Sorting sort) throws Exception {
        return this.getList(UboDeclaration[].class,UboDeclaration.class,"ubo_declaration_all", pagination,userId,sort);
    }

    @Override
    public UboDeclaration get(String userId, String uboDeclarationId) throws Exception {
        return this.getObject(UboDeclaration.class,"ubo_declaration_get",userId,uboDeclarationId);
    }

    @Override
    public Ubo createUbo(String userId,String uboDeclarationId, Ubo ubo) throws Exception {
        return this.createObject(Ubo.class,"","ubo_create",ubo,userId,uboDeclarationId);
    }

    @Override
    public Ubo updateUbo(String userId, String uboDeclarationId, Ubo ubo) throws Exception {
        return this.updateObject(Ubo.class, "ubo_update", ubo, userId, uboDeclarationId, ubo.getId());
    }

    @Override
    public Ubo getUbo(String userId, String uboDeclarationId, String uboId) throws Exception {
        return this.getObject(Ubo.class, "ubo_get", userId, uboDeclarationId, uboId);
    }

    @Override
    public UboDeclaration submitForValidation(String userId, String uboDeclarationId) throws Exception {
       UboDeclaration uboDeclaration=new UboDeclaration();
       uboDeclaration.setId(uboDeclarationId);
       uboDeclaration.setStatus(UboDeclarationStatus.VALIDATION_ASKED);
       return this.updateObject(UboDeclaration.class,"ubo_declaration_submit",uboDeclaration,userId);
    }

    @Override
    public UboDeclaration get(String uboDeclarationId) throws Exception {
        return this.getObject(UboDeclaration.class,"ubo_declaration_get_by_id",uboDeclarationId);
    }

}


<|start_filename|>src/test/java/com/mangopay/core/MandateApiImplTest.java<|end_filename|>
package com.mangopay.core;

import com.mangopay.core.enumerations.CultureCode;
import com.mangopay.entities.Mandate;
import com.mangopay.entities.Transfer;
import com.mangopay.entities.UserNatural;
import org.junit.Test;

import java.util.List;

import static org.junit.Assert.*;

/**
 * MandateApiImpl test methods.
 */
public class MandateApiImplTest extends BaseTest {

    @Test
    public void createMandate() throws Exception {
        Mandate mandatePost = new Mandate();
        mandatePost.setBankAccountId(this.getJohnsAccount().getId());
        mandatePost.setReturnUrl("http://test.test");
        mandatePost.setCulture(CultureCode.EN);

        Mandate mandate = this.api.getMandateApi().create(mandatePost);
        assertNotNull(mandate);
        assertFalse(mandate.getId().isEmpty());
    }

    @Test
    public void getMandate() throws Exception {
        Mandate mandatePost = new Mandate();
        mandatePost.setBankAccountId(this.getJohnsAccount().getId());
        mandatePost.setReturnUrl("http://test.test");
        mandatePost.setCulture(CultureCode.EN);

        Mandate mandateCreated = this.api.getMandateApi().create(mandatePost);

        Mandate mandate = this.api.getMandateApi().get(mandateCreated.getId());

        assertNotNull(mandate);
        assertFalse(mandate.getId().isEmpty());
        assertEquals(mandateCreated.getId(), mandate.getId());
    }

    /*
    @Test
    public void cancelMandate() throws Exception {
        String bankAccountId = this.getJohnsAccount().getId();
        String returnUrl = "http://test.test";

        Mandate mandatePost = new Mandate();
        mandatePost.setBankAccountId(bankAccountId);
        mandatePost.setCulture(CultureCode.EN);
        mandatePost.setReturnURL(returnUrl);

        Mandate mandate = this.api.getMandateApi().create(mandatePost);

        //	! IMPORTANT NOTE !
        //	
        //	In order to make this test pass, at this place you have to set a breakpoint,
        //	navigate to URL the mandate.RedirectURL property points to and click "CONFIRM" button.

        mandate = this.api.getMandateApi().get(mandate.getId());

        assertTrue("In order to make this test pass, after creating mandate and before cancelling it you have to navigate to URL the mandate.RedirectURL property points to and click CONFIRM button.", mandate.getStatus() == MandateStatus.SUBMITTED);

        mandate = this.api.getMandateApi().cancel(mandate.getId());

        assertNotNull(mandate);
        assertTrue(mandate.getStatus() == MandateStatus.FAILED);
    }
    */

    @Test
    public void getAllMandates() throws Exception {
        FilterMandates filters = new FilterMandates();
        List<Mandate> mandates = this.api.getMandateApi().getAll(filters, null, null);

        assertNotNull(mandates);
        assertTrue(mandates.size() > 0);
    }

    @Test
    public void getMandatesForUser() throws Exception {
        UserNatural user = this.getJohn(true);

        Mandate mandatePost = new Mandate();
        mandatePost.setBankAccountId(this.getJohnsAccount(true).getId());
        mandatePost.setReturnUrl("http://test.test");
        mandatePost.setCulture(CultureCode.EN);

        Mandate mandateCreated = this.api.getMandateApi().create(mandatePost);

        List<Mandate> mandates = this.api.getMandateApi().getForUser(user.getId(), new FilterMandates(), new Pagination(1, 1), null);

        assertNotNull(mandates);
        assertTrue(mandates.size() > 0);

        assertNotNull(mandates.get(0));
        assertTrue(mandates.get(0).getId().length() > 0);
        assertEquals(mandateCreated.getId(), mandates.get(0).getId());
    }

    @Test
    public void getMandatesForBankAccount() throws Exception {
        UserNatural user = this.getJohn(true);

        Mandate mandatePost = new Mandate();
        mandatePost.setBankAccountId(this.getJohnsAccount(true).getId());
        mandatePost.setReturnUrl("http://test.test");
        mandatePost.setCulture(CultureCode.EN);

        Mandate mandateCreated = this.api.getMandateApi().create(mandatePost);

        List<Mandate> mandates = this.api.getMandateApi().getForBankAccount(user.getId(), mandatePost.getBankAccountId(), new FilterMandates(), new Pagination(1, 1), null);

        assertNotNull(mandates);
        assertTrue(mandates.size() > 0);

        assertNotNull(mandates.get(0));
        assertTrue(mandates.get(0).getId().length() > 0);
        assertEquals(mandateCreated.getId(), mandates.get(0).getId());
    }

    @Test
    public void getMandateTransfers() throws Exception {
        String mandateId = "15397886";// synced with mangopay sandbox
        List<Transfer> transfers = this.api.getMandateApi().getTransfers("15397886", new Pagination(1, 1), null);
        assertNotNull(transfers);
        assertTrue(transfers.size() == 1);
    }

}


<|start_filename|>src/main/java/com/mangopay/entities/Transfer.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;

/**
 * Transfer entity.
 */
public class Transfer extends Transaction {

    /**
     * Debited wallet identifier.
     */
    @SerializedName("DebitedWalletId")
    private String debitedWalletId;

    /**
     * Credited wallet identifier.
     */
    @SerializedName("CreditedWalletId")
    private String creditedWalletId;

    public String getDebitedWalletId() {
        return debitedWalletId;
    }

    public void setDebitedWalletId(String debitedWalletId) {
        this.debitedWalletId = debitedWalletId;
    }

    public String getCreditedWalletId() {
        return creditedWalletId;
    }

    public void setCreditedWalletId(String creditedWalletId) {
        this.creditedWalletId = creditedWalletId;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/DeclaredUbo.java<|end_filename|>
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.enumerations.UboRefusedReasonType;
import com.mangopay.core.enumerations.DeclaredUboStatus;

/**
 * Represents validation status of a user declared as UBO.
 */
public class DeclaredUbo extends Dto {

    /**
     * ID of the declared user.
     */
    @SerializedName("UserId")
    private String userId;

    /**
     * Validation status of this declared UBO.
     */
    @SerializedName("Status")
    private DeclaredUboStatus status;

    /**
     * Reason why the declared UBO is not valid.
     */
    @SerializedName("RefusedReasonType")
    private UboRefusedReasonType refusedReasonType;

    /**
     * Message explaining why the UBO is not valid.
     */
    @SerializedName("RefusedReasonMessage")
    private String refusedReasonMessage;

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public DeclaredUboStatus getStatus() {
        return status;
    }

    public void setStatus(DeclaredUboStatus status) {
        this.status = status;
    }

    public UboRefusedReasonType getRefusedReasonType() {
        return refusedReasonType;
    }

    public void setRefusedReasonType(UboRefusedReasonType refusedReasonType) {
        this.refusedReasonType = refusedReasonType;
    }

    public String getRefusedReasonMessage() {
        return refusedReasonMessage;
    }

    public void setRefusedReasonMessage(String refusedReasonMessage) {
        this.refusedReasonMessage = refusedReasonMessage;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/interfaces/StorageStrategy.java<|end_filename|>
package com.mangopay.core.interfaces;

import com.mangopay.core.OAuthToken;

/**
 * Storage strategy interface.
 */
public interface StorageStrategy {
    
    OAuthToken get(String envKey);
    
    void store(OAuthToken token, String envKey);
    
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/MandateScheme.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Scheme of mandate.
 */
public enum MandateScheme {
    
    /**
     *  Not specified.
     */
    NotSpecified,

    /**
     * SEPA scheme.
     */
    SEPA,

    /**
     * BACS scheme.
     */
    BACS
}


<|start_filename|>src/test/java/com/mangopay/core/ObjectToolTest.java<|end_filename|>
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mangopay.core;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author <NAME> <EMAIL>
 */
public class ObjectToolTest {
    
    public ObjectToolTest() {
    }
    
    @BeforeClass
    public static void setUpClass() {
    }
    
    @AfterClass
    public static void tearDownClass() {
    }
    
    @Before
    public void setUp() {
    }
    
    @After
    public void tearDown() {
    }

    /**
     * Test of nonNull method, of class ObjectTool.
     */
    @Test
    public void testNonNull() {
        Object object = null;
        assertFalse(ObjectTool.nonNull(object));
        object = new Object();
        assertTrue(ObjectTool.nonNull(object));
    }

    /**
     * Test of isNull method, of class ObjectTool.
     */
    @Test
    public void testIsNull() {
        Object object = null;
        assertTrue(ObjectTool.isNull(object));
        object = new Object();
        assertFalse(ObjectTool.isNull(object));
    }
    
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/TransferApi.java<|end_filename|>
package com.mangopay.core.APIs;

import com.mangopay.core.Pagination;
import com.mangopay.core.Sorting;
import com.mangopay.entities.Refund;
import com.mangopay.entities.Transfer;

import java.util.List;

/**
 * Created by thepa on 18-Jan-17.
 */
public interface TransferApi {
    /**
     * Creates new transfer.
     * @param transfer  Instance of Transfer class to be created.
     * @return          Transfer object returned from API.
     * @throws Exception
     */
    Transfer create(Transfer transfer) throws Exception;

    /**
     * Creates new transfer.
     * @param idempotencyKey    idempotency key for this request.
     * @param transfer          Instance of Transfer class to be created.
     * @return                  Transfer object returned from API.
     * @throws Exception
     */
    Transfer create(String idempotencyKey, Transfer transfer) throws Exception;

    /**
     * Gets the transfer.
     * @param transferId    Transfer identifier.
     * @return              Transfer instance returned from API.
     * @throws Exception
     */
    Transfer get(String transferId) throws Exception;

    /**
     * Creates refund for transfer object.
     * @param transferId Transfer identifier.
     * @param refund Refund object to create.
     * @return Refund entity instance returned from API.
     * @throws Exception
     */
    Refund createRefund(String transferId, Refund refund) throws Exception;

    /**
     * Creates refund for transfer object.
     * @param idempotencyKey    idempotency key for this request.
     * @param transferId        Transfer identifier.
     * @param refund            Refund object to create.
     * @return Refund entity instance returned from API.
     * @throws Exception
     */
    Refund createRefund(String idempotencyKey, String transferId, Refund refund) throws Exception;

    /**
     * Gets refund for transfer object.
     * @param transferId Transfer identifier.
     * @return Refund entity instance returned from API.
     * @throws Exception
     */
    Refund getRefund(String transferId) throws Exception;

    /**
     * Get first page of transfer's refunds
     * @param transferId Transfer identifier
     * @return Collection of transfer refunds
     * @throws Exception
     */
    List<Refund> getRefunds(String transferId) throws Exception;

    /**
     * Get a page of transfer's refunds
     * @param transferId Transfer identifier
     * @param pagination Pagination object
     * @param sorting Sorting object
     * @return Collection of refunds
     * @throws Exception
     */
    List<Refund> getRefunds(String transferId, Pagination pagination, Sorting sorting) throws Exception;
}


<|start_filename|>src/main/java/com/mangopay/entities/RecurringPayment.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;

public class RecurringPayment extends CreateRecurringPayment {
    @SerializedName("Id")
    private String id;

    @SerializedName("Status")
    private String status;

    @SerializedName("TotalAmount")
    private Integer totalAmount;

    @SerializedName("CycleNumber")
    private Integer cycleNumber;

    @SerializedName("FreeCycles")
    private Integer freeCycles;

    public String getId() {
        return id;
    }

    public String getStatus() {
        return status;
    }

    public int getTotalAmount() {
        return totalAmount;
    }

    public int getCycleNumber() {
        return cycleNumber;
    }

    public int getFreeCycles() {
        return freeCycles;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/FundsType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Funds type enumeration.
 */
public enum FundsType {
    
    /**
     * Not specified.
     */
    NotSpecified,
    
    /**
     * Default type.
     */
    DEFAULT,
    
    /**
     * Fees type.
     */
    FEES,
    
    /**
     * Credit type.
     */
    CREDIT
    
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/UboRefusedReasonType.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Enumerated reasons why declaration of a user as UBO was refused.
 */
public enum UboRefusedReasonType {

    /**
     * When user should not be declared as UBO
     */
    INVALID_DECLARED_UBO,

    /**
     * User declared as UBO was created with wrong
     * details (i.e. date of birth, country of residence).
     */
    INVALID_UBO_DETAILS
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/SortDirection.java<|end_filename|>
package com.mangopay.core.enumerations;


/**
 * Sort direction enumeration.
 */
public enum SortDirection {
    
    none,
    asc,
    desc
    
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/HookApi.java<|end_filename|>
package com.mangopay.core.APIs;

import com.mangopay.core.Pagination;
import com.mangopay.core.Sorting;
import com.mangopay.entities.Hook;

import java.util.List;

/**
 * Created by thepa on 18-Jan-17.
 */
public interface HookApi {
    /**
     * Creates new hook.
     * @param hook      Hook instance to be created.
     * @return          Hook instance returned from API.
     * @throws Exception
     */
    Hook create(Hook hook) throws Exception;

    /**
     * Creates new hook.
     * @param idempotencyKey    idempotency key for this request.
     * @param hook              Hook instance to be created.
     * @return                  Hook instance returned from API.
     * @throws Exception
     */
    Hook create(String idempotencyKey, Hook hook) throws Exception;

    /**
     * Gets hook.
     * @param hookId    Hook identifier.
     * @return          Hook instance returned from API.
     * @throws Exception
     */
    Hook get(String hookId) throws Exception;

    /**
     * Saves hook.
     * @param hook      Hook instance to be saved.
     * @return          Hook instance returned from API.
     * @throws Exception
     */
    Hook update(Hook hook) throws Exception;

    /**
     * Gets all hooks.
     * @param pagination    Pagination.
     * @return              List of Hook instances returned from API.
     * @throws Exception
     */
    List<Hook> getAll(Pagination pagination, Sorting sorting) throws Exception;

    /**
     * Gets all hooks.
     * @return              List of Hook instances returned from API.
     * @throws Exception
     */
    List<Hook> getAll() throws Exception;
}


<|start_filename|>src/main/java/com/mangopay/entities/ReportRequest.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.EntityBase;
import com.mangopay.core.FilterReports;
import com.mangopay.core.Sorting;
import com.mangopay.core.enumerations.DownloadReportFormat;
import com.mangopay.core.enumerations.ReportStatus;
import com.mangopay.core.enumerations.ReportType;
import com.mangopay.core.enumerations.SortDirection;

import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;

import static com.mangopay.core.enumerations.ReportType.TRANSACTIONS;

/**
 * Report request entity.
 */
public class ReportRequest extends EntityBase {

    /**
     * Date of when the report was requested.
     */
    @SerializedName("ReportDate")
    private long reportDate;

    /**
     * Status of the report.
     */
    @SerializedName("Status")
    private ReportStatus status;

    /**
     * Download file format.
     */
    @SerializedName("DownloadFormat")
    private DownloadReportFormat downloadFormat;

    /**
     * Download URL.
     */
    @SerializedName("DownloadURL")
    private String downloadUrl;

    /**
     * Callback URL.
     */
    @SerializedName("CallbackURL")
    private String callbackUrl;

    /**
     * Type of the report.
     */
    @SerializedName("ReportType")
    private ReportType reportType;

    /**
     * Sorting.
     */
    @SerializedName("Sort")
    private String sort;

    /**
     * If true, the report will be limited to the first few lines.
     */
    @SerializedName("Preview")
    private boolean preview;

    /**
     * Filters for the report list results.
     */
    @SerializedName("Filters")
    private FilterReports filters;

    /**
     * Columns to be included in the report.
     * Allowed values: "Alias", "BankAccountId", "BankWireRef", "CardId",
     * "CardType", "Country", "Culture", "Currency", "DeclaredDebitedFundsAmount",
     * "DeclaredDebitedFundsCurrency", "DeclaredFeesAmount",
     * "DeclaredFeesCurrency", "ExecutionType", "ExpirationDate", "PaymentType",
     * "PreauthorizationId", "WireReference".
     */
    @SerializedName("Columns")
    private List<String> columns;

    /**
     * Request's result code.
     */
    @SerializedName("ResultCode")
    private String resultCode;

    /**
     * Request's result message.
     */
    @SerializedName("ResultMessage")
    private String resultMessage;

    public ReportRequest() {
        this.downloadFormat = DownloadReportFormat.CSV;
        this.filters = new FilterReports();
        this.reportType = TRANSACTIONS;

        Sorting s = new Sorting();
        s.addField("CreationDate", SortDirection.asc);

        this.sort = s.getFields();
    }

    public long getReportDate() {
        return reportDate;
    }

    public void setReportDate(long reportDate) {
        this.reportDate = reportDate;
    }

    public ReportStatus getStatus() {
        return status;
    }

    public void setStatus(ReportStatus status) {
        this.status = status;
    }

    public DownloadReportFormat getDownloadFormat() {
        return downloadFormat;
    }

    public void setDownloadFormat(DownloadReportFormat downloadFormat) {
        this.downloadFormat = downloadFormat;
    }

    public String getDownloadUrl() {
        return downloadUrl;
    }

    public void setDownloadUrl(String downloadUrl) {
        this.downloadUrl = downloadUrl;
    }

    public String getCallbackUrl() {
        return callbackUrl;
    }

    public void setCallbackUrl(String callbackUrl) {
        this.callbackUrl = callbackUrl;
    }

    public ReportType getReportType() {
        return reportType;
    }

    public void setReportType(ReportType reportType) {
        this.reportType = reportType;
    }

    public String getSort() {
        return sort;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public boolean isPreview() {
        return preview;
    }

    public void setPreview(boolean preview) {
        this.preview = preview;
    }

    public FilterReports getFilters() {
        return filters;
    }

    public void setFilters(FilterReports filters) {
        this.filters = filters;
    }

    public List<String> getColumns() {
        return columns;
    }

    public void setColumns(List<String> columns) {
        this.columns = columns;
    }

    public String getResultCode() {
        return resultCode;
    }

    public void setResultCode(String resultCode) {
        this.resultCode = resultCode;
    }

    public String getResultMessage() {
        return resultMessage;
    }

    public void setResultMessage(String resultMessage) {
        this.resultMessage = resultMessage;
    }

    /**
     * Gets map which property is an object and what type of object.
     *
     * @return Collection of field name-field type pairs.
     */
    @Override
    public Map<String, Type> getSubObjects() {

        Map<String, Type> result = super.getSubObjects();

        result.put("Filters", FilterReports.class);

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/subentities/PayInPaymentDetailsApplePay.java<|end_filename|>
package com.mangopay.entities.subentities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Dto;
import com.mangopay.core.interfaces.PayInPaymentDetails;

import java.lang.reflect.Type;
import java.util.Map;

public class PayInPaymentDetailsApplePay extends Dto implements PayInPaymentDetails {

    @SerializedName("PaymentData")
    private PaymentData paymentData;

    @SerializedName("StatementDescriptor")
    private String statementDescriptor;

    public PaymentData getPaymentData() {
        return paymentData;
    }

    public PayInPaymentDetailsApplePay setPaymentData(PaymentData paymentData) {
        this.paymentData = paymentData;
        return this;
    }

    public String getStatementDescriptor() {
        return statementDescriptor;
    }

    public PayInPaymentDetailsApplePay setStatementDescriptor(String statementDescriptor) {
        this.statementDescriptor = statementDescriptor;
        return this;
    }

    @Override
    public Map<String, Type> getSubObjects() {
        Map<String, Type> subObjects = super.getSubObjects();

        subObjects.put("PaymentData", PaymentData.class);

        return subObjects;
    }
}


<|start_filename|>src/main/java/com/mangopay/entities/Hook.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.EntityBase;
import com.mangopay.core.enumerations.EventType;
import com.mangopay.core.enumerations.HookStatus;
import com.mangopay.core.enumerations.Validity;

/**
 * Hooks and Notifications entity.
 */
public class Hook extends EntityBase {

    /**
     * This is the URL where you receive notification for various event types.
     */
    @SerializedName("Url")
    private String url;

    /**
     * Hook status.
     */
    @SerializedName("Status")
    private HookStatus status;

    /**
     * Hook validity.
     */
    @SerializedName("Validity")
    private Validity validity;

    /**
     * Event type (the <code>EventType.ALL</code> value is forbidden here).
     */
    @SerializedName("EventType")
    private EventType eventType;

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public HookStatus getStatus() {
        return status;
    }

    public void setStatus(HookStatus status) {
        this.status = status;
    }

    public Validity getValidity() {
        return validity;
    }

    public void setValidity(Validity validity) {
        this.validity = validity;
    }

    public EventType getEventType() {
        return eventType;
    }

    public void setEventType(EventType eventType) {
        this.eventType = eventType;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/APIs/implementation/OAuthApiImpl.java<|end_filename|>
package com.mangopay.core.APIs.implementation;

import com.mangopay.MangoPayApi;
import com.mangopay.core.APIs.ApiBase;
import com.mangopay.core.APIs.OAuthApi;
import com.mangopay.core.AuthenticationHelper;
import com.mangopay.core.OAuthToken;
import com.mangopay.core.RestTool;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * API for OAuth.
 */
public class OAuthApiImpl extends ApiBase implements OAuthApi {

    /**
     * Instantiates new OAuthApiImpl object.
     *
     * @param root Root/parent instance that holds the OAuthToken and Configuration instance.
     */
    public OAuthApiImpl(MangoPayApi root) {
        super(root);
    }

    @Override
    public OAuthToken createToken() throws Exception {

        String urlMethod = this.getRequestUrl("authentication_oauth");
        String requestType = this.getRequestType("authentication_oauth");
        Map<String, String> requestData = new HashMap<String, String>() {{
            put("grant_type", "client_credentials");
        }};

        RestTool rest = new RestTool(this.root, false);
        AuthenticationHelper authHlp = new AuthenticationHelper(root);

        try {
            rest.addRequestHttpHeader("Host", (new URL(root.getConfig().getBaseUrl())).getHost());
        } catch (MalformedURLException ex) {
            Logger.getLogger(OAuthApiImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            rest.addRequestHttpHeader("Authorization", "Basic " + authHlp.getHttpHeaderBasicKey());
        } catch (Exception ex) {
            Logger.getLogger(OAuthApiImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        rest.addRequestHttpHeader("Content-Type", "application/x-www-form-urlencoded");
        rest.addRequestHttpHeader("User-Agent",  String.format("MangoPay V2 SDK Java %s", getRoot().getConfig().getVersion()));
        OAuthToken response = rest.request(OAuthToken.class, null, urlMethod, requestType, requestData);

        return response;
    }

}


<|start_filename|>src/main/java/com/mangopay/entities/UserNatural.java<|end_filename|>
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Address;
import com.mangopay.core.enumerations.CountryIso;
import com.mangopay.core.enumerations.NaturalUserCapacity;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Map;

import static com.mangopay.core.enumerations.PersonType.NATURAL;

/**
 * UserNatural entity.
 */
public final class UserNatural extends User {

    /**
     * First name.
     */
    @SerializedName("FirstName")
    private String firstName;

    /**
     * Last name.
     */
    @SerializedName("LastName")
    private String lastName;

    /**
     * Address.
     */
    @SerializedName("Address")
    private Address address;

    /**
     * Date of birth (UNIX timestamp).
     */
    @SerializedName("Birthday")
    private long birthday;

    /**
     * Place of birth.
     */
    @SerializedName("Birthplace")
    private String birthplace;

    /**
     * User's country.
     */
    @SerializedName("Nationality")
    private CountryIso nationality;

    /**
     * Country of residence.
     */
    @SerializedName("CountryOfResidence")
    private CountryIso countryOfResidence;

    /**
     * User's occupation.
     */
    @SerializedName("Occupation")
    private String occupation;

    /**
     * Income ranges:
     * 1 (-18K€),
     * 2 (18-30K€),
     * 3 (30-50K€),
     * 4 (50-80K€),
     * 5 (80-120K€),
     * 6 (+120K€)
     */
    public static class IncomeRanges {
        public static final Integer Below18 = 1;
        public static final Integer From18To30 = 2;
        public static final Integer From30To50 = 3;
        public static final Integer From50To80 = 4;
        public static final Integer From80To120 = 5;
        public static final Integer Above120 = 6;
    }

    /**
     * Income range. One of UserNatural.IncomeRanges constants.
     */
    @SerializedName("IncomeRange")
    private Integer incomeRange;

    /**
     * Proof of identity.
     */
    @SerializedName("ProofOfIdentity")
    private String proofOfIdentity;

    /**
     * Proof of address.
     */
    @SerializedName("ProofOfAddress")
    private String proofOfAddress;

    /**
     * Capacity of the user within MangoPay.
     */
    @SerializedName("Capacity")
    private NaturalUserCapacity capacity;

    /**
     * Instantiates new UserNatural object.
     */
    public UserNatural() {
        this.personType = NATURAL;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public com.mangopay.core.Address getAddress() {
        return address;
    }

    public void setAddress(com.mangopay.core.Address address) {
        this.address = address;
    }

    public long getBirthday() {
        return birthday;
    }

    public void setBirthday(long birthday) {
        this.birthday = birthday;
    }

    public String getBirthplace() {
        return birthplace;
    }

    public void setBirthplace(String birthplace) {
        this.birthplace = birthplace;
    }

    public CountryIso getNationality() {
        return nationality;
    }

    public void setNationality(CountryIso nationality) {
        this.nationality = nationality;
    }

    public CountryIso getCountryOfResidence() {
        return countryOfResidence;
    }

    public void setCountryOfResidence(CountryIso countryOfResidence) {
        this.countryOfResidence = countryOfResidence;
    }

    public String getOccupation() {
        return occupation;
    }

    public void setOccupation(String occupation) {
        this.occupation = occupation;
    }

    public Integer getIncomeRange() {
        return incomeRange;
    }

    public void setIncomeRange(Integer incomeRange) {
        this.incomeRange = incomeRange;
    }

    public String getProofOfIdentity() {
        return proofOfIdentity;
    }

    public void setProofOfIdentity(String proofOfIdentity) {
        this.proofOfIdentity = proofOfIdentity;
    }

    public String getProofOfAddress() {
        return proofOfAddress;
    }

    public void setProofOfAddress(String proofOfAddress) {
        this.proofOfAddress = proofOfAddress;
    }

    public NaturalUserCapacity getCapacity() {
        return capacity;
    }

    public void setCapacity(NaturalUserCapacity capacity) {
        this.capacity = capacity;
    }

    /**
     * Gets map which property is an object and what type of object.
     *
     * @return Collection of field name-field type pairs.
     */
    @Override
    public Map<String, Type> getSubObjects() {

        Map<String, Type> result = super.getSubObjects();

        result.put("Address", Address.class);

        return result;
    }

    /**
     * Gets the collection of read-only fields names.
     *
     * @return List of field names.
     */
    @Override
    public ArrayList<String> getReadOnlyProperties() {

        ArrayList<String> result = super.getReadOnlyProperties();

        result.add("ProofOfIdentity");
        result.add("ProofOfAddress");

        return result;
    }
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/AVSResult.java<|end_filename|>
package com.mangopay.core.enumerations;

public enum AVSResult {

    FULL_MATCH, ADDRESS_MATCH_ONLY, POSTAL_CODE_MATCH_ONLY, NO_MATCH, NO_CHECK
}


<|start_filename|>src/main/java/com/mangopay/core/enumerations/ReportStatus.java<|end_filename|>
package com.mangopay.core.enumerations;

/**
 * Status of a report.
 */
public enum ReportStatus {

    /**
     * Not specified.
     */
    NotSpecified,

    /**
     * Report is pending.
     */
    PENDING,

    /**
     * Report has expired.
     */
    EXPIRED,

    /**
     * Report creation failed.
     */
    FAILED,

    /**
     * Report is ready to download.
     */
    READY_FOR_DOWNLOAD
}


<|start_filename|>src/main/java/com/mangopay/entities/subentities/BankAccountDetailsGB.java<|end_filename|>
package com.mangopay.entities.subentities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Dto;
import com.mangopay.core.interfaces.BankAccountDetails;

/**
 * Class represents GB type of bank account.
 */
public class BankAccountDetailsGB extends Dto implements BankAccountDetails {

    /**
     * Account number.
     */
    @SerializedName("AccountNumber")
    private String accountNumber;

    /**
     * Sort code.
     */
    @SerializedName("SortCode")
    private String sortCode;

    public String getAccountNumber() {
        return accountNumber;
    }

    public void setAccountNumber(String accountNumber) {
        this.accountNumber = accountNumber;
    }

    public String getSortCode() {
        return sortCode;
    }

    public void setSortCode(String sortCode) {
        this.sortCode = sortCode;
    }
}
