diff --git a/app/api/routes/routes.py b/app/api/routes/routes.py index 76374a9..a88429b 100644 --- a/app/api/routes/routes.py +++ b/app/api/routes/routes.py @@ -119,3 +119,12 @@ def authorize(): # logger.info(f"Authorize request received: {data}") response = AuthorizationService.process_request(data) return response + + +# Authorize refresh endpoint +@api.route("/AuthorizeRefresh", methods=["POST"]) +def refresh(): + data = request.get_json() + # logger.info(f"Authorize refresh request received: {data}") + response = AuthorizationService.process_refresh_request(data) + return response diff --git a/app/api/services/authorization.py b/app/api/services/authorization.py index 210a56f..f664445 100644 --- a/app/api/services/authorization.py +++ b/app/api/services/authorization.py @@ -29,7 +29,7 @@ class AuthorizationService(BaseService): try: logger.info("Processing Authorization request") - if not request.is_json: + if not data: return ResponseHelper.bad_request(message="Missing JSON in request") # Validate input data using the Authorization schema @@ -66,3 +66,35 @@ class AuthorizationService(BaseService): return ResponseHelper.internal_server_error( message=f"Error processing Authorization request: {e}" ) + + @staticmethod + def process_refresh_request(): + """ + Process the RefreshToken request. + + Args: + data (dict): The request data. + + Returns: + dict: A standardized response. + """ + try: + logger.info("Processing RefreshToken request") + + identity = get_jwt_identity() + access_token = create_access_token(identity=identity) + + # Simulated processing logic + response_data = { + "access_token": access_token, + } + + return ResponseHelper.success( + data=response_data, message="RefreshToken processed successfully" + ) + + except Exception as e: + logger.error(f"Error processing RefreshToken request: {e}") + return ResponseHelper.internal_server_error( + message=f"Error processing RefreshToken request: {e}" + ) diff --git a/app/swagger/digifi_swagger.json b/app/swagger/digifi_swagger.json index 5ed7133..bfc4128 100644 --- a/app/swagger/digifi_swagger.json +++ b/app/swagger/digifi_swagger.json @@ -85,6 +85,14 @@ "description": "Find out more", "url": "https://www.simbrellang.net" } + }, + { + "name": "AuthorizeRefresh", + "description": "This feature will be used for refreshing authorized customers.", + "externalDocs": { + "description": "Find out more", + "url": "https://www.simbrellang.net" + } } ], "paths": { @@ -111,6 +119,9 @@ }, "/Authorize": { "$ref": "swagger/paths/Authorize.json" + }, + "/AuthorizeRefresh": { + "$ref": "swagger/paths/AuthorizeRefresh.json" } }, "components": { @@ -156,6 +167,15 @@ }, "AuthorizeResponse": { "$ref": "swagger/schemas/AuthorizeResponse.json" + }, + "AuthorizeRequest": { + "$ref": "swagger/schemas/AuthorizeRequest.json" + }, + "AuthorizeRefreshResponse": { + "$ref": "swagger/schemas/AuthorizeRefreshResponse.json" + }, + "AuthorizeRefreshRequest": { + "$ref": "swagger/schemas/AuthorizeRefreshRequest.json" } }, "securitySchemes": { diff --git a/app/swagger/paths/AuthorizeRefresh.json b/app/swagger/paths/AuthorizeRefresh.json new file mode 100644 index 0000000..a5f19ee --- /dev/null +++ b/app/swagger/paths/AuthorizeRefresh.json @@ -0,0 +1,54 @@ +{ + "post": { + "tags": ["Authorize Refresh"], + "summary": "Customer Authorize Refresh Request", + "description": "Customer Authorize Refresh Request", + "operationId": "AuthorizeRefresh", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "../schemas/AuthorizeRefreshRequest.json" + } + }, + "application/xml": { + "schema": { + "$ref": "../schemas/AuthorizeRefreshRequest.json" + } + }, + "application/x-www-form-urlencoded": { + "schema": { + "$ref": "../schemas/AuthorizeRefreshRequest.json" + } + } + } + }, + "responses": { + "200": { + "description": "Successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "../schemas/AuthorizeRefreshResponse.json" + } + }, + "application/xml": { + "schema": { + "$ref": "../schemas/AuthorizeRefreshResponse.json" + } + } + } + }, + "400": { + "description": "Invalid request parameters" + }, + "422": { + "description": "Validation exception" + }, + "500": { + "description": "Internal server error" + } + } + } +} diff --git a/app/swagger/schemas/AuthorizeRefreshRequest.json b/app/swagger/schemas/AuthorizeRefreshRequest.json new file mode 100644 index 0000000..7221fab --- /dev/null +++ b/app/swagger/schemas/AuthorizeRefreshRequest.json @@ -0,0 +1,12 @@ +{ + "type": "object", + "properties": { + "access_token": { + "type": "string", + "example": "access_token" + } + }, + "xml": { + "name": "AuthorizeRefreshRequest" + } +} diff --git a/app/swagger/schemas/AuthorizeRefreshResponse.json b/app/swagger/schemas/AuthorizeRefreshResponse.json new file mode 100644 index 0000000..9559696 --- /dev/null +++ b/app/swagger/schemas/AuthorizeRefreshResponse.json @@ -0,0 +1,16 @@ +{ + "type": "object", + "properties": { + "resultCode": { + "type": "string", + "example": "00" + }, + "resultDescription": { + "type": "string", + "example": "Successful" + } + }, + "xml": { + "name": "AuthorizeRefreshResponse" + } +}