From f2935804745a6c90d526d2e5dd5d3a49af66bb41 Mon Sep 17 00:00:00 2001 From: Norbert Bartels Date: Sun, 2 Oct 2022 14:32:34 +0200 Subject: [PATCH] Issue #1253: sending contact message added --- .../whatsapp/WhatsappMessagesValue.java | 1 + .../types/whatsapp/platform/SendMessage.java | 18 +++- .../platform/{ => message}/Contact.java | 3 +- .../types/whatsapp/platform/send/Contact.java | 95 +++++++++++++++++++ .../platform/send/contact/Address.java | 57 +++++++++++ .../whatsapp/platform/send/contact/Email.java | 37 ++++++++ .../whatsapp/platform/send/contact/Name.java | 56 +++++++++++ .../platform/send/contact/Organisation.java | 41 ++++++++ .../whatsapp/platform/send/contact/Phone.java | 42 ++++++++ .../whatsapp/platform/send/contact/Url.java | 37 ++++++++ .../com/restfb/types/WABPwebhookTest.java | 2 +- .../whatsapp/platform/SendMessageTest.java | 83 ++++++++++++++++ 12 files changed, 469 insertions(+), 3 deletions(-) rename src/main/lombok/com/restfb/types/whatsapp/platform/{ => message}/Contact.java (93%) create mode 100644 src/main/lombok/com/restfb/types/whatsapp/platform/send/Contact.java create mode 100644 src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Address.java create mode 100644 src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Email.java create mode 100644 src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Name.java create mode 100644 src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Organisation.java create mode 100644 src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Phone.java create mode 100644 src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Url.java diff --git a/src/main/lombok/com/restfb/types/webhook/whatsapp/WhatsappMessagesValue.java b/src/main/lombok/com/restfb/types/webhook/whatsapp/WhatsappMessagesValue.java index 478e89017..7dbea574b 100644 --- a/src/main/lombok/com/restfb/types/webhook/whatsapp/WhatsappMessagesValue.java +++ b/src/main/lombok/com/restfb/types/webhook/whatsapp/WhatsappMessagesValue.java @@ -28,6 +28,7 @@ import com.restfb.types.whatsapp.platform.*; import com.restfb.types.whatsapp.platform.Error; +import com.restfb.types.whatsapp.platform.message.Contact; import lombok.Getter; import lombok.Setter; diff --git a/src/main/lombok/com/restfb/types/whatsapp/platform/SendMessage.java b/src/main/lombok/com/restfb/types/whatsapp/platform/SendMessage.java index 878e487fd..5e428d5da 100644 --- a/src/main/lombok/com/restfb/types/whatsapp/platform/SendMessage.java +++ b/src/main/lombok/com/restfb/types/whatsapp/platform/SendMessage.java @@ -24,9 +24,13 @@ import com.restfb.Facebook; import com.restfb.types.AbstractFacebookType; import com.restfb.types.whatsapp.platform.send.*; +import com.restfb.types.whatsapp.platform.send.Contact; import lombok.Getter; import lombok.Setter; +import java.util.ArrayList; +import java.util.List; + public class SendMessage extends AbstractFacebookType { @Getter @@ -68,6 +72,9 @@ public class SendMessage extends AbstractFacebookType { @Facebook private Location location; + @Facebook + private List contacts; + @Facebook @Setter private Type type = Type.text; @@ -126,7 +133,16 @@ public void setLocation(Location location) { this.type = Type.location; } + public void addContact(Contact contact) { + if (contacts == null) { + contacts = new ArrayList<>(); + } + + contacts.add(contact); + this.type = Type.contacts; + } + public enum Type { - text, reaction, audio, video, document, sticker, image, interactive, location; + text, reaction, audio, video, document, sticker, image, interactive, location, contacts; } } diff --git a/src/main/lombok/com/restfb/types/whatsapp/platform/Contact.java b/src/main/lombok/com/restfb/types/whatsapp/platform/message/Contact.java similarity index 93% rename from src/main/lombok/com/restfb/types/whatsapp/platform/Contact.java rename to src/main/lombok/com/restfb/types/whatsapp/platform/message/Contact.java index 799198cda..c49c9c154 100644 --- a/src/main/lombok/com/restfb/types/whatsapp/platform/Contact.java +++ b/src/main/lombok/com/restfb/types/whatsapp/platform/message/Contact.java @@ -19,11 +19,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package com.restfb.types.whatsapp.platform; +package com.restfb.types.whatsapp.platform.message; import com.restfb.Facebook; import com.restfb.types.AbstractFacebookType; +import com.restfb.types.whatsapp.platform.Profile; import lombok.Getter; import lombok.Setter; diff --git a/src/main/lombok/com/restfb/types/whatsapp/platform/send/Contact.java b/src/main/lombok/com/restfb/types/whatsapp/platform/send/Contact.java new file mode 100644 index 000000000..0d4abfac6 --- /dev/null +++ b/src/main/lombok/com/restfb/types/whatsapp/platform/send/Contact.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2010-2022 Mark Allen, Norbert Bartels. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.restfb.types.whatsapp.platform.send; + +import com.restfb.Facebook; +import com.restfb.types.AbstractFacebookType; +import com.restfb.types.whatsapp.platform.send.contact.*; +import com.restfb.util.DateUtils; +import lombok.Setter; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class Contact extends AbstractFacebookType { + + @Facebook + private List
addresses; + + @Facebook + private String birthday; + + @Facebook + private List emails; + + @Setter + @Facebook + private Name name; + + @Setter + @Facebook + private Organisation org; + + @Facebook + private List phones; + + @Facebook + private List urls; + + public void setBirthday(Date birthday) { + this.birthday = DateUtils.toShortFormatFromDate(birthday); + } + + public void addAddress(Address address) { + if (addresses == null) { + this.addresses = new ArrayList<>(); + } + + this.addresses.add(address); + } + + public void addEmail(Email email) { + if (emails == null) { + this.emails = new ArrayList<>(); + } + + this.emails.add(email); + } + + public void addPhone(Phone phone) { + if (phones == null) { + this.phones = new ArrayList<>(); + } + + this.phones.add(phone); + } + + public void addUrl(Url url) { + if (urls == null) { + this.urls = new ArrayList<>(); + } + + this.urls.add(url); + } + +} diff --git a/src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Address.java b/src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Address.java new file mode 100644 index 000000000..a2d13e6b9 --- /dev/null +++ b/src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Address.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2010-2022 Mark Allen, Norbert Bartels. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.restfb.types.whatsapp.platform.send.contact; + +import com.restfb.Facebook; +import com.restfb.types.AbstractFacebookType; +import lombok.Setter; + +public class Address extends AbstractFacebookType { + + @Setter + @Facebook + private String street; + + @Setter + @Facebook + private String city; + + @Setter + @Facebook + private String state; + + @Setter + @Facebook + private String zip; + + @Setter + @Facebook + private String country; + + @Setter + @Facebook("country_code") + private String countryCode; + + @Setter + @Facebook + private String type; +} diff --git a/src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Email.java b/src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Email.java new file mode 100644 index 000000000..37b2d5fe0 --- /dev/null +++ b/src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Email.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2010-2022 Mark Allen, Norbert Bartels. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.restfb.types.whatsapp.platform.send.contact; + +import com.restfb.Facebook; +import com.restfb.types.AbstractFacebookType; +import lombok.Setter; + +public class Email extends AbstractFacebookType { + + @Setter + @Facebook + private String email; + + @Setter + @Facebook + private String type; +} diff --git a/src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Name.java b/src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Name.java new file mode 100644 index 000000000..6436f6fc3 --- /dev/null +++ b/src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Name.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2010-2022 Mark Allen, Norbert Bartels. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.restfb.types.whatsapp.platform.send.contact; + +import com.restfb.Facebook; +import com.restfb.types.AbstractFacebookType; +import lombok.Setter; + +public class Name extends AbstractFacebookType { + + @Facebook("formatted_name") + private String formattedName; + + @Setter + @Facebook("first_name") + private String firstName; + + @Setter + @Facebook("last_name") + private String lastLame; + + @Setter + @Facebook("middle_name") + private String middleName; + + @Setter + @Facebook + private String suffix; + + @Setter + @Facebook + private String prefix; + + public Name(String formattedName) { + this.formattedName = formattedName; + } +} diff --git a/src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Organisation.java b/src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Organisation.java new file mode 100644 index 000000000..062e1ce3a --- /dev/null +++ b/src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Organisation.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2010-2022 Mark Allen, Norbert Bartels. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.restfb.types.whatsapp.platform.send.contact; + +import com.restfb.Facebook; +import com.restfb.types.AbstractFacebookType; +import lombok.Setter; + +public class Organisation extends AbstractFacebookType { + + @Setter + @Facebook + private String company; + + @Setter + @Facebook + private String department; + + @Setter + @Facebook + private String title; +} diff --git a/src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Phone.java b/src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Phone.java new file mode 100644 index 000000000..8e959fa1b --- /dev/null +++ b/src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Phone.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2010-2022 Mark Allen, Norbert Bartels. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.restfb.types.whatsapp.platform.send.contact; + +import com.restfb.Facebook; +import com.restfb.types.AbstractFacebookType; +import lombok.Setter; + +public class Phone extends AbstractFacebookType { + + @Setter + @Facebook + private String phone; + + @Setter + @Facebook + private String type; + + @Setter + @Facebook("wa_id") + private String waId; + +} diff --git a/src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Url.java b/src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Url.java new file mode 100644 index 000000000..ed8985002 --- /dev/null +++ b/src/main/lombok/com/restfb/types/whatsapp/platform/send/contact/Url.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2010-2022 Mark Allen, Norbert Bartels. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.restfb.types.whatsapp.platform.send.contact; + +import com.restfb.Facebook; +import com.restfb.types.AbstractFacebookType; +import lombok.Setter; + +public class Url extends AbstractFacebookType { + + @Setter + @Facebook + private String url; + + @Setter + @Facebook + private String type; +} diff --git a/src/test/java/com/restfb/types/WABPwebhookTest.java b/src/test/java/com/restfb/types/WABPwebhookTest.java index 21357ee48..feb694693 100644 --- a/src/test/java/com/restfb/types/WABPwebhookTest.java +++ b/src/test/java/com/restfb/types/WABPwebhookTest.java @@ -32,7 +32,7 @@ import com.restfb.types.webhook.WebhookEntry; import com.restfb.types.webhook.WebhookObject; import com.restfb.types.webhook.whatsapp.WhatsappMessagesValue; -import com.restfb.types.whatsapp.platform.Contact; +import com.restfb.types.whatsapp.platform.message.Contact; import com.restfb.types.whatsapp.platform.Message; import com.restfb.types.whatsapp.platform.Status; import com.restfb.types.whatsapp.platform.message.*; diff --git a/src/test/java/com/restfb/types/whatsapp/platform/SendMessageTest.java b/src/test/java/com/restfb/types/whatsapp/platform/SendMessageTest.java index eb26e4910..2bc4e069a 100644 --- a/src/test/java/com/restfb/types/whatsapp/platform/SendMessageTest.java +++ b/src/test/java/com/restfb/types/whatsapp/platform/SendMessageTest.java @@ -24,15 +24,18 @@ import com.restfb.DefaultJsonMapper; import com.restfb.JsonMapper; import com.restfb.testutils.AssertJson; +import com.restfb.types.whatsapp.platform.send.Contact; import com.restfb.types.whatsapp.platform.send.Image; import com.restfb.types.whatsapp.platform.send.Interactive; import com.restfb.types.whatsapp.platform.send.Reaction; import com.restfb.types.whatsapp.platform.send.Text; +import com.restfb.types.whatsapp.platform.send.contact.*; import com.restfb.types.whatsapp.platform.send.interactive.*; import org.junit.jupiter.api.Test; import java.net.MalformedURLException; import java.net.URL; +import java.util.Date; class SendMessageTest { @@ -120,4 +123,84 @@ void checkInteractive2() { + "\"type\":\"interactive\",\"messaging_product\":\"whatsapp\"}", mappedMessage); } + + @Test + void checkContacts() { + Address address1 = createAddress("HOME"); + Address address2 = createAddress("WORK"); + Contact contact = new Contact(); + contact.addAddress(address1); + contact.addAddress(address2); + contact.setBirthday(new Date(1664713264745L)); + + Email email1 = new Email(); + email1.setEmail("EMAIL"); + email1.setType("HOME"); + Email email2 = new Email(); + email2.setEmail("EMAIL"); + email2.setType("WORK"); + + contact.addEmail(email1); + contact.addEmail(email2); + + Organisation organisation = new Organisation(); + organisation.setCompany("COMPANY"); + organisation.setDepartment("DEPARTMENT"); + organisation.setTitle("TITLE"); + + contact.setOrg(organisation); + + Phone phone1 = new Phone(); + phone1.setPhone("PHONE_NUMBER"); + phone1.setType("HOME"); + + Phone phone2 = new Phone(); + phone2.setPhone("PHONE_NUMBER"); + phone2.setType("WORK"); + phone2.setWaId("PHONE_OR_WA_ID"); + + contact.addPhone(phone1); + contact.addPhone(phone2); + + Url url1 = new Url(); + url1.setUrl("URL"); + url1.setType("WORK"); + + Url url2 = new Url(); + url2.setUrl("URL"); + url2.setType("HOME"); + + contact.addUrl(url1); + contact.addUrl(url2); + + SendMessage message = new SendMessage("PHONE_NUMBER"); + message.addContact(contact); + + JsonMapper mapper = new DefaultJsonMapper(); + String mappedMessage = mapper.toJson(message, true); + + AssertJson.assertEquals("{\"to\":\"PHONE_NUMBER\"," + "\"contacts\":[" + "{\"addresses\":[" + + "{\"street\":\"STREET\",\"city\":\"CITY\",\"state\":\"STATE\",\"zip\":\"ZIP\",\"country\":\"COUNTRY\",\"country_code\":\"COUNTRY_CODE\",\"type\":\"HOME\"}," + + "{\"street\":\"STREET\",\"city\":\"CITY\",\"state\":\"STATE\",\"zip\":\"ZIP\",\"country\":\"COUNTRY\",\"country_code\":\"COUNTRY_CODE\",\"type\":\"WORK\"}]," + + "\"birthday\":\"2022-10-02\"," + "\"emails\":[" + "{\"email\":\"EMAIL\",\"type\":\"HOME\"}," + + "{\"email\":\"EMAIL\",\"type\":\"WORK\"}]," + + "\"org\":{\"company\":\"COMPANY\",\"department\":\"DEPARTMENT\",\"title\":\"TITLE\"}," + "\"phones\":[" + + "{\"phone\":\"PHONE_NUMBER\",\"type\":\"HOME\"}," + + "{\"phone\":\"PHONE_NUMBER\",\"type\":\"WORK\",\"wa_id\":\"PHONE_OR_WA_ID\"}]," + "\"urls\":[" + + "{\"url\":\"URL\",\"type\":\"WORK\"}," + "{\"url\":\"URL\",\"type\":\"HOME\"}]}]," + + "\"type\":\"contacts\",\"messaging_product\":\"whatsapp\"}", + mappedMessage); + } + + private static Address createAddress(String type) { + Address address1 = new Address(); + address1.setCity("CITY"); + address1.setStreet("STREET"); + address1.setState("STATE"); + address1.setType(type); + address1.setZip("ZIP"); + address1.setCountry("COUNTRY"); + address1.setCountryCode("COUNTRY_CODE"); + return address1; + } }