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
449 stars 163 forks source link

Missing parameters in Media Object Type #115

Closed derrickobedgiu1 closed 1 year ago

derrickobedgiu1 commented 1 year ago

Hello, I've been ignoring this minor issue of missing parameters in the media object I think because I haven't been frequently testing and using it as my main focus was on Text type. But I can confirm that there are missing parameters the object isn't returning for the media object. Below are examples of the cases:

CASE 1 FOR NORMAL DUMP:

{
    "object": "whatsapp_business_account",
    "entry": [
        {
            "id": "100822442994608",
            "changes": [
                {
                    "value": {
                        "messaging_product": "whatsapp",
                        "metadata": {
                            "display_phone_number": "**********",
                            "phone_number_id": "***********"
                        },
                        "contacts": [
                            {
                                "profile": {
                                    "name": "De Rick"
                                },
                                "wa_id": "25********"
                            }
                        ],
                        "messages": [
                            {
                                "from": "25*********",
                                "id": "wamid.HBgMMjU2NzQyMDMwNDAzFQIAEhgWM0VCMDlGNkEzQTI2REUyN0NGQzVCQwA=",
                                "timestamp": "1687370616",
                                "type": "document",
                                "document": {
                                    "filename": "Packet Tracer Guide.docx",
                                    "mime_type": "application\/vnd.openxmlformats-officedocument.wordprocessingml.document",
                                    "sha256": "EHebbB0CwZndBi9LvLB5PQVYPhHdJsnDxzmRpUv+KkY=",
                                    "id": "184921594550426"
                                }
                            }
                        ]
                    },
                    "field": "messages"
                }
            ]
        }
    ]
}

CASE 1 FOR LIB DUMP

Netflie\WhatsAppCloudApi\WebHook\Notification\Media Object
(
    [image_id] => 184921594550426
    [mime_type] => application/vnd.openxmlformats-officedocument.wordprocessingml.document
    [caption] => 
    [customer] => Netflie\WhatsAppCloudApi\WebHook\Notification\Support\Customer Object
        (
            [id] => **********
            [name] => De Rick
            [phone_number] => 25**********
        )

    [id] => wamid.HBgMMjU2NzQyMDMwNDAzFQIAEhgWM0VCMDlGNkEzQTI2REUyN0NGQzVCQwA=
    [business] => Netflie\WhatsAppCloudApi\WebHook\Notification\Support\Business Object
        (
            [phone_number_id] => ************
            [phone_number] => **********
        )

    [received_at] => DateTimeImmutable Object
        (
            [date] => 2023-06-21 21:03:36.000000
            [timezone_type] => 3
            [timezone] => Africa/Kampala
        )

)

The tests I made all include the "filename" parameter and "sha256". Is it possible to include these parameters in future versions of the LIB? Thank you. I'm always ready to test and provide immediate feedback.

angelomelonas commented 1 year ago

Hi @derrickobedgiu1, I would also like these additional fields to be available for Media messages. I will try to spend some time this weekend to see if I can come up with a Pull Request to add them.

derrickobedgiu1 commented 1 year ago

@angelomelonas Thanks for that. I checked the files and found it's only the document media type that comes with the filename parameter. The image didn't come with the parameters. So the issue I've created here is concerned with the document type only, AT LEAST FOR NOW. I figured you may be interested in having this information.

winkelco commented 1 year ago

Done.

I also need these data and they are not in the MEDIA class

filename: https://github.com/netflie/whatsapp-cloud-api/pull/126/commits/53b957d833470ee2ef110ba673b01fabe38d3459 sha256: https://github.com/netflie/whatsapp-cloud-api/pull/126/commits/242327e5ff06527fece4da9225338ecd9ff97836

aalbarca commented 1 year ago

Hi @winkelco thanks for your support. Can you open a PR? Thanks!

aalbarca commented 1 year ago

Filename and sha256 are now available from v2.1.0 release.