tag

package
v0.0.0-...-de2618e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StateChangeEvent is constant for state change trigger rule
	StateChangeEvent = "stateChange"
	// OutOfStockEvent is constant for out of stock trigger rule
	OutOfStockEvent = "outOfStock"
)
View Source
const (

	// UndefinedProductID is the constant to set the product id when it cannot be decoded
	UndefinedProductID = "undefined"
)

Variables

This section is empty.

Functions

func DecodeTagData

func DecodeTagData(tagData string) (productID string, URI string, err error)

DecodeTagData extracts a ProductID and URI from tag data, according to the configured tag decoders. If none of the decoders can successfully decode the data, it returns `encodingInvalid` for both.

func Delete

func Delete(dbs *sql.DB, epc string) error

Delete removes tag from database based on epc nolint :dupl

func DeleteTagCollection

func DeleteTagCollection(dbs *sql.DB) error

DeleteTagCollection removes tag collection from database nolint :dupl

func Replace

func Replace(dbs *sql.DB, tagData []Tag) error

Replace bulk upserts tags into database

func Update

func Update(dbs *sql.DB, epc string, facilityId string, object map[string]string) error

Update updates a tag in the database

Types

type ASNContext

type ASNContext struct {
	// ASNID is the ID of the shipment copied from the top level of the ASN that added this EPC.
	ASNID string `json:"asnId"`
	// EventTime is a string provided by the ASN indicating when it was updated.
	EventTime string `json:"eventTime"`
	// SiteID indicates the site to which this ASN applies.
	SiteID string `json:"siteId"`
	// ItemGTIN is a company identifier provided with the original ASN data.
	ItemGTIN string `json:"itemGtin"`
	// ItemID is also a company identifier provided with the original ASN data.
	ItemID string `json:"itemId"`
}

ASNContext represents the data to be marshaled into the EPCContext field for an Advanced Shipping Notice for each EPC to which the ASN applies.

type ASNInputItem

type ASNInputItem struct {
	// EPCs to which this ASN applies
	EPCs []string `json:"itemEpcs"`
	// ItemGTIN is a company identifier provided with the original ASN data.
	ItemGTIN string `json:"itemGtin"`
	// ItemID is also a company identifier provided with the original ASN data.
	ItemID string `json:"itemId"`
}

ASNInputItem is a block of metadata and list of EPCs to which the metadata applies.

type AdvanceShippingNotice

type AdvanceShippingNotice struct {
	// ID is the ID of this shipment.
	ID string `json:"asnId"`
	// EventTime is a string provided by the ASN indicating when it was updated.
	EventTime string `json:"eventTime"`
	// SiteID indicates the site to which this ASN applies.
	SiteID string `json:"siteId"`
	// Items is the list of ASNInputItems for this ASN.
	Items []ASNInputItem `json:"items"`
}

AdvanceShippingNotice models the information meant to be serialized to the EPCContext field for all the EPCs in the provided data list.

type CountType

type CountType struct {
	Count *int `json:"count"`
}

CountType is the model for returning only the number of tags of a given query

func Retrieve

func Retrieve(dbs *sql.DB, query url.Values, maxSize int) (interface{}, *CountType, error)

Retrieve retrieves tags from database based on Odata query and a size limit

type LocationHistory

type LocationHistory struct {
	Location  string `json:"location"`
	Timestamp int64  `json:"timestamp"`
	Source    string `json:"source"`
}

LocationHistory is the model to record the whereabouts history of a tag

type PagingType

type PagingType struct {
	Cursor string `json:"cursor,omitempty"`
}

PagingType is the model used for paging that is returned in the query response

type PurgingRequest

type PurgingRequest struct {
	Days int `json:"days"`
}

PurgingRequest is the model for request body of the api used for purging the collection periodically

type RequestBody

type RequestBody struct {
	// User set qualified state for the item
	QualifiedState string `json:"qualified_state"`
	// Return only facilities provided
	FacilityID string `json:"facility_id"`
	// EPC state of ‘present’ or ‘departed’
	EpcState string `json:"epc_state"`
	// Millisecond epoch start time
	StartTime int64 `json:"starttime"`
	// Millisecond epoch stop time
	EndTime int64 `json:"endtime"`
	// Millisecond epoch current time
	Time int64 `json:"time"`
	// Minimum probability items must meet
	Confidence float64 `json:"confidence"`
	// Cursor from previous response used to retrieve next page of results.
	Cursor string `json:"cursor"`
	// Number of results per page
	Size int `json:"size"`
	// Return only tag count
	CountOnly bool `json:"count_only"`
	// GTIN-14 decoded from EPC
	ProductID string `json:"productId"`
	// SGTIN EPC code
	Epc string `json:"epc"`
}

RequestBody is the model for request body used for many data apis.

type Response

type Response struct {
	PagingType *PagingType `json:"paging,omitempty"`
	Count      *int        `json:"count,omitempty"`
	Results    interface{} `json:"results"`
}

Response is the model used to return the query response

type Tag

type Tag struct {
	// URI string representation of tag
	URI string `json:"uri"`
	// SGTIN EPC code
	Epc string `json:"epc"`
	// ProductID
	ProductID string `json:"product_id" bson:"product_id"`
	// Part of EPC, denotes packaging level of the item
	FilterValue int64 `json:"filter_value" bson:"filter_value"`
	// Tag manufacturer ID
	Tid string `json:"tid"`
	// TBD
	EpcEncodeFormat string `json:"encode_format" bson:"encode_format"`
	// Facility ID
	FacilityID string `json:"facility_id" bson:"facility_id"`
	// Last event recorded for tag
	Event string `json:"event"`
	// Arrival time in milliseconds epoch
	Arrived int64 `json:"arrived"`
	// Tag last read time in milliseconds epoch
	LastRead int64 `json:"last_read" bson:"last_read"`
	// Where tags were read from (fixed or handheld)
	Source string `json:"source"`
	// Array of objects showing history of the tag's location
	LocationHistory []LocationHistory `json:"location_history" bson:"location_history"`
	// Current state of tag, either ’present’ or ’departed’
	EpcState string `json:"epc_state" bson:"epc_state"`
	// Customer defined state
	QualifiedState string `json:"qualified_state" bson:"qualified_state"`
	// Customer defined context
	EpcContext string `json:"epc_context" bson:"epc_context"`
	// Probability item is actually present
	Confidence float64 `json:"confidence,omitempty"` //omitempty - confidence is not stored in the db
	// Cycle Count indicator
	CycleCount bool `json:"-"`
}

Tag is the model containing items for a Tag

func FindByEpc

func FindByEpc(dbs *sql.DB, epc string) (Tag, error)

FindByEpc searches DB for tag based on the epc value Returns the tag if found or empty tag if it does not exist

func RetrieveOdataAll

func RetrieveOdataAll(dbs *sql.DB, query url.Values) ([]Tag, error)

RetrieveOdataAll retrieves all tags from the database that matches the query without any size limit

func (Tag) IsEmpty

func (tag Tag) IsEmpty() bool

IsEmpty determines if a tag is empty

func (Tag) IsEqual

func (tag Tag) IsEqual(target Tag) bool

IsEqual compares 2 tag structures nolint :gocyclo

func (Tag) IsShippingNoticeEntry

func (tag Tag) IsShippingNoticeEntry() bool

IsShippingNoticeEntry is function to determine if a tag in the DB was the result of an Advance Shipping Notice. This is needed to attempt to distinguish between tags inserted by a tag read versus those that resulted from an ASN. NOTE: This DOES NOT determine that a tag *has* a shipping notice -- instead, it determines that a tag *only exists because* of a shipping notice.

func (Tag) IsTagReadByRspController

func (tag Tag) IsTagReadByRspController() bool

IsTagReadByRspController returns true if a tag was read by the RSP Controller, versus a result of ASN

func (*Tag) Scan

func (tag *Tag) Scan(value interface{}) error

Scan implements sql.Scanner interfaces

func (*Tag) Value

func (tag *Tag) Value() (driver.Value, error)

Value implements driver.Valuer interfaces

type TagStateChange

type TagStateChange struct {
	PreviousState Tag `json:"previousState" `
	CurrentState  Tag `json:"currentState" `
}

TagStateChange is the model to capture the previous and current state of a tag nolint :golint

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL