Skip to content

Commit

Permalink
add nodoInviaCarrelloRPT
Browse files Browse the repository at this point in the history
  • Loading branch information
esposimo committed Mar 14, 2024
1 parent 5606cd1 commit 533ce37
Show file tree
Hide file tree
Showing 54 changed files with 3,886 additions and 356 deletions.
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,31 @@ USER root:root
# find vendor/ -type d -name ".git" -exec rm -rf {} \;
#
# Add a .gitignore rule (/vendor/**/.git)


# valutare questo dockerfile
## FROM alpine:latest as git_repo
##
## RUN apk upgrade && apk update && apk add git
##
## WORKDIR /tmp
##
## RUN git clone https://github.com/pagopa/pagopa-qi-log-crawler
##
##
##
## FROM composer:latest as composer
##
## RUN mkdir -p /tmp/repo
##
## COPY --from=git_repo /tmp/pagopa-qi-log-crawler/src /tmp/repo/
##
## WORKDIR /tmp/repo
##
## RUN composer install
##
## FROM php:8.2-fpm
##
## RUN mkdir -p /var/www/html/sherlock
##
## COPY --from=composer /tmp/repo/ /var/www/html/sherlock
15 changes: 12 additions & 3 deletions src/src/crawler/AbstractEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

use pagopa\crawler\methods\MethodInterface;
use pagopa\database\sherlock\Transaction;
use pagopa\database\sherlock\TransactionDetails;
use pagopa\database\sherlock\TransactionRe;
use pagopa\database\sherlock\Workflow;

abstract class AbstractEvent implements EventInterface
{
Expand Down Expand Up @@ -175,21 +177,28 @@ abstract public function getBrokerPsp(): string|null;
/**
* @inheritDoc
*/
public function getIdCarrello(): string
public function getIdCarrello(): string|null
{
return '';
return null;
}

/**
* @inheritDoc
*/
abstract public function getKey(int $index = 0): string;
abstract public function getKey(int $index = 0): string|null;

/**
* @inheritDoc
*/
abstract public function transaction(int $index = 0): Transaction|null;


abstract public function transactionDetails(int $transfer, int $index = 0): TransactionDetails|null;


abstract public function workflowEvent(int $index = 0): Workflow|null;


/**
* @inheritDoc
*/
Expand Down
22 changes: 20 additions & 2 deletions src/src/crawler/EventInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

use pagopa\crawler\methods\MethodInterface;
use pagopa\database\sherlock\Transaction;
use pagopa\database\sherlock\TransactionDetails;
use pagopa\database\sherlock\TransactionRe;
use pagopa\database\sherlock\Workflow;

interface EventInterface
{
Expand Down Expand Up @@ -152,9 +154,9 @@ public function getPayload() : string|null;

/**
* Restituisce il numero di pagamenti gestiti dall'evento
* @return int
* @return int|null
*/
public function getPaymentsCount() : int;
public function getPaymentsCount() : int|null;


/**
Expand Down Expand Up @@ -208,6 +210,22 @@ public function getKey(int $index = 0) : string|null;
*/
public function transaction(int $index = 0) : Transaction|null;

/**
* Restituisce una istanza per l'inserimento/aggiornamento nella transaction update
* @param int $transfer
* @param int $index
* @return TransactionDetails|null
*/
public function transactionDetails(int $transfer, int $index = 0) : TransactionDetails|null;


/**
* Restituisce una istanza per l'inserimento nella transaction events
* @param int $index
* @return Workflow|null
*/
public function workflowEvent(int $index = 0) : Workflow|null;


/**
* Restituisce true/false se la transazione i-esima del carrello contiene elementi sufficienti
Expand Down
94 changes: 89 additions & 5 deletions src/src/crawler/events/req/activatePaymentNotice.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<?php
namespace pagopa\crawler\events\req;


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


class activatePaymentNotice extends \pagopa\crawler\AbstractEvent
class activatePaymentNotice extends AbstractEvent
{

protected Payload $method;
Expand Down Expand Up @@ -198,9 +202,66 @@ public function getKey(int $index = 0): string
* @param int $index
* @return \pagopa\database\sherlock\Transaction|null
*/
public function transaction(int $index = 0): \pagopa\database\sherlock\Transaction|null
public function transaction(int $index = 0): Transaction|null
{
// TODO: Implement transaction() method.
$iuv = $this->getIuv($index);
$pa_emittente = $this->getPaEmittente($index);
$date_event = $this->getInsertedTimestamp()->format('Y-m-d');

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

$broker_psp = $this->getBrokerPsp();
$psp_id = $this->getPsp();
$canale = $this->getCanale();

$broker_pa = $this->getBrokerPa();
$stazione = $this->getStazione();

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

$transaction = new Transaction($this->getInsertedTimestamp());
$transaction->setIuv($iuv);
$transaction->setPaEmittente($pa_emittente);
$transaction->setInsertedTimestamp($this->getInsertedTimestamp());
$transaction->setNewColumnValue('date_event', $date_event);
$transaction->setBollo(false); // sempre a false perchè l'activatePaymentNotice non gestisce bollo

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

if (!is_null($broker_psp))
{
$transaction->setBrokerPsp($broker_psp);
}

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

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

if (!is_null($broker_pa))
{
$transaction->setBrokerPa($broker_pa);
}

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

if (!is_null($importo))
{
$transaction->setImporto($importo);
}

return $transaction;
}

/**
Expand All @@ -219,6 +280,29 @@ public function isValid(int $index = 0): bool
return ($date && $iuv && $pa && $token);
}

/**
* @param int $index
* @return TransactionDetails|null
*/
public function transactionDetails(int $transfer = 0, int $index = 0): TransactionDetails|null
{
return null;
}

/**
* @param int $index
* @return Workflow|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(1);
return $workflow;
}

/**
* @return MethodInterface
*/
Expand All @@ -231,7 +315,7 @@ public function getMethodInterface(): MethodInterface
* Restituisce 1 perchè la activatePaymentNotice gestisce un solo pagamento
* @return int
*/
public function getPaymentsCount(): int
public function getPaymentsCount(): int|null
{
return 1;
}
Expand Down
Loading

0 comments on commit 533ce37

Please sign in to comment.