Fixing up the imports and exports

This commit is contained in:
Justin Dalrymple 2017-12-17 15:26:52 -05:00
parent ecdf2391aa
commit 5dedd5a8ea
39 changed files with 296 additions and 302 deletions

View File

@ -1,5 +1,5 @@
const Request = require('request-promise');
const { Groups, Projects, Issues, Runners, Users, Labels } = require('./Models');
import Request from 'request-promise';
import { Groups, Projects, Issues, Runners, Users, Labels } from './Models';
function defaultRequest(url, endpoint, { headers, body, qs, formData, resolveWithFullResponse = false }) {
const params = {
@ -75,5 +75,4 @@ class API {
}
}
module.exports = API;
export default API;

View File

@ -1,4 +1,4 @@
const LinkParser = require('parse-link-header');
import LinkParser from 'parse-link-header';
async function getAllPages(client, endpoint, options, results = []) {
const response = await client.get(endpoint, options, true);
@ -48,4 +48,4 @@ class BaseModel {
}
}
module.exports = BaseModel;
export default BaseModel;

View File

@ -1,18 +1,18 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class GroupProjects extends BaseModel {
all(groupId, options = {}) {
const gId = Utils.parse(groupId);
const gId = parse(groupId);
return this.get(`groups/${gId}/projects`, options);
}
add(groupId, projectId) {
const [gId, pId] = [groupId, projectId].map(Utils.parse);
const [gId, pId] = [groupId, projectId].map(parse);
return this.post(`groups/${gId}/projects/${pId}`);
}
}
module.exports = GroupProjects;
export default GroupProjects;

View File

@ -1,11 +1,10 @@
const BaseModel = require('./BaseModel');
const GroupProjects = require('./GroupProjects');
const ResourceAccessRequests = require('./ResourceAccessRequests');
const ResourceCustomAttributes = require('./ResourceCustomAttributes');
const ResourceMembers = require('./ResourceMembers');
const ResourceMilestones = require('./ResourceMilestones');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import GroupProjects from './GroupProjects';
import ResourceAccessRequests from './ResourceAccessRequests';
import ResourceCustomAttributes from './ResourceCustomAttributes';
import ResourceMembers from './ResourceMembers';
import ResourceMilestones from './ResourceMilestones';
import { parse } from '../Utils';
class Groups extends BaseModel {
constructor(...args) {
@ -23,13 +22,13 @@ class Groups extends BaseModel {
}
allSubgroups(groupId, options = {}) {
const gId = Utils.parse(groupId);
const gId = parse(groupId);
return this.get(`groups/${gId}/subgroups`, options);
}
show(groupId) {
const gId = Utils.parse(groupId);
const gId = parse(groupId);
return this.get(`groups/${gId}`);
}
@ -39,7 +38,7 @@ class Groups extends BaseModel {
}
remove(groupId) {
const gId = Utils.parse(groupId);
const gId = parse(groupId);
return this.delete(`groups/${gId}`);
}
@ -51,4 +50,4 @@ class Groups extends BaseModel {
}
}
module.exports = Groups;
export default Groups;

View File

@ -1,4 +1,4 @@
const BaseModel = require('./BaseModel');
import BaseModel from './BaseModel';
class Issues extends BaseModel {
all(options = {}) {
@ -6,4 +6,4 @@ class Issues extends BaseModel {
}
}
module.exports = Issues;
export default Issues;

View File

@ -1,12 +1,9 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
class MergeRequests extends BaseModel {
all(projectId, options = {}) {
const pId = Utils.parse(projectId);
return this.get(`merge_requests`, options);
return this.get('merge_requests', options);
}
}
module.exports = MergeRequests;
export default MergeRequests;

View File

@ -1,24 +1,24 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class ProjectDeployKeys extends BaseModel {
add(projectId, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.post(`projects/${pId}/deploy_keys`, options);
}
all(projectId) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/deploy_keys`);
}
show(projectId, keyId) {
const [pId, kId] = [projectId, keyId].map(Utils.parse);
const [pId, kId] = [projectId, keyId].map(parse);
return this.get(`projects/${pId}/deploy_keys/${kId}`);
}
}
module.exports = ProjectDeployKeys;
export default ProjectDeployKeys;

View File

@ -1,36 +1,36 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class ProjectHooks extends BaseModel {
all(projectId) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/hooks`);
}
show(projectId, hookId) {
const [pId, hId] = [projectId, hookId].map(Utils.parse);
const [pId, hId] = [projectId, hookId].map(parse);
return this.get(`projects/${pId}/hooks/${hId}`);
}
add(projectId, url, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.post(`projects/${pId}/hooks`, Object.assign({ url }, options));
}
edit(projectId, hookId, url, options = {}) {
const [pId, hId] = [projectId, hookId].map(Utils.parse);
const [pId, hId] = [projectId, hookId].map(parse);
return this.put(`projects/${pId}/hooks/${hId}`, Object.assign({ url }, options));
}
remove(projectId, hookId) {
const [pId, hId] = [projectId, hookId].map(Utils.parse);
const [pId, hId] = [projectId, hookId].map(parse);
return this.delete(`projects/${pId}/hooks/${hId}`);
}
}
module.exports = ProjectHooks;
export default ProjectHooks;

View File

@ -1,6 +1,6 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
const ResourceNotes = require('./ResourceNotes');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
import ResourceNotes from './ResourceNotes';
class ProjectIssues extends BaseModel {
constructor(...args) {
@ -10,53 +10,53 @@ class ProjectIssues extends BaseModel {
}
all(projectId, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/issues`, options);
}
create(projectId, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.post(`projects/${pId}/issues`, options);
}
edit(projectId, issueId, options = {}) {
const [pId, iId] = [projectId, issueId].map(Utils.parse);
const [pId, iId] = [projectId, issueId].map(parse);
return this.put(`projects/${pId}/issues/${iId}`, options);
}
link(projectId, issueIId, targetProjectId, targetIssueId, options = {}) {
const [pId, iId] = [projectId, issueIId].map(Utils.parse);
const [targetpId, targetIId] = [targetProjectId, targetIssueId].map(Utils.parse);
const [pId, iId] = [projectId, issueIId].map(parse);
const [targetpId, targetIId] = [targetProjectId, targetIssueId].map(parse);
return this.post(`projects/${pId}/issues/${iId}/links`, Object.assign({ target_project_id: targetpId, target_issue_id: targetIId }, options));
}
remove(projectId, issueId) {
const [pId, iId] = [projectId, issueId].map(Utils.parse);
const [pId, iId] = [projectId, issueId].map(parse);
return this.delete(`projects/${pId}/issues/${iId}`);
}
show(projectId, issueId) {
const [pId, iId] = [projectId, issueId].map(Utils.parse);
const [pId, iId] = [projectId, issueId].map(parse);
return this.get(`projects/${pId}/issues/${iId}`);
}
subscribe(projectId, issueId, options = {}) {
const [pId, iId] = [projectId, issueId].map(Utils.parse);
const [pId, iId] = [projectId, issueId].map(parse);
return this.post(`projects/${pId}/issues/${iId}/subscribe`, options);
}
unsubscribe(projectId, issueId) {
const [pId, iId] = [projectId, issueId].map(Utils.parse);
const [pId, iId] = [projectId, issueId].map(parse);
return this.delete(`projects/${pId}/issues/${iId}/unsubscribe`);
}
}
module.exports = ProjectIssues;
export default ProjectIssues;

View File

@ -1,42 +1,42 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class ProjectLabels extends BaseModel {
all(projectId, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/labels`, options);
}
create(projectId, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.post(`projects/${pId}/labels`, options);
}
edit(projectId, labelName, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.put(`projects/${pId}/labels`, Object.assign({ name: labelName }, options));
}
remove(projectId, labelName) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.delete(`projects/${pId}/labels`, { name: labelName });
}
subscribe(projectId, labelId, options = {}) {
const [pId, lId] = [projectId, labelId].map(Utils.parse);
const [pId, lId] = [projectId, labelId].map(parse);
return this.post(`projects/${pId}/issues/${lId}/subscribe`, options);
}
unsubscribe(projectId, labelId) {
const [pId, lId] = [projectId, labelId].map(Utils.parse);
const [pId, lId] = [projectId, labelId].map(parse);
return this.delete(`projects/${pId}/issues/${lId}/unsubscribe`);
}
}
module.exports = ProjectLabels;
export default ProjectLabels;

