An iterable container of response data. Attributes: data (dict): The json-encoded content of the response. Along with the headers and status code information. Methods: validate: Check if the response from Slack was successful. get: Retrieves any key from
| 10 | |
| 11 | |
| 12 | class SlackResponse: |
| 13 | """An iterable container of response data. |
| 14 | |
| 15 | Attributes: |
| 16 | data (dict): The json-encoded content of the response. Along |
| 17 | with the headers and status code information. |
| 18 | |
| 19 | Methods: |
| 20 | validate: Check if the response from Slack was successful. |
| 21 | get: Retrieves any key from the response data. |
| 22 | next: Retrieves the next portion of results, |
| 23 | if 'next_cursor' is present. |
| 24 | |
| 25 | Example: |
| 26 | ```python |
| 27 | import os |
| 28 | import slack |
| 29 | |
| 30 | client = slack.WebClient(token=os.environ['SLACK_API_TOKEN']) |
| 31 | |
| 32 | response1 = client.auth_revoke(test='true') |
| 33 | assert not response1['revoked'] |
| 34 | |
| 35 | response2 = client.auth_test() |
| 36 | assert response2.get('ok', False) |
| 37 | |
| 38 | users = [] |
| 39 | for page in client.users_list(limit=2): |
| 40 | users = users + page['members'] |
| 41 | ``` |
| 42 | |
| 43 | Note: |
| 44 | Some responses return collections of information |
| 45 | like channel and user lists. If they do it's likely |
| 46 | that you'll only receive a portion of results. This |
| 47 | object allows you to iterate over the response which |
| 48 | makes subsequent API requests until your code hits |
| 49 | 'break' or there are no more results to be found. |
| 50 | |
| 51 | Any attributes or methods prefixed with _underscores are |
| 52 | intended to be "private" internal use only. They may be changed or |
| 53 | removed at anytime. |
| 54 | """ |
| 55 | |
| 56 | def __init__( |
| 57 | self, |
| 58 | *, |
| 59 | client, |
| 60 | http_verb: str, |
| 61 | api_url: str, |
| 62 | req_args: dict, |
| 63 | data: Union[dict, bytes], # data can be binary data |
| 64 | headers: dict, |
| 65 | status_code: int, |
| 66 | ): |
| 67 | self.http_verb = http_verb |
| 68 | self.api_url = api_url |
| 69 | self.req_args = req_args |
no outgoing calls