Skip to content

Feature/customer rest api#22

Open
abiodunaremu wants to merge 1 commit into
developfrom
feature/customer-rest-api
Open

Feature/customer rest api#22
abiodunaremu wants to merge 1 commit into
developfrom
feature/customer-rest-api

Conversation

@abiodunaremu

@abiodunaremu abiodunaremu commented Jun 1, 2020

Copy link
Copy Markdown
Collaborator

Description

Created the following REST endpoints

  • Customer signup
  • Search Customer by criteria
  • Search Customer by Id
  • Reset password
  • Customer sign in
  • Customer logout
  • Token verification

Fixes #8 #9 #21

How Has This Been Tested?

Postman-Rest Client

Checklist:

  • [x ] My code follows the style guidelines of this project
  • [ x] I have performed a self-review of my own code
  • [ x] I have commented my code, particularly in hard-to-understand areas
  • [ x] I have added necessary inline code documentation
  • I have added tests that prove my fix is effective and that this feature works
  • New and existing unit tests pass locally with my changes

Copy link
Copy Markdown
Collaborator Author

Codacy Here is an overview of what got changed by this pull request:

Issues
======
+ Solved 2
- Added 379
           

Complexity increasing per file
==============================
- customer_service/lib/FileManager/FileType/FileTypeHandler.php  6
- customer_service/lib/ErrorReporter/ObjectError.php  1
- customer_service/lib/ResponseBuilder/JsonResponseBuilder.php  8
- customer_service/lib/EmailManager/PHPMailerEmailAPI.php  4
- customer_service/lib/FileManager/FileCreator/FileCreatorHandler.php  6
- customer_service/lib/DatabaseManager/DatabaseManager.php  2
- customer_service/lib/FileManager/FileManager.php  1
- customer_service/lib/FileManager/FileFormatter/FileFormatterFactory.php  1
- customer_service/lib/FileManager/FileFormatter/Image/JPEGImageFileFormatter.php  3
- customer_service/lib/ResponseBuilder/JsonHandler.php  1
- customer_service/lib/EmailManager/ResetPasswordEmailContent.php  3
- customer_service/lib/FileManager/File/PersistFileHandler.php  6
- customer_service/lib/FileManager/FileFormatter/FileFormatterPool.php  4
- customer_service/lib/FileUploadManager/FileUploadManager.php  1
- customer_service/lib/EmailManager/EmailManager.php  2
- customer_service/lib/EmailManager/SMTPEmailConnection.php  1
- customer_service/lib/FileUploadManager/MultipleFileUploader.php  5
- customer_service/lib/FileManager/FileGroup/FileGroupHandler.php  6
- customer_service/lib/FileUploadManager/SingleFileUploader.php  3
- customer_service/src/Services/CustomerService.php  2
- customer_service/lib/EmailManager/SignupEmailContent.php  3
- customer_service/lib/FileManager/FileType/FileType.php  1
- customer_service/lib/ResponseBuilder/JsonClientResponseArray.php  3
- customer_service/src/Repositories/CustomerSessionRepository.php  6
- customer_service/src/Controllers/CustomerController.php  6
- customer_service/lib/EmailManager/SMTPEmailConnectionFactory.php  1
- customer_service/src/Models/CustomerModel.php  3
- customer_service/src/Services/CustomerSessionService.php  3
- customer_service/lib/ErrorReporter/PersistenceError.php  1
- customer_service/src/Controllers/CustomerSessionController.php  4
- customer_service/lib/ErrorReporter/ErrorReporter.php  2
- customer_service/lib/FileManager/File/LogicFile.php  2
- customer_service/lib/FileManager/FileGroup/FileGroup.php  1
- customer_service/lib/ErrorReporter/EmptyError.php  1
- customer_service/lib/FileManager/File/PersistFile.php  1
- customer_service/src/Repositories/CustomerRepository.php  8
- customer_service/lib/ResponseBuilder/JsonClientResponseData.php  3
- customer_service/src/Models/CustomerSessionModel.php  1
- customer_service/src/Controllers/ApplicationController.php  1
- customer_service/lib/FileManager/FileCreator/FileCreator.php  1
- customer_service/lib/ErrorReporter/ErrorNodeFactory.php  1
- customer_service/lib/ErrorReporter/Errors.php  2
         

Clones added
============
- customer_service/lib/EmailManager/ResetPasswordEmailContent.php  1
- customer_service/lib/FileUploadManager/MultipleFileUploader.php  1
- customer_service/lib/FileUploadManager/SingleFileUploader.php  1
- customer_service/lib/EmailManager/SignupEmailContent.php  1
         

See the complete overview on Codacy


