Skip to content

Commit d1c4620

Browse files
committed
finished channels api
1 parent e60a20a commit d1c4620

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

ThreadFixProApi/Networks/_utils/_channels.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,24 @@ def __init__(self, host, api_key, verify_ssl, timeout, headers, user_agent, cert
2121
the private key and the certificate) or as a tuple of both file’s path
2222
:param debug: Prints requests and responses, useful for debugging.
2323
"""
24-
super().__init__(host, api_key, verify_ssl, timeout, headers, user_agent, cert, debug)
24+
super().__init__(host, api_key, verify_ssl, timeout, headers, user_agent, cert, debug)
25+
26+
def fetch_all_channels(self, page=1, limit=50, href=None):
27+
"""
28+
Fetches all channels one page at a time of limit
29+
:param page: The page of the channels to get (optional if you have href)
30+
:param limit: The amount of channels per page
31+
:param href: The link to the next page in the system from a previous call
32+
"""
33+
# If href (calling another page gives an href tag for next page in line)
34+
if href:
35+
return super().request('GET', '/api/network' + href)
36+
# First call
37+
return super().request('GET', f'/api/network/channels?_page={page}&_limit={limit}')
38+
39+
def find_channel_by_id(self, channel_id):
40+
"""
41+
Gets a channel by its id
42+
:param channel_id: ID of the channel to get
43+
"""
44+
return super().request('GET', f'/api/network/channels/{channel_id}')

0 commit comments

Comments
 (0)