Skip to content

Commit 9dcbffc

Browse files
Kullanıcı bilgileri modeli ve fonksiyonları eklendi
1 parent 470b2e1 commit 9dcbffc

File tree

1 file changed

+93
-2
lines changed

1 file changed

+93
-2
lines changed

src/InvoiceManager.php

Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class InvoiceManager {
1313
*/
1414
const BASE_URL = "https://earsivportal.efatura.gov.tr";
1515
const TEST_URL = "https://earsivportaltest.efatura.gov.tr";
16-
//const TEST_URL = "https://enfoxetrfhod.x.pipedream.net/";
1716

1817
/**
1918
* Username field for auth
@@ -78,6 +77,13 @@ class InvoiceManager {
7877
*/
7978
protected $invoices = [];
8079

80+
/**
81+
* User Informations
82+
*
83+
* @var furkankadioglu\eFatura\UserInformations
84+
*/
85+
protected $userInformations;
86+
8187
/**
8288
* Base headers
8389
*
@@ -538,7 +544,7 @@ public function getInvoiceFromAPI(Invoice $invoice = null)
538544
"jp" => "".json_encode($data)."",
539545
]
540546
]);
541-
547+
542548
$body = json_decode($response->getBody(), true);
543549

544550
$this->checkError($body);
@@ -570,6 +576,91 @@ public function getDownloadURL(Invoice $invoice = null, $signed = true)
570576
return $this->getBaseUrl()."/earsiv-services/download?token={$this->token}&ettn={$this->invoice->getUuid()}&belgeTip=FATURA&onayDurumu={$signed}&cmd=downloadResource";
571577
}
572578

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+
573664

574665

575666

0 commit comments

Comments
 (0)