Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

Hook Data Templates #4

Open
lylepratt opened this issue Nov 21, 2013 · 3 comments
Open

Hook Data Templates #4

lylepratt opened this issue Nov 21, 2013 · 3 comments

Comments

@lylepratt
Copy link

Hi!

We've been thinking about our shiny new RestHooks and thought that it would be neat if there was another column in the Hooks table that let you define an option "template" for the hook data if the hook destination needed it in an alternative format.

Very Simple example. Say I have this normal hook response defined in serialize_hook, but the data destination is expecting "phone_number" instead of "from_number":

data  = {
   'from_number': self.from_number
}

With hook templates I could change that to:

{
    'phone_number': {from_number}
}

Thoughts?

-Lyle

meric pushed a commit to meric/django-rest-hooks that referenced this issue Apr 22, 2015
Adding initial South migration
@avelis
Copy link
Contributor

avelis commented Sep 22, 2015

@lylepratt I realize it has been almost two years since you have made this issue so I do apologize for getting to it so late.

Looking at the feature request, it appears that you could currently do this with Django's Template engine. This in turn could create the ideal payload based on your own criteria.

Further following separation's of concerns, I feel more inclined to say that your feature really belongs outside the scope of django-rest-hooks.

I am of course open for more discourse on this to possibly drill down the root of the feature. (i.e. what is django-rest-hooks lacking).

-Andrew

@lylepratt
Copy link
Author

Hi Andrew,

Yes its definitely possible to use Django template for the data transformation. However, the template would need to be stored with the Hook data and users would need to be able to pass in their own "data templates" when they create hooks using the Rest API. Essentially, this would require an additional model field, and if the hook model contained a valid template in that field, it should run the transformation right before sending off the hook.

@Ryanb58
Copy link

Ryanb58 commented Jun 22, 2018

Seems like you can do this now with the serialize_hook method.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants