venmo/business-rules

Calculate variables from an api response?

Opened this issue · 1 comments

Variables represent values in the system , but what if i wanted to compute the data not direct coming from the database but the data that came from an Api end point? where in i will just call the endpoint and parse the values and then do calculations based on the response result .Is the business rule capable for that?
Thank You.

You could call the api inside the variable definitation

class MyVars(BaseVariable)
    @numeric_rule_variable
    def variable_from_api(self):
        response = api_call()
        return compute_variable(response)