Skip to content

Commit ae0259c

Browse files
committed
fix: resolve test failures in calendar and configuration models
1 parent 39e871d commit ae0259c

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

nylas/models/events.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,15 @@ def _decode_conferencing(conferencing: dict) -> Union[Conferencing, None]:
243243

244244
if "autocreate" in conferencing:
245245
return Autocreate.from_dict(conferencing)
246+
247+
# Handle case where provider exists but details/autocreate doesn't
248+
if "provider" in conferencing:
249+
# Create a Details object with empty details
250+
details_dict = {
251+
"provider": conferencing["provider"],
252+
"details": conferencing.get("conf_settings", {}) if "conf_settings" in conferencing else {}
253+
}
254+
return Details.from_dict(details_dict)
246255

247256
raise ValueError(f"Invalid conferencing object, unknown type found: {conferencing}")
248257

nylas/models/scheduler.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from dataclasses import dataclass
2-
from typing import Dict, Optional, List
1+
from dataclasses import dataclass, field
2+
from typing import Dict, Optional, List, Any, Literal, Union
33

4-
from dataclasses_json import dataclass_json
5-
from typing_extensions import TypedDict, NotRequired, Literal
6-
from nylas.models.events import Conferencing
4+
from dataclasses_json import dataclass_json, config
5+
from typing_extensions import TypedDict, NotRequired
6+
from nylas.models.events import Conferencing, _decode_conferencing
77
from nylas.models.availability import AvailabilityRules, OpenHours
88

99
BookingType = Literal["booking", "organizer-confirmation"]
@@ -161,7 +161,9 @@ class EventBooking:
161161
location: Optional[str] = None
162162
timezone: Optional[str] = None
163163
booking_type: Optional[BookingType] = None
164-
conferencing: Optional[Conferencing] = None
164+
conferencing: Optional[Conferencing] = field(
165+
default=None, metadata=config(decoder=_decode_conferencing)
166+
)
165167
disable_emails: Optional[bool] = None
166168
reminders: Optional[List[BookingReminder]] = None
167169

nylas/resources/calendars.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,11 @@ def get_availability(
177177
Response: The availability response from the API.
178178
"""
179179
json_response, headers = self._http_client._execute(
180-
method="POST",
181-
path="/v3/calendars/availability",
182-
request_body=request_body,
180+
"POST",
181+
"/v3/calendars/availability",
182+
None,
183+
None,
184+
request_body,
183185
overrides=overrides,
184186
)
185187

@@ -203,9 +205,11 @@ def get_free_busy(
203205
Response: The free/busy response from the API.
204206
"""
205207
json_response, headers = self._http_client._execute(
206-
method="POST",
207-
path=f"/v3/grants/{identifier}/calendars/free-busy",
208-
request_body=request_body,
208+
"POST",
209+
f"/v3/grants/{identifier}/calendars/free-busy",
210+
None,
211+
None,
212+
request_body,
209213
overrides=overrides,
210214
)
211215

0 commit comments

Comments
 (0)