How to use the cassiopeia.type.dto function in cassiopeia

To help you get started, we’ve selected a few cassiopeia examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github meraki-analytics / cassiopeia / cassiopeia / type / dto / status.py View on Github external
def _sa_bind_shard_status():
    global ShardStatus

    @cassiopeia.type.core.common.inheritdocs
    class ShardStatus(ShardStatus, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "ShardStatus"
        hostname = sqlalchemy.Column(sqlalchemy.String(50))
        locales = sqlalchemy.Column(cassiopeia.type.dto.common.JSONEncoded)
        name = sqlalchemy.Column(sqlalchemy.String(30))
        region_tag = sqlalchemy.Column(sqlalchemy.String(30))
        services = sqlalchemy.orm.relationship("cassiopeia.type.dto.status.Service", cascade="all, delete-orphan", passive_deletes=True)
        slug = sqlalchemy.Column(sqlalchemy.String(30))
        _id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
github meraki-analytics / cassiopeia / cassiopeia / type / core / tournament.py View on Github external
def _sa_rebind_all():
    TournamentCode.dto_type = cassiopeia.type.dto.tournament.TournamentCode
    LobbyEvent.dto_type = cassiopeia.type.dto.tournament.LobbyEvent
github meraki-analytics / kernel / merakikernel / integrations / cassiopeia / statusbindings.py View on Github external
def get_shards():
    return [cassiopeia.type.dto.status.Shard(shard) for shard in merakikernel.riotapi.statusapi.shards()]
github meraki-analytics / cassiopeia / cassiopeia / dto / teamapi.py View on Github external
Returns:
        dict>: the requested summoners' teams
    """
    # Can only have 10 summoners max if it's a list
    if isinstance(summoner_ids, list) and len(summoner_ids) > 10:
        raise ValueError("Can only get up to 10 summoners' teams at once.")

    id_string = ",".join(str(x) for x in summoner_ids) if isinstance(summoner_ids, list) else str(summoner_ids)

    # Get JSON response
    request = "{version}/team/by-summoner/{ids}".format(version=cassiopeia.dto.requests.api_versions["team"], ids=id_string)
    response = cassiopeia.dto.requests.get(request)

    # Convert response to Dto type
    for id_, teams in response.items():
        response[id_] = [cassiopeia.type.dto.team.Team(team) for team in teams]

    return response
github meraki-analytics / cassiopeia / cassiopeia / type / core / matchlist.py View on Github external
import datetime

import cassiopeia.riotapi
import cassiopeia.type.core.common
import cassiopeia.type.dto.matchlist


@cassiopeia.type.core.common.inheritdocs
class MatchReference(cassiopeia.type.core.common.CassiopeiaObject):
    dto_type = cassiopeia.type.dto.matchlist.MatchReference

    def __str__(self):
        return "Match {id} Reference".format(id=self.id)

    def __eq__(self, other):
        return self.id == other.id

    def __ne__(self, other):
        return self.id != other.id

    def __hash__(self):
        return hash(self.id)

    @cassiopeia.type.core.common.immutablemethod
    def match(self, include_timeline=True):
        """
github meraki-analytics / kernel / merakikernel / integrations / cassiopeia / featuredgamesbindings.py View on Github external
def get_featured_games():
    region = cassiopeia.dto.requests.region
    return cassiopeia.type.dto.featuredgames.FeaturedGames(merakikernel.riotapi.featuredgamesapi.featured_games(region))
github meraki-analytics / cassiopeia / cassiopeia / type / api / store.py View on Github external
import cassiopeia.type.dto.matchlist
    import cassiopeia.type.dto.staticdata
    import cassiopeia.type.dto.stats
    import cassiopeia.type.dto.status
    import cassiopeia.type.dto.summoner
    import cassiopeia.type.dto.team
    import cassiopeia.type.dto.tournament
    cassiopeia.type.dto.champion._sa_bind_all()
    cassiopeia.type.dto.championmastery._sa_bind_all()
    cassiopeia.type.dto.currentgame._sa_bind_all()
    cassiopeia.type.dto.featuredgames._sa_bind_all()
    cassiopeia.type.dto.game._sa_bind_all()
    cassiopeia.type.dto.league._sa_bind_all()
    cassiopeia.type.dto.match._sa_bind_all()
    cassiopeia.type.dto.matchlist._sa_bind_all()
    cassiopeia.type.dto.staticdata._sa_bind_all()
    cassiopeia.type.dto.stats._sa_bind_all()
    cassiopeia.type.dto.status._sa_bind_all()
    cassiopeia.type.dto.summoner._sa_bind_all()
    cassiopeia.type.dto.team._sa_bind_all()
    cassiopeia.type.dto.tournament._sa_bind_all()

    import cassiopeia.type.core.champion
    import cassiopeia.type.core.championmastery
    import cassiopeia.type.core.currentgame
    import cassiopeia.type.core.featuredgames
    import cassiopeia.type.core.game
    import cassiopeia.type.core.league
    import cassiopeia.type.core.match
    import cassiopeia.type.core.matchlist
    import cassiopeia.type.core.staticdata
    import cassiopeia.type.core.stats
github meraki-analytics / cassiopeia / cassiopeia / type / core / staticdata.py View on Github external
    @property
    def percent_time_dead_per_level(self):
        """
        Returns:
            float: percent time dead modification per level
        """
        return abs(self.data.rPercentTimeDeadModPerLevel)


################
# Map Endpoint #
################
@cassiopeia.type.core.common.inheritdocs
class MapDetails(cassiopeia.type.core.common.CassiopeiaObject):
    dto_type = cassiopeia.type.dto.staticdata.MapDetails

    def __str__(self):
        return self.data.name

    def __eq__(self, other):
        return self.data.mapId == other.data.mapId

    def __ne__(self, other):
        return self.data.mapId != other.data.mapId

    def __hash__(self):
        return hash(self.data.mapId)

    @cassiopeia.type.core.common.lazyproperty
    def image(self):
        """
github meraki-analytics / cassiopeia / cassiopeia / dto / currentgameapi.py View on Github external
def get_current_game(summoner_id):
    """
    https://developer.riotgames.com/api/methods#!/976/3336

    Args:
        summoner_id (int): the ID of the summoner to find an active game for

    Returns:
        CurrentGameInfo: the summoner's current game (or None if they aren't in one)
    """
    region = cassiopeia.type.core.common.Region(cassiopeia.dto.requests.region)
    platform = cassiopeia.type.core.common.Platform[region.name]
    request = "https://{server}.api.pvp.net/observer-mode/rest/consumer/getSpectatorGameInfo/{platform}/{summoner_id}".format(server=cassiopeia.dto.requests.region, platform=platform.value, summoner_id=summoner_id)
    try:
        return cassiopeia.type.dto.currentgame.CurrentGameInfo(cassiopeia.dto.requests.get(request, include_base=False))
    except cassiopeia.type.api.exception.APIError as e:
        if e.error_code == 404:
            return None
        raise e