Skip to content

Commit

Permalink
add nodoChiediCopiaRT to the crawler
Browse files Browse the repository at this point in the history
  • Loading branch information
esposimo committed May 13, 2024
1 parent 316a184 commit 7a421a4
Show file tree
Hide file tree
Showing 16 changed files with 1,621 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/mock_crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@
$a->run();


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

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


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

Expand Down
206 changes: 205 additions & 1 deletion 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 @@ -42,7 +42,9 @@ INSERT INTO mapped_events(tipo_evento,sotto_tipo_evento ,fk_event) values
('nodoNotificaAnnullamento' , 'REQ' , 41),
('nodoNotificaAnnullamento' , 'RESP', 42),
('nodoInoltraPagamentoMod1' , 'REQ' , 43),
('nodoInoltraPagamentoMod1' , 'RESP', 44);
('nodoInoltraPagamentoMod1' , 'RESP', 44),
('nodoChiediCopiaRT' , 'REQ' , 45),
('nodoChiediCopiaRT' , 'RESP', 46);

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

class nodoChiediCopiaRT 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)) ? null : array($value);
}

/**
* @inheritDoc
*/
public function getPaEmittenti(): array|null
{
$value = $this->getPaEmittente();
return (is_null($value)) ? null : array($value);
}

/**
* @inheritDoc
*/
public function getCcps(): array|null
{
$value = $this->getCcp();
return (is_null($value)) ? null : 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();

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(int $index = 0): string|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
{
$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_%s', $this->getSessionId(), $this->getTipoEvento(), $this->getSottoTipoEvento());
$return[] = $key;
}
if (!is_null($this->getPaymentToken()))
{
$key = sprintf('token_%s', $this->getPaymentToken());
$return[] = $key;
}
return $return;
}
}
165 changes: 165 additions & 0 deletions src/src/crawler/events/resp/nodoChiediCopiaRT.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<?php

namespace pagopa\crawler\events\resp;

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\resp\nodoChiediCopiaRT as Payload;

class nodoChiediCopiaRT 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)) ? null : array($value);
}

/**
* @inheritDoc
*/
public function getPaEmittenti(): array|null
{
$value = $this->getPaEmittente();
return (is_null($value)) ? null : array($value);
}

/**
* @inheritDoc
*/
public function getCcps(): array|null
{
$value = $this->getCcp();
return (is_null($value)) ? null : 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();

if (!is_null($id_psp))
{
$workflow->setPsp($id_psp);
}
if (!is_null($stazione))
{
$workflow->setStazione($stazione);
}
if (!is_null($canale))
{
$workflow->setCanale($canale);
}
if ($this->getMethodInterface()->isFaultEvent())
{
$workflow->setFaultCode($this->getMethodInterface()->getFaultCode());
}
if (!is_null($this->getMethodInterface()->outcome()))
{
$workflow->setOutcomeEvent($this->getMethodInterface()->outcome());
}
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
{
$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
{
$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_%s', $this->getSessionId(), $this->getTipoEvento(), $this->getSottoTipoEvento());
$return[] = $key;
}
if (!is_null($this->getPaymentToken()))
{
$key = sprintf('token_%s', $this->getPaymentToken());
$return[] = $key;
}
return $return;
}
}
15 changes: 15 additions & 0 deletions src/src/crawler/methods/object/RT.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,21 @@ private function getElementXml(string $block, string $element) : string|null
return null;
}

public function getIuv() : string|null
{
return $this->getElementXml($this->payload, 'identificativoUnivocoVersamento');
}

public function getPaEmittente() : string|null
{
return $this->getElementXml($this->payload, 'identificativoDominio');
}

public function getCcp() : string|null
{
return $this->getElementXml($this->payload, 'CodiceContestoPagamento');
}


public function getImporto() : string|null
{
Expand Down
25 changes: 25 additions & 0 deletions src/src/crawler/methods/req/nodoChiediCopiaRT.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace pagopa\crawler\methods\req;

use pagopa\crawler\methods\AbstractXmlPayload;

class nodoChiediCopiaRT extends AbstractXmlPayload
{

protected $prefix_xpath = 'nodoChiediCopiaRT';
const XPATH_BROKER_PA = '/identificativoIntermediarioPA';
const XPATH_STATION = '/identificativoStazioneIntermediarioPA';

const XPATH_IUV = '/identificativoUnivocoVersamento';

const XPATH_PA_EMITTENTE = '/identificativoDominio';

const XPATH_TOKEN_CCP = '/codiceContestoPagamento';

public function getPaymentsCount(): int|null
{
return 1;
}

}
Loading

0 comments on commit 7a421a4

Please sign in to comment.