Files
AdPlatform-Client/Client-TestApi/src/services/serviceCatalog.js
2026-02-03 15:45:39 -08:00

110 lines
2.7 KiB
JavaScript

// src/services/serviceCatalog.js
/**
* Service catalog organized by Provider → Service → Action
*
* Structure:
* - provider: Ad platform (google, meta, msads)
* - service: Sub-module/microservice (system, campaigns, reporting, accounts)
* - action: Specific operation (ping, create, list, get, update, delete)
*/
export const servicesByProvider = {
gateway: [
{
id: 'GatewayPing',
service: 'system',
action: 'ping',
label: 'Gateway Ping (SQL test)',
sample: {},
endpoint: '/api/test/ping',
method: 'GET'
}
],
google: [
// System service
{
id: 'Ping',
service: 'system',
action: 'ping',
label: 'System: Ping (GoogleApi round trip)',
sample: {}
},
// Campaigns service
{
id: 'CreateCampaign',
service: 'campaigns',
action: 'create',
label: 'Campaigns: Create',
sample: { name: 'Test Campaign', budgetMicros: 10000000, type: 'Search' }
},
{
id: 'ListCampaigns',
service: 'campaigns',
action: 'list',
label: 'Campaigns: List',
sample: {}
},
{
id: 'GetCampaign',
service: 'campaigns',
action: 'get',
label: 'Campaigns: Get by ID',
sample: { campaignId: 'campaigns/123' }
},
// Reporting service
{
id: 'GetCampaignStats',
service: 'reporting',
action: 'campaignStats',
label: 'Reporting: Campaign Stats',
sample: { campaignId: 'campaigns/123', startDate: '2026-01-01', endDate: '2026-01-26' }
},
{
id: 'GetAccountStats',
service: 'reporting',
action: 'accountStats',
label: 'Reporting: Account Stats',
sample: { startDate: '2026-01-01', endDate: '2026-01-26' }
},
// Accounts service
{
id: 'ListAccounts',
service: 'accounts',
action: 'list',
label: 'Accounts: List Accessible',
sample: {}
},
{
id: 'GetAccount',
service: 'accounts',
action: 'get',
label: 'Accounts: Get Details',
sample: { customerId: '1234567890' }
}
]
};
export function getServices(providerId) {
return servicesByProvider[providerId] || [];
}
export function getService(providerId, serviceId) {
return getServices(providerId).find(s => s.id === serviceId);
}
/**
* Get unique service modules for a provider
*/
export function getServiceModules(providerId) {
const services = getServices(providerId);
const modules = [...new Set(services.map(s => s.service))];
return modules;
}
/**
* Get actions for a specific service module
*/
export function getActionsForModule(providerId, serviceModule) {
return getServices(providerId).filter(s => s.service === serviceModule);
}