mirror of
https://github.com/jambonz/jambonz-webapp.git
synced 2026-10-26 13:24:34 +00:00
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:
1 parent
781ccb95f2
commit
29cd5a5fa7
3 files changed
+32
-5
No files matched your search
+14
-2
@@ -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);
|
||||
};
|
||||
|
||||
@@ -299,6 +299,7 @@ export interface Carrier {
|
||||
|
||||
export interface PredefinedCarrier extends Carrier {
|
||||
requires_static_ip: boolean;
|
||||
predefined_carrier_sid: string;
|
||||
}
|
||||
|
||||
export interface Gateway {
|
||||
|
||||
Reference in new issue
Block a user