CouponsConfidenceChangedPayload coupons.confidence.changed@1

Generated at from openvibe-contracts v0.34.2 and openvibe-sdk v0.5.0.

Version
1.0.0
Owner
coupons
Visibility
first-party
Status
active
Compatibility
backward
Schema
https://openvibe.network/contracts/events/payloads/coupons.confidence.changed.v1.json

coupons.confidence.changed v1 (OpenVibe.Coupons server/domain/coupons.js recompute). A code's confidence moved, in the transaction of the recompute: a new or corrected report, evidence added or withdrawn (evidence on one of the merchant's own domains raises the prior), or the sweep letting old reports decay (to null once no report is younger than 30 days). confidence = (a0 + W) / (a0 + 1 + W + F), rounded to 2 decimals, over recency-weighted worked (W) and failed (F) reports (half-life 7 days, each reporter's latest report only; a0 = 1, or 1.5 with merchant evidence); null = no counted report in the 30-day window. from and to always differ. status is the code's status after the change; a status change also emits coupons.coupon.updated, .expired or .disabled. Never names a reporter. Envelope: subject { type: coupon, id: cpn_… }, visibility internal, priority important (not set: the Events default), actor service:coupons. No known consumers.

Fields

FieldTypeRequiredDescriptionConstraints
merchant_idstringyesThe merchant the code belongs to.
  • pattern ^mer_[0-9A-HJKMNP-TV-Z]{26}$
fromnumber | nullyesConfidence before; null = no counted report.
  • minimum 0
  • maximum 1
tonumber | nullyesConfidence after; null = no counted report left in the window.
  • minimum 0
  • maximum 1
statusenumyesThe code's status after the change (reported_working at confidence >= 0.6, reported_failed at <= 0.4, given enough recent reports).
  • one of "unknown", "reported_working", "reported_failed", "expired", "disabled"

Examples

From the contract's own test fixtures: valid ones validate, rejected ones must fail.

Valid: decayed-out
{
  "merchant_id": "mer_01K5R7A1B2C3D4E5F6G7H8J9KM",
  "from": 0.33,
  "to": null,
  "status": "unknown"
}
Valid: first-report
{
  "merchant_id": "mer_01K5R7A1B2C3D4E5F6G7H8J9KM",
  "from": null,
  "to": 0.67,
  "status": "reported_working"
}
Rejected: missing-status
{
  "merchant_id": "mer_01K5R7A1B2C3D4E5F6G7H8J9KM",
  "from": 0.5,
  "to": 0.6
}
Rejected: percent
{
  "merchant_id": "mer_01K5R7A1B2C3D4E5F6G7H8J9KM",
  "from": null,
  "to": 67,
  "status": "reported_working"
}

Validate

const contracts = require('openvibe-contracts');
contracts.validate('coupons.confidence.changed@1', value);   // { valid, errors: [{ path, message }] }