"""
Wrap all calls to the divera api as defined by https://api.divera247.com/?urls.primaryName=api%2Fv2%2Fevent
"""
from divera.api import endpointwrappers as _epw
from divera.api.v2 import models as _models
[docs]
class GetAll(_models.GetAll):
path = '/api/v2/events'
[docs]
class Get(_models.Get):
@property
def path(self):
return f'/api/v2/events/{self.object_id}'
[docs]
class Confirm(_models.Confirm):
@property
def path(self):
return f'/api/v2/events/confirm/{self.object_id}'
def __init__(
self,
object_id: [int, str],
response_id: str,
response_text: str = None,
):
super().__init__(
type_='Event',
object_id=object_id,
response_id=response_id,
response_text=response_text,
)
[docs]
class Read(_models.Read):
@property
def path(self):
return f'/api/v2/events/read/{self.object_id}'
[docs]
class ICS(_epw.FunctionalEndPoint):
method = 'GET'
headers = {
'accept': 'text/calendar',
}
path = '/api/v2/events/ics'
def __call__(
self,
base_url: str,
access_token: str,
*args, **kwargs
) -> [list, dict]:
return (
base_url.rstrip('/') + self.path + f'?accesskey={access_token}',
), {}