コード例 #1
0
class User(object):
    """
    Class to access Bungie.net User API
    """
    def __init__(self):
        self.public_api = API()

    def get_bungie_net_user_by_id(self, uid: int):
        req = API.bungie_api + '/User/GetBungieNetUserById/' + str(uid) + '/'
        return self.public_api.call_bungie_public_api(req)

    def search_users(self, display_name: str):
        req = API.bungie_api + '/User/SearchUsers/?q=' + display_name
        return self.public_api.call_bungie_public_api(req)

    def get_membership_data_by_id(self, uid: int, membership_type: int = 254):
        req = API.bungie_api + '/User/GetMembershipsById/' + str(
            uid) + '/' + str(membership_type) + '/'
        return self.public_api.call_bungie_public_api(req)

    def get_partnerships(self, uid: int):
        req = API.bungie_api + '/User/' + str(uid) + '/Partnerships/'
        return self.public_api.call_bungie_public_api(req)
コード例 #2
0
class GroupsV2(object):
    """
    Class to access Bungie.net User API
    """
    def __init__(self):
        self.public_api = API()

    def get_group(self, group_id: int) -> str:
        req = API.bungie_api + '/GroupV2/' + str(group_id) + '/'
        return self.public_api.call_bungie_public_api(req)

    def get_group_by_name(self, group_name: str, group_type: int) -> str:
        """GroupType: 0=General, 1=Clan"""
        req = API.bungie_api + '/GroupV2/Name/' + group_name + '/' + str(
            group_type) + '/'
        return self.public_api.call_bungie_public_api(req)

    def get_members_of_group(self,
                             group_id: int,
                             current_page: int = 1) -> str:
        """GroupType: 0=General, 1=Clan"""
        req = API.bungie_api + '/GroupV2/' + str(
            group_id) + '/Members/?currentPage=' + str(current_page)
        return self.public_api.call_bungie_public_api(req)

    def get_andmins_and_founder_of_group(self, group_id: int) -> str:
        """GroupType: 0=General, 1=Clan"""
        req = API.bungie_api + '/GroupV2/' + str(
            group_id) + '/AdminsAndFounder/'
        return self.public_api.call_bungie_public_api(req)

    def get_banned_members_of_group(self, group_id: int) -> str:
        req = API.bungie_api + '/GroupV2/' + str(group_id) + '/Banned/'
        return self.public_api.call_bungie_public_api(req)

    def get_groups_for_member(self, membership_type: int, membership_id: int,
                              search_filter: int, group_type: int) -> str:
        """filter: 0 all, 1 founded, 2 non-founded"""
        req = API.bungie_api + '/GroupV2/User/' + str(
            membership_type) + '/' + str(membership_id) + '/' + str(
                search_filter) + '/' + str(group_type) + '/'
        return self.public_api.call_bungie_public_api(req)

    def get_potential_groups_for_member(self, membership_type: int,
                                        membership_id: int, search_filter: int,
                                        group_type: int) -> str:
        req = API.bungie_api + '/GroupV2/User/Potential/' + str(
            membership_type) + '/' + str(membership_id) + '/' + str(
                search_filter) + '/' + str(group_type) + '/'
        return self.public_api.call_bungie_public_api(req)
