Create a bulletin object from an API response (dict), containing `sbj`, etc.

def fromapi(_class, apiresponse):
        """Create a bulletin object from an API response (dict), containing `sbj`, etc."""
        for resp in apiresponse['sb']:
            # Extract details from dict
            _id = "n/a" or resp.get("nm")
            subject = resp.get("sbj")
            text = resp.get('dtl') + "\n" + resp.get('brf')
            priority = "n/a" or resp.get('prty')
            for_stops, for_routes = [], []
            svc = resp.get('srvc')
        
            # Create list of affected routes/stops, if there are any
            if svc:
                has_stop = 'stpid' in svc or 'stpnm' in svc
                has_rt = 'rt' in svc or 'rtdir' in svc
            
                if has_stop: 
                    aff = _class.affected_service('stop', svc.get('stpid'), svc.get('stpnm'))
                    for_stops.append(aff)
                if has_rt:
                    aff = _class.affected_service('route', svc.get('rt'), svc.get('rtdir'))
                    for_routes.append(aff)

            yield _class(_id, subject, text, priority, for_stops, for_routes)