# IGP.UnitySDK.CloudArchive

Optional Cloud Archive module for the IGP Unity SDK.

The module exposes user-scoped cloud save APIs through the main `IGP.UnitySDK`
desktop session. The SDK does not call the public API directly and does not
manage user access tokens. Desktop owns authentication and forwards requests.

## Install

Install the main package first:

```text
adapters/unity/Runtime/IGP.UnitySDK/package.json
```

Then install this optional package:

```text
adapters/unity/Runtime/IGP.UnitySDK.CloudArchive/package.json
```

Published package:

```text
cn.indiegp.sdk.unity.cloud-archive-<cloud-archive-version>.unitypackage
```

## Minimal Usage

```csharp
using IGP.UnitySDK;
using IGP.UnitySDK.CloudArchive;

public sealed class CloudSaveDriver
{
    private IGPRuntimeManager runtimeManager;
    private string version;

    public async void Load()
    {
        var result = await IGPCloudArchive.LoadCloudArchiveAsync(
            runtimeManager,
            IGPCloudArchive.Slot1);
        version = result.version;
    }

    public async void Save(string json)
    {
        try
        {
            var result = await IGPCloudArchive.SaveCloudArchiveAsync(
                runtimeManager,
                IGPCloudArchive.Slot1,
                json,
                new IGPCloudArchiveSaveOptions { baseVersion = version });
            version = result.version;
        }
        catch (IGPCloudArchiveException ex) when (ex.HttpStatus == 409 || ex.ApiCode == 10005)
        {
            var latest = ex.Conflict?.currentVersion;
            // Reload, reconcile, then save again with the latest version.
        }
    }
}
```

## Behavior

- Requires `attached.capabilities.cloudArchive == true`.
- Uses desktop named command `cloudArchiveForward`.
- `slot` must be one of `IGPCloudArchive.Slot1` through `IGPCloudArchive.Slot5`.
- `data` is an opaque string; serialize JSON before calling save.
- `version` and `baseVersion` are opaque strings.
- API errors are exposed through `IGPCloudArchiveException.BodyJson`, `Body`,
  `HttpStatus`, and `ApiCode`.
