Refactor names for the Company, Category, User APIs and tests.
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -26,19 +26,19 @@ class CategoryController extends Controller
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$matrix_username = $request->input('matrix_username') ?? '';
|
||||
$company_uuid = $request->input('uuid') ?? '';
|
||||
$matrixUsername = $request->input('matrixUsername') ?? '';
|
||||
$companyUUID = $request->input('uuid') ?? '';
|
||||
$user = null;
|
||||
$cart = null;
|
||||
$company = null;
|
||||
|
||||
if($company_uuid != ''){
|
||||
$company = Company::where('uuid', $company_uuid)->first();
|
||||
if($companyUUID != ''){
|
||||
$company = Company::where('uuid', $companyUUID)->first();
|
||||
}
|
||||
|
||||
if($matrix_username) {
|
||||
if($matrixUsername) {
|
||||
$user = User::firstOrCreate([
|
||||
'matrix_username' => $matrix_username
|
||||
'matrix_username' => $matrixUsername
|
||||
]);
|
||||
|
||||
$cart = Cart::firstOrCreate([
|
||||
@@ -47,7 +47,7 @@ class CategoryController extends Controller
|
||||
]);
|
||||
|
||||
$company = $cart->getCompany();
|
||||
$company_uuid = $company->uuid;
|
||||
$companyUUID = $company->uuid;
|
||||
}
|
||||
|
||||
if(!$company)
|
||||
@@ -59,7 +59,7 @@ class CategoryController extends Controller
|
||||
$fetcher = new ApiFetcher();
|
||||
$categoryItemAPI = new CategoryItemAPI($fetcher);
|
||||
|
||||
$categoriesItemsMap = $categoryItemAPI->getMap($company_uuid);
|
||||
$categoriesItemsMap = $categoryItemAPI->getMap($companyUUID);
|
||||
$categoryItemAPI->saveMap($categoriesItemsMap, $company);
|
||||
|
||||
// Companies Categories
|
||||
|
||||
@@ -26,35 +26,36 @@ class CompanyController extends Controller
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$matrix_username = $request->input('matrix_username') ?? '';
|
||||
$city_uuid = $request->input('uuid') ?? '';
|
||||
$matrixUsername = $request->input('matrixUsername') ?? '';
|
||||
$cityUUID = $request->input('uuid') ?? '';
|
||||
$user = null;
|
||||
$cart = null;
|
||||
$city = null;
|
||||
|
||||
if($city_uuid != ''){
|
||||
$city = City::where('uuid', $city_uuid)->first();
|
||||
if($cityUUID != ''){
|
||||
$city = City::where('uuid', $cityUUID)->first();
|
||||
}
|
||||
|
||||
if($matrix_username) {
|
||||
if($matrixUsername) {
|
||||
$user = User::firstOrCreate([
|
||||
'matrix_username' => $matrix_username
|
||||
'matrix_username' => $matrixUsername
|
||||
]);
|
||||
|
||||
// TODO valid city exists
|
||||
$cart = Cart::firstOrCreate([
|
||||
'user_id' => $user->id,
|
||||
'status' => 'CART'
|
||||
]);
|
||||
|
||||
$city = $cart->getCity();
|
||||
$city_uuid = $city->uuid;
|
||||
$cityUUID = $city->uuid;
|
||||
}
|
||||
|
||||
// Update list of companies
|
||||
$fetcher = new ApiFetcher();
|
||||
$companyAPI = new CompanyAPI($fetcher);
|
||||
|
||||
$companyMap = $companyAPI->getMap($city_uuid);
|
||||
$companyMap = $companyAPI->getMap($cityUUID);
|
||||
$companyAPI->saveMap($companyMap, $city);
|
||||
|
||||
$companies = $city->getCompanies();
|
||||
|
||||
@@ -12,7 +12,7 @@ class UserController extends Controller
|
||||
public function register(Request $request)
|
||||
{
|
||||
$username = $request->input('username') ?? '';
|
||||
$matrix_username = $request->input('matrix_username') ?? '';
|
||||
$matrixUsername = $request->input('matrixUsername') ?? '';
|
||||
$phone = $request->input('phone') ?? '';
|
||||
|
||||
if($username == '') {
|
||||
@@ -26,7 +26,7 @@ class UserController extends Controller
|
||||
// if username is free then the new user will be created
|
||||
// with addition arguments:
|
||||
[
|
||||
'matrix_username' => $matrix_username,
|
||||
'matrix_username' => $matrixUsername,
|
||||
'phone' => $phone
|
||||
]
|
||||
);
|
||||
@@ -45,7 +45,7 @@ class UserController extends Controller
|
||||
public function login(Request $request)
|
||||
{
|
||||
$username = $request->input('username') ?? '';
|
||||
$matrix_username = $request->input('matrix_username') ?? '';
|
||||
$matrixUsername = $request->input('matrixUsername') ?? '';
|
||||
|
||||
if($username == '') {
|
||||
return response()->json([
|
||||
@@ -63,8 +63,8 @@ class UserController extends Controller
|
||||
|
||||
// Update matrix user if needed
|
||||
// TODO add verification check
|
||||
if($user->matrix_username != $matrix_username) {
|
||||
$user->matrix_username = $matrix_username;
|
||||
if($user->matrix_username != $matrixUsername) {
|
||||
$user->matrix_username = $matrixUsername;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user