View File

@ -1,12 +1,12 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class ProjectMergeRequestChanges extends BaseModel {
show(projectId, mergerequestId) {
const [pId, mId] = [projectId, mergerequestId].map(Utils.parse);
const [pId, mId] = [projectId, mergerequestId].map(parse);
return this.get(`projects/${pId}/merge_requests/${mId}/changes`);
}
}
module.exports = ProjectMergeRequestChanges;
export default ProjectMergeRequestChanges;

View File

@ -1,12 +1,12 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class ProjectMergeRequestCommits extends BaseModel {
show(projectId, mergerequestId) {
const [pId, mId] = [projectId, mergerequestId].map(Utils.parse);
const [pId, mId] = [projectId, mergerequestId].map(parse);
return this.get(`projects/${pId}/merge_requests/${mId}/commits`);
}
}
module.exports = ProjectMergeRequestCommits;
export default ProjectMergeRequestCommits;

View File

@ -1,18 +1,18 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class ProjectMergeRequestVersions extends BaseModel {
all(projectId, mergerequestId) {
const [pId, mId] = [projectId, mergerequestId].map(Utils.parse);
const [pId, mId] = [projectId, mergerequestId].map(parse);
return this.get(`projects/${pId}/merge_requests/${mId}/versions`);
}
show(projectId, mergerequestId, versionId) {
const [pId, mId, vId] = [projectId, mergerequestId, versionId].map(Utils.parse);
const [pId, mId, vId] = [projectId, mergerequestId, versionId].map(parse);
return this.get(`projects/${pId}/merge_requests/${mId}/versions/${vId}`);
}
}
module.exports = ProjectMergeRequestVersions;
export default ProjectMergeRequestVersions;

