Skip to content

Commit

Permalink
fix: ResourceAwardEmojis API wasn't properly filtering based on awardId
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalrymple committed Oct 12, 2018
1 parent e9c8bb8 commit 70f4315
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/templates/ResourceAwardEmojis.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import URLJoin from 'url-join';
import { BaseService, RequestHelper } from '../infrastructure';

function url(projectId, resourceType, resourceId, noteId) {
function url(projectId, resourceType, resourceId, awardId, noteId) {
const [pId, rId] = [projectId, resourceId].map(encodeURIComponent);
let output = `${pId}/${resourceType}/${rId}/`;

if (noteId) {
output += `notes/${encodeURIComponent(noteId)}/`;
}
if (noteId) output += `notes/${encodeURIComponent(noteId)}/`;

output += 'award_emoji';

if (awardId) output += `/${encodeURIComponent(awardId)}/`;

return output;
}

Expand All @@ -24,22 +24,25 @@ class ResourceAwardsEmojis extends BaseService {
this.resourceType = resourceType;
}

all(projectId, resourceId, options, noteId) {
return RequestHelper.get(this, url(projectId, this.resourceType, resourceId, noteId), options);
all(projectId, resourceId, noteId) {
return RequestHelper.get(this, url(projectId, this.resourceType, resourceId, null, noteId));
}

award(projectId, resourceId, name, noteId) {
return RequestHelper.post(this, url(projectId, this.resourceType, resourceId, noteId), {
return RequestHelper.post(this, url(projectId, this.resourceType, resourceId, null, noteId), {
name,
});
}

remove(projectId, resourceId, awardId, noteId) {
return RequestHelper.delete(this, url(projectId, this.resourceType, resourceId, noteId));
return RequestHelper.delete(
this,
url(projectId, this.resourceType, resourceId, awardId, noteId),
);
}

show(projectId, resourceId, awardId, noteId) {
return RequestHelper.get(this, url(projectId, this.resourceType, resourceId, noteId));
return RequestHelper.get(this, url(projectId, this.resourceType, resourceId, awardId, noteId));
}
}

Expand Down

0 comments on commit 70f4315

Please sign in to comment.