Skip to content

Commit 502e3a7

Browse files
Sync SDK v1.1.3 from neo repository
1 parent beef9f5 commit 502e3a7

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

‎ofspectrum/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
print(f"Remaining: {quota.remaining}/{quota.quota_limit}")
3030
"""
3131

32-
__version__ = "1.1.2"
32+
__version__ = "1.1.3"
3333
__author__ = "OfSpectrum"
3434

3535
from .client import OfSpectrum, AsyncOfSpectrum

‎ofspectrum/models/quota.py‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,23 @@ def is_exceeded(self) -> bool:
3535

3636
@classmethod
3737
def from_dict(cls, data: dict) -> "Quota":
38-
"""Create Quota from API response dict"""
38+
"""Create Quota from API response dict.
39+
40+
Handles both snake_case (from /quotas/all) and camelCase (from /quota) formats.
41+
"""
42+
# Handle both snake_case and camelCase field names
43+
service_name = data.get("service_name") or data.get("serviceName", "")
44+
quota_type = data.get("quota_type") or data.get("quotaType", "request_limit")
45+
quota_limit = data.get("quota_limit") or data.get("quotaLimit", 0)
46+
current_usage = data.get("current_usage") or data.get("currentUsage", 0)
47+
reset_at = data.get("reset_at") or data.get("resetDate") or data.get("reset_date")
48+
3949
return cls(
40-
service_name=data.get("service_name", ""),
41-
quota_type=data.get("quota_type", "request_limit"),
42-
quota_limit=data.get("quota_limit", 0),
43-
current_usage=data.get("current_usage", 0),
44-
reset_at=data.get("reset_at"),
50+
service_name=service_name,
51+
quota_type=quota_type,
52+
quota_limit=int(quota_limit) if quota_limit else 0,
53+
current_usage=int(current_usage) if current_usage else 0,
54+
reset_at=reset_at,
4555
)
4656

4757
def __str__(self) -> str:

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "ofspectrum"
7-
version = "1.1.2"
7+
version = "1.1.3"
88
description = "OfSpectrum Audio Watermarking SDK"
99
readme = "README.md"
1010
license = {text = "MIT"}

0 commit comments

Comments
 (0)