Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
docs(catalog): show a priceFormatted example the gateway emits
Yudhi Armyndharisc3cbcb3929f8
diff --git a/src/modules/catalog/dto/catalog-response.dto.spec.ts b/src/modules/catalog/dto/catalog-response.dto.spec.tsnew file mode 100644index 000000000..897e5dacb--- /dev/null+++ b/src/modules/catalog/dto/catalog-response.dto.spec.ts@@ -0,0 +1,16 @@+import { ProductDto } from './catalog-response.dto';++describe('ProductDto', () => {+ // The Baileys adapter renders priceFormatted with Intl.NumberFormat('en', { style: 'currency' }), so+ // the documented example has to be a string that call can produce (Intl separates the code with a+ // no-break space, which the example writes as a plain one).+ it('documents a priceFormatted example the gateway actually emits', () => {+ const props = Reflect.getMetadata('swagger/apiModelProperties', ProductDto.prototype, 'priceFormatted') as {+ example?: string;+ };+ const rendered = new Intl.NumberFormat('en', { style: 'currency', currency: 'IDR' })+ .format(85000)+ .replace(/\u00a0/g, ' ');+ expect(props.example).toBe(rendered);+ });+});diff --git a/src/modules/catalog/dto/catalog-response.dto.ts b/src/modules/catalog/dto/catalog-response.dto.tsindex d39af8960..502dd5c0e 100644--- a/src/modules/catalog/dto/catalog-response.dto.ts+++ b/src/modules/catalog/dto/catalog-response.dto.ts@@ -55,7 +55,7 @@ export class ProductDto {'Price rendered for display. Synthesized by the gateway from price + currency, so an ' +'unrecognised currency code falls back to a plain "CODE amount" pair, and a product with no ' +'currency shows the bare amount. Present only when price is.',- example: 'IDR 85,000.00',+ example: 'IDR 85,000',})priceFormatted?: string;