(20241221) Zerodha Auth Ready. Users can now integrate Kite.
This commit is contained in:
@@ -75,25 +75,21 @@ REGEX_SESSION_TOKEN = r"^[a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[89ab][a-f0-9]
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
class SafaricomMPesaExpressAuth(BaseModel):
|
||||
class ZerodhaKiteAuth(BaseModel):
|
||||
|
||||
consumerKey: str = Field(
|
||||
description = "the app's consumer key given by safaricom; found in 'my apps'",
|
||||
apiKey: str = Field(
|
||||
description = (
|
||||
"the api key of your kite connect app; "
|
||||
"this remains constant throughout the life of the app"
|
||||
),
|
||||
frozen = True
|
||||
)
|
||||
|
||||
consumerSecret: str = Field(
|
||||
description = "the app's consumer secret given by safaricom; found in 'my apps'",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
businessShortCode: str = Field(
|
||||
description = "your app's business short code; found in 'my apps'",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
appPasskey: str = Field(
|
||||
description = "your app's passkey; taken from human representative",
|
||||
apiSecret: str = Field(
|
||||
description = (
|
||||
"the api secret of your kite connect app; "
|
||||
"this can change if you think the security of your app has been compromised"
|
||||
),
|
||||
frozen = True
|
||||
)
|
||||
|
||||
@@ -109,7 +105,7 @@ class SafaricomMPesaExpressAuth(BaseModel):
|
||||
# ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class PGAuthRequestHeaders(BaseModel):
|
||||
class TradingAuthRequestHeaders(BaseModel):
|
||||
|
||||
sessionToken: str = Field(
|
||||
description = "the session token of the user who is requesting the service",
|
||||
@@ -133,10 +129,10 @@ class PGAuthRequestHeaders(BaseModel):
|
||||
# ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class PGAuthRequestData(BaseModel):
|
||||
class TradingAuthRequestData(BaseModel):
|
||||
|
||||
client: Literal["safaricomMPesaExpress"] = Field(alias = "client")
|
||||
auth: Union[SafaricomMPesaExpressAuth]
|
||||
client: Literal["zerodhaKite"] = Field(alias = "client")
|
||||
auth: Union[ZerodhaKiteAuth]
|
||||
|
||||
# ┏┓ ┏•
|
||||
# ┃ ┏┓┏┓╋┓┏┓
|
||||
@@ -155,7 +151,7 @@ class PGAuthRequestData(BaseModel):
|
||||
client = values.client
|
||||
auth = values.auth
|
||||
harmony_map = {
|
||||
"safaricomMPesaExpress": SafaricomMPesaExpressAuth
|
||||
"zerodhaKite": ZerodhaKiteAuth
|
||||
}
|
||||
if not isinstance(auth, harmony_map[client]):
|
||||
raise ValueError(f"incorrect 'auth' for selected client '{client}'")
|
||||
|
||||
@@ -95,7 +95,11 @@ class CoreAuthTokenModel(BaseModel):
|
||||
default_factory = lambda: ObjectId()
|
||||
)
|
||||
|
||||
serviceType: Literal["software", "email", "sms", "chat", "paymentGateway"] = Field(
|
||||
serviceType: Literal[
|
||||
"email", "sms", "chat", # ............. Message
|
||||
"paymentGateway", "stockTrading", # ... Finstitutions
|
||||
"software", # ......................... God knows
|
||||
] = Field(
|
||||
description = "the kind of service this message was sent/received from",
|
||||
frozen = True
|
||||
)
|
||||
@@ -105,6 +109,7 @@ class CoreAuthTokenModel(BaseModel):
|
||||
"telegram", "whatsapp", # .................. Chat Clients
|
||||
"nimbusSmsIndia", "savvyBulkSmsKenya", # ... SMS Clients
|
||||
"razorpay", "safaricomMPesaExpress", # ..... Payment Gateways
|
||||
"zerodhaKite", # ........................... Stock Brokers
|
||||
"theCaOfficeAi" # .......................... Software
|
||||
] = Field(
|
||||
description = "the third-part client that was used",
|
||||
|
||||
Reference in New Issue
Block a user