Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/generate_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def main() -> int:
"--field-constraints",
"--use-field-description",
"--capitalise-enum-members",
"--use-subclass-enum",
"--use-default-kwarg",
"--collapse-root-models",
"--use-union-operator",
Expand Down
23 changes: 21 additions & 2 deletions scripts/generate_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,20 +394,39 @@ def generate_resource_class(
" default for optional string args, and the API rejects empty query",
" values (e.g. ``platform=``) with a 400. Filtering here keeps both direct",
" SDK callers and MCP tool callers safe.",
"",
" Enum members are unwrapped to their value: httpx serializes params",
' via str(), which yields "ClassName.MEMBER" for Enum members, so',
" e.g. ``status=PostStatus.FAILED`` would otherwise reach the API as",
" ``status=PostStatus.FAILED`` instead of ``status=failed``.",
' """',
" from enum import Enum",
" def to_camel(s: str) -> str:",
' parts = s.split("_")',
' return parts[0] + "".join(p.title() for p in parts[1:])',
' return {to_camel(k): v for k, v in kwargs.items() if v is not None and v != ""}',
" result: dict[str, Any] = {}",
" for k, v in kwargs.items():",
" if isinstance(v, Enum):",
" v = v.value",
' if v is None or v == "":',
" continue",
" result[to_camel(k)] = v",
" return result",
"",
" def _build_payload(self, **kwargs: Any) -> dict[str, Any]:",
' """Build request payload, filtering None values."""',
' """Build request payload, filtering None values. Enum members are',
' unwrapped to their value so JSON bodies carry e.g. "failed" rather',
" than a raw Enum member (plain Enum members are not JSON-serializable).",
' """',
" from datetime import datetime",
" from enum import Enum",
" def to_camel(s: str) -> str:",
' parts = s.split("_")',
' return parts[0] + "".join(p.title() for p in parts[1:])',
" result: dict[str, Any] = {}",
" for k, v in kwargs.items():",
" if isinstance(v, Enum):",
" v = v.value",
" if v is None:",
" continue",
" if isinstance(v, datetime):",
Expand Down
4 changes: 2 additions & 2 deletions src/late/client/late_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
AdCampaignsResource,
AdCreativesResource,
AdInsightsResource,
AdTargetingResource,
AdsResource,
AdTargetingResource,
AnalyticsResource,
ApiKeysResource,
BroadcastsResource,
CallsResource,
CommentAutomationsResource,
CommentsResource,
ConnectResource,
ConnectedAppsResource,
ConnectResource,
ContactsResource,
ConversionsResource,
CustomFieldsResource,
Expand Down
5 changes: 3 additions & 2 deletions src/late/mcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,9 @@ def posts_retry(post_id: str) -> str:
post = post_response.post
if not post:
return f"\u274c Post {post_id} not found"
if post.status != PostStatus.FAILED:
return f"\u26a0\ufe0f Post {post_id} is not in failed status (current: {post.status})"
status_value = post.status.value if post.status else "unknown"
if status_value != PostStatus.FAILED.value:
return f"\u26a0\ufe0f Post {post_id} is not in failed status (current: {status_value})"
except Exception as e:
return f"\u274c Could not find post {post_id}: {e}"

Expand Down
Loading
Loading