View File

@ -1,9 +1,9 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
const ProjectMergeRequestVersions = require('./ProjectMergeRequestVersions');
const ProjectMergeRequestChanges = require('./ProjectMergeRequestChanges');
const ProjectMergeRequestCommits = require('./ProjectMergeRequestCommits');
const ResourceNotes = require('./ResourceNotes');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
import ProjectMergeRequestVersions from './ProjectMergeRequestVersions';
import ProjectMergeRequestChanges from './ProjectMergeRequestChanges';
import ProjectMergeRequestCommits from './ProjectMergeRequestCommits';
import ResourceNotes from './ResourceNotes';
class ProjectMergeRequests extends BaseModel {
constructor(...args) {
@ -16,31 +16,31 @@ class ProjectMergeRequests extends BaseModel {
}
accept(projectId, mergerequestId, options = {}) {
const [pId, mId] = [projectId, mergerequestId].map(Utils.parse);
const [pId, mId] = [projectId, mergerequestId].map(parse);
return this.put(`projects/${pId}/merge_requests/${mId}/merge`, options);
}
all(projectId, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/merge_requests`, options);
}
cancelOnPipelineSucess(projectId, mergerequestId) {
const [pId, mId] = [projectId, mergerequestId].map(Utils.parse);
const [pId, mId] = [projectId, mergerequestId].map(parse);
return this.put(`projects/${pId}/merge_requests/${mId}/cancel_merge_when_pipeline_succeeds`);
}
closesIssues(projectId, mergerequestId) {
const [pId, mId] = [projectId, mergerequestId].map(Utils.parse);
const [pId, mId] = [projectId, mergerequestId].map(parse);
return this.get(`projects/${pId}/merge_requests/${mId}/closes_issues`);
}
create(projectId, sourceBranch, targetBranch, title, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.post(`projects/${pId}/merge_requests`, Object.assign({
id: pId,
@ -51,70 +51,70 @@ class ProjectMergeRequests extends BaseModel {
}
createTodo(projectId, mergerequestId) {
const [pId, mId] = [projectId, mergerequestId].map(Utils.parse);
const [pId, mId] = [projectId, mergerequestId].map(parse);
return this.post(`projects/${pId}/merge_requests/${mId}/todo`);
}
edit(projectId, mergerequestId, options = {}) {
const [pId, mId] = [projectId, mergerequestId].map(Utils.parse);
const [pId, mId] = [projectId, mergerequestId].map(parse);
return this.put(`projects/${pId}/merge_requests/${mId}`, options);
}
remove(projectId, mergerequestId) {
const [pId, mId] = [projectId, mergerequestId].map(Utils.parse);
const [pId, mId] = [projectId, mergerequestId].map(parse);
return this.delete(`projects/${pId}/merge_requests/${mId}`);
}
show(projectId, mergerequestId) {
const [pId, mId] = [projectId, mergerequestId].map(Utils.parse);
const [pId, mId] = [projectId, mergerequestId].map(parse);
return this.get(`projects/${pId}/merge_requests/${mId}`);
}
subscribe(projectId, mergerequestId, options = {}) {
const [pId, mId] = [projectId, mergerequestId].map(Utils.parse);
const [pId, mId] = [projectId, mergerequestId].map(parse);
return this.post(`projects/${pId}/merge_requests/${mId}/subscribe`, options);
}
resetSpentTime(projectId, mergerequestId) {
const [pId, mId] = [projectId, mergerequestId].map(Utils.parse);
const [pId, mId] = [projectId, mergerequestId].map(parse);
return this.post(`projects/${pId}/merge_requests/${mId}/reset_spent_time`);
}
resetTimeEstimate(projectId, mergerequestId) {
const [pId, mId] = [projectId, mergerequestId].map(Utils.parse);
const [pId, mId] = [projectId, mergerequestId].map(parse);
return this.post(`projects/${pId}/merge_requests/${mId}/reset_time_estimate`);
}
spentTime(projectId, mergerequestId, duration) {
const [pId, mId] = [projectId, mergerequestId].map(Utils.parse);
const [pId, mId] = [projectId, mergerequestId].map(parse);
return this.post(`projects/${pId}/merge_requests/${mId}/add_spent_time`, { duration });
}
timeEstimate(projectId, mergerequestId, duration) {
const [pId, mId] = [projectId, mergerequestId].map(Utils.parse);
const [pId, mId] = [projectId, mergerequestId].map(parse);
return this.post(`projects/${pId}/merge_requests/${mId}/time_estimate`, { duration });
}
timeStats(projectId, mergerequestId) {
const [pId, mId] = [projectId, mergerequestId].map(Utils.parse);
const [pId, mId] = [projectId, mergerequestId].map(parse);
return this.get(`projects/${pId}/merge_requests/${mId}/time_stats`);
}
unsubscribe(projectId, mergerequestId) {
const [pId, mId] = [projectId, mergerequestId].map(Utils.parse);
const [pId, mId] = [projectId, mergerequestId].map(parse);
return this.delete(`projects/${pId}/merge_requests/${mId}/unsubscribe`);
}
}
module.exports = ProjectMergeRequests;
export default ProjectMergeRequests;

View File

@ -1,12 +1,12 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class Pipelines extends BaseModel {
all(projectId, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/pipelines`, options);
}
}
module.exports = Pipelines;
export default Pipelines;