if ($this->customer === null) {
$responseData->addValue("href", "app/customers");
echo $responseBuilder->setName("resetcustomerpassword")

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SET vhTimeOut = NULL;
SET vhTimeLastCheck = NOW();
SET chCheckState = chStartState;
SET chEndState = NULL;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$errorMessages = $errorMessages.$jsonHandler->quoteString("errors")
." : [{".
$jsonHandler->quoteString("head")." : ";
$headError = ErrorReporter::getResponseMessageType() === 0 ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread customer_service/sql/z#default.sql Outdated
CALL prnInsCountry('BAHAMAS');
CALL prnInsCountry('BAHRAIN');
CALL prnInsCountry('BANGLADESH');
CALL prnInsCountry('BARBADOS');

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread customer_service/lib/SQL/FileType.sql Outdated
SET chStatus=@Status;
END IF;

IF thDescription='' OR thDescription IS NULL

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread customer_service/index.php Outdated
header("Access-Control-Allow-Methods: GET,HEAD,OPTIONS,POST,PUT");
header("access-control-allow-methods: GET,HEAD,OPTIONS,POST,PUT");
header("Access-Control-Allow-Headers: Or_+_igin, X-Requested-With, Content-Type, Accept, Authorization,Access-Control-Allow-Origin,access-control-allow-headers");
header("access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, Authorization,Access-Control-Allow-Origin,access-control-allow-headers,access-control-allow-methods");

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread customer_service/index.php Outdated
if(in_array($_SERVER['REQUEST_METHOD'], array('POST', 'PUT', 'DELETE'))) {

//Make sure that the content type of the request has been set to application/json
$contentType = isset($_SERVER["CONTENT_TYPE"]) ? trim($_SERVER["CONTENT_TYPE"]) : '';

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ELSE
SET @A='Nill';/**SELECT 'Specified Currency Name not be found';**/
END IF;
END$$

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Class:FileHandler->persistFile; Empty status returned ",
"Unable to register file.<br/>Please try again Later"
);
ErrorReporter::addNode($errorNode);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread customer_service/sql/z#default.sql Outdated
CALL prnInsCountry('AUSTRALIA');
CALL prnInsCountry('AUSTRIA');
CALL prnInsCountry('AZERBAIJAN');
CALL prnInsCountry('BAHAMAS');

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread customer_service/lib/SQL/FileType.sql Outdated
SET vhName=@Name;
END IF;

IF chStatus='' OR chStatus IS NULL

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread customer_service/lib/SQL/FileType.sql Outdated
dLastUpdate datetime not null,
cStatus char(1) not null
);
alter table `broomy_db`.`FileType` auto_increment = 1;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread customer_service/sql/z#default.sql Outdated
CALL prnInsCountry('CENTRAL AFRICAN');
CALL prnInsCountry('REPUBLIC');
CALL prnInsCountry('CHAD');
CALL prnInsCountry('CHILE');

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return $this->id;
}

public function setId($id)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (DatabaseManager::mysql_query($query)) {
$result = DatabaseManager::mysql_query($querySelectHolder);
if ($result) {
$num_results = DatabaseManager::mysql_num_rows($result);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Customer Object already exist: will not create new user ",
"Internal error occured. Please try again later."
);
ErrorReporter::addNode($errorNode);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return $this->id;
}

public function setId($id)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
if ($this->nextNode) {
return $this->nextNode;
} else {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread customer_service/lib/SQL/FileType.sql Outdated
@@ -0,0 +1,88 @@
USE broomy_db;

DROP TABLE IF EXISTS `broomy_db`.`FileType`;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$this->decoded['dateofbirth']
);
} elseif (strcasecmp($_SERVER['REQUEST_METHOD'], 'GET')
=== 0 && sizeof($this->params) === $this->index_entity+2) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public function persistFile($sessionId, $fileGroupId, $fileType, $oldName, $fileDirPath, $extension, $size)
{
$error = "";
$response = "";

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

USE broomy_db;

DROP TABLE IF EXISTS `broomy_db`.`CustomerSession`;
CREATE TABLE `broomy_db`.`CustomerSession`

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$row="";
$response="";
$error="";
$result = DatabaseManager::mysql_query($query);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread customer_service/sql/country.sql Outdated
SET CountryCode=CONCAT('0',CAST(COUNTER AS CHAR(3)));
WHEN COUNTER>99 and COUNTER<=999 THEN
SET CountryCode=CAST(COUNTER AS CHAR(3));
END CASE;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} elseif (strcasecmp($_SERVER['REQUEST_METHOD'], 'GET')
=== 0 && sizeof($this->params) === $this->index_entity+2) {
//retrieve customer information by id
$customerId = $this->params[sizeof($this->params)-1];

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnsonfash johnsonfash force-pushed the feature/customer-rest-api branch from 25b8cb9 to cf72b75 Compare July 1, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[@A] Create Customer REST API For CRUD Operations

1 participant