Skip to content

Commit

Permalink
Changes:
Browse files Browse the repository at this point in the history
- introduced enums to replace raw string values
- code cleanup
  • Loading branch information
lukasz-drzewiecki committed Apr 30, 2015
1 parent f688270 commit 1b57c6d
Show file tree
Hide file tree
Showing 108 changed files with 2,895 additions and 459 deletions.
2 changes: 1 addition & 1 deletion src/com/mangopay/MangoPayApi.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.mangopay;

import com.mangopay.core.Configuration;
import com.mangopay.core.APIs.*;
import com.mangopay.core.*;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.mangopay.core;
package com.mangopay.core.APIs;

import com.mangopay.core.enumerations.RequestType;
import com.mangopay.MangoPayApi;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.mangopay.core.*;
import java.util.*;

/**
* Base class for all API classes.
Expand All @@ -20,85 +20,85 @@ public abstract class ApiBase {
*/
private Map<String, String[]> methods = new HashMap<String, String[]>(){{

put("authentication_base", new String[] { "/api/clients/", RequestType.POST });
put("authentication_oauth", new String[] { "/oauth/token ", RequestType.POST });
put("authentication_base", new String[] { "/api/clients/", RequestType.POST.toString() });
put("authentication_oauth", new String[] { "/oauth/token ", RequestType.POST.toString() });

put("events_all", new String[] { "/events", RequestType.GET });
put("events_all", new String[] { "/events", RequestType.GET.toString() });

put("hooks_create", new String[] { "/hooks", RequestType.POST });
put("hooks_all", new String[] { "/hooks", RequestType.GET });
put("hooks_get", new String[] { "/hooks/%s", RequestType.GET });
put("hooks_save", new String[] { "/hooks/%s", RequestType.PUT });
put("hooks_create", new String[] { "/hooks", RequestType.POST.toString() });
put("hooks_all", new String[] { "/hooks", RequestType.GET.toString() });
put("hooks_get", new String[] { "/hooks/%s", RequestType.GET.toString() });
put("hooks_save", new String[] { "/hooks/%s", RequestType.PUT.toString() });

put("cardregistration_create", new String[] { "/cardregistrations", RequestType.POST });
put("cardregistration_get", new String[] { "/cardregistrations/%s", RequestType.GET });
put("cardregistration_save", new String[] { "/cardregistrations/%s", RequestType.PUT });
put("cardregistration_create", new String[] { "/cardregistrations", RequestType.POST.toString() });
put("cardregistration_get", new String[] { "/cardregistrations/%s", RequestType.GET.toString() });
put("cardregistration_save", new String[] { "/cardregistrations/%s", RequestType.PUT.toString() });

put("preauthorization_create", new String[] { "/preauthorizations/card/direct", RequestType.POST });
put("preauthorization_get", new String[] { "/preauthorizations/%s", RequestType.GET });
put("preauthorization_save", new String[] { "/preauthorizations/%s", RequestType.PUT });
put("preauthorization_create", new String[] { "/preauthorizations/card/direct", RequestType.POST.toString() });
put("preauthorization_get", new String[] { "/preauthorizations/%s", RequestType.GET.toString() });
put("preauthorization_save", new String[] { "/preauthorizations/%s", RequestType.PUT.toString() });

put("card_get", new String[] { "/cards/%s", RequestType.GET });
put("card_save", new String[] { "/cards/%s", RequestType.PUT });
put("card_get", new String[] { "/cards/%s", RequestType.GET.toString() });
put("card_save", new String[] { "/cards/%s", RequestType.PUT.toString() });

// pay ins URLs
put("payins_card-web_create", new String[] { "/payins/card/web/", RequestType.POST });
put("payins_card-direct_create", new String[] { "/payins/card/direct/", RequestType.POST });
put("payins_preauthorized-direct_create", new String[] { "/payins/preauthorized/direct/", RequestType.POST });
put("payins_bankwire-direct_create", new String[] { "/payins/bankwire/direct/", RequestType.POST });
put("payins_directdebit-web_create", new String[] { "/payins/directdebit/web", RequestType.POST });
put("payins_get", new String[] { "/payins/%s", RequestType.GET });
put("payins_getrefunds", new String[] { "/payins/%s/refunds", RequestType.GET });
put("payins_createrefunds", new String[] { "/payins/%s/refunds", RequestType.POST });
put("payins_card-web_create", new String[] { "/payins/card/web/", RequestType.POST.toString() });
put("payins_card-direct_create", new String[] { "/payins/card/direct/", RequestType.POST.toString() });
put("payins_preauthorized-direct_create", new String[] { "/payins/preauthorized/direct/", RequestType.POST.toString() });
put("payins_bankwire-direct_create", new String[] { "/payins/bankwire/direct/", RequestType.POST.toString() });
put("payins_directdebit-web_create", new String[] { "/payins/directdebit/web", RequestType.POST.toString() });
put("payins_get", new String[] { "/payins/%s", RequestType.GET.toString() });
put("payins_getrefunds", new String[] { "/payins/%s/refunds", RequestType.GET.toString() });
put("payins_createrefunds", new String[] { "/payins/%s/refunds", RequestType.POST.toString() });

put("payouts_bankwire_create", new String[] { "/payouts/bankwire/", RequestType.POST });
put("payouts_get", new String[] { "/payouts/%s", RequestType.GET });
put("payouts_bankwire_create", new String[] { "/payouts/bankwire/", RequestType.POST.toString() });
put("payouts_get", new String[] { "/payouts/%s", RequestType.GET.toString() });

put("refunds_get", new String[] { "/refunds/%s", RequestType.GET });
put("refunds_get", new String[] { "/refunds/%s", RequestType.GET.toString() });

put("transfers_create", new String[] { "/transfers", RequestType.POST });
put("transfers_get", new String[] { "/transfers/%s", RequestType.GET });
put("transfers_getrefunds", new String[] { "/transfers/%s/refunds", RequestType.GET });
put("transfers_createrefunds", new String[] { "/transfers/%s/refunds", RequestType.POST });
put("transfers_create", new String[] { "/transfers", RequestType.POST.toString() });
put("transfers_get", new String[] { "/transfers/%s", RequestType.GET.toString() });
put("transfers_getrefunds", new String[] { "/transfers/%s/refunds", RequestType.GET.toString() });
put("transfers_createrefunds", new String[] { "/transfers/%s/refunds", RequestType.POST.toString() });

put("users_createnaturals", new String[] { "/users/natural", RequestType.POST });
put("users_createlegals", new String[] { "/users/legal", RequestType.POST });
put("users_createnaturals", new String[] { "/users/natural", RequestType.POST.toString() });
put("users_createlegals", new String[] { "/users/legal", RequestType.POST.toString() });

put("users_createbankaccounts_iban", new String[] { "/users/%s/bankaccounts/iban", RequestType.POST });
put("users_createbankaccounts_gb", new String[] { "/users/%s/bankaccounts/gb", RequestType.POST });
put("users_createbankaccounts_us", new String[] { "/users/%s/bankaccounts/us", RequestType.POST });
put("users_createbankaccounts_ca", new String[] { "/users/%s/bankaccounts/ca", RequestType.POST });
put("users_createbankaccounts_other", new String[] { "/users/%s/bankaccounts/other", RequestType.POST });
put("users_createbankaccounts_iban", new String[] { "/users/%s/bankaccounts/iban", RequestType.POST.toString() });
put("users_createbankaccounts_gb", new String[] { "/users/%s/bankaccounts/gb", RequestType.POST.toString() });
put("users_createbankaccounts_us", new String[] { "/users/%s/bankaccounts/us", RequestType.POST.toString() });
put("users_createbankaccounts_ca", new String[] { "/users/%s/bankaccounts/ca", RequestType.POST.toString() });
put("users_createbankaccounts_other", new String[] { "/users/%s/bankaccounts/other", RequestType.POST.toString() });

put("users_all", new String[] { "/users", RequestType.GET });
put("users_allwallets", new String[] { "/users/%s/wallets", RequestType.GET });
put("users_allbankaccount", new String[] { "/users/%s/bankaccounts", RequestType.GET });
put("users_allcards", new String[] { "/users/%s/cards", RequestType.GET });
put("users_alltransactions", new String[] { "/users/%s/transactions", RequestType.GET });
put("users_allkycdocuments", new String[] { "/users/%s/KYC/documents", RequestType.GET });
put("users_get", new String[] { "/users/%s", RequestType.GET });
put("users_getnaturals", new String[] { "/users/natural/%s", RequestType.GET });
put("users_getlegals", new String[] { "/users/legal/%s", RequestType.GET });
put("users_getbankaccount", new String[] { "/users/%s/bankaccounts/%s", RequestType.GET });
put("users_savenaturals", new String[] { "/users/natural/%s", RequestType.PUT });
put("users_savelegals", new String[] { "/users/legal/%s", RequestType.PUT });
put("users_all", new String[] { "/users", RequestType.GET.toString() });
put("users_allwallets", new String[] { "/users/%s/wallets", RequestType.GET.toString() });
put("users_allbankaccount", new String[] { "/users/%s/bankaccounts", RequestType.GET.toString() });
put("users_allcards", new String[] { "/users/%s/cards", RequestType.GET.toString() });
put("users_alltransactions", new String[] { "/users/%s/transactions", RequestType.GET.toString() });
put("users_allkycdocuments", new String[] { "/users/%s/KYC/documents", RequestType.GET.toString() });
put("users_get", new String[] { "/users/%s", RequestType.GET.toString() });
put("users_getnaturals", new String[] { "/users/natural/%s", RequestType.GET.toString() });
put("users_getlegals", new String[] { "/users/legal/%s", RequestType.GET.toString() });
put("users_getbankaccount", new String[] { "/users/%s/bankaccounts/%s", RequestType.GET.toString() });
put("users_savenaturals", new String[] { "/users/natural/%s", RequestType.PUT.toString() });
put("users_savelegals", new String[] { "/users/legal/%s", RequestType.PUT.toString() });

put("wallets_create", new String[] { "/wallets", RequestType.POST });
put("wallets_alltransactions", new String[] { "/wallets/%s/transactions", RequestType.GET });
put("wallets_get", new String[] { "/wallets/%s", RequestType.GET });
put("wallets_save", new String[] { "/wallets/%s", RequestType.PUT });
put("wallets_create", new String[] { "/wallets", RequestType.POST.toString() });
put("wallets_alltransactions", new String[] { "/wallets/%s/transactions", RequestType.GET.toString() });
put("wallets_get", new String[] { "/wallets/%s", RequestType.GET.toString() });
put("wallets_save", new String[] { "/wallets/%s", RequestType.PUT.toString() });

put("users_createkycdocument", new String[] { "/users/%s/KYC/documents/", RequestType.POST });
put("users_getkycdocument", new String[] { "/users/%s/KYC/documents/%s", RequestType.GET });
put("users_savekycdocument", new String[] { "/users/%s/KYC/documents/%s", RequestType.PUT });
put("kyc_page_create", new String[] { "/users/%s/KYC/documents/%s/pages", RequestType.POST });
put("kyc_documents_all", new String[] { "/KYC/documents", RequestType.GET });
put("users_createkycdocument", new String[] { "/users/%s/KYC/documents/", RequestType.POST.toString() });
put("users_getkycdocument", new String[] { "/users/%s/KYC/documents/%s", RequestType.GET.toString() });
put("users_savekycdocument", new String[] { "/users/%s/KYC/documents/%s", RequestType.PUT.toString() });
put("kyc_page_create", new String[] { "/users/%s/KYC/documents/%s/pages", RequestType.POST.toString() });
put("kyc_documents_all", new String[] { "/KYC/documents", RequestType.GET.toString() });

// These are temporary functions and WILL be removed in the future.
// Contact support before using these features or if have any queries.
put("temp_paymentcards_create", new String[] { "/temp/paymentcards", RequestType.POST });
put("temp_paymentcards_get", new String[] { "/temp/paymentcards/%s", RequestType.GET });
put("temp_immediatepayins_create", new String[] { "/temp/immediate-payins", RequestType.POST });
put("temp_paymentcards_create", new String[] { "/temp/paymentcards", RequestType.POST.toString() });
put("temp_paymentcards_get", new String[] { "/temp/paymentcards/%s", RequestType.GET.toString() });
put("temp_immediatepayins_create", new String[] { "/temp/immediate-payins", RequestType.POST.toString() });
}};

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mangopay.core;
package com.mangopay.core.APIs;