View File

@ -1,30 +1,30 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class ProjectProtectedBranches extends BaseModel {
all(projectId) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/protected_branches`);
}
protect(projectId, branchName, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.post(`projects/${pId}/protected_branches`, Object.assign(options, { name: branchName }));
}
show(projectId, branchName) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/protected_branches/${branchName}`);
}
unprotect(projectId, branchName) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.delete(`projects/${pId}/protected_branches/${branchName}`);
}
}
module.exports = ProjectProtectedBranches;
export default ProjectProtectedBranches;

View File

@ -1,9 +1,9 @@
const BaseModel = require('./BaseModel');
const ProjectRepositoryBranches = require('./ProjectRepositoryBranches');
const ProjectRepositoryTags = require('./ProjectRepositoryTags');
const ProjectRepositoryCommits = require('./ProjectRepositoryCommits');
const ProjectRepositoryFiles = require('./ProjectRepositoryFiles');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
import ProjectRepositoryBranches from './ProjectRepositoryBranches';
import ProjectRepositoryTags from './ProjectRepositoryTags';
import ProjectRepositoryCommits from './ProjectRepositoryCommits';
import ProjectRepositoryFiles from './ProjectRepositoryFiles';
class ProjectRepository extends BaseModel {
constructor(...args) {
@ -16,40 +16,40 @@ class ProjectRepository extends BaseModel {
}
compare(projectId, from, to) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/repository/compare`, { from, to });
}
contributors(projectId) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/repository/contributors`);
}
showArchive(projectId, { sha }) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/repository/archive`, { sha });
}
showBlob(projectId, sha) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/repository/blobs/${sha}`);
}
showBlobRaw(projectId, sha) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/repository/blobs/${sha}/raw`);
}
tree(projectId, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/repository/tree`, options);
}
}
module.exports = ProjectRepository;
export default ProjectRepository;

View File

@ -1,42 +1,42 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class ProjectRepositoryBranches extends BaseModel {
all(projectId) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/repository/branches`);
}
create(projectId, branchName, ref) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.post(`projects/${pId}/repository/branches`, { branch: branchName, ref });
}
protect(projectId, branchName, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.put(`projects/${pId}/repository/branches/${branchName}/protect`, options);
}
remove(projectId, branchName) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.delete(`projects/${pId}/repository/branches/${branchName}`);
}
show(projectId, branchName) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/repository/branches/${branchName}`);
}
unprotect(projectId, branchName) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.put(`projects/${pId}/repository/branches/${branchName}/unprotect`);
}
}
module.exports = ProjectRepositoryBranches;
export default ProjectRepositoryBranches;

View File

@ -1,18 +1,18 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class ProjectRepositoryCommitComments extends BaseModel {
all(projectId, sha) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/repository/commits/${sha}/comments`);
}
create(projectId, sha, note, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.post(`projects/${pId}/repository/commits/${sha}/comments`, Object.assign({ note }, options));
}
}
module.exports = ProjectRepositoryCommitComments;
export default ProjectRepositoryCommitComments;

View File

@ -1,6 +1,6 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
const ProjectRepositoryCommitComments = require('./ProjectRepositoryCommitComments');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
import ProjectRepositoryCommitComments from './ProjectRepositoryCommitComments';
class ProjectRepositoryCommits extends BaseModel {
constructor(...args) {
@ -10,28 +10,28 @@ class ProjectRepositoryCommits extends BaseModel {
}
all(projectId) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/repository/commits`);
}
diff(projectId, sha) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/repository/commits/${sha}/diff`);
}
show(projectId, sha) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/repository/commits/${sha}`);
}
statuses(projectId, sha, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/repository/commits/${sha}/statuses`, options);
}
}
module.exports = ProjectRepositoryCommits;
export default ProjectRepositoryCommits;

View File

@ -1,36 +1,36 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class ProjectRepositoryFiles extends BaseModel {
create(projectId, filePath, branch, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.post(`projects/${pId}/repository/files/${filePath}`, Object.assign({ branch }, options));
}
edit(projectId, filePath, branch, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.put(`projects/${pId}/repository/files/${filePath}`, Object.assign({ branch }, options));
}
remove(projectId, filePath, branch, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.delete(`projects/${pId}/repository/files/${filePath}`, Object.assign({ branch }, options));
}
show(projectId, filePath, ref) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/repository/files/${filePath}`, { ref });
}
showRaw(projectId, filePath, ref) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/repository/files/${filePath}/raw`, { ref });
}
}
module.exports = ProjectRepositoryFiles;
export default ProjectRepositoryFiles;

View File

@ -1,30 +1,30 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class ProjectRepositoryTags extends BaseModel {
all(projectId) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/repository/tags`);
}
create(projectId, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.post(`projects/${pId}/repository/tags`, options);
}
remove(projectId, tagName) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.delete(`projects/${pId}/repository/tags/${encodeURI(tagName)}`);
}
show(projectId, tagName) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/repository/tags/${encodeURI(tagName)}`);
}
}
module.exports = ProjectRepositoryTags;
export default ProjectRepositoryTags;

View File

@ -1,15 +1,15 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class ProjectRunners extends BaseModel {
all(projectId, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/runners`, options);
}
enable(projectId, runnerId) {
const [pId, rId] = [projectId, runnerId].map(Utils.parse);
const [pId, rId] = [projectId, runnerId].map(parse);
return this.post(`projects/${pId}/runners`, {
runner_id: rId,
@ -17,10 +17,10 @@ class ProjectRunners extends BaseModel {
}
disable(projectId, runnerId) {
const [pId, rId] = [projectId, runnerId].map(Utils.parse);
const [pId, rId] = [projectId, runnerId].map(parse);
return this.delete(`projects/${pId}/runners/${rId}`);
}
}
module.exports = ProjectRunners;
export default ProjectRunners;

View File

@ -1,24 +1,24 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class ProjectServices extends BaseModel {
edit(projectId, serviceName, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.put(`projects/${pId}/services/${serviceName}`, options);
}
remove(projectId, serviceName) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.delete(`projects/${pId}/services/${serviceName}`);
}
show(projectId, serviceName) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/services/${serviceName}`);
}
}
module.exports = ProjectServices;
export default ProjectServices;

View File

@ -1,36 +1,36 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class ProjectTriggers extends BaseModel {
add(projectId, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.post(`projects/${pId}/triggers`, options);
}
all(projectId) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}/triggers`);
}
edit(projectId, triggerId, options = {}) {
const [pId, tId] = [projectId, triggerId].map(Utils.parse);
const [pId, tId] = [projectId, triggerId].map(parse);
return this.put(`projects/${pId}/triggers/${tId}`, options);
}
remove(projectId, triggerId) {
const [pId, tId] = [projectId, triggerId].map(Utils.parse);
const [pId, tId] = [projectId, triggerId].map(parse);
return this.delete(`projects/${pId}/triggers/${tId}`);
}
show(projectId, triggerId) {
const [pId, tId] = [projectId, triggerId].map(Utils.parse);
const [pId, tId] = [projectId, triggerId].map(parse);
return this.get(`projects/${pId}/triggers/${tId}`);
}
}
module.exports = ProjectTriggers;
export default ProjectTriggers;

View File

