Skip to content

Commit

Permalink
add pspInviaCarrelloRPT to the crawler
Browse files Browse the repository at this point in the history
  • Loading branch information
esposimo committed Apr 10, 2024
1 parent d491ec5 commit b2050d9
Show file tree
Hide file tree
Showing 25 changed files with 3,365 additions and 16 deletions.
9 changes: 9 additions & 0 deletions src/mock_crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@
$a = new \pagopa\crawler\paymentlist\resp\sendPaymentOutcome(new DateTime('2024-03-11'), 'sendPaymentOutcome', 'RESP', $redis_cache);
$a->run();


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

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



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

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/sql/01_2024_create_types_touchpoint.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
create type TOUCHPOINT_TYPE as ENUM ('TOUCHPOINT_PSP','TOUCHPOINT_PSP_OLD', 'CHECKOUT', 'APP_IO', 'TOUCHPOINT_EC', 'TOUCHPOINT_EC_OLD', 'NO_NAV_PSP');
create type PAYMENT_TYPE as ENUM ('CC', 'PPAL', 'BPAY', 'APPL', 'GOOG', 'MYBK', 'RBPR','RBPB', 'RBPP', 'RPIC', 'RBPS');
create type TRANSFER_TYPE as ENUM ('ACTIVATE_PAYMENT_LIST','ACTIVATE_TRANSFER_LIST', 'PA_PAYMENT_LIST', 'PA_TRANSFER_LIST', 'PSP_PAYMENT_LIST','PSP_TRANSFER_LIST');
2 changes: 1 addition & 1 deletion src/sql/02_2024_create_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ create table if not exists public.transaction_2024 (
importo numeric null,
esito varchar(10) null,
touchpoint TOUCHPOINT_TYPE null,
payment_method PAYMENT_TYPE null,
payment_method varchar(15) null,
fee numeric null,
date_wf json null,
CONSTRAINT "TRANSACTION_2024_pk" PRIMARY KEY (date_event, id)
Expand Down
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 @@ -4,7 +4,9 @@ INSERT INTO mapped_events(tipo_evento,sotto_tipo_evento ,fk_event) values
('nodoInviaCarrelloRPT' , 'REQ' , 3),
('nodoInviaCarrelloRPT' , 'RESP', 4),
('sendPaymentOutcome' , 'REQ' , 5),
('sendPaymentOutcome' , 'RESP', 6);
('sendPaymentOutcome' , 'RESP', 6),
('pspInviaCarrelloRPT' , 'REQ' , 7),
('pspInviaCarrelloRPT' , 'RESP', 8);

insert into mapped_payment_methods (tipoversamento, descrizione) values
('CC', 'Carta di Credito'),
Expand Down
2 changes: 1 addition & 1 deletion src/src/crawler/events/req/nodoInviaCarrelloRPT.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public function getTransferCount(int $index = 0): int|null

/**
* Restituisce l'id carrello
* @return string
* @return string|null
*/
public function getIdCarrello(): string|null
{
Expand Down
259 changes: 259 additions & 0 deletions src/src/crawler/events/req/pspInviaCarrelloRPT.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
<?php

namespace pagopa\crawler\events\req;

use pagopa\crawler\AbstractEvent;
use pagopa\crawler\methods\MethodInterface;
use pagopa\database\sherlock\Transaction;
use pagopa\database\sherlock\TransactionDetails;
use pagopa\database\sherlock\Workflow;
use pagopa\crawler\MapEvents;
use pagopa\crawler\methods\req\pspInviaCarrelloRPT as Payload;

class pspInviaCarrelloRPT extends AbstractEvent
{

protected Payload $method;

public function __construct(array $eventData)
{
parent::__construct($eventData);
$this->method = new Payload($this->data['payload']);
}
/**
* @inheritDoc
*/
public function getPaEmittente(int $index = 0): string|null
{
return $this->getMethodInterface()->getPaEmittente($index);
}

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

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

/**
* @inheritDoc
*/
public function getNoticeNumber(int $index = 0): string|null
{
return null;
}

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

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

/**
* @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 getPsp(): string|null
{
$column = $this->getColumn('psp');
if (empty($column))
{
return $this->getMethodInterface()->getPsp();
}
return $column;
}

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

public function getCanale(): string|null
{
$canale = $this->getColumn('canale');
if (empty($canale))
{
return $this->getMethodInterface()->getCanale();
}
return $canale;
}

public function getBrokerPa(): string|null
{
return null;
}

public function getBrokerPsp(): string|null
{
$broker = $this->getColumn('canale');
if (empty($broker))
{
return $this->getMethodInterface()->getBrokerPsp();
}
$e = explode('_', $broker, 2);
return $e[0];
}

/**
* @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
{
if (($index + 1) > $this->getPaymentsCount())
{
return null;
}

$workflow = new Workflow($this->getInsertedTimestamp());
$workflow->setNewColumnValue('date_event', $this->getInsertedTimestamp()->format('Y-m-d'));
$workflow->setEventId($this->getUniqueId());
$workflow->setEventTimestamp($this->getInsertedTimestamp());
if (!is_null($this->getCanale()))
{
$workflow->setCanale($this->getCanale());
}
if (!is_null($this->getPsp()))
{
$workflow->setPsp($this->getPsp());
}
$workflow->setFkTipoEvento(MapEvents::getMethodId($this->getTipoEvento(), $this->getSottoTipoEvento()));
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);
}

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

/**
* @inheritDoc
*/
public function getCacheKeyPayment(): string
{
$session = $this->getSessionIdOriginal();
return base64_encode(sprintf('sessionOriginal_%s', $session));
}

/**
* @inheritDoc
*/
public function getCacheKeyAttempt(): string
{
$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;
}
}
14 changes: 5 additions & 9 deletions src/src/crawler/events/resp/nodoInviaCarrelloRPT.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function transaction(int $index = 0): Transaction|null
/**
* @inheritDoc
*/
public function getMethodInterface(): MethodInterface
public function getMethodInterface(): Payload
{
return $this->method;
}
Expand Down Expand Up @@ -194,14 +194,10 @@ public function workflowEvent(int $index = 0): Workflow|null
$workflow->setNewColumnValue('date_event', $this->getInsertedTimestamp()->format('Y-m-d'));
$workflow->setEventId($this->getUniqueId());
$workflow->setEventTimestamp($this->getInsertedTimestamp());
//$workflow->setFkTipoEvento(MapEvents::getMethodId($this->getTipoEvento(), $this->getSottoTipoEvento()));
$workflow->setFkTipoEvento(4);
$workflow->setFkTipoEvento(MapEvents::getMethodId($this->getTipoEvento(), $this->getSottoTipoEvento()));
$stazione = $this->getStazione();
$canale = $this->getCanale();
if ($this->getMethodInterface()->isFaultEvent())
{
$workflow->setFaultCode($this->getMethodInterface()->getFaultCode());
}
$workflow->setOutcomeEvent($this->getMethodInterface()->outcome());
if (!is_null($stazione))
{
$workflow->setStazione($stazione);
Expand All @@ -210,9 +206,9 @@ public function workflowEvent(int $index = 0): Workflow|null
{
$workflow->setCanale($canale);
}
if (!is_null($this->getMethodInterface()->outcome()))
if ($this->getMethodInterface()->isFaultEvent())
{
$workflow->setOutcomeEvent($this->getMethodInterface()->outcome());
$workflow->setFaultCode($this->getMethodInterface()->getFaultCode());
}
return $workflow;
}
Expand Down
Loading

0 comments on commit b2050d9

Please sign in to comment.