# Policy

### Fetch policies list

To fetch policies list for logged in user, the following API can be used.

Concrete Example

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

```swift
let service = PolicyService()

service.fetchPolicies() { result in
    switch result {
    case .success(let policies):
        // fetch successful
    case .failure:
        // API call failed
    }
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val service = PolicyService()

service.fetchPolicies { result ->
    if (result is Result.Success) {
        val policies = result.value // List<Policy>
        // fetch successful
    } else if (result is Result.Failure) {
        // API call failed
        val error = result.throwable
    }
}
```

{% endtab %}
{% endtabs %}

## FetchAssociatedUsers

To fetch the list of users associated for a specific policy, the following API can be used

Concrete Example

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

```swift
let service = PolicyService()

service.fetchAssociatedUsers(policyId: policyId) { result in
    switch result {
    case .success(let associatedUsers):
        // fetch successful
    case .failure:
        // API call failed
    }
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val service = PolicyService()

service.fetchAssociatedUsers(policyId = policyId) { result ->
    if (result is Result.Success) {
        val associatedUsers = result.value // List<AssociatedUser>
        // fetch successful
    } else if (result is Result.Failure) {
        // API call failed
        val error = result.throwable
    }
}
```

{% endtab %}
{% endtabs %}
