import json, urllib.request

class WrnexusApi:
    def __init__(self, base_url): self.base_url = base_url.rstrip('/')
    def request(self, method, path, body=None):
        data = None if body is None else json.dumps(body).encode()
        request = urllib.request.Request(self.base_url + path, data=data, method=method, headers={'content-type':'application/json'})
        with urllib.request.urlopen(request) as response: return json.load(response)
    def postWebhooksPayment(self, path, body=None): return self.request('POST', path, body)
    def getUsersCsr(self, path, body=None): return self.request('GET', path, body)
    def getUsersSsr(self, path, body=None): return self.request('GET', path, body)
    def postGraphqlExample(self, path, body=None): return self.request('POST', path, body)
    def postTypedUser(self, path, body=None): return self.request('POST', path, body)
    def postLogout(self, path, body=None): return self.request('POST', path, body)
    def getHello(self, path, body=None): return self.request('GET', path, body)
    def postLogin(self, path, body=None): return self.request('POST', path, body)
    def getEcho(self, path, body=None): return self.request('GET', path, body)
    def postEcho(self, path, body=None): return self.request('POST', path, body)
    def getMe(self, path, body=None): return self.request('GET', path, body)
