5959 */
6060public class NIP24Client {
6161
62- public final static String VERSION = "1.3.3 " ;
62+ public final static String VERSION = "1.3.4 " ;
6363
6464 public final static String PRODUCTION_URL = "https://www.nip24.pl/api" ;
6565 public final static String TEST_URL = "https://www.nip24.pl/api-test" ;
@@ -801,6 +801,119 @@ public IBANStatus getIBANStatus(String nip, String iban)
801801 return getIBANStatus (Number .NIP , nip , iban , null );
802802 }
803803
804+ /**
805+ * Sprawdzenie statusu firmy na podstawie pliku białej listy podatników VAT
806+ * @param type typ numeru identyfikującego firmę
807+ * @param number numer określonego typu
808+ * @param iban numer IBAN rachunku do sprawdzenia (polskie rachunki mogą być bez prefiksu PL)
809+ * @param date dzień, którego ma dotyczyć sprawdzenie statusu (null - bieżący dzień)
810+ * @return bieżący status rachunku bankowego lub null w przypadku błędu
811+ */
812+ public WLStatus getWhitelistStatus (Number type , String number , String iban , Date date )
813+ {
814+ try {
815+ // clear error
816+ err = null ;
817+
818+ // validate number and construct path
819+ String suffix = null ;
820+
821+ if ((suffix = getPathSuffix (type , number )) == null ) {
822+ return null ;
823+ }
824+
825+ if (!IBAN .isValid (iban )) {
826+ iban = "PL" + iban ;
827+
828+ if (!IBAN .isValid (iban )) {
829+ err = "Numer IBAN jest nieprawidłowy" ;
830+ return null ;
831+ }
832+ }
833+
834+ if (date == null ) {
835+ date = new Date ();
836+ }
837+
838+ SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd" );
839+
840+ // prepare url
841+ String url = (this .url .toString () + "/check/whitelist/" + suffix + "/" + IBAN .normalize (iban ) + "/" + sdf .format (date ));
842+
843+ // prepare request
844+ StringBuilder sb = new StringBuilder ();
845+
846+ byte [] b = get (url , sb );
847+
848+ if (b == null ) {
849+ err = "Nie udało się nawiązać połączenia z serwisem NIP24" ;
850+ return null ;
851+ }
852+
853+ // parse response
854+ Document doc = dbf .newDocumentBuilder ().parse (new ByteArrayInputStream (b ));
855+
856+ if (doc == null ) {
857+ err = "Odpowiedź serwisu NIP24 ma nieprawidłowy format" ;
858+ return null ;
859+ }
860+
861+ String res = getString (doc , "/result/error/code" , null );
862+
863+ if (res != null ) {
864+ err = getString (doc , "/result/error/description" , null );
865+ return null ;
866+ }
867+
868+ WLStatus wl = new WLStatus ();
869+
870+ wl .setUID (getString (doc , "/result/whitelist/uid" , null ));
871+
872+ wl .setNIP (getString (doc , "/result/whitelist/nip" , null ));
873+ wl .setIBAN (getString (doc , "/result/whitelist/iban" , null ));
874+
875+ wl .setValid (getString (doc , "/result/whitelist/valid" , "false" ).equals ("true" ));
876+ wl .setVirtual (getString (doc , "/result/whitelist/virtual" , "false" ).equals ("true" ));
877+
878+ wl .setStatus (Integer .parseInt (getString (doc , "/result/whitelist/vatStatus" , "0" )));
879+ wl .setResult (getString (doc , "/result/whitelist/vatResult" , null ));
880+
881+ wl .setHashIndex (Integer .parseInt (getString (doc , "/result/whitelist/hashIndex" , "-1" )));
882+ wl .setMaskIndex (Integer .parseInt (getString (doc , "/result/whitelist/maskIndex" , "-1" )));
883+ wl .setDate (getDate (doc , "/result/whitelist/date" ));
884+ wl .setSource (getString (doc , "/result/whitelist/source" , null ));
885+
886+ return wl ;
887+ }
888+ catch (Exception ignored ) {
889+ }
890+
891+ return null ;
892+ }
893+
894+ /**
895+ * Sprawdzenie statusu firmy na podstawie pliku białej listy podatników VAT dla bieżącego dnia
896+ * @param type typ numeru identyfikującego firmę
897+ * @param number numer określonego typu
898+ * @param iban numer IBAN rachunku do sprawdzenia (polskie rachunki mogą być bez prefiksu PL)
899+ * @return bieżący status rachunku bankowego lub null w przypadku błędu
900+ */
901+ public WLStatus getWhitelistStatus (Number type , String number , String iban )
902+ {
903+ return getWhitelistStatus (type , number , iban , null );
904+ }
905+
906+ /**
907+ * Sprawdzenie statusu firmy na podstawie pliku białej listy podatników VAT dla bieżącego dnia
908+ * @param nip numer NIP
909+ * @param iban numer IBAN rachunku do sprawdzenia (polskie rachunki mogą być bez prefiksu PL)
910+ * @return bieżący status rachunku bankowego lub null w przypadku błędu
911+ */
912+ public WLStatus getWhitelistStatus (String nip , String iban )
913+ {
914+ return getWhitelistStatus (Number .NIP , nip , iban , null );
915+ }
916+
804917 /**
805918 * Sprawdzenie bieżącego stanu konta użytkownika
806919 * @return status konta lub null w przypadku błędu
@@ -850,6 +963,7 @@ public AccountStatus getAccountStatus()
850963 status .setItemPriceInvoice (Float .parseFloat (getString (doc , "/result/account/billingPlan/itemPriceInvoiceData" , "0" )));
851964 status .setItemPriceAll (Float .parseFloat (getString (doc , "/result/account/billingPlan/itemPriceAllData" , "0" )));
852965 status .setItemPriceIBAN (Float .parseFloat (getString (doc , "/result/account/billingPlan/itemPriceIBANStatus" , "0" )));
966+ status .setItemPriceWhitelist (Float .parseFloat (getString (doc , "/result/account/billingPlan/itemPriceWLStatus" , "0" )));
853967
854968 status .setLimit (Integer .parseInt (getString (doc , "/result/account/billingPlan/limit" , "0" )));
855969 status .setRequestDelay (Integer .parseInt (getString (doc , "/result/account/billingPlan/requestDelay" , "0" )));
@@ -872,13 +986,15 @@ public AccountStatus getAccountStatus()
872986 status .setFuncGetVIESData (getString (doc , "/result/account/billingPlan/funcGetVIESData" , "false" ).equals ("true" ));
873987 status .setFuncGetVATStatus (getString (doc , "/result/account/billingPlan/funcGetVATStatus" , "false" ).equals ("true" ));
874988 status .setFuncGetIBANStatus (getString (doc , "/result/account/billingPlan/funcGetIBANStatus" , "false" ).equals ("true" ));
989+ status .setFuncGetWhitelistStatus (getString (doc , "/result/account/billingPlan/funcGetWLStatus" , "false" ).equals ("true" ));
875990
876991 status .setInvoiceDataCount (Integer .parseInt (getString (doc , "/result/account/requests/invoiceData" , "0" )));
877992 status .setAllDataCount (Integer .parseInt (getString (doc , "/result/account/requests/allData" , "0" )));
878993 status .setFirmStatusCount (Integer .parseInt (getString (doc , "/result/account/requests/firmStatus" , "0" )));
879994 status .setVATStatusCount (Integer .parseInt (getString (doc , "/result/account/requests/vatStatus" , "0" )));
880995 status .setVIESStatusCount (Integer .parseInt (getString (doc , "/result/account/requests/viesStatus" , "0" )));
881996 status .setIBANStatusCount (Integer .parseInt (getString (doc , "/result/account/requests/ibanStatus" , "0" )));
997+ status .setWhitelistStatusCount (Integer .parseInt (getString (doc , "/result/account/requests/wlStatus" , "0" )));
882998 status .setTotalCount (Integer .parseInt (getString (doc , "/result/account/requests/total" , "0" )));
883999
8841000 return status ;
0 commit comments