コード例 #3
0
class Destiny2(object):
    """
    Class to access Bungie.net User API
    All GET requests done
    """
    def __init__(self):
        self.public_api = API()

    def get_profile(self, uid: int, membership_type: int, membership_id: int,
                    raw_components: list):
        components = ','.join(str(e) for e in raw_components)
        req = API.bungie_api + "/Destiny2/" + str(membership_type) + "/Profile/" + str(membership_id) \
              + "/?components=" + str(components)
        return self.public_api.call_bungie_private_api_automated(uid, req)

    def get_character(self, membership_type, membership_id, character_id):
        req = API.bungie_api + "/Destiny2/" + str(
            membership_type) + "/Profile/" + str(
                membership_id) + "/Character/" + str(character_id) + "/"
        return self.public_api.call_bungie_public_api(req)

    def get_clan_weekly_reward_state(self, clan_id):
        req = API.bungie_api + "/Destiny2/Clan/" + str(
            clan_id) + "/WeeklyRewardState/"
        return self.public_api.call_bungie_public_api(req)

    def get_item(self, membership_type, membership_id, item_instance_hash):
        req = API.bungie_api + "/Destiny2/" + str(membership_type) + "/Profile/" + str(membership_id) + "/Item/" + \
              str(item_instance_hash) + "/"
        return self.public_api.call_bungie_public_api(req)

    def get_vendors(self, membership_type, membership_id, character_id):
        req = API.bungie_api + "/Destiny2/" + str(
            membership_type) + "/Profile/" + str(
                membership_id) + "/Character/" + str(
                    character_id) + "/Vendors/"
        return self.public_api.call_bungie_public_api(req)

    def get_vendor(self, membership_type, membership_id, character_id,
                   vendor_hash):
        req = API.bungie_api + "/Destiny2/" + str(
            membership_type) + "/Profile/" + str(
                membership_id) + "/Character/" + str(
                    character_id) + "/Vendors/" + str(vendor_hash) + "/"
        return self.public_api.call_bungie_public_api(req)

    def get_post_game_carnage_report(self, activity_id):
        req = API.bungie_api + "/Destiny2/Stats/PostGameCarnageReport/" + str(
            activity_id) + "/"
        return self.public_api.call_bungie_public_api(req)

    def get_clan_leaderboards(self, clan_id):
        req = API.bungie_api + "/Destiny2/Stats/Leaderboards/Clans/" + str(
            clan_id) + "/"
        return self.public_api.call_bungie_public_api(req)

    def get_clan_aggregate_stats(self, clan_id):
        req = API.bungie_api + "/Destiny2/Stats/AggregateClanStats/" + str(
            clan_id) + "/"
        return self.public_api.call_bungie_public_api(req)

    def get_leaderboards(self, membership_type, membership_id):
        req = API.bungie_api + "/Destiny2/" + str(
            membership_type) + "/Account/" + str(
                membership_id) + "/Stats/Leaderboards/"
        return self.public_api.call_bungie_public_api(req)

    def get_leaderboards_for_character(self, membership_type, membership_id,
                                       character_id):
        req = API.bungie_api + "/Destiny2/Stats/Leaderboards/" + str(membership_type) + "/" + str(membership_id) + "/" + \
              str(character_id) + "/"
        return self.public_api.call_bungie_public_api(req)

    def get_historical_stats(self, membership_type, membership_id,
                             character_id):
        req = API.bungie_api + "/Destiny2/" + str(
            membership_type) + "/Profile/" + str(
                membership_id) + "/Character/" + str(character_id) + "/Stats/"
        return self.public_api.call_bungie_public_api(req)

    def get_historical_stats_for_account(self, membership_type, membership_id):
        req = API.bungie_api + "/Destiny2/" + str(
            membership_type) + "/Account/" + str(membership_id) + "/Stats/"
        return self.public_api.call_bungie_public_api(req)

    def get_activity_history(self, membership_type, membership_id,
                             character_id):
        req = API.bungie_api + "/Destiny2/" + str(
            membership_type) + "/Account/" + str(
                membership_id) + "/Character/" + str(
                    character_id) + "/Stats/Activities/"
        return self.public_api.call_bungie_public_api(req)

    def get_unique_weapon_history(self, membership_type, membership_id,
                                  character_id):
        req = API.bungie_api + "/Destiny2/" + str(
            membership_type) + "/Account/" + str(
                membership_id) + "/Character/" + str(
                    character_id) + "/Stats/UniqueWeapons/"
        return self.public_api.call_bungie_public_api(req)

    def get_destiny_aggregate_activity_stats(self, membership_type,
                                             membership_id, character_id):
        req = API.bungie_api + "/Destiny2/" + str(
            membership_type) + "/Account/" + str(
                membership_id) + "/Character/" + str(
                    character_id) + "/Stats/AggregateActivityStats/"
        return self.public_api.call_bungie_public_api(req)

    def get_public_milestones_content(self, milestone_hash):
        req = API.bungie_api + "/Destiny2/Milestones/" + str(
            milestone_hash) + "/Content/"
        return self.public_api.call_bungie_public_api(req)

    def get_public_milestones(self, ):
        req = API.bungie_api + "/Destiny2/Milestones/"
        return self.public_api.call_bungie_public_api(req)

    # Milestone Helper
    @staticmethod
    def milestone_types(this_type: int) -> str:
        """
        Returns the correct English Language Milestone Type
        :param this_type: The milestone type from the milestone definition
        :type this_type: int
        :return: English Language Milestone Type
        :rtype: str
        """
        if this_type == 1:
            return 'Tutorial'
        elif this_type == 2:
            return 'OneTime'
        elif this_type == 3:
            return 'Weekly'
        elif this_type == 4:
            return 'Daily'
        elif this_type == 5:
            return 'Special'
        else:
            return 'UNKNOWN'