feat: adds new endpoint to fetch outbound provider metadata (#36424)
Co-authored-by: Diego Sampaio <8591547+sampaiodiego@users.noreply.github.com>pull/36497/head^2
parent
960a9149dd
commit
296b29bbf8
@ -0,0 +1,5 @@ |
||||
--- |
||||
"@rocket.chat/meteor": minor |
||||
--- |
||||
|
||||
Adds an endpoint to fetch a Outbound Comms Provider's metadata. |
||||
@ -1,55 +1,50 @@ |
||||
import type { IOutboundProvider } from '@rocket.chat/core-typings'; |
||||
import { ajv } from '@rocket.chat/rest-typings'; |
||||
|
||||
import { API } from '../../../../../app/api/server'; |
||||
import { isGETOutboundProviderParams } from '../outboundcomms/rest'; |
||||
import { |
||||
GETOutboundProvidersResponseSchema, |
||||
GETOutboundProviderParamsSchema, |
||||
GETOutboundProviderBadRequestErrorSchema, |
||||
GETOutboundProviderMetadataSchema, |
||||
} from '../outboundcomms/rest'; |
||||
import { outboundMessageProvider } from './lib/outbound'; |
||||
import type { ExtractRoutesFromAPI } from '../../../../../app/api/server/ApiClass'; |
||||
|
||||
const outboundCommsEndpoints = API.v1.get( |
||||
'omnichannel/outbound/providers', |
||||
{ |
||||
response: { |
||||
200: ajv.compile<{ providers: IOutboundProvider[] }>({ |
||||
type: 'object', |
||||
properties: { |
||||
providers: { |
||||
type: 'array', |
||||
items: { |
||||
type: 'object', |
||||
properties: { |
||||
providerId: { |
||||
type: 'string', |
||||
}, |
||||
providerName: { |
||||
type: 'string', |
||||
}, |
||||
supportsTemplates: { |
||||
type: 'boolean', |
||||
}, |
||||
providerType: { |
||||
type: 'string', |
||||
}, |
||||
documentationUrl: { |
||||
type: 'string', |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
}), |
||||
const outboundCommsEndpoints = API.v1 |
||||
.get( |
||||
'omnichannel/outbound/providers', |
||||
{ |
||||
response: { |
||||
200: GETOutboundProvidersResponseSchema, |
||||
400: GETOutboundProviderBadRequestErrorSchema, |
||||
}, |
||||
query: GETOutboundProviderParamsSchema, |
||||
authRequired: true, |
||||
}, |
||||
query: isGETOutboundProviderParams, |
||||
authRequired: true, |
||||
}, |
||||
async function action() { |
||||
const { type } = this.queryParams; |
||||
async function action() { |
||||
const { type } = this.queryParams; |
||||
|
||||
const providers = outboundMessageProvider.listOutboundProviders(type); |
||||
return API.v1.success({ |
||||
providers, |
||||
}); |
||||
}, |
||||
); |
||||
const providers = outboundMessageProvider.listOutboundProviders(type); |
||||
return API.v1.success({ |
||||
providers, |
||||
}); |
||||
}, |
||||
) |
||||
.get( |
||||
'omnichannel/outbound/providers/:id/metadata', |
||||
{ |
||||
response: { |
||||
200: GETOutboundProviderMetadataSchema, |
||||
400: GETOutboundProviderBadRequestErrorSchema, |
||||
}, |
||||
authRequired: true, |
||||
}, |
||||
async function action() { |
||||
const { id } = this.urlParams; |
||||
|
||||
const providerMetadata = await outboundMessageProvider.getProviderMetadata(id); |
||||
return API.v1.success({ |
||||
metadata: providerMetadata, |
||||
}); |
||||
}, |
||||
); |
||||
|
||||
export type OutboundCommsEndpoints = ExtractRoutesFromAPI<typeof outboundCommsEndpoints>; |
||||
|
||||
Loading…
Reference in new issue