Skip to content

Commit

Permalink
fixing ui integration tutorial (#1493)
Browse files Browse the repository at this point in the history
* fixing indentations in ui integration tutorial's code
  • Loading branch information
barryyosi-panw authored Feb 12, 2024
1 parent 1fa3208 commit 9cddd87
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions docs/tutorials/tut-integration-ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ class Client(BaseClient):

self.api_key = api_key

if self.api_key:
self._headers = {'X-Funtranslations-Api-Secret': self.api_key}
if self.api_key:
self._headers = {'X-Funtranslations-Api-Secret': self.api_key}

def translate(self, text: str):
return self._http_request(method='POST', url_suffix='yoda', data={'text': text}, resp_type='json', ok_codes=(200,))
def translate(self, text: str):
return self._http_request(method='POST', url_suffix='yoda', data={'text': text}, resp_type='json', ok_codes=(200,))
```

The Client is an object that communicates with the API. We create a class called *Client*.
Expand Down Expand Up @@ -292,21 +292,21 @@ We now create a Client using the given parameters. The Client is defined.

```python
try:
client = Client(api_key=api_key, base_url=base_url, verify=verify, proxy=proxy)
client = Client(api_key=api_key, base_url=base_url, verify=verify, proxy=proxy)
```

There are two possible commands that can be passed to the *main* function in our integration.

```python
if command == 'test-module':
# This is the call made when clicking the integration Test button.
return_results(test_module(client))
if command == 'test-module':
# This is the call made when clicking the integration Test button.
return_results(test_module(client))

elif command == 'yoda-speak-translate':
return_results(translate_command(client, **args))
elif command == 'yoda-speak-translate':
return_results(translate_command(client, **args))

else:
raise NotImplementedError(f"command {command} is not implemented.")
else:
raise NotImplementedError(f"command {command} is not implemented.")
```

- ***test-module***
Expand All @@ -323,11 +323,11 @@ There is also an *else* option - this returns an error if someone tries to run a

```python
# Log exceptions and return errors
except Exception as e:
demisto.error(traceback.format_exc()) # print the traceback
return_error("\n".join(("Failed to execute {command} command.",
"Error:",
str(e))))
except Exception as e:
demisto.error(traceback.format_exc()) # print the traceback
return_error("\n".join(("Failed to execute {command} command.",
"Error:",
str(e))))
```
If any errors occur during the execution of our code, show those errors to the user and also return an error.

Expand Down

0 comments on commit 9cddd87

Please sign in to comment.