Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Events integration #64

Merged
merged 13 commits into from
Dec 9, 2017
Merged

Events integration #64

merged 13 commits into from
Dec 9, 2017

Conversation

svenpopping
Copy link
Member

@svenpopping svenpopping commented Nov 27, 2017

Fixes #63

Description

Integration between Events and Payments.

Todos

  • Tests
  • Documentation
  • Fix build

Steps to Test or Reproduce

Run the tests.

@svenpopping svenpopping changed the title Fb events integration Events integration Nov 27, 2017
@svenpopping svenpopping requested a review from skamoen November 27, 2017 11:04
*/
private void changeProductCommittee(Product product, ProductEventsSync productEventsSync) {
CommitteeEnum committeeEnum = CommitteeEnum.valueOf(productEventsSync.getOrganizedBy());
int year = 2017;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be dynamic!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue #65

Copy link

@skamoen skamoen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this implementation is very specific for CH Events, the code looks good and is simple enough to maintain. I'd prefer a more generic product creation API with managed tokens for access, but I also think this is good enough while CH Events is the only system actually using this. It's also easy enough to modify when another service is going to this later on.

Some small requested changes in the comments, and I'm missing a test for the edit functionality

}

switch (productEventsSync.getTrigger()) {
case "PRODUCT_CREATE_EDIT":
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's turn magic strings into Enums?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix in af590d2


switch (productEventsSync.getTrigger()) {
case "PRODUCT_CREATE_EDIT":
this.determineCreateOrUpdate(productEventsSync);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're not determining anything, you're creating or updating it. createOrUpdate() works just fine here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix in commit b9e45db


@PostMapping("/product/")
public ResponseEntity<?> eventSync(HttpServletRequest request, @RequestBody ProductEventsSync productEventsSync) {
String[] credentials = this.decryptBasicAuthHeader(request.getHeader("Authorization"));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels ugly, but it's quick and effective I guess... I'd prefer a more native Spring way using filters and an in-memory events user.

return createResponseEntity(HttpStatus.BAD_REQUEST, "Events trigger not supported!", null);
}

return createResponseEntity(HttpStatus.OK, null, null);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be more specific, with HttpStatus.CREATED when a new product is created

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a HttpStatus.OK, otherwise CH events thinks the sync failed.

@svenpopping
Copy link
Member Author

The implementation should be specific for CH Events. Because it should be an endpoint which Events call when something has been changed.

@svenpopping
Copy link
Member Author

testCreateProductSyncUpdate() tests the edit functionality

@skamoen skamoen merged commit d65a975 into master Dec 9, 2017
@skamoen skamoen deleted the fb_events-integration branch December 9, 2017 15:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants