Skip to content

Commit

Permalink
fix: WhatsApp location lat/long properties
Browse files Browse the repository at this point in the history
  • Loading branch information
SMadani committed Oct 21, 2024
1 parent c21b5a2 commit 2bf35e0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Added `@JsonCreator` annotation to webhook classes' `fromJson(String)` method
- Added `app_id` to `com.vonage.client.numbers.OwnedNumber`
- Fixed Viber Video message TTL field being set incorrectly
- Fixed incorrect serialisation of outbound WhatsApp Location message
- Added end-to-end encryption support for Video sessions
- Added `leg_persistence_time` to Application Voice capability
- Added `signed_callbacks` to Application RTC capability
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.vonage.client.messages.whatsapp;

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.vonage.client.JsonableBaseObject;

Expand All @@ -39,12 +40,14 @@ public final class Location extends JsonableBaseObject {
address = builder.address;
}

@JsonProperty("lat")
@JsonAlias("lat")
@JsonProperty("latitude")
public double getLatitude() {
return latitude;
}

@JsonProperty("long")
@JsonAlias("long")
@JsonProperty("longitude")
public double getLongitude() {
return longitude;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public void testSerializeAllParams() {
.longitude(longitude).latitude(latitude)
.build().toJson();
assertTrue(json.contains("\"custom\":{\"type\":\"location\",\"location\":{" +
"\"lat\":"+latitude+",\"long\":"+longitude+",\"name\":\""+name+"\",\"address\":\""+address+"\"}}"
"\"latitude\":"+latitude+",\"longitude\":"+longitude+
",\"name\":\""+name+"\",\"address\":\""+address+"\"}}"
));
assertTrue(json.contains("\"message_type\":\"custom\""));
assertTrue(json.contains("\"channel\":\"whatsapp\""));
Expand All @@ -42,7 +43,7 @@ public void testSerializeRequiredParams() {
.longitude(51.5216317).latitude(-0.0890882)
.from("317900000002").to("447900000001")
.build().toJson();
assertTrue(json.contains("\"location\":{\"lat\":-0.0890882,\"long\":51.5216317}"));
assertTrue(json.contains("\"location\":{\"latitude\":-0.0890882,\"longitude\":51.5216317}"));
assertTrue(json.contains("\"message_type\":\"custom\""));
assertTrue(json.contains("\"channel\":\"whatsapp\""));
}
Expand Down

0 comments on commit 2bf35e0

Please sign in to comment.