evrythng / epcis2.js

EPCIS 2.0 Javascript SDK
Apache License 2.0
35 stars 4 forks source link

Ability to construct events via constructor or "flat" options object #8

Closed domguinard closed 3 years ago

domguinard commented 3 years ago

(suggested by Scott at Zebra) add ability to pass additional parameters via constructor

  const pick1 = new AggregationEvent(actionType = actionTypes.add,
                                     bizStep = bizSteps.picking,
                                     disposition = dispositions.in_progress,
                                     parentId = '...', 
                                     childEPCs = ['...', '...'],
                                     readPoint = '...',
                                     bizLocation = '...',
                                     bizTransactions = ['...', '...']);

or... ability to pass options parameter to set values

  options = {
              actionType: actionTypes.add,
              bizStep: bizSteps.picking,
              dispostions: dispositions.in_progress,
              parentId = '...', 
              childEPCs = ['...', '...'],
              readPoint = '...',
              bizLocation = '...',
              bizTransactions = ['...', '...']
              }
  const pick1 = new AggregationEvent(options);
clementh59 commented 3 years ago

In the next version of epcis2.js, you'll be able to "flatten" the options object for readPoint and bizLocation, like this:

const options = {
    actionType: actionTypes.add,
    bizStep: bizSteps.picking,
    dispositions: dispositions.in_progress,
    parentId : '...',
    childEPCs : ['...', '...'],
    readPoint : '...',
    bizLocation : '...',
    bizTransactions : ['...', '...']
};

const pick1 = new AggregationEvent(options);
domguinard commented 3 years ago

Added to release 1.1.0.