Skip to content

Commit

Permalink
Update mcc_api.island schema to support cosmetics, fishing, MCC+, and…
Browse files Browse the repository at this point in the history
… A.N.G.L.R. Tokens
  • Loading branch information
JamesMCo committed Dec 17, 2024
1 parent ed0466e commit c6b3494
Show file tree
Hide file tree
Showing 6 changed files with 401 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![🐍 PyPI](https://img.shields.io/pypi/v/mcc-api?label=🐍%20PyPI)](https://pypi.org/project/mcc-api/)
[![👑 Targeting Event API v1.6.0](https://img.shields.io/badge/👑_Targeting_Event_API-v1.6.0-red)](https://github.com/Noxcrew/mcchampionship-api/releases/tag/v1.6.0)
[![🏝️ Targeting Island API v24.12.04](https://img.shields.io/badge/🏝️_Targeting_Island_API-v24.12.04-aqua)](https://github.com/Noxcrew/mccisland-api/releases/tag/v24.12.04)
[![🏝️ Targeting Island API v24.12.17](https://img.shields.io/badge/🏝️_Targeting_Island_API-v24.12.17-aqua)](https://github.com/Noxcrew/mccisland-api/releases/tag/v24.12.17)

A helper library for the [MC Championship](https://mcchampionship.com) APIs
([Event](https://github.com/Noxcrew/mcchampionship-api), inspired by [derNiklaas's](https://github.com/derNiklaas)
Expand Down
6 changes: 3 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ python_mcc_api
.. image:: https://img.shields.io/badge/👑_Targeting_Event_API-v1.6.0-red
:alt: 👑 Targeting Event API v1.6.0
:target: https://github.com/Noxcrew/mcchampionship-api/releases/tag/v1.6.0
.. image:: https://img.shields.io/badge/🏝️_Targeting_Island_API-v24.12.04-aqua
:alt: 🏝️ Targeting Island API v24.12.04
:target: https://github.com/Noxcrew/mccisland-api/releases/tag/v24.12.04
.. image:: https://img.shields.io/badge/🏝️_Targeting_Island_API-v24.12.17-aqua
:alt: 🏝️ Targeting Island API v24.12.17
:target: https://github.com/Noxcrew/mccisland-api/releases/tag/v24.12.17

A helper library for the `MC Championship <https://mcchampionship.com>`_ APIs
(`Event <https://github.com/Noxcrew/mcchampionship-api>`_, inspired by `derNiklaas's <https://github.com/derNiklaas>`_
Expand Down
2 changes: 1 addition & 1 deletion mcc_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"__version__"
]

__version__ = "1.1.8"
__version__ = "1.2.0"
__user_agent: t.Final[str] = f"python_mcc_api/{__version__} (https://github.com/JamesMCo/python_mcc_api)"

# update version of package
Expand Down
126 changes: 125 additions & 1 deletion mcc_api/island/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,102 @@


__all__ = [
"game_enum", "rank_enum", "rotation_enum", "server_category_enum", "trophy_category_enum"
"cosmetic_category_enum",
"fish_catch_time_enum",
"fish_weight_enum",
"game_enum",
"rank_enum",
"rarity_enum",
"rotation_enum",
"server_category_enum",
"trophy_category_enum"
]

cosmetic_category_enum = GraphQLEnumType(
name="CosmeticCategory",
description="Different categories of cosmetics.",
values={
"ACCESSORY": GraphQLEnumValue(
value="ACCESSORY",
description="Accessories."
),
"AURA": GraphQLEnumValue(
value="AURA",
description="Auras."
),
"CLOAK": GraphQLEnumValue(
value="CLOAK",
description="Cloaks."
),
"HAIR": GraphQLEnumValue(
value="HAIR",
description="Hair."
),
"HAT": GraphQLEnumValue(
value="HAT",
description="Hats."
),
"ROD": GraphQLEnumValue(
value="ROD",
description="Fishing rods."
),
"TRAIL": GraphQLEnumValue(
value="TRAIL",
description="Trails."
)
}
)

fish_catch_time_enum = GraphQLEnumType(
name="FishCatchTime",
description="The time a fish can be caught in.",
values={
"ALWAYS": GraphQLEnumValue(
value="ALWAYS",
description="The fish can always be caught."
),
"DAY": GraphQLEnumValue(
value="DAY",
description="The fish can only be caught during daytime."
),
"NIGHT": GraphQLEnumValue(
value="NIGHT",
description="The fish can only be caught during nighttime."
)
}
)

fish_weight_enum = GraphQLEnumType(
name="FishWeight",
description="The weight of a fish.\n\n"
"Note that some weights are not used for crabs, or are only used for crabs.",
values={
"AVERAGE": GraphQLEnumValue(
value="AVERAGE",
description="Average."
),
"COLOSSAL": GraphQLEnumValue(
value="COLOSSAL",
description="Colossal.\n\n"
"This weight is only used for crabs."
),
"GARGANTUAN": GraphQLEnumValue(
value="GARGANTUAN",
description="Gargantuan.\n\n"
"This weight is not used for crabs."
),
"LARGE": GraphQLEnumValue(
value="LARGE",
description="Large."
),
"MASSIVE": GraphQLEnumValue(
value="MASSIVE",
description="Massive.\n\n"
"This weight is not used for crabs."
)
}
)

game_enum = GraphQLEnumType(
name="Game",
description="A game.",
Expand Down Expand Up @@ -75,6 +168,37 @@
}
)

rarity_enum = GraphQLEnumType(
name="Rarity",
description="Different tiers of rarity.",
values={
"COMMON": GraphQLEnumValue(
value="COMMON",
description="Common."
),
"EPIC": GraphQLEnumValue(
value="EPIC",
description="Epic."
),
"LEGENDARY": GraphQLEnumValue(
value="LEGENDARY",
description="Legendary."
),
"MYTHIC": GraphQLEnumValue(
value="MYTHIC",
description="Mythic."
),
"RARE": GraphQLEnumValue(
value="RARE",
description="Rare."
),
"UNCOMMON": GraphQLEnumValue(
value="UNCOMMON",
description="Uncommon."
)
}
)

rotation_enum = GraphQLEnumType(
name="Rotation",
description="A rotation period.\n\n"
Expand Down
30 changes: 28 additions & 2 deletions mcc_api/island/scalars.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,41 @@
from datetime import datetime
from datetime import date, datetime
from graphql import GraphQLScalarType, ValueNode
from graphql.utilities import value_from_ast_untyped
from uuid import UUID
import typing as t


__all__ = [
"datetime_scalar", "uuid_scalar"
"date_scalar", "datetime_scalar", "uuid_scalar"
]


# Date scalar based on datetime example in gql library documentation
# https://gql.readthedocs.io/en/latest/usage/custom_scalars_and_enums.html

def date_serialize(value: date) -> str:
return value.isoformat()


def date_parse_value(value: str) -> date:
return date.fromisoformat(value)


def date_parse_literal(value_node: ValueNode, variables: t.Optional[dict[str, t.Any]] = None) -> date:
ast_value = value_from_ast_untyped(value_node, variables)
return date_parse_value(ast_value)


date_scalar = GraphQLScalarType(
name="Date",
description="An RFC-3339 compliant Full Date Scalar",
specified_by_url="https://tools.ietf.org/html/rfc3339",
serialize=date_serialize,
parse_value=date_parse_value,
parse_literal=date_parse_literal
)


# Datetime scalar from example in gql library documentation
# https://gql.readthedocs.io/en/latest/usage/custom_scalars_and_enums.html

Expand Down
Loading

0 comments on commit c6b3494

Please sign in to comment.