import com.mangopay.MangoPayApi;
import com.mangopay.entities.CardPreAuthorization;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mangopay.core;
package com.mangopay.core.APIs;

import com.mangopay.MangoPayApi;
import com.mangopay.entities.CardRegistration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.mangopay.core;
package com.mangopay.core.APIs;

import com.mangopay.core.enumerations.Validity;
import com.mangopay.MangoPayApi;
import com.mangopay.entities.Card;
import com.mangopay.entities.TemporaryPaymentCard;
import com.mangopay.entities.*;

/**
* API for cards.
Expand Down Expand Up @@ -46,7 +42,7 @@ public Card update(Card card) throws Exception {
* @throws Exception
*/
public Card disable(Card card) throws Exception {
card.Validity = "INVALID";
card.Validity = Validity.INVALID;
return update(card);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.mangopay.core;
package com.mangopay.core.APIs;

import com.mangopay.MangoPayApi;
import com.mangopay.core.RestTool;
import com.mangopay.entities.Client;
import java.util.HashMap;
import java.util.Map;
import java.util.*;

/**
* API for clients.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mangopay.core;
package com.mangopay.core.APIs;

import com.mangopay.MangoPayApi;
import com.mangopay.core.*;
import com.mangopay.entities.Event;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mangopay.core;
package com.mangopay.core.APIs;

import com.mangopay.MangoPayApi;
import com.mangopay.core.*;
import com.mangopay.entities.Hook;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mangopay.core;
package com.mangopay.core.APIs;

import com.mangopay.MangoPayApi;
import com.mangopay.core.*;
import com.mangopay.entities.KycDocument;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.mangopay.core;
package com.mangopay.core.APIs;

import com.mangopay.MangoPayApi;
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;
import com.mangopay.core.*;
import java.net.*;
import java.util.*;
import java.util.logging.*;

/**
* API for OAuth.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.mangopay.core;
package com.mangopay.core.APIs;

import com.mangopay.MangoPayApi;
import com.mangopay.entities.PayIn;
import com.mangopay.entities.Refund;
import com.mangopay.entities.TemporaryImmediatePayIn;
import com.mangopay.entities.*;

/**
* API for PayIns.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mangopay.core;
package com.mangopay.core.APIs;

import com.mangopay.MangoPayApi;
import com.mangopay.entities.PayOut;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mangopay.core;
package com.mangopay.core.APIs;

import com.mangopay.MangoPayApi;
import com.mangopay.entities.Refund;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.mangopay.core;
package com.mangopay.core.APIs;

import com.mangopay.MangoPayApi;
import com.mangopay.entities.Refund;
import com.mangopay.entities.Transfer;
import com.mangopay.entities.*;

/**
* API for transfers.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.mangopay.core;
package com.mangopay.core.APIs;

import com.mangopay.core.enumerations.KycDocumentType;
import com.mangopay.MangoPayApi;
import com.mangopay.core.*;
import com.mangopay.entities.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.*;
import java.util.List;
import org.apache.commons.codec.binary.Base64;

Expand Down Expand Up @@ -240,7 +240,7 @@ public void createKycPage(String userId, String kycDocumentId, String filePath)
*/
public KycDocument createKycDocument(String userId, KycDocumentType type) throws Exception {
KycDocument kycDocument = new KycDocument();
kycDocument.Type = type.name();
kycDocument.Type = type;

return this.createObject(KycDocument.class, "users_createkycdocument", kycDocument, userId);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.mangopay.core;
package com.mangopay.core.APIs;

import com.mangopay.MangoPayApi;
import com.mangopay.entities.Transaction;
import com.mangopay.entities.Wallet;
import com.mangopay.core.*;
import com.mangopay.entities.*;
import java.util.List;

/**
Expand Down
5 changes: 2 additions & 3 deletions src/com/mangopay/core/AuthenticationHelper.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.mangopay.core;

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

/**
* Authentication helper class.
*/
class AuthenticationHelper {
public class AuthenticationHelper {

/**
* Root/parent instance that holds the OAuthToken and Configuration instance.
Expand Down
2 changes: 2 additions & 0 deletions src/com/mangopay/core/AuthorizationTokenManager.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.mangopay.core;

import com.mangopay.core.interfaces.IStorageStrategy;
import com.mangopay.core.APIs.ApiBase;
import com.mangopay.MangoPayApi;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/com/mangopay/core/DefaultStorageStrategy.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.mangopay.core;

import com.mangopay.core.interfaces.IStorageStrategy;

/**
* Default token storage strategy implementation.
*/
Expand Down
11 changes: 0 additions & 11 deletions src/com/mangopay/core/DepositAccountType.java

This file was deleted.

4 changes: 1 addition & 3 deletions src/com/mangopay/core/Dto.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.mangopay.core;

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

/**
* Base abstract class for entities.
Expand Down
Loading

0 comments on commit 1b57c6d

Please sign in to comment.