Skip to content

Commit

Permalink
fix: add support for language_code on applicable methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kmaphoenix committed Aug 23, 2024
1 parent 80c7a5b commit 794067c
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/dfcx_scrapi/core/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ def train_flow(self, flow_id: str) -> str:
return response

@scrapi_base.api_call_counter_decorator
def list_flows(self, agent_id: str = None) -> List[types.Flow]:
def list_flows(
self,
agent_id: str = None,
language_code: str = "en") -> List[types.Flow]:
"""Get a List of all Flows in the current Agent.
Args:
Expand All @@ -209,6 +212,7 @@ def list_flows(self, agent_id: str = None) -> List[types.Flow]:

request = types.flow.ListFlowsRequest()
request.parent = agent_id
request.language_code = language_code

client_options = self._set_region(agent_id)
client = services.flows.FlowsClient(
Expand All @@ -223,7 +227,7 @@ def list_flows(self, agent_id: str = None) -> List[types.Flow]:
return flows

def get_flow_by_display_name(
self, display_name: str, agent_id: str
self, display_name: str, agent_id: str, language_code: str = "en"
) -> types.Flow:
"""Get a single CX Flow object based on its display name.
Expand All @@ -245,12 +249,12 @@ def get_flow_by_display_name(
f"does not exist in the specified agent."
)

flow = self.get_flow(flow_id=flow_id)
flow = self.get_flow(flow_id=flow_id, language_code=language_code)

return flow

@scrapi_base.api_call_counter_decorator
def get_flow(self, flow_id: str) -> types.Flow:
def get_flow(self, flow_id: str, language_code: str = "en") -> types.Flow:
"""Get a single CX Flow object.
Args:
Expand All @@ -259,12 +263,15 @@ def get_flow(self, flow_id: str) -> types.Flow:
Returns:
A single CX Flow object
"""
request = types.flow.GetFlowRequest()
request.name = flow_id
request.language_code = language_code

client_options = self._set_region(flow_id)
client = services.flows.FlowsClient(
credentials=self.creds, client_options=client_options
)
response = client.get_flow(name=flow_id)
response = client.get_flow(request)

return response

Expand Down

0 comments on commit 794067c

Please sign in to comment.