-
-
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.
- Loading branch information
1 parent
dd8b450
commit ea2274b
Showing
5 changed files
with
188 additions
and
0 deletions.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
src/main/java/com/whatsapp/api/domain/messages/LocationMessage.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,98 @@ | ||
package com.whatsapp.api.domain.messages; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
|
||
/** | ||
* The type Template message. | ||
*/ | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class LocationMessage { | ||
|
||
@JsonProperty("longitude") | ||
private String longitude; | ||
@JsonProperty("latitude") | ||
private String latitude; | ||
@JsonProperty("name") | ||
private String name; | ||
@JsonProperty("address") | ||
private String address; | ||
|
||
/** | ||
* Gets name. | ||
* | ||
* @return the name | ||
*/ | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
/** | ||
* Sets name. | ||
* | ||
* @param name the name | ||
* @return the LocationMessage | ||
*/ | ||
public LocationMessage setName(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
/** | ||
* Gets longitude. | ||
* @return the longitude | ||
*/ | ||
public String getLongitude() { | ||
return longitude; | ||
} | ||
|
||
/** | ||
* Sets longitude. | ||
* | ||
* @param longitude | ||
* @return LocationMessage | ||
*/ | ||
public LocationMessage setLongitude(String longitude) { | ||
this.longitude = longitude; | ||
return this; | ||
} | ||
|
||
/** | ||
* Gets latitude. | ||
* @return the latitude | ||
*/ | ||
public String getLatitude() { | ||
return latitude; | ||
} | ||
|
||
/** | ||
* Sets latitude. | ||
* | ||
* @param latitude | ||
* @return LocationMessage | ||
*/ | ||
public LocationMessage setLatitude(String latitude) { | ||
this.latitude = latitude; | ||
return this; | ||
} | ||
|
||
/** | ||
* Gets address. | ||
* @return the address | ||
*/ | ||
public String getAddress() { | ||
return address; | ||
} | ||
|
||
/** | ||
* Sets address. | ||
* | ||
* @param address | ||
* @return LocationMessage | ||
*/ | ||
public LocationMessage setAddress(String address) { | ||
this.address = address; | ||
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
34 changes: 34 additions & 0 deletions
34
src/test/java/com/whatsapp/api/examples/SendLocationMessageExample.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,34 @@ | ||
package com.whatsapp.api.examples; | ||
|
||
import static com.whatsapp.api.TestConstants.PHONE_NUMBER_1; | ||
import static com.whatsapp.api.TestConstants.PHONE_NUMBER_ID; | ||
import static com.whatsapp.api.TestConstants.TOKEN; | ||
|
||
import com.whatsapp.api.WhatsappApiFactory; | ||
import com.whatsapp.api.domain.messages.LocationMessage; | ||
import com.whatsapp.api.domain.messages.Message.MessageBuilder; | ||
import com.whatsapp.api.domain.messages.response.MessageResponse; | ||
import com.whatsapp.api.impl.WhatsappBusinessCloudApi; | ||
|
||
public class SendLocationMessageExample { | ||
|
||
public static void main(String[] args) { | ||
|
||
WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); | ||
|
||
WhatsappBusinessCloudApi whatsappBusinessCloudApi = factory.newBusinessCloudApi(); | ||
var locationMessage = new LocationMessage()// | ||
.setLongitude("38.819830") | ||
.setLatitude("-77.151700"); | ||
|
||
var message = MessageBuilder.builder()// | ||
.setTo(PHONE_NUMBER_1)// | ||
.buildLocationMessage(locationMessage); | ||
|
||
MessageResponse messageResponse = whatsappBusinessCloudApi.sendMessage(PHONE_NUMBER_ID, message); | ||
|
||
System.out.println(messageResponse); | ||
|
||
} | ||
|
||
} |
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
12 changes: 12 additions & 0 deletions
12
src/test/resources/expected/message/expectedMessage13.json
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,12 @@ | ||
{ | ||
"messaging_product": "whatsapp", | ||
"recipient_type": "individual", | ||
"to": "121212121212", | ||
"type": "location", | ||
"location": { | ||
"longitude": "-84.265742", | ||
"latitude": "39.284064", | ||
"name": "Loveland Castle Museum", | ||
"address": "12025 Shore Dr, Loveland, OH 45140" | ||
} | ||
} |