-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70a971e
commit 1036e53
Showing
3 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace KianKamgar\MoadianPhp\Services; | ||
|
||
use DateTime; | ||
use GuzzleHttp\Exception\GuzzleException; | ||
use GuzzleHttp\Psr7\Query; | ||
use KianKamgar\MoadianPhp\Consts\Url; | ||
use KianKamgar\MoadianPhp\Helpers\InquiryHelper; | ||
use KianKamgar\MoadianPhp\Helpers\RequestHelper; | ||
use KianKamgar\MoadianPhp\Models\InquiryResponseModel; | ||
|
||
class InquiryByUid extends Url | ||
{ | ||
public function __construct( | ||
private array $uidList, | ||
private string $fiscalId, | ||
private ?DateTime $start = null, | ||
private ?DateTime $end = null, | ||
) | ||
{} | ||
|
||
/** | ||
* @throws GuzzleException | ||
*/ | ||
public function request(string $token): InquiryResponseModel | ||
{ | ||
$data = [ | ||
'uidList' => $this->uidList, | ||
'fiscalId' => $this->fiscalId | ||
]; | ||
|
||
if (!empty($this->start)) { | ||
|
||
$data['start'] = InquiryHelper::getFormattedDate($this->start); | ||
} | ||
|
||
if (!empty($this->end)) { | ||
|
||
$data['end'] = InquiryHelper::getFormattedDate($this->end); | ||
} | ||
|
||
return (new RequestHelper(self::INQUIRY_BY_UID_URL, InquiryResponseModel::class)) | ||
->setToken($token) | ||
->get(Query::build($data)); | ||
} | ||
} |