def from_vendor(contact): """ Take contact data retrieved from SFDC and convert it for ease of use @param contact: contact data from SFDC @return: """ news_map = newsletter_inv_map() data = {} newsletters = [] for fn, fv in contact.items(): if fn in INV_FIELD_MAP: data_name = INV_FIELD_MAP[fn] if data_name in FIELD_DEFAULTS: fv = fv or FIELD_DEFAULTS[data_name] if data_name in PROCESSORS_FROM_VENDOR: fv = PROCESSORS_FROM_VENDOR[data_name](fv) data[data_name] = fv elif fn in news_map and fv: newsletters.append(news_map[fn]) data["newsletters"] = newsletters return data
def from_vendor(contact): """ Take contact data retrieved from SFDC and convert it for ease of use @param contact: contact data from SFDC @return: """ news_map = newsletter_inv_map() data = {} newsletters = [] for fn, fv in contact.iteritems(): if fn in INV_FIELD_MAP: data_name = INV_FIELD_MAP[fn] if data_name in FIELD_DEFAULTS: fv = fv or FIELD_DEFAULTS[data_name] if data_name in PROCESSORS_FROM_VENDOR: fv = PROCESSORS_FROM_VENDOR[data_name](fv) data[data_name] = fv elif fn in news_map and fv: newsletters.append(news_map[fn]) data['newsletters'] = newsletters return data