Merge branch '640-new-rider-api-call-to-return-customer-hash' into 'master-fix'

Resolve "New rider api call to return customer hash"

See merge request jankstudio/resq!752
This commit is contained in:
Kendrick Chan 2021-12-03 05:56:57 +00:00
commit a5f5ac861d
8 changed files with 1008 additions and 762 deletions

View file

@ -2,18 +2,30 @@
"type": "project",
"license": "proprietary",
"repositories": [
{ "type": "vcs", "url": "git@gitlab.com:jankstudio-catalyst/auth-bundle.git" },
{ "type": "vcs", "url": "git@gitlab.com:jankstudio-catalyst/menu-bundle.git" }
{
"type": "vcs",
"url": "git@gitlab.com:jankstudio-catalyst/auth-bundle.git"
},
{
"type": "vcs",
"url": "git@gitlab.com:jankstudio-catalyst/menu-bundle.git"
}
],
"require": {
"php": "^7.1.3",
"ext-iconv": "*",
"catalyst/auth-bundle": "dev-master",
"catalyst/menu-bundle": "dev-master",
"composer/package-versions-deprecated": "1.11.99.4",
"creof/doctrine2-spatial": "^1.2",
"data-dog/audit-bundle": "^0.1.10",
"doctrine/common": "^2",
"doctrine/doctrine-bundle": "^2",
"doctrine/doctrine-migrations-bundle": "^2",
"doctrine/orm": "^2",
"edwinhoksberg/php-fcm": "^1.0",
"guzzlehttp/guzzle": "^6.3",
"hashids/hashids": "^4.1",
"microsoft/azure-storage-blob": "^1.5",
"predis/predis": "^1.1",
"sensio/framework-extra-bundle": "^5.1",
@ -26,9 +38,7 @@
"symfony/framework-bundle": "^4.0",
"symfony/maker-bundle": "^1.0",
"symfony/monolog-bundle": "^3.7",
"symfony/orm-pack": "^1.0",
"symfony/process": "^4.0",
"symfony/profiler-pack": "^1.0",
"symfony/security-bundle": "^4.0",
"symfony/translation": "^4.0",
"symfony/twig-bundle": "^4.0",
@ -38,7 +48,9 @@
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.0",
"symfony/dotenv": "^4.0",
"symfony/thanks": "^1.0"
"symfony/stopwatch": "^4.0",
"symfony/thanks": "^1.0",
"symfony/web-profiler-bundle": "^4.0"
},
"config": {
"preferred-install": {

1631
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -216,6 +216,11 @@ api_latest_job_order:
controller: App\Controller\APIController::getLatestJobOrder
methods: [GET]
api_customer_hash_get:
path: /api/customer_hash
controller: App\Controller\APIController::getCustomerHash
methods: [GET]
#api_completed_job_orders:
# path: /api/job_orders/completed
# controller: App\Controller\APIController::getCompletedJobOrders

View file

@ -94,4 +94,3 @@ capi_rider_jo_start:
path: /rider_api/start
controller: App\Controller\CAPI\RiderAppController::startJobOrder
methods: [POST]

View file

@ -0,0 +1,44 @@
<?php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use App\Service\HashGenerator;
class TestHashGeneratorCommand extends Command
{
protected $hash;
protected function configure()
{
$this->setName('test:hash')
->setDescription('Test hash generator.')
->setHelp('Test hash generator service.');
}
public function __construct(HashGenerator $hash)
{
$this->hash = $hash;
parent::__construct();
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$orig_id = 39095;
error_log('original id - ' . $orig_id);
$hash_id = $this->hash->getHash($orig_id);
error_log('hash id - ' . $hash_id);
$id = $this->hash->getID($hash_id);
error_log('id - ' . $id);
return 0;
}
}

View file

@ -47,6 +47,7 @@ use App\Service\HubSelector;
use App\Service\HubDistributor;
use App\Service\HubFilterLogger;
use App\Service\HubFilteringGeoChecker;
use App\Service\HashGenerator;
use App\Entity\MobileSession;
use App\Entity\Customer;
@ -3848,6 +3849,35 @@ class APIController extends Controller implements LoggedController
return $res->getReturnResponse();
}
public function getCustomerHash(Request $req, EntityManagerInterface $em, HashGenerator $hash)
{
// check required parameters and api key
$res = $this->checkParamsAndKey($req, $em, []);
if ($res->isError())
return $res->getReturnResponse();
// get customer
$cust = $this->session->getCustomer();
if ($cust == null)
{
$res->setError(true)
->setErrorMessage('No customer information found');
return $res->getReturnResponse();
}
// hash customer id
$hashed_id = $hash->getHash($cust->getID());
$data = [
'cust_hash' => $hashed_id,
];
$res->setData($data);
// response
return $res->getReturnResponse();
}
// commenting it out. Modify the getJOHistory instead to just get the fulfilled
// and cancelled job orders, since ongoing is not yet part of history
/*

View file

@ -0,0 +1,28 @@
<?php
namespace App\Service;
use Hashids\Hashids;
class HashGenerator
{
// TODO: set in env file and set in constructor
protected $salt = 'salt that should be in the env file 230498';
protected $length = 15;
public function getHash($id)
{
$hi = new Hashids($this->salt, $this->length);
return $hi->encode($id);
}
public function getID($hash)
{
$hi = new Hashids($this->salt, $this->length);
$id_array = $hi->decode($hash);
// first one should be the id
return $id_array[0];
}
}

View file

@ -110,6 +110,9 @@
"guzzlehttp/psr7": {
"version": "1.4.2"
},
"hashids/hashids": {
"version": "4.1.0"
},
"jdorn/sql-formatter": {
"version": "v1.2.17"
},
@ -269,9 +272,6 @@
"config/packages/test/monolog.yaml"
]
},
"symfony/orm-pack": {
"version": "v1.0.5"
},
"symfony/polyfill-ctype": {
"version": "v1.9.0"
},
@ -290,9 +290,6 @@
"symfony/process": {
"version": "v4.4.9"
},
"symfony/profiler-pack": {
"version": "v1.0.3"
},
"symfony/property-access": {
"version": "v4.0.2"
},