Getting pledge history of a member

Hi, I’m trying to get the pledge history of the members, I can do it but I don’t have the tier_id that corresponds to the event. I tried to add 'fields[pledge-event]': 'tier_id', however this is added to the include part of the query, except that include is not connected to a specific member like the data part of the query. Do you know how to know which information in include corresponds to which members?


async def fetch_patreons(campaign_id, access_token):
    patreons = {}
    url = f'{campaign_id}/members'
    params = {
        'include': 'user,currently_entitled_tiers,pledge_history',
        'fields[user]': 'social_connections',
        'fields[pledge-event]': 'tier_id',
    headers = {'Authorization': f'Bearer {access_token}'}
    while True:
        async with aiohttp.ClientSession() as session:
            async with session.get(url, params=params, headers=headers) as response:
                valid_pledge = []
                used_event_pledge = []

                patreon_data = await response.json()
                for i in patreon_data['data']:
                pagination_data = patreon_data['meta']['pagination']
                if not pagination_data.get('cursors'):
                next_cursor_id = pagination_data['cursors']['next']
                params['page[cursor]'] = next_cursor_id

and data that I get:

{'data': [{'attributes': {}, 'id': 'XXX', 'relationships': {'currently_entitled_tiers': {'data': []}, 'pledge_history': {'data': [{'id': 'pledge_delete:110292198', 'type': 'pledge-event'}, {'id': 'pledge_downgrade:110292198', 'type': 'pledge-event'}, {'id': 'pledge_downgrade:110289281', 'type': 'pledge-event'}, {'id': 'pledge_upgrade:110289233', 'type': 'pledge-event'}, {'id': 'pledge_start:110289207', 'type': 'pledge-event'}]}, 'user': {'data': {'id': '67418049', 'type': 'user'}, 'links': {'related': ''}}}, 'type': 'member'}, {'attributes': {}, 'id': 'XXX, 'relationships': {'currently_entitled_tiers': {'data': []}, 'pledge_history': {'data': [{'id': 'pledge_delete:108023070', 'type': 'pledge-event'}, {'id': 'pledge_start:108023070', 'type': 'pledge-event'}, {'id': 'pledge_delete:106740441', 'type': 'pledge-event'}, {'id': 'pledge_start:106740441', 'type': 'pledge-event'}]}, 'user': {'data': {'id': 'XXX', 'type': 'user'}, 'links': {'related': ''}}}, 'type': 'member'}], 'included': [{'attributes': {}, 'id': 'XXX', 'type': 'user'}, {'attributes': {}, 'id': '78906740', 'type': 'user'}, {'attributes': {'tier_id': '9042131'}, 'id': 'pledge_delete:110292198', 'type': 'pledge-event'}, {'attributes': {'tier_id': '9042131'}, 'id': 'pledge_downgrade:110292198', 'type': 'pledge-event'}, {'attributes': {'tier_id': '9041036'}, 'id': 'pledge_downgrade:110289281', 'type': 'pledge-event'}, {'attributes': {'tier_id': '9041443'}, 'id': 'pledge_upgrade:110289233', 'type': 'pledge-event'}, {'attributes': {'tier_id': '9041036'}, 'id': 'pledge_start:110289207', 'type': 'pledge-event'}, {'attributes': {'tier_id': '9042131'}, 'id': 'pledge_delete:108023070', 'type': 'pledge-event'}, {'attributes': {'tier_id': '9042131'}, 'id': 'pledge_start:108023070', 'type': 'pledge-event'}, {'attributes': {'tier_id': '9042131'}, 'id': 'pledge_delete:106740441', 'type': 'pledge-event'}, {'attributes': {'tier_id': '9042131'}, 'id': 'pledge_start:106740441', 'type': 'pledge-event'}], 'meta': {'pagination': {'total': 2}}}

You can get the currently entitled tiers of a member using currently_entitled_tiers outside pledge events.