# Contact

If your application is using the core implementation type, you can use the **TapCoreContactManager** class to manage your user's contacts.

| TapTalk Contact Method                                                                        | Description                                                                      |
| --------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| [Get All User Contacts](#get-all-user-contacts)                                               | Get all of the user's contact data from local storage                            |
| [Fetch All User Contacts from Server](#fetch-all-user-contacts-from-server)                   | Fetch the user's latest contact data from TapTalk.io server                      |
| [Get Contact Detail Info with TapTalk User ID](#get-contact-detail-info-with-taptalk-user-id) | Get a detailed contact info with selected TapTalk.io user ID                     |
| [Get Contact Detail Info with Client User ID](#get-contact-detail-info-with-client-user-id)   | Get a detailed contact info with selected Client user ID (xcUserID)              |
| [Add User to Contact with User ID](#add-user-to-contact-with-user-id)                         | Add a user with selected TapTalk.io user ID to the active user's contacts        |
| [Add User to Contact with Phone Number](#add-user-to-contact-with-phone-number)               | Add a user with selected phone number to the active user's contacts              |
| [Remove User from Contact](#remove-user-from-contact)                                         | Remove a user with selected TapTalk.io user ID from the active user's contacts   |
| [Save User Data](#save-user-data)                                                             | Save or update existing user data to local cache                                 |
| [Search Local Contact](#search-local-message)                                                 | Search the active user's contacts from the device's local storage with a keyword |
| [Report User](#report-user)                                                                   | Submit a report for a selected user.                                             |
| [Report Message](#report-message)                                                             | Submit a report for a selected message.                                          |
| [Block User](#block-user)                                                                     | Block a user from sending or receiving messages.                                 |
| [Unblock User](#unblock-user)                                                                 | Unblock a blocked user.                                                          |
| [Get Blocked User List](#get-blocked-user-list)                                               | Retrieve a list of blocked users.                                                |
| [Get Blocked User IDs](#get-blocked-user-ids)                                                 | Retrieve a list of IDs from blocked users.                                       |
| [Get Groups in Common](#get-groups-in-common)                                                 | Retrieve the list of groups in common with another user.                         |

### Get All User Contacts

Get all of the user's contact data from TapTalk.io.

{% tabs %}
{% tab title="Java" %}

```java
TapCoreContactManager.getInstance().getAllUserContacts(new TapCoreGetMultipleContactListener() {
    @Override
    public void onSuccess(List<TAPUserModel> users) {
        // Returns a list of the active user's TapTalk.io contacts
    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
TapCoreContactManager.getInstance().getAllUserContacts(object : TapCoreGetMultipleContactListener() {
    override fun onSuccess(users: List<TAPUserModel>?) {
        // Returns a list of the active user's TapTalk.io contacts
    }

    override fun onError(errorCode: String?, errorMessage: String?) {

    }
})
```

{% endtab %}
{% endtabs %}

### Fetch All User Contacts from Server

Calling `fetchAllUserContactsFromServer` will fetch the user's latest contact data from TapTalk.io server and syncs it to the device's local storage.

{% tabs %}
{% tab title="Java" %}

```java
TapCoreContactManager.getInstance().fetchAllUserContactsFromServer(new TapCoreGetMultipleContactListener() {
    @Override
    public void onSuccess(List<TAPUserModel> users) {
        // Returns a list of the active user's TapTalk.io contacts
    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
TapCoreContactManager.getInstance().fetchAllUserContactsFromServer(object : TapCoreGetMultipleContactListener() {
    override fun onSuccess(users: List<TAPUserModel>?) {
        // Returns a list of the active user's TapTalk.io contacts
    }

    override fun onError(errorCode: String?, errorMessage: String?) {

    }
})
```

{% endtab %}
{% endtabs %}

### Get Contact Detail Info with TapTalk User ID

Get a detailed contact info with selected TapTalk.io user ID.

{% tabs %}
{% tab title="Java" %}

```java
TapCoreContactManager.getInstance().getUserDataWithUserID(USER_ID, new TapCoreGetContactListener() {
    @Override
    public void onSuccess(TAPUserModel user) {
        // Returns detailed user info
    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
TapCoreContactManager.getInstance().getUserDataWithUserID(USER_ID, object : TapCoreGetContactListener() {
    override fun onSuccess(user: TAPUserModel?) {
        // Returns detailed user info
    }

    override fun onError(errorCode: String?, errorMessage: String?) {

    }
})
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
`USER_ID`: (String) Taptalk.io User ID of the selected user
{% endhint %}

### Get Contact Detail Info with Client User ID

Get a detailed contact info with selected Client user ID (xcUserID).

{% tabs %}
{% tab title="Java" %}

```java
TapCoreContactManager.getInstance().getUserDataWithXCUserID(XC_USER_ID, new TapCoreGetContactListener() {
    @Override
    public void onSuccess(TAPUserModel user) {
        // Returns detailed user info
    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
TapCoreContactManager.getInstance().getUserDataWithXCUserID(XC_USER_ID, object : TapCoreGetContactListener() {
    override fun onSuccess(user: TAPUserModel?) {
        // Returns detailed user info
    }

    override fun onError(errorCode: String?, errorMessage: String?) {

    }
})
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
`XC_USER_ID`: (String) Client User ID of the selected user
{% endhint %}

### Add User to Contact with User ID

Add a user with selected TapTalk.io user ID to the active user's contacts.

{% tabs %}
{% tab title="Java" %}

```java
TapCoreContactManager.getInstance().addToTapTalkContactsWithUserID(USER_ID, new TapCoreGetContactListener() {
    @Override
    public void onSuccess(TAPUserModel user) {
        // Added to contacts successfully
    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
TapCoreContactManager.getInstance().addToTapTalkContactsWithUserID(USER_ID, object : TapCoreGetContactListener() {
    override fun onSuccess(user: TAPUserModel?) {
        // Added to contacts successfully
    }

    override fun onError(errorCode: String?, errorMessage: String?) {

    }
})
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
`USER_ID`: (String) Taptalk.io User ID of the contact to be added
{% endhint %}

### Add User to Contact with Phone Number

Add a user with selected phone number to the active user's contacts.

{% tabs %}
{% tab title="Java" %}

```java
TapCoreContactManager.getInstance().addToTapTalkContactsWithPhoneNumber(PHONE_NUMBER, new TapCoreGetContactListener() {
    @Override
    public void onSuccess(TAPUserModel user) {
        // Added to contacts successfully
    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
TapCoreContactManager.getInstance().addToTapTalkContactsWithPhoneNumber(PHONE_NUMBER, object : TapCoreGetContactListener() {
    override fun onSuccess(user: TAPUserModel?) {
        // Added to contacts successfully
    }

    override fun onError(errorCode: String?, errorMessage: String?) {

    }
})
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
`PHONE_NUMBER`: (String) phone number of the contact to be added
{% endhint %}

### Remove User from Contact

Remove a user with selected TapTalk.io user ID from the active user's contacts.

{% tabs %}
{% tab title="Java" %}

```java
TapCoreContactManager.getInstance().removeFromTapTalkContacts(USER_ID, new TapCommonListener() {
    @Override
    public void onSuccess(String successMessage) {
        // Removed from contacts successfully
    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
TapCoreContactManager.getInstance().removeFromTapTalkContacts(USER_ID, object : TapCommonListener() {
    override fun onSuccess(successMessage: String?) {
        // Removed from contacts successfully
    }

    override fun onError(errorCode: String?, errorMessage: String?) {

    }
})
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
`USER_ID`: (String) Taptalk.io User ID of the contact to remove
{% endhint %}

### Save User Data

Save or update existing user data to local cache.

{% tabs %}
{% tab title="Java" %}

```java
TapCoreContactManager.getInstance().saveUserData(USER);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
TapCoreContactManager.getInstance().saveUserData(USER)
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
`USER`: (TAPUserModel) the user data model to be saved
{% endhint %}

### Search Local Contact

Call this method to search the active user's contacts from the device's local storage with a keyword. Provided keyword will be used to filter the contacts' **full name** in the search result.

{% tabs %}
{% tab title="Java" %}

```java
TapCoreContactManager.getInstance().searchLocalContactByName(KEYWORD, new TapCoreGetMultipleContactListener() {
    @Override
    public void onSuccess(List<TAPUserModel> users) {
        // Returns filtered contacts
    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
TapCoreContactManager.getInstance().searchLocalContactByName(KEYWORD, object : TapCoreGetMultipleContactListener() {
    override fun onSuccess(users: List<TAPUserModel>?) {
        // Returns filtered contacts
    }

    override fun onError(errorCode: String?, errorMessage: String?) {

    }
})
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`KEYWORD`**: (String) search keyword to filter full name
{% endhint %}

### Report User

You may call this method to submit a report for a selected user. Submitted reports can then be viewed through the dashboard.

{% tabs %}
{% tab title="Java" %}

```java
TapCoreContactManager.getInstance().reportUser(USER_ID, CATEGORY, IS_OTHER_CATEGORY, REASON, new TapCommonListener() {
    @Override
    public void onSuccess(String successMessage) {
        // Successfully reported user
    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
TapCoreContactManager.getInstance().reportUser(USER_ID, IS_OTHER_CATEGORY, REASON, object : TapCommonListener() {
    override fun onSuccess(successMessage: String?) {
        // Successfully reported user
    }

    override fun onError(errorCode: String?, errorMessage: String?) {

    }
})
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`USER_ID`**: (String) ID of the user to report\
\&#xNAN;**`CATEGORY`**: (String) Category of the violation. max length is 100 characters\
\&#xNAN;**`IS_OTHER_CATEGORY`**: (Boolean) If the category is other than the predefined categories\
\&#xNAN;**`REASON`**: (String) reason why the user is reported
{% endhint %}

### Report Message

You may call this method to submit a report for a selected message. Submitted reports can then be viewed through the dashboard.

{% tabs %}
{% tab title="Java" %}

```java
TapCoreContactManager.getInstance().reportMessage(MESSAGE_ID, ROOM_ID, CATEGORY, IS_OTHER_CATEGORY, REASON, new TapCommonListener() {
    @Override
    public void onSuccess(String successMessage) {
        // Successfully reported message
    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
TapCoreContactManager.getInstance().reportMessage(MESSAGE_ID, ROOM_ID, IS_OTHER_CATEGORY, REASON, object : TapCommonListener() {
    override fun onSuccess(successMessage: String?) {
        // Successfully reported message
    }

    override fun onError(errorCode: String?, errorMessage: String?) {

    }
})
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`MESSAGE_ID`**: (String) unique server ID of the message to report\
\&#xNAN;**`ROOM_ID`**: (String) ID of the room where the message belongs to\
\&#xNAN;**`CATEGORY`**: (String) Category of the violation. max length is 100 characters\
\&#xNAN;**`IS_OTHER_CATEGORY`**: (Boolean) If the category is other than the predefined categories\
\&#xNAN;**`REASON`**: (String) reason why the message is reported
{% endhint %}

### Block User

You may block a user to stop conversation flow with the blocked user. Blocked users will not be able to send and receive message, or retrieve profile info from the active user.

{% tabs %}
{% tab title="Java" %}

```java
TapCoreContactManager.getInstance().blockUser(USER_ID, new TapCoreGetContactListener() {
    @Override
    public void onSuccess(TAPUserModel user) {
        // Successfully blocked user
    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
TapCoreContactManager.getInstance().blockUser(USER_ID, object : TapCoreGetContactListener() {
    override fun onSuccess(user: TAPUserModel?) {
        // Successfully blocked user
    }

    override fun onError(errorCode: String?, errorMessage: String?) {

    }
})
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`USER_ID`**: (String) ID of the user to block
{% endhint %}

### Unblock User

You may unblock a blocked user to let them send and receive message from the active user.

{% tabs %}
{% tab title="Java" %}

```java
TapCoreContactManager.getInstance().unblockUser(USER_ID, new TapCoreGetContactListener() {
    @Override
    public void onSuccess(TAPUserModel user) {
        // Successfully unblocked user
    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
TapCoreContactManager.getInstance().unblockUser(USER_ID, object : TapCoreGetContactListener() {
    override fun onSuccess(user: TAPUserModel?) {
        // Successfully unblocked user
    }

    override fun onError(errorCode: String?, errorMessage: String?) {

    }
})
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`USER_ID`**: (String) ID of the user to unblock
{% endhint %}

### Get Blocked User List

You may call this method to retrieve a list of blocked users.

{% tabs %}
{% tab title="Java" %}

```java
TapCoreContactManager.getInstance().getBlockedUserList(new TapCoreGetMultipleContactListener() {
    @Override
    public void onSuccess(List<TAPUserModel> blockedUsers) {
         // Successfully retrieved blocked users
    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
TapCoreContactManager.getInstance().getBlockedUserList(object : TapCoreGetMultipleContactListener() {
    override fun onSuccess(blockedUsers: List<TAPUserModel>) {
         // Successfully retrieved blocked users
    }

    override fun onError(errorCode: String?, errorMessage: String?) {

    }
})
```

{% endtab %}
{% endtabs %}

### Get Blocked User IDs

You may call this method to retrieve a list of IDs from blocked users.

{% tabs %}
{% tab title="Java" %}

```java
TapCoreContactManager.getInstance().getBlockedUserIDs(new TapCoreGetStringArrayListener() {
    @Override
    public void onSuccess(ArrayList<String> blockedUserIDs) {
         // Successfully retrieved blocked user IDs
    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
TapCoreContactManager.getInstance().getBlockedUserIDs(object : TapCoreGetStringArrayListener() {
    override fun onSuccess(blockedUserIDs: ArrayList<String>) {
        // Successfully retrieved blocked user IDs
    }

    override fun onError(errorCode: String?, errorMessage: String?) {

    }
})
```

{% endtab %}
{% endtabs %}

### Get Groups in Common

You may use **`getGroupsInCommon`** method to retrieve the list of groups in common with another user.

{% tabs %}
{% tab title="Java" %}

```java
TapCoreContactManager.getInstance().getGroupsInCommon(USER_ID, new TapCoreGetRoomArrayListener() {
    @Override
    public void onSuccess(ArrayList<TAPRoomModel> rooms) {
        // Successfully retrieved rooms
    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
TapCoreContactManager.getInstance().getGroupsInCommon(USER_ID, object : TapCoreGetRoomArrayListener() {
    override fun onSuccess(rooms: ArrayList<TAPRoomModel>) {
        // Successfully retrieved rooms
    }

    override fun onError(errorCode: String?, errorMessage: String?) {

    }
})
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`USER_ID`**: (String) ID of the other user
{% endhint %}
