Sindbad~EG File Manager

Current Path : /home/numerotech/paymentapi.numerotech.com/paymentapi/core/model/
Upload File :
Current File : //home/numerotech/paymentapi.numerotech.com/paymentapi/core/model/APIModel.py

from sqlalchemy import create_engine, MetaData, Table, insert, select,update,delete,text
from sqlalchemy.sql import and_, or_
from core import app
import json

engine = create_engine(app.config['DATABASE_URI'],pool_size=5000,pool_pre_ping=True,pool_recycle=3600,future =True)

class APIModel():
	def __init__(self):
		try:
			self.meta = MetaData()
			self.payments = Table("payments", self.meta,  autoload_with=engine)
		except Exception as e:
			print(e)

	def getAppMasterGateway(self,am_id):
		with engine.connect() as conn:
			stmt    = text("select g.*,a.am_id,a.app_name,a.app_key,a.is_active from gateway_settings g inner join app_master a on a.am_id = g.am_id where a.am_id ="+str(am_id)+" ;")
			print(stmt)
			result = conn.execute(stmt).one_or_none()
			return  dict(result._mapping)  if result else None


	# get webhook data by unique_id -- October 31, 2022
	def getPaymentDataByUniqueId(self,unique_ids,unique_id_count):
		with engine.connect() as conn:
			if unique_id_count and unique_id_count > 1 :
				stmt    = text("select name,email,mobile,payment_status,updated_at,currency,payment_id,unique_id,amount,method,is_webhook_update from payments where unique_id in ("+str(unique_ids)+") order by created_at desc ;")
				result 	= conn.execute(stmt).all()
				results = [dict(r._mapping) for r in result] if result else None	
				return results
			else : 
				stmt    = text("select name,email,mobile,payment_status,updated_at,currency,payment_id,unique_id,amount,method,is_webhook_update from payments where unique_id = ('"+str(unique_ids)+"') order by created_at desc ;")
				result = conn.execute(stmt).one_or_none()
				return  dict(result._mapping)  if result else None
		

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists