n4.cuwo.messages.BarcodeScanned

When barcode scanning is enabled, a BarcodeScanned message is sent to the CUWO every time the user scans a barcode (or manually enters one via the native UI).

The message has the following structure:

{
  "@type": "n4.cuwo.messages.BarcodeScanned",
  "id": "...",

  "barcode": {
    "@type": "n4.data.barcodes.Barcode",
    "barcodeFormat": {
      "@type": "n4.data.barcodes.BarcodeFormat",
      "value": "..."
    },
    "rawValue": "...",
    "codeValue": "...",
    "parsedData": {
      ...
    },
  },

  // deprecated fields
  "barcodeType": {
    "@type": "n4.cuwo.messages.BarcodeType",
    "value": "..."
  },
  "barcodeValue": "...",
  "barcodeCode": "..."
}

The various member provide the information necessary for the operation:

  • id - The ID of the message
  • barcode - The barcode that was scanned.
  • Deprecated fields:
    • barcodeType - The type of barcode that was scanned. One of EAN13, EAN8, EAN5, EAN2, UPCE, QRCODE, CODE128, CODE39, CODE93, CODABAR, DATAMATRIX, ITF, PDF417, DATABAR, DATABAR_EXPANDED
    • barcodeValue - The barcode value as a base64 encoded string. The string must use the “base64” encoding defined in RFC 4648 Section 4. Note that the scanned value may consist of not just the code but also some additional data such as a prefix indicating the code type or type-variant.
    • barcodeCode - The code part of the barcode that was scanned as a plain-text string. The enfore platform tries to clean up the scanned value as much as possible but there may be cases where some additional data is not detected and thus left in the code.

The Barcode structure is defined as:

/**
 * Data structure holding information about a barcode.
 */
class Barcode {
    readonly "@type" : string = "n4.data.barcodes.Barcode";

    /**
     * The format/symbology of the barcode.
     */
    public barcodeFormat : BarcodeFormat;

    /**
     * The full barcode value that was scanned as a base64
     * encoded string.
     * 
     * The string must use the “base64” encoding defined in
     * RFC 4648 Section 4.
     * 
     * Note that the scanned value may consist of not just the code
     * but also some additional data such as a prefix indicating the
     * code type or type-variant.
     */
    public rawValue : string;

    /**
     * The code part of the barcode that was scanned.
     * 
     * The enfore platform tries to clean up the scanned value as
     * much as possible but there may be cases where some additional
     * data is not detected and thus left in the code.
     */
    public codeValue : string;

    /**
     * A barcode may contain data that is understood by the enfore
     * platform and can thus be parsed into structured data.
     * 
     * For example, a barcode may contain a GTIN encoding "Variable
     * Measure Retail Item" information (mainly a combination of a
     * product identifier/PLU and a price or a weight/pieces
     * quantity value).
     * 
     * If such data is detected within the code, the enfore platform
     * will make it available via this field.
     */
    public parsedData? : BarcodeData;
}

Barcode data

The enfore platform provides additional support for some commonly used standards of data being encoded in barcodes.

GS1

Variable measure RCNs

The enfore platform provides parsed data for GS1 RCNs within the prefix range 20 to 29 for variable measure trade items that contain money or quantity information.

GS1VariableMeasurePrice

/**
 * Data structure holding the information parsed from a GS1 RCN
 * (Restricted Circulation Number) holding price information for
 * a variable measure trade item.
 * 
 * See https://www.gs1.org/docs/barcodes/SummaryOfGS1MOPrefixes20-29.pdf for more information
 */
class GS1VariableMeasurePrice extends BarcodeData {
    readonly "@type" : string = "n4.data.barcodes.data.gs1.GS1VariableMeasurePrice";

