Download automation/src/modules/cx/api.ts from EnergyVenom/patchwise-agent-studio: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/automation/src/modules/cx/api.ts
- Command line
-
hf download hf://spaces/EnergyVenom/patchwise-agent-studio/automation/src/modules/cx/api.ts
-
curl -L -o api.ts https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/automation/src/modules/cx/api.ts
1.53 kB
| import { expect } from '@playwright/test'; | |
| import { MockApi, MOCK, Persona } from '../../api'; | |
| /** CX REST helpers (SCRIPT ONLY; never run: execution_hold, no CX mock pack). */ | |
| export class CXApi { | |
| constructor(public api: MockApi) {} | |
| rest(as: Persona, method: string, path: string, data?: unknown) { return this.api.call(as, method, path, data, MOCK.restBase); } | |
| async restQ<T = any>(as: Persona, resource: string, q: string, extra = '') { const r = await this.rest(as, 'GET', `/${resource}?q=${encodeURIComponent(q)}${extra}`); expect(r.status, `GET ${resource}`).toBe(200); return (r.body as { items: T[] }).items; } | |
| /** DR-CX-ACT-001: synthetic account + contact (fictitious address, example.invalid mail). */ | |
| async account(suffix: string) { return this.api.ok('sales_rep', 'POST', '/cx/accounts', { name: `ZZ Testco ${suffix}`, address: '1 Test Way, Testville (fictitious)', postalCode: '99999 (MOCK)' }); } | |
| async contact(suffix: string, account: string) { return this.api.ok('sales_rep', 'POST', '/cx/contacts', { account, last: 'Testcontact', first: 'Beta', email: `beta.${suffix}@example.invalid`, phone: '+1 555 0100' }); } | |
| /** DR-CX-OPP-001: opportunity with 2 revenue lines (10 x 100.00, 5 x 200.00). */ | |
| async opportunity(suffix: string) { return this.api.ok('sales_rep', 'POST', '/cx/opportunities', { name: `ZZ Opp ${suffix}`, account: `ZZ Testco ${suffix}`, lines: [{ product: 'ZZ-CX-ITEM-1', quantity: 10, price: 100 }, { product: 'ZZ-CX-ITEM-2', quantity: 5, price: 200 }] }); } | |
| } | |