import requests
import json


def mac_vendor_api_call(list_of_mac_address_info):
    """Searches a list of dictionaries to do an API call against the MAC address to obtain vendor information
    
    Params:
    mac_vendor_api_call(dict): Contains output from function mac_parser that has MAC addr, VLAN, interface
    
    Returns:
    list_of_mac_address_info(list): Returns a new list of dictionaries with a new key value pair of 
           Company(key) with the vendor name(value)"""

    for dict in list_of_mac_address_info:
        r = requests.get('https://macvendors.co/api/{0}'.format(dict['MAC_ADDRESS']))
        api_return = json.loads(r.text)
        if api_return['result']['company']:
            dict['COMPANY'] = api_return['result']['company']
        else:
            dict['COMPANY'] = 'NOT FOUND'
    return list_of_mac_address_info