@openfoodfacts/openfoodfacts-nodejs
    Preparing search index...

    Class NutriPatrol

    Index

    Constructors

    • Parameters

      • fetch: {
            (input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
            (input: string | Request | URL, init?: RequestInit): Promise<Response>;
        }
          • (input: RequestInfo | URL, init?: RequestInit): Promise<Response>
          • Parameters

            • input: RequestInfo | URL
            • Optionalinit: RequestInit

            Returns Promise<Response>

          • (input: string | Request | URL, init?: RequestInit): Promise<Response>
          • Parameters

            • input: string | Request | URL
            • Optionalinit: RequestInit

            Returns Promise<Response>

      • options: { baseUrl: string } = ...

      Returns NutriPatrol

    Properties

    raw: Client<paths>

    Methods

    • Create a flag in the NutriPatrol API.

      Parameters

      • flagData: {
            barcode?: null | string;
            comment?: null | string;
            confidence?: null | number;
            created_at?: string;
            flavor: "off" | "obf" | "opff" | "opf" | "off-pro";
            image_id?: null | string;
            reason?: null | string;
            source: "mobile" | "web" | "robotoff";
            type: "search" | "product" | "image";
            url: string;
            user_id: string;
        }

        Data for the flag to create.

        • Optionalbarcode?: null | string

          Barcode

          Barcode of the product, if the flag is about a product or a product image. In case of a search issue, this field is null.

        • Optionalcomment?: null | string

          Comment

          Comment provided by the user during flagging. This is a free text field.

        • Optionalconfidence?: null | number

          Confidence

          Confidence score of the model that generated the flag, this field should only be provided by Robotoff.

        • Optionalcreated_at?: string

          Created At Format: date-time

          Creation datetime of the flag

        • flavor: "off" | "obf" | "opff" | "opf" | "off-pro"

          Flavor (project) associated with the ticket

        • Optionalimage_id?: null | string

          Image Id

          ID of the flagged image

        • Optionalreason?: null | string

          Reason

          Reason for flagging provided by the user. The field is optional.

        • source: "mobile" | "web" | "robotoff"

          Source of the flag. It can be a user from the mobile app, the web or a flag generated automatically by robotoff.

        • type: "search" | "product" | "image"

          Type of the issue

        • url: string

          Url

          URL of the product or of the flagged image

        • user_id: string

          User Id

          Open Food Facts User ID of the flagger

      Returns Promise<
          | NutriPatrolError
          | {
              barcode?: null
              | string;
              comment?: null | string;
              confidence?: null | number;
              created_at?: string;
              flavor: "off" | "obf" | "opff" | "opf" | "off-pro";
              image_id?: null | string;
              reason?: null | string;
              source: "mobile" | "web" | "robotoff";
              type: "search" | "product" | "image";
              url: string;
              user_id: string;
          },
      >

      • A promise that resolves with the flag created or error..

      The error can be one of the following:

      • A NutriPatrolError with status 422 if there is a validation issue (e.g., invalid flag ID).
      • A NutriPatrolError with the corresponding HTTP status code for other types of errors (e.g., 404, 500).
      • A generic NutriPatrolError with status 500 for unexpected errors.
    • Create a ticket in the NutriPatrol API.

      Parameters

      • ticketData: Omit<
            {
                barcode?: null
                | string;
                created_at?: string;
                flavor: "off" | "obf" | "opff" | "opf" | "off-pro";
                id: number;
                image_id?: null | string;
                status?: "closed" | "open";
                type: "search" | "product" | "image";
                url: string;
            },
            "id",
        >

        Data for the ticket to create.

      Returns Promise<
          | NutriPatrolError
          | {
              barcode?: null
              | string;
              created_at?: string;
              flavor: "off" | "obf" | "opff" | "opf" | "off-pro";
              id: number;
              image_id?: null | string;
              status?: "closed" | "open";
              type: "search" | "product" | "image";
              url: string;
          },
      >

      • A promise that resolves with the ticket created or error.

      The error can be one of the following:

      • A NutriPatrolError with status 422 if there is a validation issue (e.g., invalid ticket status).
      • A NutriPatrolError with the corresponding HTTP status code for other types of errors (e.g., 404, 500).
      • A generic NutriPatrolError with status 500 for unexpected errors.
    • Get the status of the NutriPatrol API.

      Returns Promise<NutriPatrolError | { status: string }>

      • A promise that resolves with the API status or error.

      The error can be one of the following:

      • A NutriPatrolError with the corresponding HTTP status code for other types of errors (e.g., 404, 500).
      • A generic NutriPatrolError with status 500 for unexpected errors.
    • Retrieves a specific flag by its ID from the NutriPatrol API.

      Parameters

      • flagId: number

        The ID of the flag to fetch.

      Returns Promise<
          | NutriPatrolError
          | {
              barcode?: null
              | string;
              comment?: null | string;
              confidence?: null | number;
              created_at?: string;
              flavor: "off" | "obf" | "opff" | "opf" | "off-pro";
              image_id?: null | string;
              reason?: null | string;
              source: "mobile" | "web" | "robotoff";
              type: "search" | "product" | "image";
              url: string;
              user_id: string;
          },
      >

      • A promise that resolves with the flag data if found or error.

      The error can be one of the following:

      • A NutriPatrolError with status 422 if there is a validation issue (e.g., invalid flag ID).
      • A NutriPatrolError with the corresponding HTTP status code for other types of errors (e.g., 404, 500).
      • A generic NutriPatrolError with status 500 for unexpected errors.
    • List all flags.

      Returns Promise<
          | NutriPatrolError
          | {
              barcode?: null
              | string;
              comment?: null | string;
              confidence?: null | number;
              created_at?: string;
              flavor: "off" | "obf" | "opff" | "opf" | "off-pro";
              image_id?: null | string;
              reason?: null | string;
              source: "mobile" | "web" | "robotoff";
              type: "search" | "product" | "image";
              url: string;
              user_id: string;
          }[],
      >

      • A promise that resolves with the list of flag data or error.

      The error can be one of the following:

      • A NutriPatrolError with status 422 if there is a validation issue (e.g., invalid flag ID).
      • A NutriPatrolError with the corresponding HTTP status code for other types of errors (e.g., 404, 500).
      • A generic NutriPatrolError with status 500 for unexpected errors.
    • Get flags by ticket batch.

      Parameters

      • ticketIds: number[]

        Ids of ticket to get flags from.

      Returns Promise<
          | NutriPatrolError
          | {
              [ticketId: string]: {
                  barcode?: null
                  | string;
                  comment?: null | string;
                  confidence?: null | number;
                  created_at?: string;
                  flavor: "off" | "obf" | "opff" | "opf" | "off-pro";
                  image_id?: null | string;
                  reason?: null | string;
                  source: "mobile" | "web" | "robotoff";
                  type: "search" | "product" | "image";
                  url: string;
                  user_id: string;
              }[];
          },
      >

      • A promise that resolves with the flags associated to each ticket or error.

      The error can be one of the following:

      • A NutriPatrolError with status 422 if there is a validation issue (e.g., invalid flag ID).
      • A NutriPatrolError with the corresponding HTTP status code for other types of errors (e.g., 404, 500).
      • A generic NutriPatrolError with status 500 for unexpected errors.
    • Retrieves a specific ticket by its ID from the NutriPatrol API.

      Parameters

      • ticketId: number

        The ID of the ticket to fetch.

      Returns Promise<
          | NutriPatrolError
          | {
              barcode?: null
              | string;
              created_at?: string;
              flavor: "off" | "obf" | "opff" | "opf" | "off-pro";
              id: number;
              image_id?: null | string;
              status?: "closed" | "open";
              type: "search" | "product" | "image";
              url: string;
          },
      >

      • A promise that resolves with the ticket data if found or error.

      The error can be one of the following:

      • A NutriPatrolError with status 422 if there is a validation issue (e.g., invalid ticket ID).
      • A NutriPatrolError with the corresponding HTTP status code for other types of errors (e.g., 404, 500).
      • A generic NutriPatrolError with status 500 for unexpected errors.
    • List all tickets.

      Parameters

      • query: {
            page?: number;
            page_size?: number;
            reason?: "other" | "inappropriate" | "human" | "beauty";
            status: "closed" | "open";
            type?: string;
        }

        Parameters to filter the tickets.

      Returns Promise<
          | NutriPatrolError
          | {
              barcode?: null
              | string;
              created_at?: string;
              flavor: "off" | "obf" | "opff" | "opf" | "off-pro";
              id: number;
              image_id?: null | string;
              status?: "closed" | "open";
              type: "search" | "product" | "image";
              url: string;
          }[],
      >

      • A promise that resolves with the list of ticket data or error.

      The error can be one of the following:

      • A NutriPatrolError with status 422 if there is a validation issue (e.g., invalid filter value).
      • A NutriPatrolError with the corresponding HTTP status code for other types of errors (e.g., 404, 500).
      • A generic NutriPatrolError with status 500 for unexpected errors.
    • Update a ticket status in the NutriPatrol API.

      Parameters

      • ticketId: number

        The ID of the ticket to update.

      • status: "closed" | "open"

        The new status of the ticket.

      Returns Promise<
          | NutriPatrolError
          | {
              barcode?: null
              | string;
              created_at?: string;
              flavor: "off" | "obf" | "opff" | "opf" | "off-pro";
              id: number;
              image_id?: null | string;
              status?: "closed" | "open";
              type: "search" | "product" | "image";
              url: string;
          },
      >

      • A promise that resolves with the ticket updated or error.

      The error can be one of the following:

      • A NutriPatrolError with status 422 if there is a validation issue (e.g., invalid ticket status).
      • A NutriPatrolError with the corresponding HTTP status code for other types of errors (e.g., 404, 500).
      • A generic NutriPatrolError with status 500 for unexpected errors.