mirror of
https://github.com/sctn4elk/CustomerRewardsRESTAPI.git
synced 2025-01-09 15:14:29 -06:00
Work on update customer
This commit is contained in:
parent
3ba4af82fa
commit
24da83e643
|
@ -179,13 +179,19 @@ class CustomerController extends BaseController{
|
|||
if (strtoupper($this->requestMethod) == $request) {
|
||||
$response = 'true';
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
private function validatePerson($input)
|
||||
{
|
||||
return true;
|
||||
$validtion = false;
|
||||
if($input->customer_name_first != null){
|
||||
$validtion = true;
|
||||
if($input->customer_name_last == null) {
|
||||
$validtion = false;
|
||||
}
|
||||
}
|
||||
return $validtion;
|
||||
}
|
||||
|
||||
private function unprocessableEntityResponse()
|
||||
|
@ -194,6 +200,8 @@ class CustomerController extends BaseController{
|
|||
$response['body'] = json_encode([
|
||||
'error' => 'Invalid input'
|
||||
]);
|
||||
$this->strErrorDesc = 'Unprocessable Payload';
|
||||
$this->strErrorHeader = 'HTTP/1.1 422 Unprocessable Payload';
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
@ -201,6 +209,8 @@ class CustomerController extends BaseController{
|
|||
{
|
||||
$response['status_code_header'] = 'HTTP/1.1 404 Entity Not Found';
|
||||
$response['body'] = null;
|
||||
$this->strErrorDesc = 'Request Entity Not Found';
|
||||
$this->strErrorHeader = 'HTTP/1.1 422 Entity Not Found';
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,34 +88,13 @@ class CustomerModel extends Database {
|
|||
|
||||
public function insertCustomer($jsonPayLoad)
|
||||
{
|
||||
$rowCount = $this->processStatement("CALL insert_new_customer_proc(?,?,?,?,?,?,?,?,?,?)",
|
||||
[$jsonPayLoad->customer_name_first,
|
||||
$jsonPayLoad->last,
|
||||
$jsonPayLoad->email,
|
||||
$jsonPayLoad->phone,
|
||||
$jsonPayLoad->birthday,
|
||||
$jsonPayLoad->street,
|
||||
$jsonPayLoad->city,
|
||||
$jsonPayLoad->state,
|
||||
$jsonPayLoad->zip,
|
||||
$jsonPayLoad->loyalty]);
|
||||
$rowCount = $this->processStatement("CALL insert_new_customer_proc", $jsonPayLoad);
|
||||
return $rowCount;
|
||||
}
|
||||
|
||||
public function updateCustomer($jsonPayLoad)
|
||||
{
|
||||
$rowCount = $this->processStatement("CALL update_existing_customer_proc(?,?,?,?,?,?,?,?,?,?,?)",
|
||||
[$jsonPayLoad->customer_id,
|
||||
$jsonPayLoad->customer_name_first,
|
||||
$jsonPayLoad->customer_name_last,
|
||||
$jsonPayLoad->customer_email,
|
||||
$jsonPayLoad->customer_phone,
|
||||
$jsonPayLoad->customer_birthday,
|
||||
$jsonPayLoad->customer_street,
|
||||
$jsonPayLoad->address_city,
|
||||
$jsonPayLoad->address_state,
|
||||
$jsonPayLoad->address_zip,
|
||||
$jsonPayLoad->loyalty_member]);
|
||||
$rowCount = $this->processStatement("CALL update_existing_customer_proc", $jsonPayLoad);
|
||||
return $rowCount;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,8 @@ class Database {
|
|||
public function processStatement($query = "", $params = [])
|
||||
{
|
||||
try {
|
||||
$parameters = str_repeat('?,', count($params) - 1) . '?';
|
||||
$query += "(".$parameters.")";
|
||||
$stmt = $this->executeStatement( $query, $params );
|
||||
$result = $this->connection->affected_rows;
|
||||
$stmt->close();
|
||||
|
@ -76,12 +78,13 @@ class Database {
|
|||
if($stmt === false) {
|
||||
throw New Exception("Unable to do prepared statement: " . $query);
|
||||
}
|
||||
if( $params ) {
|
||||
$stmt->bind_param(str_repeat("s", count($params)), ...$params);
|
||||
//$stmt->bind_param("isssssssssi", $params[0],$params[1],$params[2],$params[3],$params[4],$params[5],$params[6],$params[7],$params[8],$params[9],$params[10]);
|
||||
}
|
||||
|
||||
$stmt->execute();
|
||||
/*if( $params ) {
|
||||
$stmt->bind_param(str_repeat("s", count($params)), ...$params);
|
||||
}*/
|
||||
|
||||
$stmt->execute($params);
|
||||
//$stmt->execute();
|
||||
return $stmt;
|
||||
} catch(Exception $e) {
|
||||
throw New Exception( $e->getMessage() );
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
],
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "11",
|
||||
"vitexsoftware/phpunit-skeleton-generator": "*"
|
||||
"vitexsoftware/phpunit-skeleton-generator": "*",
|
||||
"php-webdriver/webdriver": "*"
|
||||
}
|
||||
}
|
||||
|
|
129
composer.lock
generated
129
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "242e5f38e4bcb2865e1a959b6ab2eae0",
|
||||
"content-hash": "cda368583fd799f54642eb879b836eb5",
|
||||
"packages": [],
|
||||
"packages-dev": [
|
||||
{
|
||||
|
@ -242,6 +242,72 @@
|
|||
},
|
||||
"time": "2022-02-21T01:04:05+00:00"
|
||||
},
|
||||
{
|
||||
"name": "php-webdriver/webdriver",
|
||||
"version": "1.15.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-webdriver/php-webdriver.git",
|
||||
"reference": "cd52d9342c5aa738c2e75a67e47a1b6df97154e8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/cd52d9342c5aa738c2e75a67e47a1b6df97154e8",
|
||||
"reference": "cd52d9342c5aa738c2e75a67e47a1b6df97154e8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*",
|
||||
"ext-zip": "*",
|
||||
"php": "^7.3 || ^8.0",
|
||||
"symfony/polyfill-mbstring": "^1.12",
|
||||
"symfony/process": "^5.0 || ^6.0 || ^7.0"
|
||||
},
|
||||
"replace": {
|
||||
"facebook/webdriver": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"ergebnis/composer-normalize": "^2.20.0",
|
||||
"ondram/ci-detector": "^4.0",
|
||||
"php-coveralls/php-coveralls": "^2.4",
|
||||
"php-mock/php-mock-phpunit": "^2.0",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.2",
|
||||
"phpunit/phpunit": "^9.3",
|
||||
"squizlabs/php_codesniffer": "^3.5",
|
||||
"symfony/var-dumper": "^5.0 || ^6.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-SimpleXML": "For Firefox profile creation"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"lib/Exception/TimeoutException.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Facebook\\WebDriver\\": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "A PHP client for Selenium WebDriver. Previously facebook/webdriver.",
|
||||
"homepage": "https://github.com/php-webdriver/php-webdriver",
|
||||
"keywords": [
|
||||
"Chromedriver",
|
||||
"geckodriver",
|
||||
"php",
|
||||
"selenium",
|
||||
"webdriver"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/php-webdriver/php-webdriver/issues",
|
||||
"source": "https://github.com/php-webdriver/php-webdriver/tree/1.15.1"
|
||||
},
|
||||
"time": "2023-10-20T12:21:20+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
"version": "11.0.3",
|
||||
|
@ -2052,6 +2118,67 @@
|
|||
],
|
||||
"time": "2024-01-29T20:11:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/process",
|
||||
"version": "v7.0.7",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/process.git",
|
||||
"reference": "3839e56b94dd1dbd13235d27504e66baf23faba0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/process/zipball/3839e56b94dd1dbd13235d27504e66baf23faba0",
|
||||
"reference": "3839e56b94dd1dbd13235d27504e66baf23faba0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.2"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Process\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Executes commands in sub-processes",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/process/tree/v7.0.7"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-04-18T09:29:19+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/service-contracts",
|
||||
"version": "v3.4.2",
|
||||
|
|
Loading…
Reference in New Issue
Block a user