Exemplo n.º 1
0
    def update_product(self, insight: ProductInsight) -> AnnotationResult:
        brand: str = insight.data['brand']

        product = get_product(insight.barcode, ['brands_tags'])

        if product is None:
            return MISSING_PRODUCT_RESULT

        brand_tags: List[str] = product.get('brands_tags') or []

        if brand_tags:
            # For now, don't annotate if a brand has already been provided
            return ALREADY_ANNOTATED_RESULT

        add_brand(insight.barcode, brand)
        return UPDATED_ANNOTATION_RESULT
Exemplo n.º 2
0
    def update_product(
            self,
            insight: ProductInsight,
            auth: Optional[OFFAuthentication] = None) -> AnnotationResult:
        product = get_product(insight.barcode, ["brands_tags"])

        if product is None:
            return MISSING_PRODUCT_RESULT

        add_brand(
            insight.barcode,
            insight.value,
            insight_id=insight.id,
            server_domain=insight.server_domain,
            auth=auth,
        )
        return UPDATED_ANNOTATION_RESULT