Created
August 29, 2013 10:41
-
-
Save tfennelly/6376596 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.foxweave.mocksaas; | |
import com.cloudbees.weave.api.webhook.WEAVEHook; | |
import com.foxweave.mocksaas.model.Contact; | |
import javax.inject.Inject; | |
import javax.ws.rs.Consumes; | |
import javax.ws.rs.POST; | |
import javax.ws.rs.Path; | |
import javax.ws.rs.Produces; | |
@Path("/contacts") | |
@Produces("application/json") | |
@Consumes("application/json") | |
public class ContactService { | |
private WEAVEHook contactWeaveHook = new WEAVEHook(); | |
/** | |
* HOOK/UNHOOK a "contact" Webhook. | |
* @param webhookDirective The Webhook directive. | |
*/ | |
@POST | |
@Path("/webhook") | |
public void webhook(String webhookDirective) { | |
contactWeaveHook.hook(webhookDirective); | |
} | |
/** | |
* Receive a "contact" CREATED event from a WEAVE@cloud integration. | |
* @param contact The contact JSON bound into a Contact object. | |
*/ | |
@POST | |
@Path("/created") | |
public void created(Contact contact) { | |
System.out.println("Contact added in source system: [" + contact + "]."); | |
// Do some business "stuff" ... | |
// Publish a "contact" notification to any WEAVE@cloud apps that have registered | |
// interest (via a Webhook) in contact CREATED events... | |
contactWeaveHook.created(contact); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment