# Contact

## Get contact list

```objectivec
- (MXHTTPOperation*)getContactsListWithUserId:(NSString *)userId
                                      success:(void (^)(MXContactsListResponse *contactsListResponse))success
                                      failure:(void (^)(NSError *error))failure;
```

**Input Parameters**:

| Name      | Type     | Description    | Required |
| --------- | -------- | -------------- | -------- |
| `user_id` | NSString | user id string | true     |

**Output Parameters**

`MXContactsListResponse`

## Add user as a contact

```objectivec
- (MXHTTPOperation*)addToFavoritesWithUserId:(NSString *)userId
                                   contactId:(NSString *)contactId
                                        tags:(NSArray*)tags
                                     isRoom:(BOOL)isRoom
                                     success:(void (^)(void))success
                                     failure:(void (^)(NSError *error))failure;
```

**Input Parameters**:

| Name      | Type     | Description                 | Required |
| --------- | -------- | --------------------------- | -------- |
| userId    | NSString | user id string              | true     |
| contactId | NSString | contact id string           | true     |
| tags      | NSArray  | tags NSArray                | false    |
| isRoom    | bool     | whether is a direct message | true     |

## Remove contact

```objectivec
- (MXHTTPOperation*)deleteFavoritesWithUserId:(NSString *)userId
                                   contactId:(NSString *)contactId
                                     isRoom:(BOOL)isRoom
                                     success:(void (^)(void))success
                                      failure:(void (^)(NSError *error))failure;
```

**Input Parameters**:

| Name      | Type     | Description                 | Required |
| --------- | -------- | --------------------------- | -------- |
| userId    | NSString | user id string              | true     |
| contactId | NSString | contact id string           | True     |
| isRoom    | BOOL     | whether is a direct message | True     |

**Output Parameters**：

| Name    | Type  | Description                                       | Required |
| ------- | ----- | ------------------------------------------------- | -------- |
| success | block | A block object called when the operation succeeds | true     |
| failure | block | A block object called when the operation fails.   | true     |

***

{% hint style="warning" %}
The methods below are deprecated. Please avoid using them.
{% endhint %}

## (Deprecated) Get contact list

```swift
client?.getContactsList(withUserId: user_id, success: { <#MXContactsListResponse?#> in }, failure: <#T##((Error?) -> Void)!##((Error?) -> Void)!##(Error?) -> Void#>)
```

Parameters:

| Name      | Type   | Description    | Required |
| --------- | ------ | -------------- | -------- |
| `user_id` | string | user id string | true     |

Returns

`MXContactsListResponse`

## (Deprecated) Add user as a contact

```swift
client?.addToFavorites(withUserId: user_id, contactId: contactId, isRoom: true, success: {}, failure: { error in })
```

Parameters:

| Name        | Type   | Description                 | Required |
| ----------- | ------ | --------------------------- | -------- |
| `user_id`   | string | user id string              | true     |
| `contactId` | string | contact id string           | true     |
| `isRoom`    | bool   | whether is a direct message | true     |

## (Deprecated) Remove contact

```swift
client?.deleteFavorites(withUserId: user_id, contactId: contactId, isRoom: true, success: {}, failure: { error in })
```

Parameters:

| Name        | Type   | Description                 | Required |
| ----------- | ------ | --------------------------- | -------- |
| `user_id`   | string | user id string              | true     |
| `contactId` | string | contact id string           | True     |
| `isRoom`    | bool   | whether is a direct message | True     |
