fpl/models/user.py
async def transfer(self, players_out, players_in, max_hit=60,
                       wildcard=False, free_hit=False):
        """Transfers given players out and transfers given players in.

        :param players_out: List of IDs of players who will be transferred out.
        :type players_out: list
        :param players_in: List of IDs of players who will be transferred in.
        :type players_in: list
        :param max_hit: Maximum hit that should be taken by making the
            transfer(s), defaults to 60
        :param max_hit: int, optional
        :param wildcard: Boolean for playing wildcard, defaults to False
        :param wildcard: bool, optional
        :param free_hit: Boolean for playing free hit, defaults to False
        :param free_hit: bool, optional
        :return: Returns the response given by a succesful transfer.
        :rtype: dict
        """
        if wildcard and free_hit:
            raise Exception("Can only use 1 of wildcard and free hit.")

        if not logged_in(self._session):
            raise Exception("User must be logged in.")

        if not players_out or not players_in:
            raise Exception(
                "Lists must both contain at least one player's ID.")

        if len(players_out) != len(players_in):
            raise Exception("Number of players transferred in must be same as "
                            "number transferred out.")

        if not set(players_in).isdisjoint(players_out):
            raise Exception("Player ID can't be in both lists.")

        user_team = await self.get_team()
        team_ids = [player["element"] for player in user_team]

        if not set(team_ids).isdisjoint(players_in):
            raise Exception(
                "Cannot transfer a player in who is already in the user's team.")

        if set(team_ids).isdisjoint(players_out):
            raise Exception(
                "Cannot transfer a player out who is not in the user's team.")

        players = await fetch(self._session, API_URLS["static"])
        players = players["elements"]
        player_ids = [player["id"] for player in players]

        if set(player_ids).isdisjoint(players_in):
            raise Exception("Player ID in `players_in` does not exist.")

        # Send POST requests with `confirmed` set to False; this basically
        # checks if there are any errors from FPL's side for this transfer,
        # e.g. too many players from the same team, or not enough money.
        payload = self._get_transfer_payload(
            players_out, players_in, user_team, players, wildcard, free_hit)
        headers = get_headers(
            "https://fantasy.premierleague.com/a/squad/transfers")
        post_response = await post(
            self._session, API_URLS["transfers"], json.dumps(payload), headers)

        if "non_form_errors" in post_response:
            raise Exception(post_response["non_form_errors"])

        if post_response["spent_points"] > max_hit:
            raise Exception(
                f"Point hit for transfer(s) [-{post_response['spent_points']}]"
                f" exceeds max_hit [{max_hit}].")

        # Everything is okay, so push the transfer through!
        payload["confirmed"] = True
        post_response = await post(
            self._session, API_URLS["transfers"], json.dumps(payload), headers)
        return post_response
Transfers given players out and transfers given players in.

        :param players_out: List of IDs of players who will be transferred out.
        :type players_out: list
        :param players_in: List of IDs of players who will be transferred in.
        :type players_in: list
        :param max_hit: Maximum hit that should be taken by making the
            transfer(s), defaults to 60
        :param max_hit: int, optional
        :param wildcard: Boolean for playing wildcard, defaults to False
        :param wildcard: bool, optional
        :param free_hit: Boolean for playing free hit, defaults to False
        :param free_hit: bool, optional
        :return: Returns the response given by a succesful transfer.
        :rtype: dict
        
Transfers given players out and transfers given players in.
Transfers given players out and transfers given players in .
async def transfer(self, players_out, players_in, max_hit=60,
                       wildcard=False, free_hit=False):
        if wildcard and free_hit:
            raise Exception("Can only use 1 of wildcard and free hit.")
        if not logged_in(self._session):
            raise Exception("User must be logged in.")
        if not players_out or not players_in:
            raise Exception(
                "Lists must both contain at least one player's ID.")
        if len(players_out) != len(players_in):
            raise Exception("Number of players transferred in must be same as "
                            "number transferred out.")
        if not set(players_in).isdisjoint(players_out):
            raise Exception("Player ID can't be in both lists.")
        user_team = await self.get_team()
        team_ids = [player["element"] for player in user_team]
        if not set(team_ids).isdisjoint(players_in):
            raise Exception(
                "Cannot transfer a player in who is already in the user's team.")
        if set(team_ids).isdisjoint(players_out):
            raise Exception(
                "Cannot transfer a player out who is not in the user's team.")
        players = await fetch(self._session, API_URLS["static"])
        players = players["elements"]
        player_ids = [player["id"] for player in players]
        if set(player_ids).isdisjoint(players_in):
            raise Exception("Player ID in `players_in` does not exist.")
        payload = self._get_transfer_payload(
            players_out, players_in, user_team, players, wildcard, free_hit)
        headers = get_headers(
            "https://fantasy.premierleague.com/a/squad/transfers")
        post_response = await post(
            self._session, API_URLS["transfers"], json.dumps(payload), headers)
        if "non_form_errors" in post_response:
            raise Exception(post_response["non_form_errors"])
        if post_response["spent_points"] > max_hit:
            raise Exception(
                f"Point hit for transfer(s) [-{post_response['spent_points']}]"
                f" exceeds max_hit [{max_hit}].")
        payload["confirmed"] = True
        post_response = await post(
            self._session, API_URLS["transfers"], json.dumps(payload), headers)
        return post_response
async def transfer ( self , players_out , players_in , max_hit = 60 , wildcard = False , free_hit = False ) : if wildcard and free_hit : raise Exception ( "Can only use 1 of wildcard and free hit." ) if not logged_in ( self . _session ) : raise Exception ( "User must be logged in." ) if not players_out or not players_in : raise Exception ( "Lists must both contain at least one player's ID." ) if len ( players_out ) != len ( players_in ) : raise Exception ( "Number of players transferred in must be same as " "number transferred out." ) if not set ( players_in ) . isdisjoint ( players_out ) : raise Exception ( "Player ID can't be in both lists." ) user_team = await self . get_team ( ) team_ids = [ player [ "element" ] for player in user_team ] if not set ( team_ids ) . isdisjoint ( players_in ) : raise Exception ( "Cannot transfer a player in who is already in the user's team." ) if set ( team_ids ) . isdisjoint ( players_out ) : raise Exception ( "Cannot transfer a player out who is not in the user's team." ) players = await fetch ( self . _session , API_URLS [ "static" ] ) players = players [ "elements" ] player_ids = [ player [ "id" ] for player in players ] if set ( player_ids ) . isdisjoint ( players_in ) : raise Exception ( "Player ID in `players_in` does not exist." ) payload = self . _get_transfer_payload ( players_out , players_in , user_team , players , wildcard , free_hit ) headers = get_headers ( "https://fantasy.premierleague.com/a/squad/transfers" ) post_response = await post ( self . _session , API_URLS [ "transfers" ] , json . dumps ( payload ) , headers ) if "non_form_errors" in post_response : raise Exception ( post_response [ "non_form_errors" ] ) if post_response [ "spent_points" ] > max_hit : raise Exception ( f"Point hit for transfer(s) [-{post_response['spent_points']}]" f" exceeds max_hit [{max_hit}]." ) payload [ "confirmed" ] = True post_response = await post ( self . _session , API_URLS [ "transfers" ] , json . dumps ( payload ) , headers ) return post_response
Transfers given players out and transfers given players in.
Transfers given players out and transfers given players in .
"""Transfers given players out and transfers given players in.

        :param players_out: List of IDs of players who will be transferred out.
        :type players_out: list
        :param players_in: List of IDs of players who will be transferred in.
        :type players_in: list
        :param max_hit: Maximum hit that should be taken by making the
            transfer(s), defaults to 60
        :param max_hit: int, optional
        :param wildcard: Boolean for playing wildcard, defaults to False
        :param wildcard: bool, optional
        :param free_hit: Boolean for playing free hit, defaults to False
        :param free_hit: bool, optional
        :return: Returns the response given by a succesful transfer.
        :rtype: dict
        """ # Send POST requests with `confirmed` set to False; this basically # checks if there are any errors from FPL's side for this transfer, # e.g. too many players from the same team, or not enough money. # Everything is okay, so push the transfer through!
Returns the response given by a succesful transfer.
Returns the response given by a succesful transfer .
dict
self
players_out
List of IDs of players who will be transferred out.
List of IDs of players who will be transferred out .
players_in
List of IDs of players who will be transferred in.
List of IDs of players who will be transferred in .
max_hit
None
wildcard
None
free_hit
None