Add GetAccount

This commit is contained in:
clerie 2022-01-06 18:13:48 +01:00
parent 496b915c9d
commit f62579ce90
3 changed files with 41 additions and 2 deletions

View File

@ -37,6 +37,18 @@ class OMMClient2:
else:
self.session = session
def get_account(self, id):
"""
Get account
:param id: User id
"""
r = self.session.request(message.GetAccount(id))
r.raise_on_error()
return r.account[0]
def ping(self):
"""
Is OMM still there?

View File

@ -97,10 +97,9 @@ class Response:
def maxLen(self):
return self.attrs.get("maxLen")
from .getaccount import GetAccount, GetAccountResp
from .ping import Ping, PingResp
def construct(request):
"""
Builds the XML message DOM and returns as string
@ -123,6 +122,7 @@ def construct(request):
def _response_type_by_name(name):
response_types = [
GetAccountResp,
PingResp,
]

View File

@ -0,0 +1,27 @@
#!/usr/bin/env python3
from . import Request, Response
class GetAccount(Request):
def __init__(self, id, maxRecords=None, **kwargs):
super().__init__("GetAccount", **kwargs)
self.attrs["id"] = id
if maxRecords is not None:
self.attrs["maxRecords"] = maxRecords
@property
def id(self):
return self.attrs.get("id")
@property
def maxRecords(self):
return self.attrs.get("maxRecords")
class GetAccountResp(Response):
@property
def account(self):
return self.attrs.get("account")