import json


def get_offenses(api_client, filter):
    """
    Get offense summaries consisting of the following fields from the offense
    structure:

        - id
        - description
        - status
        - offense_type
        - offense_source

    Passes the provided filter parameter to only return only the requested
    offenses. Returns the list of offense summaries or None if there was an
    error.
    """

    endpoint = 'siem/offenses'
    params = {'fields': 'id,description,status,offense_type,offense_source',
              'filter': filter}

    response = api_client.call_api(endpoint, 'GET', params=params,
                                   print_request=True)
    response_body = response.read().decode('utf-8')

    if response.code > 299 or response.code < 200:

        print("API call failed.")
        print(response_body)
        return None

    offenses = json.loads(response_body)

    return offenses