Skip to content

Commit

Permalink
refactor: Implement lazy loading for images in DashboardV2 and update…
Browse files Browse the repository at this point in the history
… chat route
  • Loading branch information
Arghya721 committed Jun 24, 2024
1 parent 2c7c6b4 commit 1bb7910
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
from firebase_admin import firestore
from google.cloud.firestore_v1.base_query import FieldFilter
import uvicorn
import razorpay
from razorpay.resources.subscription import Subscription


dotenv.load_dotenv()
Expand Down Expand Up @@ -76,6 +78,10 @@ def get_environment_variable(key):

db = firestore.client()

client = razorpay.Client(auth=(RAZORPAY_KEY_ID, RAZORPAY_KEY_SECRET))
# Create an instance of the Subscription class
subscription = Subscription(client)

# This will just define that the Authorization header is required
auth_scheme = HTTPBearer()

Expand Down Expand Up @@ -582,6 +588,31 @@ async def chat_by_id(chat_id: str, token_info: dict = Depends(verify_token)):
logging.error("Error processing chat request: %s", e)
raise HTTPException(status_code=500, detail="Internal server error") from e

@app.get("/v1/subscriptions", tags=["Subscription Endpoints"])
async def get_subscriptions(token_info: dict = Depends(verify_token)):
"""Get the subscriptions for the user."""
# create a subscription object using customer id as token_info['sub'] and plan id as PLAN_ID
try:
subscription_data = {
"customer_id": token_info['sub'],
"plan_id": PLAN_ID,
"total_count":6,
"quantity": 1,
"notes": {
"notes_key_1" : "This is a test note"
},
"start_at": int(datetime.datetime.now().timestamp()),
"end_at": int((datetime.datetime.now() + datetime.timedelta(days=30)).timestamp()),
}

subscription_response = subscription.create(subscription_data)

return subscription_response

except Exception as e:
logging.error("Error getting subscriptions: %s", e)
raise HTTPException(status_code=500, detail="Internal server error") from e



if __name__ == "__main__":
Expand Down

0 comments on commit 1bb7910

Please sign in to comment.