Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add support for language_code on applicable methods #222

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading