@@ -13,7 +13,6 @@ class InvoiceManager {
13
13
*/
14
14
const BASE_URL = "https://earsivportal.efatura.gov.tr " ;
15
15
const TEST_URL = "https://earsivportaltest.efatura.gov.tr " ;
16
- //const TEST_URL = "https://enfoxetrfhod.x.pipedream.net/";
17
16
18
17
/**
19
18
* Username field for auth
@@ -78,6 +77,13 @@ class InvoiceManager {
78
77
*/
79
78
protected $ invoices = [];
80
79
80
+ /**
81
+ * User Informations
82
+ *
83
+ * @var furkankadioglu\eFatura\UserInformations
84
+ */
85
+ protected $ userInformations ;
86
+
81
87
/**
82
88
* Base headers
83
89
*
@@ -538,7 +544,7 @@ public function getInvoiceFromAPI(Invoice $invoice = null)
538
544
"jp " => "" .json_encode ($ data )."" ,
539
545
]
540
546
]);
541
-
547
+
542
548
$ body = json_decode ($ response ->getBody (), true );
543
549
544
550
$ this ->checkError ($ body );
@@ -570,6 +576,91 @@ public function getDownloadURL(Invoice $invoice = null, $signed = true)
570
576
return $ this ->getBaseUrl ()."/earsiv-services/download?token= {$ this ->token }&ettn= {$ this ->invoice ->getUuid ()}&belgeTip=FATURA&onayDurumu= {$ signed }&cmd=downloadResource " ;
571
577
}
572
578
579
+ /**
580
+ * Set invoice manager user informations
581
+ *
582
+ * @param furkankadioglu\eFatura\UserInformations $userInformations
583
+ * @return furkankadioglu\eFatura\Invoice
584
+ */
585
+ public function setUserInformations (UserInformations $ userInformations )
586
+ {
587
+ $ this ->userInformations = $ userInformations ;
588
+ return $ this ;
589
+ }
590
+
591
+ /**
592
+ * Get invoice manager user informations
593
+ *
594
+ * @return furkankadioglu\eFatura\UserInformations
595
+ */
596
+ public function getUserInformations ()
597
+ {
598
+ return $ this ->userInformations ;
599
+ }
600
+
601
+ /**
602
+ * Get user informations data
603
+ *
604
+ * @return furkankadioglu\eFatura\UserInformations
605
+ */
606
+ public function getUserInformationsData ()
607
+ {
608
+ $ response = $ this ->client ->post ($ this ->getBaseUrl ()."/earsiv-services/dispatch " , [
609
+ "headers " => $ this ->headers ,
610
+ "form_params " => [
611
+ "cmd " => "EARSIV_PORTAL_KULLANICI_BILGILERI_GETIR " ,
612
+ "callid " => Uuid::uuid1 ()->toString (),
613
+ "pageName " => "RG_KULLANICI " ,
614
+ "token " => $ this ->token ,
615
+ "jp " => "{} " ,
616
+ ]
617
+ ]);
618
+
619
+ $ body = json_decode ($ response ->getBody (), true );
620
+
621
+ $ this ->checkError ($ body );
622
+
623
+ $ userInformations = new UserInformations ($ body ["data " ]);
624
+ return $ this ->userInformations = $ userInformations ;
625
+ }
626
+
627
+ /**
628
+ * Send user informations data
629
+ *
630
+ * @param Invoice $invoice
631
+ * @return array
632
+ */
633
+ public function sendUserInformationsData (UserInformations $ userInformations = null )
634
+ {
635
+ if ($ userInformations != null )
636
+ {
637
+ $ this ->userInformations = $ userInformations ;
638
+ }
639
+
640
+ if ($ this ->userInformations == null )
641
+ {
642
+ throw new Exception ("User informations null " );
643
+ }
644
+
645
+
646
+ $ response = $ this ->client ->post ($ this ->getBaseUrl ()."/earsiv-services/dispatch " , [
647
+ "headers " => $ this ->headers ,
648
+ "form_params " => [
649
+ "cmd " => "EARSIV_PORTAL_KULLANICI_BILGILERI_KAYDET " ,
650
+ "callid " => Uuid::uuid1 ()->toString (),
651
+ "pageName " => "RG_KULLANICI " ,
652
+ "token " => $ this ->token ,
653
+ "jp " => "" .json_encode ($ this ->userInformations ->export ())."" ,
654
+ ]
655
+ ]);
656
+
657
+ $ body = json_decode ($ response ->getBody (), true );
658
+
659
+ $ this ->checkError ($ body );
660
+
661
+ return $ body ["data " ];
662
+ }
663
+
573
664
574
665
575
666
0 commit comments