-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnike_itdepartment_collector_salesforce.py
53 lines (40 loc) · 1.57 KB
/
nike_itdepartment_collector_salesforce.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import typing
from typing import Optional
from dotenv import load_dotenv
from fastapi import FastAPI
from pydantic import BaseModel
from core.workflows.abstract_workflow import AbstractWorkflow
class SalesforceCredentials(BaseModel):
client_id: str
client_secret: str
username: str
password: str
security_token: str
class NikeITDepartmentCollectorSalesforceIn(BaseModel):
SalesforceCredentials: SalesforceCredentials
API_URL: str
class Status(BaseModel):
success: bool
message: str
class NikeITDepartmentCollectorSalesforceOut(BaseModel):
Status: Status
class NikeITDepartmentCollectorSalesforce(AbstractWorkflow):
def __init__(self) -> None:
super().__init__()
async def transform(
self, args: NikeITDepartmentCollectorSalesforceIn, callbacks: typing.Any
) -> NikeITDepartmentCollectorSalesforceOut:
results_dict = await super().transform(args=args, callbacks=callbacks)
nike_it_department_data = results_dict["NikeITDepartmentAPI"]
salesforce_status = results_dict["SalesforceAPI"]
status = Status(success=salesforce_status.success, message=salesforce_status.message)
out = NikeITDepartmentCollectorSalesforceOut(Status=status)
return out
load_dotenv()
nike_it_collector_app = FastAPI()
@nike_it_collector_app.post("/transform/")
async def transform(
args: NikeITDepartmentCollectorSalesforceIn,
) -> NikeITDepartmentCollectorSalesforceOut:
nike_it_collector = NikeITDepartmentCollectorSalesforce()
return await nike_it_collector.transform(args, callbacks=None)