Last active
September 25, 2015 14:22
-
-
Save javi830810/e4c726ddea5e53c29666 to your computer and use it in GitHub Desktop.
Publish Action
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
public class ObjectTransformAction: IMapTransformAction | |
{ | |
public object Transform(object input) | |
{ | |
//What do you do here?.... | |
} | |
} |
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
public IPipeline GetPipelineForMessage(EventMessage message) | |
{ | |
return new LinearPipeline () { | |
Actions = new List<IAction> () { | |
new JF.JotFormAPIAction () { }, | |
new WebhookPublishAction () { | |
MessageType = "JotFormFullMessage", | |
Bus = this.container.Resolve<IBus> (), | |
WebhookStore = container.Resolve<IWebhookStore> (), | |
} | |
} | |
}; | |
} |
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
public class WebhookPublishAction: IVoidAction | |
{ | |
public string MessageType { get; set; } | |
public IWebhookStore WebhookStore { get; set; } | |
public IBus Bus { get; set; } | |
public void Execute (object input) | |
{ | |
foreach(var webhook in WebhookStore.QueryByEventType(this.MessageType)) | |
{ | |
var body = string.Empty; | |
if (input != null && webhook.BodyTemplate != null) | |
{ | |
body = new MapTransformAction () { | |
OutputMessageTemplate = webhook.BodyTemplate | |
}.Transform((IDictionary)input); | |
} | |
Bus.Send ("ScaleBridge.Publisher", new SubmitViaHttpCommand () { | |
Url = webhook.Url, | |
Method = webhook.Method, | |
Headers = webhook.Headers, | |
Body = body | |
}); | |
} | |
} | |
} |
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
public class TemplateMapTransformAction: IMapTransformAction | |
{ | |
public ITemplate OutputMessageTemplate { get; set; } | |
public string Transform(IDictionary input) | |
{ | |
//No other Transformation happens at this level | |
return OutputMessageTemplate.Fill(input); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment