Skip to content

Create response structure for API call or Service call - easily

Notifications You must be signed in to change notification settings

dev-arindam-roy/onex-response-structure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

ONEXCRM Create Response Structure

Create response structure for API call or Service call - easily.

Installation

composer require onexcrm/response-structure

Laravel without auto-discovery:

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php

Onex\Responsestructure\OnexResponseStructureServiceProvider::class,

If you want to use the facade to log messages, add this to your facades in app.php:

'OnexResponse'=> Onex\Responsestructure\Responsestructure\ResponseStructureClassFacade::class,

How to use?:

/**
 * 1st @param  array $dataBag
 * 2nd @param  string $responseMessage (default = '')
 * 3rd @param  string $bodyMessageTitle (default = '')
 * 4th @param  string $bodyMessage (default = '')
 * 5th @param  string $messageType (default = 'success')
 * 6th @param  string $responseStatus (default = '200')
 * 7th @param  string $responseType (default = 'success')
 * 8th @param  string $httpCode (default = '200')
*/

Example #1 (Array Format)


$getResponse = OnexResponse::constructResponse($userData, 'User list found');
dd($getResponse);

Example #2 (Json Format)


$getResponse = OnexResponse::constructResponseJson($userData, 'User list found');
dd($getResponse);

Example #3 (Json Object Response Format)


$getResponse = OnexResponse::constructResponseJsonObject($userData, 'User list found');
dd($getResponse);

Sample Response


onex_resstruc

Feel free to contact me: Arindam Roy arindam.roy.developer@gmail.com

Thanks

About

Create response structure for API call or Service call - easily

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages