Prefill predefined carrier gateways in a form (#147)

* add gateways api call to hook

* add route to carrier template

* apply review comments

* omit request.body if no payload is provided

* remove ternary where not needed

* fix typing of payload

* fix payload type to allow undefined

Co-authored-by: eglehelms <e.helms@cognigy.com>
This commit is contained in:
EgleHandeglehelms authored and GitHub committed 2022-11-11 07:56:07 -05:00
1 parent 781ccb95f2
commit 29cd5a5fa7
3 files changed
+32 -5

No files matched your search

+14 -2
View File
@@ -194,10 +194,13 @@ export const getFetch = <Type>(url: string) => {
});
};
export const postFetch = <Type, Payload>(url: string, payload: Payload) => {
export const postFetch = <Type, Payload = undefined>(
url: string,
payload?: Payload
) => {
return fetchTransport<Type>(url, {
method: "POST",
body: JSON.stringify(payload),
...(payload && { body: JSON.stringify(payload) }),
headers: getAuthHeaders(),
});
};
@@ -284,6 +287,15 @@ export const postCarrier = (sid: string, payload: Partial<Carrier>) => {
);
};
export const postPredefinedCarrierTemplate = (
currentServiceProviderSid: string,
predefinedCarrierSid: string
) => {
return postFetch<SidResponse>(
`${API_BASE_URL}/ServiceProviders/${currentServiceProviderSid}/PredefinedCarriers/${predefinedCarrierSid}`
);
};
export const postSipGateway = (payload: Partial<SipGateway>) => {
return postFetch<SidResponse, Partial<SipGateway>>(API_SIP_GATEWAY, payload);
};
+1
View File
@@ -299,6 +299,7 @@ export interface Carrier {
export interface PredefinedCarrier extends Carrier {
requires_static_ip: boolean;
predefined_carrier_sid: string;
}
export interface Gateway {