# User

### Fetch user information

**Parameters**:

`expansions`: The `expansions` applied for a user

Expansions options are below:

* ASSOCIATEDUSERS
* SHAREDINFORMATION
* ASSOCIATEDACCOUNT
* CUSTOMFIELDS
* ROLE

To fetch user information, the following API can be used.

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

```swift
let userService = UserService()
userService.fetch(then: { result in 
	if let user = result.value {
		// Success
		completionHandler(user)
	} else {
		// failure
	}
})
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val userService = UserService()
userService.fetch { result: Result<User?> ->
    if (result?.value == null || result.throwable != null) {
        // failure
    } else {
        // Success
        val user = result.value
    }
}
```

{% endtab %}
{% endtabs %}

### Update user information

The HostApp can update the user information upon success.

#### Concrete example

To update user information, the following API can be used.

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

```swift
let userService = UserService()
userService.update(displayName: displayName,
                   postalCode: postalCode,
                   gender: gender,
                   dateOfBirth: dateOfBirth, then: { result in
    switch result {
    case .sucess(_):
        // update successful
    case .failure(_):
        // error
    }
})
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sdk.ims.tech/drivesync-portal/user.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
