fix(api): use TitleCase for API field names (Id, Name, Properties)

- Nexus API returns TitleCase keys, not lowercase
- Fixed all from_api() methods to use correct case
- Armor, Healing, Plate, Attachment, Enhancer, Ring, Clothing, Pet
This commit is contained in:
LemonNexus 2026-02-09 14:05:56 +00:00
parent d9921993c8
commit 27c3e5ad6e
1 changed files with 39 additions and 39 deletions

View File

@ -88,14 +88,14 @@ class NexusArmor(NexusItem):
@classmethod
def from_api(cls, data: Dict[str, Any]) -> "NexusArmor":
"""Create from API response."""
props = data.get('properties', {})
props = data.get('Properties', {})
protection = props.get('Protection', {})
economy = props.get('Economy', {})
return cls(
id=data.get('id', 0),
name=data.get('name', 'Unknown'),
item_id=str(data.get('id', 0)),
id=data.get('Id', 0),
name=data.get('Name', 'Unknown'),
item_id=str(data.get('Id', 0)),
category='armor',
durability=int(economy.get('Durability', 2000)),
protection_impact=Decimal(str(protection.get('Impact', 0))),
@ -105,7 +105,7 @@ class NexusArmor(NexusItem):
protection_cold=Decimal(str(protection.get('Cold', 0))),
protection_acid=Decimal(str(protection.get('Acid', 0))),
protection_electric=Decimal(str(protection.get('Electric', 0))),
type=data.get('type', ''),
type=props.get('Type', ''),
)
@ -122,13 +122,13 @@ class NexusPlate(NexusItem):
@classmethod
def from_api(cls, data: Dict[str, Any]) -> "NexusPlate":
"""Create from API response."""
props = data.get('properties', {})
props = data.get('Properties', {})
protection = props.get('Protection', {})
return cls(
id=data.get('id', 0),
name=data.get('name', 'Unknown'),
item_id=str(data.get('id', 0)),
id=data.get('Id', 0),
name=data.get('Name', 'Unknown'),
item_id=str(data.get('Id', 0)),
category='plate',
protection_impact=Decimal(str(protection.get('Impact', 0))),
protection_cut=Decimal(str(protection.get('Cut', 0))),
@ -151,14 +151,14 @@ class NexusAttachment(NexusItem):
@classmethod
def from_api(cls, data: Dict[str, Any]) -> "NexusAttachment":
"""Create from API response."""
props = data.get('properties', {})
props = data.get('Properties', {})
return cls(
id=data.get('id', 0),
name=data.get('name', 'Unknown'),
item_id=str(data.get('id', 0)),
id=data.get('Id', 0),
name=data.get('Name', 'Unknown'),
item_id=str(data.get('Id', 0)),
category='attachment',
attachment_type=data.get('type', ''),
attachment_type=props.get('Type', ''),
damage_bonus=Decimal(str(props.get('DamageBonus', 0))),
range_bonus=Decimal(str(props.get('RangeBonus', 0))),
decay=Decimal(str(props.get('Decay', 0))),
@ -177,14 +177,14 @@ class NexusEnhancer(NexusItem):
@classmethod
def from_api(cls, data: Dict[str, Any]) -> "NexusEnhancer":
"""Create from API response."""
props = data.get('properties', {})
props = data.get('Properties', {})
return cls(
id=data.get('id', 0),
name=data.get('name', 'Unknown'),
item_id=str(data.get('id', 0)),
id=data.get('Id', 0),
name=data.get('Name', 'Unknown'),
item_id=str(data.get('Id', 0)),
category='enhancer',
enhancer_type=data.get('type', ''),
enhancer_type=props.get('Type', ''),
tier=int(props.get('Tier', 1)),
effect_value=Decimal(str(props.get('Effect', 0))),
break_chance=Decimal(str(props.get('BreakChance', 0.01))),
@ -204,7 +204,7 @@ class NexusHealingTool(NexusItem):
@classmethod
def from_api(cls, data: Dict[str, Any]) -> "NexusHealingTool":
"""Create from API response."""
props = data.get('properties', {})
props = data.get('Properties', {})
economy = props.get('Economy', {})
heal = props.get('Heal', {})
@ -213,16 +213,16 @@ class NexusHealingTool(NexusItem):
heal_per_pec = heal_amount / decay if decay > 0 else Decimal('0')
return cls(
id=data.get('id', 0),
name=data.get('name', 'Unknown'),
item_id=str(data.get('id', 0)),
id=data.get('Id', 0),
name=data.get('Name', 'Unknown'),
item_id=str(data.get('Id', 0)),
category='healing',
heal_amount=heal_amount,
decay=decay,
heal_per_pec=heal_per_pec,
type=data.get('type', 'fap'),
type=props.get('Type', 'fap'),
profession_level=int(props.get('RequiredLevel', 0)),
is_limited='(L)' in data.get('name', ''),
is_limited='(L)' in data.get('Name', ''),
)
@ -236,16 +236,16 @@ class NexusRing(NexusItem):
@classmethod
def from_api(cls, data: Dict[str, Any]) -> "NexusRing":
"""Create from API response."""
props = data.get('properties', {})
props = data.get('Properties', {})
return cls(
id=data.get('id', 0),
name=data.get('name', 'Unknown'),
item_id=str(data.get('id', 0)),
id=data.get('Id', 0),
name=data.get('Name', 'Unknown'),
item_id=str(data.get('Id', 0)),
category='ring',
effect_type=props.get('EffectType', ''),
effect_value=Decimal(str(props.get('EffectValue', 0))),
is_limited='(L)' in data.get('name', ''),
is_limited='(L)' in data.get('Name', ''),
)
@ -259,15 +259,15 @@ class NexusClothing(NexusItem):
@classmethod
def from_api(cls, data: Dict[str, Any]) -> "NexusClothing":
"""Create from API response."""
props = data.get('properties', {})
props = data.get('Properties', {})
buffs = {k: Decimal(str(v)) for k, v in props.get('Buffs', {}).items()}
return cls(
id=data.get('id', 0),
name=data.get('name', 'Unknown'),
item_id=str(data.get('id', 0)),
id=data.get('Id', 0),
name=data.get('Name', 'Unknown'),
item_id=str(data.get('Id', 0)),
category='clothing',
slot=data.get('slot', 'body'),
slot=props.get('Slot', 'body'),
buffs=buffs,
is_cosmetic=props.get('IsCosmetic', True),
)
@ -283,12 +283,12 @@ class NexusPet(NexusItem):
@classmethod
def from_api(cls, data: Dict[str, Any]) -> "NexusPet":
"""Create from API response."""
props = data.get('properties', {})
props = data.get('Properties', {})
return cls(
id=data.get('id', 0),
name=data.get('name', 'Unknown'),
item_id=str(data.get('id', 0)),
id=data.get('Id', 0),
name=data.get('Name', 'Unknown'),
item_id=str(data.get('Id', 0)),
category='pet',
effect_type=props.get('EffectType', ''),
effect_value=Decimal(str(props.get('EffectValue', 0))),