Skip to content

Commit

Permalink
add nodoAttivaRPT to the crawler
Browse files Browse the repository at this point in the history
  • Loading branch information
esposimo committed Apr 14, 2024
1 parent a64628b commit 2c8ecd0
Show file tree
Hide file tree
Showing 20 changed files with 2,406 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/mock_crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@
$a->run();


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

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


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

Expand Down
199 changes: 199 additions & 0 deletions src/mock_insert.php

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/sql/05_2024_insert_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ INSERT INTO mapped_events(tipo_evento,sotto_tipo_evento ,fk_event) values
('pspInviaCarrelloRPTCarte' , 'RESP', 10);
('nodoInviaRPT' , 'REQ' , 11);
('nodoInviaRPT' , 'RESP', 12);
('nodoAttivaRPT' , 'REQ' , 13);
('nodoAttivaRPT' , 'RESP', 14);

insert into mapped_payment_methods (tipoversamento, descrizione) values
('CC', 'Carta di Credito'),
Expand Down
213 changes: 213 additions & 0 deletions src/src/crawler/events/req/nodoAttivaRPT.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
<?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\nodoAttivaRPT as Payload;

class nodoAttivaRPT 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
{
$iuv = $this->getIuv($index);
$pa_emittente = $this->getPaEmittente($index);
$token = $this->getPaymentToken($index);
$date_event = $this->getInsertedTimestamp()->format('Y-m-d');

$notice_id = $this->getNoticeNumber($index);



$psp_id = $this->getPsp();
$canale = $this->getCanale();
$stazione = $this->getStazione();

$importo = $this->getMethodInterface()->getImporto(0);

$transaction = new Transaction($this->getInsertedTimestamp());
$transaction->setIuv($iuv);
$transaction->setPaEmittente($pa_emittente);
$transaction->setTokenCcp($token);
$transaction->setInsertedTimestamp($this->getInsertedTimestamp());
$transaction->setNewColumnValue('date_event', $date_event);
$transaction->setTouchPoint('TOUCHPOINT_EC_OLD');

if (!is_null($notice_id))
{
$transaction->setNoticeId($notice_id);
}

if (!is_null($psp_id))
{
$transaction->setPsp($psp_id);
}

if (!is_null($canale))
{
$transaction->setCanale($canale);
}

if (!is_null($stazione))
{
$transaction->setStazione($stazione);
}

return $transaction;
}

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();

if (!is_null($id_psp))
{
$workflow->setPsp($id_psp);
}
if (!is_null($stazione))
{
$workflow->setStazione($stazione);
}
if (!is_null($canale))
{
$workflow->setCanale($canale);
}

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(): string
{
$iuv = $this->getIuv(0);
$pa_emittente = $this->getPaEmittente(0);

return base64_encode(sprintf('payment_%s_%s', $iuv, $pa_emittente));
}

/**
* @inheritDoc
*/
public function getCacheKeyAttempt(): string
{
$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));
}

/**
* @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;
}
}
Loading

0 comments on commit 2c8ecd0

Please sign in to comment.