2022-04-29 01:01:18 +03:00
|
|
|
<?php
|
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
class NpciBridge extends BridgeAbstract
|
|
|
|
{
|
|
|
|
const MAINTAINER = 'captn3m0';
|
|
|
|
const NAME = 'NCPI Circulars';
|
|
|
|
const URI = 'https://npci.org.in';
|
|
|
|
const CACHE_TIMEOUT = 3600;
|
|
|
|
const DESCRIPTION = 'Returns circulars from National Payments Corporation of India)';
|
2022-04-29 01:01:18 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
const URL_SUFFIX = [
|
|
|
|
'cts' => 'circulars',
|
|
|
|
'upi' => 'circular',
|
|
|
|
'rupay' => 'circulars',
|
|
|
|
'nach' => 'circulars',
|
|
|
|
'imps' => 'circular',
|
|
|
|
'netc-fastag' => 'circulars',
|
|
|
|
'99' => 'circular',
|
|
|
|
'nfs' => 'circulars',
|
|
|
|
'aeps' => 'circulars',
|
|
|
|
'bhim-aadhaar' => 'circular',
|
|
|
|
'e-rupi' => 'circular',
|
|
|
|
'Bharat QR' => 'circulars',
|
|
|
|
'bharat-billpay' => 'circulars',
|
|
|
|
];
|
2022-04-29 01:01:18 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
const PARAMETERS = [[
|
|
|
|
'product' => [
|
|
|
|
'name' => 'product',
|
|
|
|
'type' => 'list',
|
|
|
|
'values' => [
|
|
|
|
'CTS' => 'cts',
|
|
|
|
'UPI' => 'upi',
|
|
|
|
'RuPay' => 'rupay',
|
|
|
|
'NACH' => 'nach',
|
|
|
|
'IMPS' => 'imps',
|
|
|
|
'NETC FASTag' => 'netc-fastag',
|
|
|
|
'*99#' => '99',
|
|
|
|
'NFS' => 'nfs',
|
|
|
|
'AePS' => 'aeps',
|
|
|
|
'BHIM Aadhaar' => 'bhim-aadhaar',
|
|
|
|
'e-RUPI' => 'e-rupi',
|
|
|
|
'Bharat BillPay' => 'bharat-billpay'
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]];
|
2022-04-29 01:01:18 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function getName()
|
|
|
|
{
|
2023-03-06 22:01:51 +03:00
|
|
|
if ($this->getInput('product')) {
|
|
|
|
return 'NPCI Circulars: ' . $this->getKey('product');
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
|
|
|
return 'NPCI Circulars';
|
|
|
|
}
|
2022-04-29 01:01:18 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function getURI()
|
|
|
|
{
|
|
|
|
$product = $this->getInput('product');
|
|
|
|
return $product ? sprintf('%s/what-we-do/%s/%s', self::URI, $product, self::URL_SUFFIX[$product]) : self::URI;
|
|
|
|
}
|
2022-04-29 01:01:18 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
|
|
|
$html = getSimpleHTMLDOMCached($this->getURI());
|
|
|
|
$year = date('Y');
|
|
|
|
$elements = $html->find("div[id=year$year] .pdf-item");
|
2022-04-29 01:01:18 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
foreach ($elements as $element) {
|
|
|
|
$title = $element->find('p', 0)->innertext;
|
2022-04-29 01:01:18 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
$link = $element->find('a', 0);
|
2022-04-29 01:01:18 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
$uri = null;
|
2022-04-29 01:01:18 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
if ($link) {
|
|
|
|
$pdfLink = $link->getAttribute('href');
|
|
|
|
$uri = self::URI . str_replace(' ', '+', $pdfLink);
|
|
|
|
}
|
2022-04-29 01:01:18 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
$item = [
|
|
|
|
'uri' => $uri,
|
|
|
|
'title' => $title,
|
Fix coding style missed by phpbcf (#2901)
$ composer require --dev friendsofphp/php-cs-fixer
$ echo >.php-cs-fixer.dist.php "<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__);
$rules = [
'@PSR12' => true,
// '@PSR12:risky' => true,
'@PHP74Migration' => true,
// '@PHP74Migration:risky' => true,
// buggy, duplicates existing comment sometimes
'no_break_comment' => false,
'array_syntax' => true,
'lowercase_static_reference' => true,
'visibility_required' => false,
// Too much noise
'binary_operator_spaces' => false,
'heredoc_indentation' => false,
'trailing_comma_in_multiline' => false,
];
$config = new PhpCsFixer\Config();
return $config
->setRules($rules)
// ->setRiskyAllowed(true)
->setFinder($finder);
"
$ vendor/bin/php-cs-fixer --version
PHP CS Fixer 3.8.0 BerSzcz against war! by Fabien Potencier and Dariusz Ruminski.
PHP runtime: 8.1.7
$ vendor/bin/php-cs-fixer fix
$ rm .php-cs-fixer.cache
$ vendor/bin/php-cs-fixer fix
2022-07-08 14:00:52 +03:00
|
|
|
'content' => $title,
|
2022-07-01 16:10:30 +03:00
|
|
|
'uid' => sha1($pdfLink),
|
|
|
|
'enclosures' => [
|
|
|
|
$uri
|
|
|
|
]
|
|
|
|
];
|
2022-04-29 01:01:18 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
2022-04-29 01:01:18 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
$this->items = array_slice($this->items, 0, 15);
|
|
|
|
}
|
2022-04-29 01:01:18 +03:00
|
|
|
}
|