@ -1,23 +1,23 @@
const Fs = require('fs');
const Path = require('path');
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
const ProjectHooks = require('./ProjectHooks');
const ProjectIssues = require('./ProjectIssues');
const ProjectLabels = require('./ProjectLabels');
const ProjectRepository = require('./ProjectRepository');
const ProjectProtectedBranches = require('./ProjectProtectedBranches');
const ProjectDeployKeys = require('./ProjectDeployKeys');
const ProjectMergeRequests = require('./ProjectMergeRequests');
const ProjectServices = require('./ProjectServices');
const ProjectTriggers = require('./ProjectTriggers');
const ProjectRunners = require('./ProjectRunners');
const ProjectPipelines = require('./ProjectPipelines');
const ResourceCustomAttributes = require('./ResourceCustomAttributes');
const ResourceMembers = require('./ResourceMembers');
const ResourceAccessRequests = require('./ResourceAccessRequests');
const ResourceMilestones = require('./ResourceMilestones');
const ResourceNotes = require('./ResourceNotes');
import Fs from 'fs';
import Path from 'path';
import BaseModel from './BaseModel';
import { parse } from '../Utils';
import ProjectHooks from './ProjectHooks';
import ProjectIssues from './ProjectIssues';
import ProjectLabels from './ProjectLabels';
import ProjectRepository from './ProjectRepository';
import ProjectProtectedBranches from './ProjectProtectedBranches';
import ProjectDeployKeys from './ProjectDeployKeys';
import ProjectMergeRequests from './ProjectMergeRequests';
import ProjectServices from './ProjectServices';
import ProjectTriggers from './ProjectTriggers';
import ProjectRunners from './ProjectRunners';
import ProjectPipelines from './ProjectPipelines';
import ResourceCustomAttributes from './ResourceCustomAttributes';
import ResourceMembers from './ResourceMembers';
import ResourceAccessRequests from './ResourceAccessRequests';
import ResourceMilestones from './ResourceMilestones';
import ResourceNotes from './ResourceNotes';
class Projects extends BaseModel {
@ -48,7 +48,7 @@ class Projects extends BaseModel {
create(options = {}) {
if (options.userId) {
const uId = Utils.parse(options.userId);
const uId = parse(options.userId);
return this.post(`projects/user/${uId}`, options);
}
@ -57,19 +57,19 @@ class Projects extends BaseModel {
}
edit(projectId, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.put(`projects/${pId}`, options);
}
fork(projectId, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.post(`projects/${pId}/fork`, options);
}
remove(projectId) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.delete(`projects/${pId}`);
}
@ -79,7 +79,7 @@ class Projects extends BaseModel {
}
share(projectId, groupId, groupAccess, options) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
if (!groupId || !groupAccess) throw new Error('Missing required arguments');
@ -90,37 +90,37 @@ class Projects extends BaseModel {
}
show(projectId) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.get(`projects/${pId}`);
}
star(projectId) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.post(`projects/${pId}/star`);
}
statuses(projectId, sha, state, options = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.post(`projects/${pId}/statuses/${sha}`, Object.assign({ state }, options));
}
unshare(projectId, groupId) {
const [pId, gId] = [projectId, groupId].map(Utils.parse);
const [pId, gId] = [projectId, groupId].map(parse);
return this.delete(`projects/${pId}/share${gId}`);
}
unstar(projectId) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
return this.post(`projects/${pId}/unstar`);
}
upload(projectId, filePath, { fileName = Path.basename(filePath) } = {}) {
const pId = Utils.parse(projectId);
const pId = parse(projectId);
const file = Fs.readFileSync(filePath);
return this.postForm(`projects/${pId}/uploads`, {

View File

@ -1,5 +1,5 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
const ACCESS_LEVELS = {
GUEST: 10,
@ -10,7 +10,7 @@ const ACCESS_LEVELS = {
};
class ResourceAccessRequests extends BaseModel {
constructor(resourceType, ...args){
constructor(resourceType, ...args) {
super(...args);
this.resourceType = resourceType;
@ -18,28 +18,28 @@ class ResourceAccessRequests extends BaseModel {
}
all(resourceId) {
const rId = Utils.parse(resourceId);
const rId = parse(resourceId);
return this.get(`${this.resourceType}/${rId}/access_requests`);
}
request(resourceId) {
const rId = Utils.parse(resourceId);
const rId = parse(resourceId);
return this.post(`${this.resourceType}/${rId}/access_requests`);
}
approve(resourceId, userId, { access_level = 30 }) {
const [rId, uId] = [resourceId, userId].map(Utils.parse);
const [rId, uId] = [resourceId, userId].map(parse);
return this.post(`${this.resourceType}/${rId}/access_requests/${uId}/approve`, { access_level });
}
deny(resourceId, userId) {
const [rId, uId] = [resourceId, userId].map(Utils.parse);
const [rId, uId] = [resourceId, userId].map(parse);
return this.delete(`${this.resourceType}/${rId}/access_requests/${uId}/approve`);
}
}
module.exports = ResourceAccessRequests;
export default ResourceAccessRequests;

View File

@ -1,5 +1,5 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class ResourceCustomAttributes extends BaseModel {
constructor(resourceType, ...args) {
@ -9,28 +9,28 @@ class ResourceCustomAttributes extends BaseModel {
}
all(resourceId) {
const rId = Utils.parse(resourceId);
const rId = parse(resourceId);
return this.get(`${this.resourceType}/${rId}/custom_attributes`);
}
set(resourceId, customAttributeId, value) {
const [rId, cId] = [resourceId, customAttributeId].map(Utils.parse);
const [rId, cId] = [resourceId, customAttributeId].map(parse);
return this.put(`${this.resourceType}/${rId}/custom_attributes/${cId}`, { value });
}
remove(resourceId, customAttributeId) {
const [rId, cId] = [resourceId, customAttributeId].map(Utils.parse);
const [rId, cId] = [resourceId, customAttributeId].map(parse);
return this.delete(`${this.resourceType}/${rId}/members/${cId}`);
}
show(resourceId, customAttributeId) {
const [rId, cId] = [resourceId, customAttributeId].map(Utils.parse);
const [rId, cId] = [resourceId, customAttributeId].map(parse);
return this.get(`${this.resourceType}/${rId}/members/${cId}`);
}
}
module.exports = ResourceCustomAttributes;
export default ResourceCustomAttributes;

View File

@ -1,5 +1,5 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class ResourceMembers extends BaseModel {
constructor(resourceType, ...args) {
@ -9,13 +9,13 @@ class ResourceMembers extends BaseModel {
}
all(resourceId) {
const rId = Utils.parse(resourceId);
const rId = parse(resourceId);
return this.get(`${this.resourceType}/${rId}/members`);
}
add(resourceId, userId, accessLevel) {
const [rId, uId] = [resourceId, userId].map(Utils.parse);
const [rId, uId] = [resourceId, userId].map(parse);
return this.post(`${this.resourceType}/${rId}/members`, {
user_id: uId,
@ -24,7 +24,7 @@ class ResourceMembers extends BaseModel {
}
edit(resourceId, userId, accessLevel) {
const [rId, uId] = [resourceId, userId].map(Utils.parse);
const [rId, uId] = [resourceId, userId].map(parse);
return this.put(`${this.resourceType}/${rId}/members/${uId}`, {
access_level: parseInt(accessLevel, 10),
@ -32,16 +32,16 @@ class ResourceMembers extends BaseModel {
}
show(resourceId, userId) {
const [rId, uId] = [resourceId, userId].map(Utils.parse);
const [rId, uId] = [resourceId, userId].map(parse);
return this.get(`${this.resourceType}/${rId}/members/${uId}`);
}
remove(resourceId, userId) {
const [rId, uId] = [resourceId, userId].map(Utils.parse);
const [rId, uId] = [resourceId, userId].map(parse);
return this.delete(`${this.resourceType}/${rId}/members/${uId}`);
}
}
module.exports = ResourceMembers;
export default ResourceMembers;

View File

@ -1,5 +1,5 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class GroupMilestoneIssues extends BaseModel {
constructor(resourceType, ...args) {
@ -9,10 +9,10 @@ class GroupMilestoneIssues extends BaseModel {
}
all(resourceId, milestoneId) {
const [rId, mId] = [resourceId, milestoneId].map(Utils.parse);
const [rId, mId] = [resourceId, milestoneId].map(parse);
return this.get(`${this.resourceType}/${rId}/milestones/${mId}/issues`);
}
}
module.exports = GroupMilestoneIssues;
export default GroupMilestoneIssues;

View File

@ -1,5 +1,5 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class ResourceMilestoneMergeRequests extends BaseModel {
constructor(resourceType, ...args) {
@ -9,10 +9,10 @@ class ResourceMilestoneMergeRequests extends BaseModel {
}
all(resourceId, milestoneId) {
const [rId, mId] = [resourceId, milestoneId].map(Utils.parse);
const [rId, mId] = [resourceId, milestoneId].map(parse);
return this.get(`${this.resourceType}/${rId}/milestones/${mId}/merge_requests`);
}
}
module.exports = ResourceMilestoneMergeRequests;
export default ResourceMilestoneMergeRequests;

View File

@ -1,8 +1,7 @@
const BaseModel = require('./BaseModel');
const ResourceMilestoneIssues = require('./GroupMilestoneIssues');
const ResourceMilestoneMergeRequests = require('./GroupMilestoneMergeRequests');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
import ResourceMilestoneIssues from './ResourceMilestoneIssues';
import ResourceMilestoneMergeRequests from './ResourceMilestoneMergeRequests';
class ResourceMilestones extends BaseModel {
constructor(resourceType, ...args) {
@ -14,28 +13,28 @@ class ResourceMilestones extends BaseModel {
}
all(resourceId, options = {}) {
const rId = Utils.parse(resourceId);
const rId = parse(resourceId);
return this.get(`${this.resourceType}/${rId}/milestones`, options);
}
create(resourceId, title, options) {
const rId = Utils.parse(resourceId);
const rId = parse(resourceId);
return this.post(`${this.resourceType}/${rId}/milestones`, options);
}
edit(resourceId, milestoneId, options) {
const [rId, mId] = [resourceId, milestoneId].map(Utils.parse);
const [rId, mId] = [resourceId, milestoneId].map(parse);
return this.put(`${this.resourceType}/${rId}/milestones/${mId}`, options);
}
show(resourceId, milestoneId) {
const [rId, mId] = [resourceId, milestoneId].map(Utils.parse);
const [rId, mId] = [resourceId, milestoneId].map(parse);
return this.get(`${this.resourceType}/${rId}/milestones/${mId}`);
}
}
module.exports = ResourceMilestones;
export default ResourceMilestones;

View File

@ -1,8 +1,8 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class ResourceNotes extends BaseModel {
constructor(resourceType, resource2Type, ...args){
constructor(resourceType, resource2Type, ...args) {
super(...args);
this.resourceType = resourceType;
@ -10,38 +10,38 @@ class ResourceNotes extends BaseModel {
}
all(resourceId, resource2Id, options = {}) {
const [rId, r2Id] = [resourceId, issueIId].map(Utils.parse);
const [rId, r2Id] = [resourceId, resource2Id].map(parse);
return this.get(`${this.resourceType}/${rId}/${this.resource2Type}/${r2Id}/notes`, options);
}
create(resourceId, issueIId, options = {}) {
create(resourceId, resource2Id, options = {}) {
if (!options.body) throw new Error('Missing required property: body');
const [rId, r2Id] = [resourceId, issueIId].map(Utils.parse);
const [rId, r2Id] = [resourceId, resource2Id].map(parse);
return this.post(`${this.resourceType}/${rId}/${this.resource2Type}/${r2Id}/notes`, options);
}
edit(resourceId, issueIId, noteId, options = {}) {
edit(resourceId, resource2Id, noteId, options = {}) {
if (!options.body) throw new Error('Missing required property: body');
const [rId, r2Id, nId] = [resourceId, issueIId, noteId].map(Utils.parse);
const [rId, r2Id, nId] = [resourceId, resource2Id, noteId].map(parse);
return this.put(`${this.resourceType}/${rId}/${this.resource2Type}/${r2Id}/notes/${nId}`, options);
}
remove(resourceId, issueIId, noteId) {
const [rId, r2Id, nId] = [resourceId, issueIId, noteId].map(Utils.parse);
remove(resourceId, resource2Id, noteId) {
const [rId, r2Id, nId] = [resourceId, resource2Id, noteId].map(parse);
return this.delete(`${this.resourceType}/${rId}/${this.resource2Type}/${r2Id}/notes/${nId}`);
}
show(resourceId, issueIId, noteId) {
const [rId, r2Id, nId] = [resourceId, issueIId, noteId].map(Utils.parse);
show(resourceId, resource2Id, noteId) {
const [rId, r2Id, nId] = [resourceId, resource2Id, noteId].map(parse);
return this.get(`${this.resourceType}/${rId}/${this.resource2Type}/${r2Id}/notes/${nId}`);
}
}
module.exports = ResourceNotes;
export default ResourceNotes;

View File

@ -1,5 +1,5 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class Runners extends BaseModel {
all(options = {}) {
@ -11,28 +11,28 @@ class Runners extends BaseModel {
}
edit(runnerId, attributes) {
const rId = Utils.parse(runnerId);
const rId = parse(runnerId);
return this.put(`runners/${rId}`, attributes);
}
remove(runnerId) {
const rId = Utils.parse(runnerId);
const rId = parse(runnerId);
return this.delete(`runners/${rId}`);
}
show(runnerId) {
const rId = Utils.parse(runnerId);
const rId = parse(runnerId);
return this.get(`runners/${rId}`);
}
showJobs(runnerId) {
const rId = Utils.parse(runnerId);
const rId = parse(runnerId);
return this.get(`runners/${rId}/jobs`);
}
}
module.exports = Runners;
export default Runners;

View File

@ -1,21 +1,21 @@
const BaseModel = require('./BaseModel');
const Utils = require('../Utils');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
class UserKeys extends BaseModel {
all(userId) {
const uId = Utils.parse(userId);
return this.get(`users/${uId}/keys`);
}
add(userId, title, key) {
const uId = Utils.parse(userId);
const uId = parse(userId);
return this.post(`users/${uId}/keys`, {
title,
key,
});
}
all(userId) {
const uId = parse(userId);
return this.get(`users/${uId}/keys`);
}
}
module.exports = UserKeys;
export default UserKeys;

View File

@ -1,7 +1,7 @@
const BaseModel = require('./BaseModel');
const UserKeys = require('./UserKeys');
const Utils = require('../Utils');
const ResourceCustomAttributes = require('./ResourceCustomAttributes');
import BaseModel from './BaseModel';
import { parse } from '../Utils';
import UserKeys from './UserKeys';
import ResourceCustomAttributes from './ResourceCustomAttributes';
class Users extends BaseModel {
constructor(...args) {
@ -37,10 +37,10 @@ class Users extends BaseModel {
}
show(userId) {
const uId = Utils.parse(userId);
const uId = parse(userId);
return this.get(`users/${uId}`);
}
}
module.exports = Users;
export default Users;

View File

@ -1,11 +1,11 @@
const Groups = require('./Groups');
const Projects = require('./Projects');
const Issues = require('./Issues');
const Users = require('./Users');
const Runners = require('./Runners');
const MergeRequests = require('./MergeRequests');
import Groups from './Groups';
import Projects from './Projects';
import Issues from './Issues';
import Users from './Users';
import Runners from './Runners';
import MergeRequests from './MergeRequests';
module.exports = {
export {
Groups,
Projects,
Runners,

View File

@ -5,6 +5,6 @@ function parse(value) {
return parseInt(value, 10);
}
module.exports = {
export default {
parse,
};

View File

@ -1,3 +1,3 @@
const API = require('./API');
import API from './API';
module.exports = ({ url, token, oauthToken }) => new API({ url, token, oauthToken });
export default ({ url, token, oauthToken }) => new API({ url, token, oauthToken });