generated from pagopa/pagopa-functions-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add sendPaymentOutcomeV2 to the crawler
- Loading branch information
Showing
16 changed files
with
2,569 additions
and
2 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,166 @@ | ||
<?php | ||
|
||
namespace pagopa\crawler\events\req; | ||
|
||
use pagopa\crawler\events\AbstractEvent; | ||
use pagopa\crawler\MapEvents; | ||
use pagopa\crawler\methods\MethodInterface; | ||
use pagopa\database\sherlock\Transaction; | ||
use pagopa\database\sherlock\TransactionDetails; | ||
use pagopa\database\sherlock\Workflow; | ||
use pagopa\crawler\methods\req\sendPaymentOutcomeV2 as Payload; | ||
|
||
class sendPaymentOutcomeV2 extends AbstractEvent | ||
{ | ||
|
||
protected Payload $method; | ||
|
||
|
||
public function __construct(array $eventData) | ||
{ | ||
parent::__construct($eventData); | ||
$this->method = new Payload($this->data['payload']); | ||
} | ||
|
||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getIuvs(): array|null | ||
{ | ||
$value = $this->getIuv(); | ||
return (is_null($value)) ? $this->getMethodInterface()->getIuvs() : array($value); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getPaEmittenti(): array|null | ||
{ | ||
$value = $this->getPaEmittente(); | ||
return (is_null($value)) ? $this->getMethodInterface()->getPaEmittenti() : array($value); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getCcps(): array|null | ||
{ | ||
return $this->getMethodInterface()->getCcps(); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function transaction(int $index = 0): Transaction|null | ||
{ | ||
return null; | ||
} | ||
|
||
public function transactionDetails(int $transfer, int $index = 0): TransactionDetails|null | ||
{ | ||
return null; | ||
} | ||
|
||
public function workflowEvent(int $index = 0): Workflow|null | ||
{ | ||
$workflow = new Workflow($this->getInsertedTimestamp()); | ||
$workflow->setNewColumnValue('date_event', $this->getInsertedTimestamp()->format('Y-m-d')); | ||
$workflow->setEventTimestamp($this->getInsertedTimestamp()); | ||
$workflow->setEventId($this->getUniqueId()); | ||
$workflow->setFkTipoEvento(MapEvents::getMethodId($this->getTipoEvento(), $this->getSottoTipoEvento())); | ||
|
||
$id_psp = $this->getPsp(); | ||
$stazione = $this->getStazione(); | ||
$canale = $this->getCanale(); | ||
$outcome = $this->getMethodInterface()->outcome(); | ||
|
||
if (!is_null($id_psp)) | ||
{ | ||
$workflow->setPsp($id_psp); | ||
} | ||
if (!is_null($stazione)) | ||
{ | ||
$workflow->setStazione($stazione); | ||
} | ||
if (!is_null($canale)) | ||
{ | ||
$workflow->setCanale($canale); | ||
} | ||
if (!is_null($outcome)) | ||
{ | ||
$workflow->setOutcomeEvent($outcome); | ||
} | ||
|
||
return $workflow; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getMethodInterface(): Payload | ||
{ | ||
return $this->method; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getPaymentsCount(): int|null | ||
{ | ||
return $this->getMethodInterface()->getPaymentsCount(); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getTransferCount(int $index = 0): int|null | ||
{ | ||
return null; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getCacheKeyPayment(int $index = 0): string|null | ||
{ | ||
if ($this->getMethodInterface()->getPaymentsCount() > 1) | ||
{ | ||
return null; | ||
} | ||
$iuv = $this->getIuv(0); | ||
$pa_emittente = $this->getPaEmittente(0); | ||
|
||
return sprintf('payment_%s_%s', $iuv, $pa_emittente); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getCacheKeyAttempt(int $index = 0): string|null | ||
{ | ||
if ($this->getMethodInterface()->getPaymentsCount() > 1) | ||
{ | ||
return null; | ||
} | ||
$iuv = $this->getIuv(0); | ||
$pa_emittente = $this->getPaEmittente(0); | ||
$token = $this->getPaymentToken(0); | ||
|
||
return sprintf('attempt_%s_%s_%s', $iuv, $pa_emittente, $token); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getCacheKeyList(): array | ||
{ | ||
$return = array(); | ||
if (!is_null($this->getSessionId())) | ||
{ | ||
$key = sprintf('session_id_%s_%s', $this->getSessionId(), $this->getTipoEvento()); | ||
$return[] = $key; | ||
} | ||
return $return; | ||
} | ||
} |
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,172 @@ | ||
<?php | ||
|
||
namespace pagopa\crawler\events\resp; | ||
|
||
use pagopa\crawler\events\AbstractEvent; | ||
use pagopa\crawler\MapEvents; | ||
use pagopa\crawler\methods\MethodInterface; | ||
use pagopa\crawler\methods\resp\sendPaymentOutcomeV2 as Payload; | ||
use pagopa\database\sherlock\Transaction; | ||
use pagopa\database\sherlock\TransactionDetails; | ||
use pagopa\database\sherlock\Workflow; | ||
|
||
class sendPaymentOutcomeV2 extends AbstractEvent | ||
{ | ||
|
||
protected Payload $method; | ||
|
||
|
||
public function __construct(array $eventData) | ||
{ | ||
parent::__construct($eventData); | ||
$this->method = new Payload($this->data['payload']); | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getIuvs(): array|null | ||
{ | ||
$value = $this->getIuv(); | ||
return (is_null($value)) ? $this->getMethodInterface()->getIuvs() : array($value); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getPaEmittenti(): array|null | ||
{ | ||
$value = $this->getPaEmittente(); | ||
return (is_null($value)) ? $this->getMethodInterface()->getPaEmittenti() : array($value); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getCcps(): array|null | ||
{ | ||
$value = $this->getCcp(); | ||
return (is_null($value)) ? $this->getMethodInterface()->getCcps() : array($value); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function transaction(int $index = 0): Transaction|null | ||
{ | ||
return null; | ||
} | ||
|
||
public function transactionDetails(int $transfer, int $index = 0): TransactionDetails|null | ||
{ | ||
return null; | ||
} | ||
|
||
public function workflowEvent(int $index = 0): Workflow|null | ||
{ | ||
$workflow = new Workflow($this->getInsertedTimestamp()); | ||
$workflow->setNewColumnValue('date_event', $this->getInsertedTimestamp()->format('Y-m-d')); | ||
$workflow->setEventTimestamp($this->getInsertedTimestamp()); | ||
$workflow->setEventId($this->getUniqueId()); | ||
$workflow->setFkTipoEvento(MapEvents::getMethodId($this->getTipoEvento(), $this->getSottoTipoEvento())); | ||
|
||
$id_psp = $this->getPsp(); | ||
$stazione = $this->getStazione(); | ||
$canale = $this->getCanale(); | ||
$outcome = $this->getMethodInterface()->outcome(); | ||
$faultcode = $this->getMethodInterface()->getFaultCode(); | ||
|
||
if (!is_null($id_psp)) | ||
{ | ||
$workflow->setPsp($id_psp); | ||
} | ||
if (!is_null($stazione)) | ||
{ | ||
$workflow->setStazione($stazione); | ||
} | ||
if (!is_null($canale)) | ||
{ | ||
$workflow->setCanale($canale); | ||
} | ||
if (!is_null($outcome)) | ||
{ | ||
$workflow->setOutcomeEvent($outcome); | ||
} | ||
if (!is_null($faultcode)) | ||
{ | ||
$workflow->setFaultCode($faultcode); | ||
} | ||
|
||
return $workflow; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getMethodInterface(): Payload | ||
{ | ||
return $this->method; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getPaymentsCount(): int|null | ||
{ | ||
return 1; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getTransferCount(int $index = 0): int|null | ||
{ | ||
return null; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getCacheKeyPayment(int $index = 0): string|null | ||
{ | ||
return null; | ||
if ($this->getMethodInterface()->getPaymentsCount() > 1) | ||
{ | ||
return null; | ||
} | ||
$iuv = $this->getIuv(0); | ||
$pa_emittente = $this->getPaEmittente(0); | ||
|
||
return sprintf('payment_%s_%s', $iuv, $pa_emittente); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getCacheKeyAttempt(int $index = 0): string|null | ||
{ | ||
return null; | ||
if ($this->getMethodInterface()->getPaymentsCount() > 1) | ||
{ | ||
return null; | ||
} | ||
$iuv = $this->getIuv(0); | ||
$pa_emittente = $this->getPaEmittente(0); | ||
$token = $this->getPaymentToken(0); | ||
|
||
return sprintf('attempt_%s_%s_%s', $iuv, $pa_emittente, $token); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getCacheKeyList(): array | ||
{ | ||
$return = array(); | ||
if (!is_null($this->getSessionId())) | ||
{ | ||
$key = sprintf('session_id_%s_%s', $this->getSessionId(), $this->getTipoEvento()); | ||
$return[] = $key; | ||
} | ||
return $return; | ||
} | ||
} |
Oops, something went wrong.