refactor type
This commit is contained in:
@@ -25,7 +25,7 @@ import {
|
||||
OnCallsResponse,
|
||||
OnCall,
|
||||
} from '../components/types';
|
||||
import { PagerDutyClient } from './types';
|
||||
import { PagerDutyClient, TriggerAlarmRequest } from './types';
|
||||
|
||||
export class UnauthorizedError extends Error {}
|
||||
|
||||
@@ -67,12 +67,12 @@ export class PagerDutyClientApi implements PagerDutyClient {
|
||||
return oncalls;
|
||||
}
|
||||
|
||||
triggerAlarm(
|
||||
integrationKey: string,
|
||||
source: string,
|
||||
description: string,
|
||||
userName: string,
|
||||
) {
|
||||
triggerAlarm({
|
||||
integrationKey,
|
||||
source,
|
||||
description,
|
||||
userName,
|
||||
}: TriggerAlarmRequest): Promise<Response> {
|
||||
const body = JSON.stringify({
|
||||
event_action: 'trigger',
|
||||
routing_key: integrationKey,
|
||||
|
||||
@@ -16,6 +16,13 @@
|
||||
|
||||
import { Incident, OnCall, Service } from '../components/types';
|
||||
|
||||
export type TriggerAlarmRequest = {
|
||||
integrationKey: string;
|
||||
source: string;
|
||||
description: string;
|
||||
userName: string;
|
||||
};
|
||||
|
||||
export interface PagerDutyClient {
|
||||
/**
|
||||
* Fetches a list of services, filtered by the provided integration key.
|
||||
@@ -38,10 +45,5 @@ export interface PagerDutyClient {
|
||||
/**
|
||||
* Triggers an incident to whoever is on-call.
|
||||
*/
|
||||
triggerAlarm(
|
||||
integrationKey: string,
|
||||
source: string,
|
||||
description: string,
|
||||
userName: string,
|
||||
): Promise<Response>;
|
||||
triggerAlarm(request: TriggerAlarmRequest): Promise<Response>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user