gabrieldwight / Whatsapp-Business-Cloud-Api-Net

This is C# wrapper of whatsapp business cloud api for .NET
MIT License
284 stars 104 forks source link

[Quick FIX] Incorrect template editing method logic #89

Closed BlissoftCorp closed 1 month ago

BlissoftCorp commented 1 month ago

When using the methods:

EditTemplateAsync or EditTemplate

It returns an exception of type "Invalid parameter".

Analyzing the source code I realize that the "object messageTemplate" parameter is never sent in the logic that has the EditTemplate methods. This is what the EditTemplateAsync code looks like

public async Task<BaseSuccessResponse> EditTemplateAsync(object messageTemplate, string templateId, CancellationToken cancellationToken = default(CancellationToken))
{
    string whatsAppBusinessEndpoint = WhatsAppBusinessRequestEndpoint.GetTemplateById.Replace("{{TEMPLATE_ID}}", templateId);
    return await WhatsAppBusinessPostAsync<BaseSuccessResponse>(whatsAppBusinessEndpoint, cancellationToken);
}

It is obvious that it must be integrated in the following way:

public async Task<BaseSuccessResponse> EditTemplateAsync(object messageTemplate, string templateId, CancellationToken cancellationToken = default(CancellationToken))
{
    string whatsAppBusinessEndpoint = WhatsAppBusinessRequestEndpoint.GetTemplateById.Replace("{{TEMPLATE_ID}}", templateId);
    return await WhatsAppBusinessPostAsync<BaseSuccessResponse>(messageTemplate, whatsAppBusinessEndpoint, cancellationToken);
}

I hope you can solve this soon, greetings.

gabrieldwight commented 1 month ago

hi, thanks for the fix. I have pushed the fix