whatsapp-business-java-api icon indicating copy to clipboard operation
whatsapp-business-java-api copied to clipboard

New button type: COPY_CODE

Open brunopedrosa opened this issue 2 years ago • 5 comments

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

brunopedrosa avatar Aug 29 '23 15:08 brunopedrosa

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!

github-actions[bot] avatar Aug 29 '23 15:08 github-actions[bot]

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')

brunopedrosa avatar Aug 30 '23 14:08 brunopedrosa

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.

Bindambc avatar Sep 05 '23 03:09 Bindambc

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
    
}

brunopedrosa avatar Sep 05 '23 10:09 brunopedrosa

Can you assign this issue to me?

PenugondaJayanthi123 avatar Sep 17 '23 11:09 PenugondaJayanthi123