Skip to content

Commit

Permalink
fix(gitbeaker-core): 🐛 Notification Settings API special PUT requests
Browse files Browse the repository at this point in the history
The Notification Settings API requires the HTTP arguments to be sent in a query parameter instead of a body parameter for the PUT request.
  • Loading branch information
jdalrymple committed Feb 2, 2020
1 parent 2e9e580 commit 6c748ec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { formatQuery } from '@gitbeaker/requester-utils';
import {
BaseRequestOptions,
BaseService,
Expand All @@ -13,12 +14,11 @@ type NotificationSettingLevel =
| 'mention'
| 'custom';

type ProjectOrGroup = { projectId: string | number } | { groupId: string | number } | {};

export class NotificationSettings extends BaseService {
all({
projectId,
groupId,
...options
}: ({ projectId: string | number } | { groupId: string | number }) & PaginatedRequestOptions) {
all({ projectId, groupId, sudo, ...query }: ProjectOrGroup & PaginatedRequestOptions = {}) {
const q = formatQuery(query);
let url = '';

if (projectId) {
Expand All @@ -27,18 +27,16 @@ export class NotificationSettings extends BaseService {
url += `groups/${encodeURIComponent(groupId)}/`;
}

return RequestHelper.get(this, `${url}notification_settings`, options);
return RequestHelper.get(this, `${url}notification_settings?${q}`, { sudo });
}

edit({
projectId,
groupId,
...options
}: { level?: NotificationSettingLevel } & (
| { projectId: string | number }
| { groupId: string | number }
) &
BaseRequestOptions) {
sudo,
...query
}: { level?: NotificationSettingLevel } & ProjectOrGroup & BaseRequestOptions = {}) {
const q = formatQuery(query);
let url = '';

if (projectId) {
Expand All @@ -47,6 +45,6 @@ export class NotificationSettings extends BaseService {
url += `groups/${encodeURIComponent(groupId)}/`;
}

return RequestHelper.put(this, `${url}notification_settings`, options);
return RequestHelper.put(this, `${url}notification_settings?${q}`, { sudo });
}
}
2 changes: 1 addition & 1 deletion packages/gitbeaker-core/src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export * from './License';
export * from './LicenceTemplates';
export * from './Lint';
export * from './Namespaces';
// export * from './NotificationSettings';
export * from './NotificationSettings';
export * from './Markdown';
export * from './PagesDomains';
export * from './Search';
Expand Down

0 comments on commit 6c748ec

Please sign in to comment.