netflie / whatsapp-cloud-api

The first PHP API to send and receive messages using a cloud-hosted version of the WhatsApp Business Platform
https://netflie.es/portfolio/whatsapp-business-cloud-api-php-sdk/
MIT License
484 stars 177 forks source link

Retrieve existing WhatsApp Templates & enums #189

Open likeabas opened 7 months ago

likeabas commented 7 months ago

This change allows to request all available templates. The WHATSAPP_CLOUD_API_BUSINESS_ID should be set to make it work.

It touches upon https://github.com/netflie/whatsapp-cloud-api/discussions/182

likeabas commented 3 months ago

@aalbarca I've added a method to request whatsapp templates. Furthermore, I've used enums and updated the requirements to PHP => 8.1 (as PHP 7 is no longer supported), so it should probably mean a version bump. Furthermore, I've updated the docs a bit.

likeabas commented 3 months ago

@aalbarca do you know how I can update the PHP version of the CI?

HighLiuk commented 1 week ago

Hey there @likeabas thank you for this contribution this is exactly what I needed.

@aalbarca I've added a method to request whatsapp templates. Furthermore, I've used enums and updated the requirements to PHP => 8.1 (as PHP 7 is no longer supported), so it should probably mean a version bump. Furthermore, I've updated the docs a bit.

I don't think this will be merged if the author @aalbarca still wants to support PHP 7.4. And if you ask me, I love the most recent versions of PHP, but you can't always update your PHP version if you are in production. PHP 7.4 is still widespread and supporting it still matters in 2024.

How about rolling back the "enum" part? Note the author is already using a PHP package that allows you to use enums as if they were PHP 8.0 native enums. See this for instance. I assume that supporting only PHP 8.0 would require you to refactor the whole code with native enums (and I assume it should be a separate issue / PR / milestone).

Nevertheless, this PR is awesome. @aalbarca what do you think of it?

HighLiuk commented 1 week ago

By the way @likeabas aren't template status & template category different?

If you see the official Meta Docs, you can pass both indeed.

Quoting the docs:

Category

array<enum {ACCOUNT_UPDATE, PAYMENT_UPDATE, PERSONAL_FINANCE_UPDATE, SHIPPING_UPDATE, RESERVATION_UPDATE, ISSUE_RESOLUTION, APPOINTMENT_UPDATE, TRANSPORTATION_UPDATE, TICKET_UPDATE, ALERT_UPDATE, AUTO_REPLY, TRANSACTIONAL, OTP, UTILITY, MARKETING, AUTHENTICATION}>

Status

array<enum {APPROVED, IN_APPEAL, PENDING, REJECTED, PENDING_DELETION, DELETED, DISABLED, PAUSED, LIMIT_EXCEEDED, ARCHIVED}>

HighLiuk commented 1 week ago

@likeabas also, typo here. $example should be $exampleStrings I guess.