gitbeaker/src/services/PushRule.ts
Daniel Rose da1a8f6a63 fix: Make package Typescript-conformant
Remove the typings directory.
Declare and use the types/interfaces in the various index.ts files.
This will produce a package that can be used by Typescript without
errors.

Remove the typings directory. Declare and use the types/interfaces in the various index.ts files.

This will produce a package that can be used by Typescript without errors.
2019-06-12 15:06:00 +02:00

40 lines
1.1 KiB
TypeScript

import { BaseService, RequestHelper, BaseRequestOptions, Sudo } from '../infrastructure';
import { ProjectId } from '.';
class PushRule extends BaseService {
create(projectId: ProjectId, options?: BaseRequestOptions) {
const pId = encodeURIComponent(projectId);
return RequestHelper.post(this, `projects/${pId}/push_rule`, options);
}
edit(
projectId: ProjectId,
{ upsert = false, ...options }: { upsert: boolean } & BaseRequestOptions,
) {
const pId = encodeURIComponent(projectId);
try {
return RequestHelper.put(this, `projects/${pId}/push_rule`, options);
} catch (e) {
if (e.message.includes('exist')) return this.create(projectId, options);
throw e;
}
}
remove(projectId: ProjectId, options?: Sudo) {
const pId = encodeURIComponent(projectId);
return RequestHelper.del(this, `projects/${pId}/push_rule`, options);
}
show(projectId: ProjectId, options?: Sudo) {
const pId = encodeURIComponent(projectId);
return RequestHelper.get(this, `projects/${pId}/push_rule`, options);
}
}
export default PushRule;