Skip to content

Commit

Permalink
add paaInviaRT to the crawler
Browse files Browse the repository at this point in the history
  • Loading branch information
esposimo committed Apr 19, 2024
1 parent ada4434 commit d8703e5
Show file tree
Hide file tree
Showing 21 changed files with 2,449 additions and 24 deletions.
6 changes: 6 additions & 0 deletions src/mock_crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@
$a = new \pagopa\crawler\paymentlist\resp\nodoInviaRT(new DateTime('2024-03-10'), 'nodoInviaRT', 'RESP', $redis_cache);
$a->run();

$a = new \pagopa\crawler\paymentlist\req\paaInviaRT(new DateTime('2024-03-10'), 'paaInviaRT', 'REQ', $redis_cache);
$a->run();

$a = new \pagopa\crawler\paymentlist\resp\paaInviaRT(new DateTime('2024-03-10'), 'paaInviaRT', 'RESP', $redis_cache);
$a->run();

die();
//$a = new \pagopa\crawler\paymentlist\resp\activatePaymentNotice(new \DateTime('2024-03-10'),'activatePaymentNotice', 'RESP', $memcache);
//$a->run();
256 changes: 256 additions & 0 deletions src/mock_insert.php

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/sql/05_2024_insert_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ INSERT INTO mapped_events(tipo_evento,sotto_tipo_evento ,fk_event) values
('pspNotifyPayment' , 'REQ' , 15),
('pspNotifyPayment' , 'RESP', 16),
('nodoInviaRT' , 'REQ' , 17),
('nodoInviaRT' , 'RESP', 18);
('nodoInviaRT' , 'RESP', 18),
('paaInviaRT' , 'REQ' , 19),
('paaInviaRT' , 'RESP', 20);

insert into mapped_payment_methods (tipoversamento, descrizione) values
('CC', 'Carta di Credito'),
Expand Down
181 changes: 181 additions & 0 deletions src/src/crawler/events/req/paaInviaRT.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
<?php

namespace pagopa\crawler\events\req;

use pagopa\crawler\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\paaInviaRT as Payload;

class paaInviaRT 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
{
return $this->getMethodInterface()->getIuvs();
}

/**
* @inheritDoc
*/
public function getPaEmittenti(): array|null
{
return $this->getMethodInterface()->getPaEmittenti();
}

/**
* @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 $this->getMethodInterface()->getTransferCount(0);
}

/**
* @inheritDoc
*/
public function getCacheKeyPayment(): string
{
if ((is_null($this->getSessionIdOriginal())) || (empty($this->getSessionIdOriginal())))
{
$iuv = $this->getIuv(0);
$pa_emittente = $this->getPaEmittente(0);
$token = $this->getCcp(0);
return base64_encode(sprintf('attempt_%s_%s_%s', $iuv, $pa_emittente, $token));
}
$session = $this->getSessionIdOriginal();
return base64_encode(sprintf('sessionOriginal_%s', $session));
}

/**
* @inheritDoc
*/
public function getCacheKeyAttempt(): string
{
if ((is_null($this->getSessionIdOriginal())) || (empty($this->getSessionIdOriginal())))
{
$iuv = $this->getIuv(0);
$pa_emittente = $this->getPaEmittente(0);
$token = $this->getCcp(0);
return base64_encode(sprintf('attempt_%s_%s_%s', $iuv, $pa_emittente, $token));
}
$session = $this->getSessionIdOriginal();
return base64_encode(sprintf('sessionOriginal_%s', $session));
}

/**
* @inheritDoc
*/
public function isFaultEvent(): bool
{
return false;
}

/**
* @inheritDoc
*/
public function getFaultCode(): string|null
{
return null;
}

/**
* @inheritDoc
*/
public function getFaultString(): string|null
{
return null;
}

/**
* @inheritDoc
*/
public function getFaultDescription(): string|null
{
return null;
}
}
188 changes: 188 additions & 0 deletions src/src/crawler/events/resp/paaInviaRT.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
<?php

namespace pagopa\crawler\events\resp;

use pagopa\crawler\AbstractEvent;
use pagopa\crawler\MapEvents;
use pagopa\crawler\methods\resp\paaInviaRT as Payload;
use pagopa\database\sherlock\Transaction;
use pagopa\database\sherlock\TransactionDetails;
use pagopa\database\sherlock\Workflow;

class paaInviaRT 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 $this->getMethodInterface()->getPaymentsCount();
}

/**
* @inheritDoc
*/
public function getTransferCount(int $index = 0): int|null
{
return $this->getMethodInterface()->getTransferCount($index);
}

/**
* @inheritDoc
*/
public function getCacheKeyPayment(): string
{
if ((is_null($this->getSessionIdOriginal())) || (empty($this->getSessionIdOriginal())))
{
$iuv = $this->getIuv(0);
$pa_emittente = $this->getPaEmittente(0);
$token = $this->getCcp(0);
return base64_encode(sprintf('attempt_%s_%s_%s', $iuv, $pa_emittente, $token));
}
$session = $this->getSessionIdOriginal();
return base64_encode(sprintf('sessionOriginal_%s', $session));
}

/**
* @inheritDoc
*/
public function getCacheKeyAttempt(): string
{
if ((is_null($this->getSessionIdOriginal())) || (empty($this->getSessionIdOriginal())))
{
$iuv = $this->getIuv(0);
$pa_emittente = $this->getPaEmittente(0);
$token = $this->getCcp(0);
return base64_encode(sprintf('attempt_%s_%s_%s', $iuv, $pa_emittente, $token));
}
$session = $this->getSessionIdOriginal();
return base64_encode(sprintf('sessionOriginal_%s', $session));
}

/**
* @inheritDoc
*/
public function isFaultEvent(): bool
{
return $this->getMethodInterface()->isFaultEvent();
}

/**
* @inheritDoc
*/
public function getFaultCode(): string|null
{
return $this->getMethodInterface()->getFaultCode();
}

/**
* @inheritDoc
*/
public function getFaultString(): string|null
{
return $this->getMethodInterface()->getFaultString();
}

/**
* @inheritDoc
*/
public function getFaultDescription(): string|null
{
return $this->getMethodInterface()->getFaultDescription();
}
}
Loading

0 comments on commit d8703e5

Please sign in to comment.