Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: send form request sending undefined form body #966

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/numbers/lib/numbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class Numbers extends Client {
* @param {NumbersSearchFilter} filter - The filter criteria for searching available numbers.
* @return {Promise<NumbersAvailableList>} A promise that resolves to a list of available phone numbers or an error response.
*
* @example
* @example
* Search for available numbers that can send SMS and make voice calls
* ```ts
* import { Country, Feature } from '@vonage/numbers';
Expand Down Expand Up @@ -306,8 +306,14 @@ export class Numbers extends Client {
const resp = await this.sendFormSubmitRequest<NumbersEmptyResponse>(
`${this.config.restHost}/number/update`,
{
country: params.country,
msisdn: params.msisdn,
...(appId ? { app_id: appId } : {}),
...params,
moHttpUrl: params.moHttpUrl,
moSmppSysType: params.moSmppSysType,
voiceCallbackType: params.voiceCallbackType,
voiceCallbackValue: params.voiceCallbackValue,
voiceStatusCallback: params.voiceStatusCallback,
},
);

Expand Down
4 changes: 2 additions & 2 deletions packages/server-client/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,14 @@ export class Client {
*/
async sendFormSubmitRequest<T>(
url: string,
payload?: Record<string, string>,
payload?: Record<string, string | undefined>,
): Promise<VetchResponse<T>> {
const request = {
url,
method: HTTPMethods.POST,
type: ContentType.FORM_URLENCODED,
headers: { Accept: 'application/json' },
...(payload ? { data: payload } : {}),
...JSON.parse(JSON.stringify((payload ? { data: payload } : {}))),
} as VetchOptions;

return await this.sendRequest<T>(request);
Expand Down
Loading