    /**
     * The country used to parse the code.
     * 
     * This information is important as the GS1 prefix range 20-29
     * is controlled by each GS1 member organization and the specficiations
     * differ between countries. For example, 23 is used to encode
     * the price for both Austria and Germany but is not used (reserved)
     * for Switzerland.
     * 
     * Note that the enfore platform does not try to parse a code
     * for all possible countries. Rather, it uses a single country
     * that is either explicitly specified for the scan or derived
     * from the context information (organization country).
     * 
     * Therefore, if a CUWO or application knows that the code must
     * be interpreted using logic for country AAA but this data
     * states that is was created using logic for country BBB, the
     * CUWO/application knows that this data is invalid an must
     * be ignored.
     */
    public country : Country;

    /**
     * The prefix part of the RCN code.
     */
    public prefix : String;

    /**
     * The (product) identifier contained in the code.
     */
    public identifier : String;

    /**
     * The price contained in the code.
     */
    public price : Money;
}

GS1VariableMeasurePieces

/**
 * Data structure holding the information parsed from a GS1 RCN
 * (Restricted Circulation Number) holding pieces information for
 * a variable measure trade item.
 * 
 * See https://www.gs1.org/docs/barcodes/SummaryOfGS1MOPrefixes20-29.pdf for more information
 */
class GS1VariableMeasurePieces extends BarcodeData {
    readonly "@type" : string = "n4.data.barcodes.data.gs1.GS1VariableMeasurePieces";

    /**
     * The country used to parse the code.
     * 
     * This information is important as the GS1 prefix range 20-29
     * is controlled by each GS1 member organization and the specficiations
     * differ between countries. For example, Germany uses prefixes 25
     * and 26 for encoding pieces whereas Austria uses 28.
     * 
     * Note that the enfore platform does not try to parse a code
     * for all possible countries. Rather, it uses a single country
     * that is either explicitly specified for the scan or derived
     * from the context information (organization country).
     * 
     * Therefore, if a CUWO or application knows that the code must
     * be interpreted using logic for country AAA but this data
     * states that is was created using logic for country BBB, the
     * CUWO/application knows that this data is invalid an must
     * be ignored.
     */
    public country : Country;

    /**
     * The prefix part of the RCN code.
     */
    public prefix : String;

    /**
     * The (product) identifier contained in the code.
     */
    public identifier : String;

    /**
     * The pieces contained in the code.
     */
    public pieces : Quantity<UnitOfQuantity>;
}

GS1VariableMeasureWeight

/**
 * Data structure holding the information parsed from a GS1 RCN
 * (Restricted Circulation Number) holding weight information for
 * a variable measure trade item.
 * 
 * See https://www.gs1.org/docs/barcodes/SummaryOfGS1MOPrefixes20-29.pdf for more information
 * 
 * Note that the "weight" here technically is "mass" but "weight" is
 * used as that is the term used by GS1 and in all related documentation.
 */
class GS1VariableMeasureWeight extends BarcodeData {
    readonly "@type" : string = "n4.data.barcodes.data.gs1.GS1VariableMeasureWeight";

    /**
     * The country used to parse the code.
     * 
     * This information is important as the GS1 prefix range 20-29
     * is controlled by each GS1 member organization and the specficiations
     * differ between countries. For example, Germany uses prefixes 28
     * and 29 for encoding weight whereas Austria uses 21 and 27.
     * 
     * Note that the enfore platform does not try to parse a code
     * for all possible countries. Rather, it uses a single country
     * that is either explicitly specified for the scan or derived
     * from the context information (organization country).
     * 
     * Therefore, if a CUWO or application knows that the code must
     * be interpreted using logic for country AAA but this data
     * states that is was created using logic for country BBB, the
     * CUWO/application knows that this data is invalid an must
     * be ignored.
     */
    public country : Country;

    /**
     * The prefix part of the RCN code.
     */
    public prefix : String;

    /**
     * The (product) identifier contained in the code.
     */
    public identifier : String;

    /**
     * The weight contained in the code.
     */
    public weight : Quantity<UnitOfMass>;
}