pywa icon indicating copy to clipboard operation
pywa copied to clipboard

Implement Named parameters

Open seboraid opened this issue 8 months ago • 4 comments
trafficstars

seboraid avatar Mar 06 '25 13:03 seboraid

Codecov Report

:x: Patch coverage is 11.59420% with 61 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 84.88%. Comparing base (a662c16) to head (c1cc36b). :warning: Report is 321 commits behind head on master.

Files with missing lines Patch % Lines
pywa/types/named_parameter.py 0.00% 31 Missing :warning:
pywa/types/template.py 21.05% 30 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #108      +/-   ##
==========================================
- Coverage   86.39%   84.88%   -1.51%     
==========================================
  Files          16       17       +1     
  Lines        3183     3249      +66     
==========================================
+ Hits         2750     2758       +8     
- Misses        433      491      +58     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov-commenter avatar Mar 08 '25 21:03 codecov-commenter

@david-lev any update on when this will be merged ?

ashwanthbalakrishnan5 avatar Mar 19 '25 09:03 ashwanthbalakrishnan5

@david-lev any update on when this will be merged ?

We're very busy right now. could you briefly explain what the feature does? Is this a new template type?

yehuda-lev avatar Mar 19 '25 09:03 yehuda-lev

@yehuda-lev The current implementation only allows numbered variables for templates. While calling the send_template method we pass the values for the variables in the template in the order it's defined in the template.

Now while creating a template itself we can assign a variable name for each variable we define in the template. And the respective values of that variable can be parsed with reference to the variable name while sending a message using that template

(https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-message-templates/#text-based)

ashwanthbalakrishnan5 avatar Mar 19 '25 11:03 ashwanthbalakrishnan5

This feature is useful for us. When will it be merged ?

thiagotps avatar Jun 03 '25 17:06 thiagotps

This feature is useful for us. When will it be merged ?

Soon https://github.com/david-lev/pywa/pull/113#issuecomment-2908720098

yehuda-lev avatar Jun 03 '25 22:06 yehuda-lev

Hi @seboraid, Thank you for your contribution and the time you took to explore the idea of named parameters — I really appreciate the effort.

Since this PR was opened, I’ve gone ahead and implemented named template parameters directly in the core of Template with a slightly different design that better fits the overall direction of the library. It offers a more streamlined developer experience, tighter integration with type hints, and improved validation, while keeping backwards compatibility with positional parameters.

Given that, I’ll go ahead and close this PR — but your work definitely helped validate the need for this feature, and I’m grateful for that.

Looking forward to seeing more contributions from you in the future!

You can see the classes here:

https://pywa.readthedocs.io/en/v3/content/templates/types.html#pywa.types.templates.HeaderText https://pywa.readthedocs.io/en/v3/content/templates/types.html#pywa.types.templates.BodyText

david-lev avatar Aug 04 '25 11:08 david-lev