(cls, template)
return f"{WA_TEMPLATE_STRING}:{template['name']}:{template['language']}:{parameters}"
From the template JSON returned by Turn, create the magic string for people to copy / paste
From the template JSON returned by Turn, create the magic string for people to copy / paste
From the template JSON returned by Turn create the magic string for people to copy / paste
def generate_template_string(cls, template):
        """From the template JSON returned by Turn, create the magic string for people to copy / paste
        """

        template_text = ""
        for component in template.get("components", []):
            if component.get("type") == "BODY":
                template_text = component.get("text", "")
                break
        num_params = template_text.count("{") // 2  # each parameter is bracketed by {{}}
        parameters = ",".join(f"{{var{i}}}" for i in range(1, num_params + 1))
        return f"{WA_TEMPLATE_STRING}:{template['name']}:{template['language']}:{parameters}"
def generate_template_string ( cls , template ) : template_text = "" for component in template . get ( "components" , [ ] ) : if component . get ( "type" ) == "BODY" : template_text = component . get ( "text" , "" ) break num_params = template_text . count ( "{" ) // 2 # each parameter is bracketed by {{}} parameters = "," . join ( f"{{var{i}}}" for i in range ( 1 , num_params + 1 ) ) return f"{WA_TEMPLATE_STRING}:{template['name']}:{template['language']}:{parameters}"