-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix video object in message template, new tests
- Loading branch information
Showing
8 changed files
with
324 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.whatsapp.api.domain.messages; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonInclude.Include; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* The type Video. | ||
*/ | ||
@JsonInclude(Include.NON_NULL) | ||
public class Video { | ||
|
||
@JsonProperty("id") | ||
private String id; | ||
@JsonProperty("link") | ||
private String link; | ||
|
||
/** | ||
* Instantiates a new Video. | ||
*/ | ||
public Video() { | ||
} | ||
|
||
/** | ||
* Instantiates a new Video. | ||
* | ||
* @param id the id | ||
* @param link the link | ||
*/ | ||
public Video(String id, String link) { | ||
this.id = id; | ||
this.link = link; | ||
} | ||
|
||
/** | ||
* Gets id. | ||
* | ||
* @return the id | ||
*/ | ||
public String getId() { | ||
return id; | ||
} | ||
|
||
/** | ||
* Sets id. | ||
* | ||
* @param id the id | ||
* @return the id | ||
*/ | ||
public Video setId(String id) { | ||
this.id = id; | ||
return this; | ||
} | ||
|
||
/** | ||
* Gets link. | ||
* | ||
* @return the link | ||
*/ | ||
public String getLink() { | ||
return link; | ||
} | ||
|
||
/** | ||
* Sets link. | ||
* | ||
* @param link the link | ||
* @return the link | ||
*/ | ||
public Video setLink(String link) { | ||
this.link = link; | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/test/java/com/whatsapp/api/examples/SendTemplateAuthMessageExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.whatsapp.api.examples; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.whatsapp.api.TestConstants; | ||
import com.whatsapp.api.WhatsappApiFactory; | ||
import com.whatsapp.api.domain.messages.BodyComponent; | ||
import com.whatsapp.api.domain.messages.HeaderComponent; | ||
import com.whatsapp.api.domain.messages.Image; | ||
import com.whatsapp.api.domain.messages.ImageParameter; | ||
import com.whatsapp.api.domain.messages.Language; | ||
import com.whatsapp.api.domain.messages.Message.MessageBuilder; | ||
import com.whatsapp.api.domain.messages.TemplateMessage; | ||
import com.whatsapp.api.domain.messages.TextParameter; | ||
import com.whatsapp.api.domain.templates.type.LanguageType; | ||
import com.whatsapp.api.impl.WhatsappBusinessCloudApi; | ||
|
||
import static com.whatsapp.api.TestConstants.PHONE_NUMBER_1; | ||
import static com.whatsapp.api.TestConstants.PHONE_NUMBER_ID; | ||
|
||
public class SendTemplateAuthMessageExample { | ||
public static void main(String[] args) throws JsonProcessingException { | ||
WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TestConstants.TOKEN); | ||
|
||
WhatsappBusinessCloudApi whatsappBusinessCloudApi = factory.newBusinessCloudApi(); | ||
|
||
var message = MessageBuilder.builder()// | ||
.setTo(PHONE_NUMBER_1)// | ||
.buildTemplateMessage(// | ||
new TemplateMessage()// | ||
.setLanguage(new Language(LanguageType.PT_BR))// | ||
.setName("auth_app")// | ||
.addComponent(new HeaderComponent()// | ||
.addParameter(new ImageParameter()// | ||
.setImage(new Image("554066036582230", null)) | ||
) | ||
|
||
).addComponent(// | ||
new BodyComponent()// | ||
.addParameter(new TextParameter("T87-G74-876")))// | ||
|
||
); | ||
System.out.println(new ObjectMapper().writeValueAsString(message)); | ||
|
||
whatsappBusinessCloudApi.sendMessage(PHONE_NUMBER_ID, message); | ||
} | ||
} |
Oops, something went wrong.