# SharingResource

Canonical page: https://docs.ovok.com/java-sdk/reference/sharing-resource

```java
public final class SharingResource
```

Shares patient records through invites. Get it from [`Ovok.sharing()`](/java-sdk/reference/ovok#sharing).

## Methods [#methods]

### invites [#invites]

```java
public SharingResource.Invites invites()
```

Returns the share-invite routes.

**Returns:** the invite routes

### shares [#shares]

```java
public SharingResource.Shares shares()
```

Returns the active-share routes.

**Returns:** the share routes

### settings [#settings]

```java
public SharingResource.Settings settings()
```

Returns the sharing-settings routes.

**Returns:** the settings routes

## SharingResource.Invites [#sharingresourceinvites]

```java
public static final class Invites
```

Creates and redeems patient-sharing invites.

### Invites.create [#invitescreate]

```java
public JsonNode create(Object body, RequestOptions options) throws IOException, InterruptedException
```

Creates a sharing invite (`POST /v1/patient-sharing/invites`).

**Parameters:**

- `body`: the invite request
- `options`: per-request options, such as the timeout

**Returns:** the response body

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

### Invites.redeem [#invitesredeem]

```java
public JsonNode redeem(Object body, RequestOptions options) throws IOException, InterruptedException
```

Redeems a sharing invite (`POST /v1/patient-sharing/invites/redeem`).

**Parameters:**

- `body`: the redeem request
- `options`: per-request options, such as the timeout

**Returns:** the response body

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

## SharingResource.Shares [#sharingresourceshares]

```java
public static final class Shares
```

Lists and revokes active shares.

### Shares.list [#shareslist]

```java
public JsonNode list(RequestOptions options) throws IOException, InterruptedException
```

Lists active shares (`GET /v1/patient-sharing/shares`).

**Parameters:**

- `options`: per-request options, such as the timeout

**Returns:** the shares; missing `practitioners`, `relatedPersons` and `received` groups are empty arrays

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

### Shares.revoke [#sharesrevoke]

```java
public void revoke(
        String consentId,
        RequestOptions options) throws IOException, InterruptedException
```

Revokes a share (`DELETE /v1/patient-sharing/shares/{consentId}`).

**Parameters:**

- `consentId`: the Consent ID of the share
- `options`: per-request options, such as the timeout

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

## SharingResource.Settings [#sharingresourcesettings]

```java
public static final class Settings
```

Reads and updates the caller's sharing settings.

### Settings.retrieve [#settingsretrieve]

```java
public JsonNode retrieve(RequestOptions options) throws IOException, InterruptedException
```

Reads the sharing settings (`GET /v1/patient-sharing/settings`).

**Parameters:**

- `options`: per-request options, such as the timeout

**Returns:** the response body

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response

### Settings.update [#settingsupdate]

```java
public JsonNode update(
        Object settings,
        RequestOptions options) throws IOException, InterruptedException
```

Replaces the sharing settings (`PUT /v1/patient-sharing/settings`).

**Parameters:**

- `settings`: the new settings
- `options`: per-request options, such as the timeout

**Returns:** the response body

**Throws:**

- `IOException`: if the request cannot be sent or the response cannot be read
- `InterruptedException`: if the thread is interrupted while waiting for the response
