Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

Card Blocking API

Build Status Coverage Status Python Version

API for accessing bank card blocking information. This service provides endpoints to list banks and retrieve detailed instructions on how to block cards for a specific bank.

API Endpoints

The API exposes the following endpoints based on the OpenAPI specification:

  • GET /banks: Lists all available banks with summary information (ID, name, logo).
  • GET /banks/{bankId}: Retrieves detailed information for a specific bank, including IFSC code and various methods for blocking cards (toll-free numbers, SMS numbers, email, website links, etc.).

Refer to the openapi.json file for detailed request/response schemas.

Setup

  1. Clone the repository:

    git clone <repository-url>
    cd card-block-api
  2. Create and activate a virtual environment (recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  3. Install dependencies:

    pip install -r requirements.txt
  4. Install development dependencies (for testing):

    pip install -r requirements-dev.txt

Running the Application

Development Server

To run the application using the Flask development server:

python run.py

By default, the server runs on http://127.0.0.1:5000. You can configure the host and port using environment variables:

  • FLASK_RUN_HOST: The host to bind to (default: 127.0.0.1).
  • FLASK_RUN_PORT: The port to listen on (default: 5000).

Example:

export FLASK_RUN_HOST=0.0.0.0
export FLASK_RUN_PORT=8080
python run.py

Production Server (Gunicorn)

For production deployments, it's recommended to use a WSGI server like Gunicorn (which is included in requirements.txt).

gunicorn --bind 0.0.0.0:8000 "run:app"

Adjust the bind address and port as needed.

Running Tests

To run the automated tests using pytest:

pytest

To run tests with coverage reporting:

pytest

Test Coverage

To run tests and generate a coverage report:

pytest --cov=app tests/

This will output a summary to the console. The current test coverage is 92%. You can also generate an HTML report for more detailed analysis:

pytest --cov=app --cov-report=html tests/
# Open htmlcov/index.html in your browser

Docker

A Dockerfile is provided to build a container image for the application.

  1. Build the image:

    docker build -t card-block-api .
  2. Run the container:

    docker run -p 5000:5000 card-block-api

    This will start the application using Gunicorn inside the container, accessible on port 5000 of your host machine.

CI/CD

This project uses GitHub Actions for Continuous Integration and Continuous Deployment. The workflow configuration can be found in .github/workflows/ci-cd.yml. The workflow typically includes steps for:

  • Setting up Python
  • Installing dependencies
  • Running linters (if configured)
  • Running tests
  • Building Docker image (optional)
  • Deploying (optional)

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages