Skip to content

Commit

Permalink
fix(notification-service): adds PATCH notification APIs (#213)
Browse files Browse the repository at this point in the history
RFIT-1632
  • Loading branch information
vineet-suri authored May 19, 2021
1 parent 948cef3 commit 2c20508
Showing 1 changed file with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
getWhereSchemaFor,
HttpErrors,
param,
patch,
post,
requestBody,
} from '@loopback/rest';
Expand Down Expand Up @@ -186,6 +187,58 @@ export class NotificationController {
return this.notificationRepository.findById(id);
}

@authenticate(STRATEGY.BEARER, {
passReqToCallback: true,
})
@authorize({permissions: [PermissionKey.UpdateNotification]})
@patch(basePath, {
responses: {
[STATUS_CODE.OK]: {
description: 'Notification PATCH success count',
content: {[CONTENT_TYPE.JSON]: {schema: CountSchema}},
},
},
})
async updateAll(
@requestBody({
content: {
[CONTENT_TYPE.JSON]: {
schema: getModelSchemaRef(Notification, {partial: true}),
},
},
})
notification: Notification,
@param.query.object('where', getWhereSchemaFor(Notification))
where?: Where<Notification>,
): Promise<Count> {
return this.notificationRepository.updateAll(notification, where);
}

@authenticate(STRATEGY.BEARER, {
passReqToCallback: true,
})
@authorize({permissions: [PermissionKey.UpdateNotification]})
@patch(`${basePath}/{id}`, {
responses: {
'204': {
description: 'Notification PATCH success',
},
},
})
async updateById(
@param.path.string('id') id: string,
@requestBody({
content: {
[CONTENT_TYPE.JSON]: {
schema: getModelSchemaRef(Notification, {partial: true}),
},
},
})
notification: Notification,
): Promise<void> {
await this.notificationRepository.updateById(id, notification);
}

@authenticate(STRATEGY.BEARER)
@authorize({permissions: [PermissionKey.DeleteNotification]})
@del(basePath, {
Expand Down

0 comments on commit 2c20508

Please sign in to comment.