Skip to content

Commit

Permalink
refactor: Expose optional parameters for the NotiicationSettings API
Browse files Browse the repository at this point in the history
The NotificationSettings API was missing optional parameters in its function headers.

BREAKING CHANGE: NotificationSettings API edit function now takes one parameter, `options`
  • Loading branch information
jdalrymple committed May 25, 2019
1 parent 46a541b commit 1ba9126
Showing 1 changed file with 12 additions and 42 deletions.
54 changes: 12 additions & 42 deletions src/services/NotificationSettings.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
import { RequestOptions } from '../infrastructure/RequestHelper';

const LEVELS = {
DISABLED: 'disabled',
PARTICIPATING: 'participating',
WATCH: 'watch',
GLOBAL: 'global',
MENTION: 'mention',
CUSTOM: 'custom',
};

const EVENTS = {
NEW_NOTE: 'new_note',
NEW_ISSUE: 'new_issue',
REOPEM_ISSUE: 'reopen_issue',
CLOSE_ISSUE: 'close_issue',
REASSIGN_ISSUE: 'reassign_issue',
NEW_MERGE_REQUESTS: 'new_merge_request',
PUSH_TO_MERGE_REQUEST: 'push_to_merge_request',
REOPEN_MERGE_REQUESTS: 'reopen_merge_request',
CLOSE_MERGE_REQUEST: 'close_merge_request',
REASSIGN_MERGE_REQUEST: 'reassign_merge_request',
MERGE_MERGE_REQUEST: 'merge_merge_request',
FAILED_PIPELINE: 'failed_pipeline',
SUCCESS_PIPELINE: 'success_pipeline',
};
interface NotificationSettingsOptions {
projectId?: ProjectId;
groupId?: string;
}
class NotificationSettings extends BaseService {
protected LEVELS: typeof LEVELS;
protected EVENTS: typeof EVENTS;
constructor(baseParams: BaseModelContructorOptions) {
super(baseParams);

this.LEVELS = LEVELS;
this.EVENTS = EVENTS;
}

all({ projectId, groupId }: NotificationSettingsOptions = {}) {
all({
projectId,
groupId,
...options
}: ({ projectId: ProjectId } | { groupId: GroupId }) & PaginatedRequestOptions) {
let url = '';

if (projectId) {
Expand All @@ -49,10 +14,15 @@ class NotificationSettings extends BaseService {
url += `groups/${encodeURIComponent(groupId)}/`;
}

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

edit(options: RequestOptions, { projectId, groupId }: NotificationSettingsOptions = {}) {
edit({
projectId,
groupId,
...options
}: { level?: NotificationSettingLevel } & ({ projectId: ProjectId } | { groupId: GroupId }) &
BaseRequestOptions) {
let url = '';

if (projectId) {
Expand Down

0 comments on commit 1ba9126

Please sign in to comment.