Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(themes): Create APIs for managing themes #6658

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Conversation

ThisIsMani
Copy link
Contributor

@ThisIsMani ThisIsMani commented Nov 25, 2024

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

This PR adds APIs to manage themes.
These are the following APIs

  1. Create Theme
  2. Delete Theme
  3. Update Theme
  4. Upload Asset
  5. Find Theme by Theme ID
  6. Find Theme by Lineage

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

todo!()

Motivation and Context

Closes #6553

How did you test it?

  1. Create Theme
    curl --location 'http://localhost:8080/user/theme' \
    --header 'Content-Type: application/json' \
    --header 'api-key: ••••••' \
    --data '{
        "lineage": {
            "entity_type": "profile",
            "tenant_id": "t1",
            "org_id": "o1",
            "merchant_id": "m1",
            "profile_id": "p1"
        },
        "theme_name": "Test",
        "theme_data": {
            "settings": {
                "colors": {
                    "primary": "#3498db",
                    "sidebar": "#2ecc71"
                },
                "buttons": {
                    "primary": {
                        "hoverBackgroundColor": "#27ae60"
                    }
                }
            }
        }
    }'
    
  2. Delete Theme
    curl --location --request DELETE 'http://localhost:8080/user/theme/087c79dc-640c-4a2a-8552-6fa4e868cc63?entity_type=profile&tenant_id=t1&org_id=o1&merchant_id=m1&profile_id=p1' \
    --header 'api-key: ••••••'
    
  3. Update Theme
    curl --location --request PUT 'http://localhost:8080/user/theme/087c79dc-640c-4a2a-8552-6fa4e868cc63' \
    --header 'Content-Type: application/json' \
    --header 'api-key: test_admin' \
    --data '{
        "lineage": {
            "entity_type": "profile",
            "tenant_id": "t1",
            "org_id": "o1",
            "merchant_id": "m1",
            "profile_id": "p1"
        },
        "theme_data": {
            "settings": {
                "colors": {
                    "primary": "#3498xb",
                    "sidebar": "#2ecc71"
                },
                "buttons": {
                    "primary": {
                        "hoverBackgroundColor": "#27ae60"
                    }
                }
            }
        }
    }'
    
  4. Upload Asset
    curl --location 'http://localhost:8080/user/theme/087c79dc-640c-4a2a-8552-6fa4e868cc63?entity_type=profile&tenant_id=t1&org_id=o1&merchant_id=m1&profile_id=p1' \
    --header 'api-key: ••••••' \
    --form 'asset_name="logo.png"' \
    --form 'asset_data=@"path to file"'
    
  5. Get Theme by Theme ID
    curl --location 'http://localhost:8080/user/theme/087c79dc-640c-4a2a-8552-6fa4e868cc63' \
    --header 'api-key: ••••••'
    
  6. Get Theme by Lineage
    curl --location 'http://localhost:8080/user/theme?entity_type=merchant&tenant_id=t1&org_id=o1&merchant_id=m1&profile_id=p1' \
    --header 'api-key: ••••••'
    

Responses

  • Delete Theme and Upload Asset: 200 OK
  • Everything else
    {
        "theme_id": "087c79dc-640c-4a2a-8552-6fa4e868cc63",
        "theme_name": "Test",
        "entity_type": "profile",
        "tenant_id": "t1",
        "org_id": "o1",
        "merchant_id": "m1",
        "profile_id": "p1",
        "theme_data": {
            "settings": {
                "colors": {
                    "primary": "#3498db",
                    "sidebar": "#2ecc71"
                },
                "typography": null,
                "buttons": {
                    "primary": {
                        "backgroundColor": null,
                        "textColor": null,
                        "hoverBackgroundColor": "#27ae60"
                    },
                    "secondary": null
                },
                "borders": null,
                "spacing": null
            },
            "urls": null
        }
    }
    

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@ThisIsMani ThisIsMani added C-feature Category: Feature request or enhancement M-configuration-changes Metadata: This PR involves configuration changes A-users Area: Users labels Nov 25, 2024
@ThisIsMani ThisIsMani self-assigned this Nov 25, 2024
Copy link

semanticdiff-com bot commented Nov 25, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/core/errors/user.rs  68% smaller
  crates/router/src/routes/lock_utils.rs  33% smaller
  crates/api_models/src/events/user.rs  29% smaller
  crates/common_utils/src/types/theme.rs  5% smaller
  crates/diesel_models/src/user/theme.rs  3% smaller
  Cargo.lock Unsupported file format
  config/config.example.toml Unsupported file format
  config/deployments/env_specific.toml Unsupported file format
  config/development.toml Unsupported file format
  config/docker_compose.toml Unsupported file format
  crates/api_models/Cargo.toml Unsupported file format
  crates/api_models/src/user.rs  0% smaller
  crates/api_models/src/user/theme.rs  0% smaller
  crates/diesel_models/src/query/user/theme.rs  0% smaller
  crates/router/src/configs/secrets_transformers.rs  0% smaller
  crates/router/src/configs/settings.rs  0% smaller
  crates/router/src/core/user.rs  0% smaller
  crates/router/src/core/user/theme.rs  0% smaller
  crates/router/src/db/kafka_store.rs  0% smaller
  crates/router/src/db/user/theme.rs  0% smaller
  crates/router/src/routes/app.rs  0% smaller
  crates/router/src/routes/user.rs  0% smaller
  crates/router/src/routes/user/theme.rs  0% smaller
  crates/router/src/utils/user.rs  0% smaller
  crates/router/src/utils/user/theme.rs  0% smaller
  crates/router_env/src/logger/types.rs  0% smaller

@ThisIsMani ThisIsMani added the M-api-contract-changes Metadata: This PR involves API contract changes label Nov 26, 2024
@hyperswitch-bot hyperswitch-bot bot removed the M-api-contract-changes Metadata: This PR involves API contract changes label Nov 26, 2024
@ThisIsMani ThisIsMani marked this pull request as ready for review November 26, 2024 14:20
@ThisIsMani ThisIsMani requested review from a team as code owners November 26, 2024 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-users Area: Users C-feature Category: Feature request or enhancement M-configuration-changes Metadata: This PR involves configuration changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(themes): APIs for theme management
1 participant