I am having a syntax / understanding problem with creating a class in Pythion 3. What I am trying to do is create a class with only static methods that will return a dictionary of ‘elements’ that are needed to create an HTTP call for an API. Example:
class magicBox:
_baseURI = 'cgi-bin/magicBox.cgi'
@staticmethod
def getSerialNumber():
#need to return a dict with all the associated parts to build a request
url = _baseURI + '/endpoint'
req = {}
req.update({'method':'GET'})
req.update({'params':{'action':'getSerialNo'}})
req.update({'URL':url})
return req
What I am getting in VS Code is the squiggly line under _baseURI in the line beginning with url = …..
What am I missing here? The class will only ever have static methods and I want to repeat this static pattern for getting to the rest of the various endpoints and API functions. This class should only ever return dicts and it will grow as I add more endpoints and functions to it. Another section of the project will handle the final request builds.
Any ideas?
Cheers
The Frog