Skip to content

Commit 122a205

Browse files
committed
feat: add GET /lineitems/:id
1 parent 1461aee commit 122a205

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/main/java/org/apereo/openlrw/oneroster/endpoint/LineItemController.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,16 @@ public LineItemController(LineItemService lineItemService, MongoClassMappingRepo
4040
* @throws IllegalArgumentException
4141
*/
4242
@RequestMapping(method = RequestMethod.GET)
43-
public Collection<MongoLineItem> getUsers(JwtAuthenticationToken token) throws IllegalArgumentException {
43+
public Collection<MongoLineItem> getLineItems(JwtAuthenticationToken token) throws IllegalArgumentException {
4444
UserContext userContext = (UserContext) token.getPrincipal();
4545
return lineItemService.findAll(userContext.getTenantId(), userContext.getOrgId());
4646
}
4747

48+
@RequestMapping(value = "/{lineItemId:.+}", method = RequestMethod.GET)
49+
public MongoLineItem getLineItem(JwtAuthenticationToken token, @PathVariable("lineItemId") final String lineItemId) throws IllegalArgumentException {
50+
UserContext userContext = (UserContext) token.getPrincipal();
51+
return lineItemService.findById(userContext.getTenantId(), userContext.getOrgId(), lineItemId);
52+
}
4853

4954
/**
5055
* POST /api/lineitems

src/main/java/org/apereo/openlrw/oneroster/service/LineItemService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ public Collection<LineItem> getLineItemsForClass(final String tenantId, final St
6565
throw new LineItemNotFoundException("Line item not found");
6666
}
6767

68+
public MongoLineItem findById(final String tenantId, final String orgId, final String lineItemId) throws LineItemNotFoundException {
69+
MongoLineItem mongoLineItem = mongoLineItemRepository.findByTenantIdAndOrgIdAndLineItemSourcedId(tenantId, orgId, lineItemId);
70+
return mongoLineItem;
71+
}
72+
6873
public Collection<MongoLineItem> findAll(final String tenantId, final String orgId) throws IllegalArgumentException {
6974
if (StringUtils.isBlank(tenantId) || StringUtils.isBlank(orgId))
7075
throw new IllegalArgumentException();

0 commit comments

Comments
 (0)