Skip to content

Commit

Permalink
Issue #1253: sending contact message added
Browse files Browse the repository at this point in the history
  • Loading branch information
nbartels committed Oct 2, 2022
1 parent 15cc4c5 commit f293580
Show file tree
Hide file tree
Showing 12 changed files with 469 additions and 3 deletions.
Expand Up @@ -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;

Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -68,6 +72,9 @@ public class SendMessage extends AbstractFacebookType {
@Facebook
private Location location;

@Facebook
private List<Contact> contacts;

@Facebook
@Setter
private Type type = Type.text;
Expand Down Expand Up @@ -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;
}
}
Expand Up @@ -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;

Expand Down
@@ -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<Address> addresses;

@Facebook
private String birthday;

@Facebook
private List<Email> emails;

@Setter
@Facebook
private Name name;

@Setter
@Facebook
private Organisation org;

@Facebook
private List<Phone> phones;

@Facebook
private List<Url> 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);
}

}
@@ -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;
}
@@ -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;
}
@@ -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;
}
}
@@ -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;
}
@@ -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;

}

0 comments on commit f293580

Please sign in to comment.