File size: 4,780 Bytes
550665c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
from gcsa.conference import ConferenceSolutionCreateRequest, ConferenceSolution, EntryPoint
from .base_serializer import BaseSerializer
class EntryPointSerializer(BaseSerializer):
type_ = EntryPoint
def __init__(self, entry_point):
super().__init__(entry_point)
@staticmethod
def _to_json(entry_point):
data = {
'entryPointType': entry_point.entry_point_type,
'uri': entry_point.uri,
'label': entry_point.label,
'pin': entry_point.pin,
'accessCode': entry_point.access_code,
'meetingCode': entry_point.meeting_code,
'passcode': entry_point.passcode,
'password': entry_point.password
}
return EntryPointSerializer._remove_empty_values(data)
@staticmethod
def _to_object(json_):
return EntryPoint(
entry_point_type=json_.get('entryPointType'),
uri=json_.get('uri'),
label=json_.get('label'),
pin=json_.get('pin'),
access_code=json_.get('accessCode'),
meeting_code=json_.get('meetingCode'),
passcode=json_.get('passcode'),
password=json_.get('password')
)
class ConferenceSolutionSerializer(BaseSerializer):
type_ = ConferenceSolution
def __init__(self, conference_solution):
super().__init__(conference_solution)
@staticmethod
def _to_json(conference_solution: ConferenceSolution):
data = {
'entryPoints': [
EntryPointSerializer.to_json(ep)
for ep in conference_solution.entry_points
],
'conferenceSolution':
ConferenceSolutionSerializer._remove_empty_values(
{
'key': {
'type': conference_solution.solution_type
},
'name': conference_solution.name,
'iconUri': conference_solution.icon_uri
}
),
'conferenceId': conference_solution.conference_id,
'signature': conference_solution.signature,
'notes': conference_solution.notes,
}
return ConferenceSolutionSerializer._remove_empty_values(data)
@staticmethod
def _to_object(json_):
entry_points = [EntryPointSerializer.to_object(ep) for ep in json_.get('entryPoints', [])]
conference_solution = json_.get('conferenceSolution', {})
solution_type = conference_solution.get('key', {}).get('type')
name = conference_solution.get('name')
icon_uri = conference_solution.get('iconUri')
conference_id = json_.get('conferenceId')
signature = json_.get('signature')
notes = json_.get('notes')
return ConferenceSolution(
entry_points=entry_points,
solution_type=solution_type,
name=name,
icon_uri=icon_uri,
conference_id=conference_id,
signature=signature,
notes=notes
)
class ConferenceSolutionCreateRequestSerializer(BaseSerializer):
type_ = ConferenceSolutionCreateRequest
def __init__(self, conference_solution_create_request):
super().__init__(conference_solution_create_request)
@staticmethod
def _to_json(cscr: ConferenceSolutionCreateRequest):
data = {
'createRequest': {
'requestId': cscr.request_id,
'conferenceSolutionKey': {
'type': cscr.solution_type
}
},
'conferenceId': cscr.conference_id,
'signature': cscr.signature,
'notes': cscr.notes
}
if cscr.status is not None:
data['createRequest']['status'] = {'statusCode': cscr.status}
return ConferenceSolutionCreateRequestSerializer._remove_empty_values(data)
@staticmethod
def _to_object(json_):
create_request = json_['createRequest']
solution_type = create_request.get('conferenceSolutionKey', {}).get('type')
request_id = create_request.get('requestId')
status = create_request.get('status', {}).get('statusCode')
conference_id = json_.get('conferenceId')
signature = json_.get('signature')
notes = json_.get('notes')
return ConferenceSolutionCreateRequest(
solution_type=solution_type,
request_id=request_id,
_status=status,
conference_id=conference_id,
signature=signature,
notes=notes
)
|