import find from 'lodash/find';
import get from 'lodash/get';

export const getItemAttributeByIdentifier = (item, identifier) =>
    find(get(item, 'attributes'), { identifier });

export const getAttributeValue = (attribute, defaultValue) => get(attribute, 'values[0].value', defaultValue);

export const getItemAttributeValueByIdentifier = (item, identifier, defaultValue) =>
    getAttributeValue(getItemAttributeByIdentifier(item, identifier), defaultValue);
