Example #1
0
    def fetch_pvp_info(guardian, platform):

        guardian, platform = PyGuardian.prechecks(guardian, platform)
        account = Requester(guardian, platform)
        char_data = account.fetch_character_info()
        historical_stats = account.fetch_historical_stats()
        return json_funcs.fetch_kd(historical_stats, char_data)
Example #2
0
    def fetch_vault(guardian, platform, sort=None):

        guardian, platform = PyGuardian.prechecks(guardian, platform)
        account = Requester(guardian, platform)
        vault_data = account.fetch_vault_info()
        vault_hashes = json_funcs.fetch_vault_hashes(vault_data)
        vault_items = InventoryManifest(vault_hashes)
        return vault_items.get_full_item_details(sort_by=sort)
Example #3
0
    def get_guardian_objects(guardian, platform):

        guardian, platform = PyGuardian.prechecks(guardian, platform)
        account = Requester(guardian, platform)
        char_data = account.fetch_character_info()
        equip_data = account.fetch_character_equip_info()
        equipment_details = json_funcs.fetch_character_eq_details(
            equip_data, char_data)
        char_data = json_funcs.fetch_extended_char_info(
            char_data, equipment_details, guardian)
        return json_funcs.get_data_guardian_objects(char_data,
                                                    equipment_details)
Example #4
0
    def fetch_eq(guardian, platform):

        try:
            guardian, platform = PyGuardian.prechecks(guardian, platform)
            account = Requester(guardian, platform)
            char_data = account.fetch_character_info()
            equip_data = account.fetch_character_equip_info()
            weapon_hashes = json_funcs.fetch_eq_hashes(equip_data, char_data)
            weapon_data = InventoryManifest(weapon_hashes)
            return weapon_data.get_full_item_details()

        except (APIException, APIUnavailableException) as ape:
            logger = PyGuardianLogger()
            logger.error(ape)
        finally:
            logging.shutdown()
Example #5
0
    def _default_fetch_json(self, arbitrary_request):
        if not self.PLAYER:
            print("Gamertag not set!")
            return
        if not self.PLATFORM:
            print("Platform not set!")
            return

        requester = Requester(self.PLAYER, self.PLATFORM)
        request_dict = {
            "character": requester.fetch_character_info,
            "vault": requester.fetch_vault_info,
            "eq": requester.fetch_character_equip_info,
            "stats": requester.fetch_historical_stats
        }

        key = os.getenv("BUNGIE_API") if os.getenv(
            "BUNGIE_API") is not None else self.X_API_KEY

        return request_dict[arbitrary_request](_headers={"X-API-Key": key})
Example #6
0
 def setUpRequester(self):
     return Requester(self.test_gamertag, self.test_platform)
Example #7
0
    def fetch_last_time_played(guardian, platform):

        guardian, platform = PyGuardian.prechecks(guardian, platform)
        account = Requester(guardian, platform)
        char_data = account.fetch_character_info()
        return json_funcs.fetch_last_time_played(char_data)
Example #8
0
    def fetch_stats(guardian, platform):

        guardian, platform = PyGuardian.prechecks(guardian, platform)
        account = Requester(guardian, platform)
        response = account.fetch_character_info()
        return json_funcs.fetch_char_info(response)