MCPcopy
hub / github.com/spaceandtimefdn/SxT-Python-SDK / SXTBaseAPI

Class SXTBaseAPI

src/spaceandtime/sxtbaseapi.py:12–931  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10
11
12class SXTBaseAPI():
13 __au__:str = None
14 access_token = ''
15 refresh_token = ''
16 access_token_expires = 0
17 refresh_token_expires = 0
18 logger: logging.Logger
19 network_calls_enabled:bool = True
20 standard_headers = {
21 "accept": "application/json",
22 "content-type": "application/json"
23 }
24 versions = {}
25 APICALLTYPE = SXTApiCallTypes
26
27
28 def __init__(self, access_token:str = '', logger:logging.Logger = None) -> None:
29 if logger:
30 self.logger = logger
31 else:
32 self.logger = logging.getLogger()
33 self.logger.setLevel(logging.INFO)
34 if len(self.logger.handlers) == 0:
35 self.logger.addHandler( logging.StreamHandler() )
36
37 apiversionfile = Path(Path(__file__).resolve().parent / 'apiversions.json')
38 self.access_token = access_token
39 with open(apiversionfile,'r') as fh:
40 content = fh.read()
41 self.versions = json.loads(content)
42
43 def __settokens__(self, accessToken:str, accessTokenExpires:int, refreshToken:str='', refreshTokenExpires:int=0):
44 self.access_token = accessToken
45 self.refresh_token = refreshToken
46 self.access_token_expires = accessTokenExpires
47 self.refresh_token_expires = refreshTokenExpires
48
49 @property
50 def api_url(self):
51 return self.__au__ if self.__au__ else 'https://api.makeinfinite.dev' # default
52 @api_url.setter
53 def api_url(self, value):
54 self.__au__ = value
55
56 def prep_biscuits(self, biscuits=[]) -> list:
57 """--------------------
58 Accepts biscuits in various data types, and returns a list of biscuit_tokens as strings (list of str).
59 Primary use-case is class-internal.
60
61 Args:
62 biscuits (list | str | SXTBiscuit): biscuit_tokens as a list, str, or SXTBiscuit type.
63
64 Returns:
65 list: biscuit_tokens as a list.
66
67 Examples:
68 >>> sxt = SpaceAndTime()
69 >>> biscuits = sxt.user.base_api.prep_biscuits(['a',['b','c'], 'd'])

Callers 6

__init__Method · 0.90
test_sxtbaseapi.pyFile · 0.90
test_authenticateFunction · 0.90
test_call_apiFunction · 0.90
test_logoutFunction · 0.90

Calls

no outgoing calls

Tested by 4

test_authenticateFunction · 0.72
test_call_apiFunction · 0.72
test_logoutFunction · 0.72