Bindambc / whatsapp-business-java-api

Whatsapp business api SDK, written in java. This SDK implements the Official Whatsapp Cloud API and WhatsApp Business Management API. These allows you to: manage your WhatsApp Business Account assets, such as message templates and phone numbers; send messages to your contacts, such as simple text messages, messages with buttons...
https://bindambc.github.io/whatsapp-business-java-api/
MIT License
138 stars 69 forks source link

New button type: COPY_CODE #118

Open brunopedrosa opened 10 months ago

brunopedrosa commented 10 months ago

Is the new 'COPY_CODE' button type working? (edited: it seems not work)

github-actions[bot] commented 10 months ago

Hello and welcome! We're glad to see that you've opened your first issue. We appreciate your contribution and would love to hear more about the problem you're experiencing. Our team is actively monitoring this repository and we will do our best to respond to your issue as soon as possible. Thank you for using our project and we look forward to working with you!

brunopedrosa commented 10 months ago

Caused by: com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id 'COPY_CODE' as a subtype of com.whatsapp.api.domain.templates.Button: known type ids = [Button, PHONE_NUMBER, QUICK_REPLY, URL] (for POJO property 'buttons')

Bindambc commented 10 months ago

Hello @brunopedrosa, thank you for informing. This is a new feature that has been added to the API as per the changelog.

API documentation: https://developers.facebook.com/docs/whatsapp/business-management-api/authentication-templates

I'll be implementing this feature soon. If you've already implemented something related, feel free to share.

brunopedrosa commented 10 months ago

Hello @Bindambc,

It seems to be working, but I'm not sure if the code is 100%. It would be a good idea to give it a review.

package com.whatsapp.api.domain.templates;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.whatsapp.api.domain.templates.type.ButtonType;

/**
 * The type Quick reply button.
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CopyCodeButton extends Button {

    @JsonProperty("example")
    private List<String> urlExample;

    /**
     * Instantiates a new Copy code button.
     */
    protected CopyCodeButton() {
        super(ButtonType.COPY_CODE);
    }

    /**
     * Instantiates a new Copy code button.
     *
     * @param text the text
     */
    public CopyCodeButton(String text) {
        super(ButtonType.COPY_CODE, text);
    }

    public List<String> getUrlExample() {
        return urlExample;
    }

    public void setUrlExample(List<String> urlExample) {
        this.urlExample = urlExample;
    }
}
package com.whatsapp.api.domain.templates.type;

/**
 * The enum Button type.
 */
public enum ButtonType {
    /**
     * Phone number button type.
     */
    PHONE_NUMBER,
    /**
     * Url button type.
     */
    URL,
    /**
     * Quick reply button type.
     */
    QUICK_REPLY,
    /**
     * Copy code button type.
     */
    COPY_CODE

}
PenugondaJayanthi123 commented 9 months ago

Can you assign this issue to me?