CouponsResolveResult coupons.resolve-result@1

Generated at from openvibe-contracts v0.53.0 and openvibe-sdk v0.11.0.

Version
1.0.0
Owner
coupons
Visibility
first-party
Status
active
Compatibility
backward
Schema
https://openvibe.network/contracts/coupons/resolve-result.v1.json

coupons.resolve-result@1: the answer of GET /api/v1/merchants/resolve?host= on OpenVibe.Coupons (coupons.merchant.resolve; public, anonymous allowed, rate-limited, CORS for the configured extension origins): the merchant whose domain rule matches the host. No match is 404 merchant.not_found with the normalised host and its registrable domain; a missing host is 400 host.required.

Fields

FieldTypeRequiredDescriptionConstraints
hoststringyes
registrable_domainstringyes
matched_ruleobjectyes
matched_rule.hoststringyes
matched_rule.include_subdomainsbooleanyes
matched_rule.path_prefixstring | nullyes
merchantcoupons.merchantyes

Examples

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

Valid: match
{
  "host": "www.shoes.example.com",
  "registrable_domain": "example.com",
  "matched_rule": {
    "host": "shoes.example.com",
    "include_subdomains": true,
    "path_prefix": null
  },
  "merchant": {
    "id": "mer_01JAB2C3D4E5F6G7H8J9K0MNPQ",
    "slug": "example-shoes",
    "name": "Example Shoes",
    "homepage_url": "https://shoes.example.com/",
    "url": "https://openvibe.coupons/m/example-shoes",
    "domains": [
      {
        "host": "shoes.example.com",
        "include_subdomains": true,
        "path_prefix": null
      }
    ],
    "active_codes": 2,
    "hints": [
      "Enter the code in the Promo field at checkout."
    ]
  }
}
Rejected: no-merchant
{
  "host": "x.example.com",
  "registrable_domain": "example.com"
}

Validate

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