Ejemplo n.º 1
0
def open_information(target_id: int) -> ESIResponse:
    api_v1: App = get_api()
    client: EsiClient = get_esi_client()

    resp = client.request(api_v1.op['post_ui_openwindow_information'](target_id=target_id))
    if resp.status == 204:
        return ESIResponse(get_expire_time(resp), resp.status, None)
    return make_error_response(resp)
Ejemplo n.º 2
0
def open_information(target_id: int) -> ESIResponse:
    """
    Tries to open an ingame information window for the given id.
    :param target_id: id to open ingame information window for
    :return: ESIResponse
    :raises APIException if there is something wrong with tokens
    """
    token: Optional[SSOToken] = current_user.get_a_sso_token_with_scopes(esi_scopes.open_ui_window)
    if token is None:
        return ESIResponse(datetime.datetime.utcnow(), 403, f"No token with the required scopes:"
                                                            f" {''.join(esi_scopes.open_ui_window)} exists.")
    api_v1: App = get_api()
    client: EsiClient = get_esi_client(token)

    resp = client.request(api_v1.op['post_ui_openwindow_information'](target_id=target_id))
    if resp.status == 204:
        return ESIResponse(get_expire_time(resp), resp.status, None)
    return make_error_response(resp)
Ejemplo n.º 3
0
    def set_wing_name(self, wing_id: int, name: str) -> ESIResponse:
        # type: (int, str) -> ESIResponse
        data = {'name': name}
        response = self.__client.request(
            self.__api.op['put_fleets_fleet_id_wings_wing_id'](
                fleet_id=self.__fleetID, wing_id=wing_id, naming=data))

        if response.status == 204:
            return ESIResponse(get_expire_time(response), response.status,
                               None)

        return make_error_response(response)
Ejemplo n.º 4
0
    def set_squad_name(self, squad_id: int, name: str) -> ESIResponse:
        response = self.__client.request(
            self.__api.op['put_fleets_fleet_id_squads_squad_id'](
                fleet_id=self.__fleetID,
                squad_id=squad_id,
                naming={
                    'name': name
                }))

        if response.status == 204:
            return ESIResponse(get_expire_time(response), response.status,
                               None)
        return make_error_response(response)
Ejemplo n.º 5
0
    def set_fleet_settings(self, is_free_move: bool, motd: str) -> ESIResponse:
        settings = FleetSettings(is_free_move, motd)
        logger.info(
            f"Changing Fleetsetting to for fleet={self.__fleetID} to {settings.get_esi_data()}"
        )
        request = self.__api.op['put_fleets_fleet_id'](
            fleet_id=self.__fleetID, new_settings=settings.get_esi_data())
        response = self.__client.request(request)
        if response.status == 204:
            logger.info("Got 204 back")
            return ESIResponse(get_expire_time(response), response.status,
                               None)

        return make_error_response(response)
Ejemplo n.º 6
0
def open_mail(token: SSOToken,
              recipients: Sequence[int],
              body: str,
              subject: str,
              to_corp_or_alliance_id: int = None,
              to_mailing_list_id: int = None) -> ESIResponse:
    """
    {
        "body": "string",
        "recipients": [
            0 # min 1 item
        ],
        "subject": "string",
        "to_corp_or_alliance_id": 0, # optional
        "to_mailing_list_id": 0 # optional
        # max 1 of the 2 optimal values
    }
    """

    payload: Dict[str, Any] = {}
    if to_corp_or_alliance_id is not None and to_mailing_list_id is not None:
        raise ValueError(
            "Only to_mailing_list_id or to_corp_or_alliance_id can have a value, not both!"
        )

    payload['body'] = body
    payload['subject'] = subject
    if to_mailing_list_id is not None:
        payload['to_mailing_list_id'] = to_mailing_list_id

    if to_corp_or_alliance_id is not None:
        payload['to_corp_or_alliance_id'] = to_corp_or_alliance_id

    payload['recipients'] = []

    for charID in recipients:
        payload['recipients'].append(charID)

    if len(payload['recipients']) <= 0:
        payload['recipients'] = [0]

    client = get_esi_client(token, False)
    api: App = get_api()
    response = client.request(
        api.op['post_ui_openwindow_newmail'](new_mail=payload))
    if response.status == 204:
        return ESIResponse(get_expire_time(response), response.status, None)

    return make_error_response(response)
Ejemplo n.º 7
0
    def invite(self, character_id: int, role: str, squad_id: int,
               wing_id: int) -> ESIResponse:
        """
        'fleet_commander', 'wing_commander', 'squad_commander', 'squad_member'
        """
        invite: Dict[str, Any] = {'character_id': character_id, 'role': role}
        if squad_id is not None:
            invite['squad_id'] = squad_id
        if wing_id is not None:
            invite['wing_id'] = wing_id
        response = self.__client.request(
            self.__api.op['post_fleets_fleet_id_members'](
                fleet_id=self.__fleetID, invitation=invite))

        if response.status == 204:
            return ESIResponse(get_expire_time(response), response.status,
                               None)
        return make_error_response(response)