Skip to content

AdminApi

The AdminApi class is an abstract base class in the ByteCobra Updater framework, responsible for managing administrative operations related to application updates. It is only used in the Unity editor for managing game versions, uploading new versions, etc. This class provides a structured interface for interacting with the update system, allowing developers to implement specific update-related functionalities.

Example Usage

Here's an example of how to create a custom class that inherits from AdminApi:

using ByteCobra.Updater;
using ByteCobra.Updater.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;

public class CustomAdminApi : AdminApi
{
    public CustomAdminApi(string username, string password) 
        : base(username, password)
    {
        // Initialize any custom properties or settings here.
    }

    public override async Task PublishAsync(
        string applicationName, 
        Platform platform, 
        ushort minor, 
        ushort major)
    {
        // Implement your custom logic for publishing updates.
    }

    public override async Task<bool> UploadAsync(
        string applicationName, 
        Platform platform, 
        ushort major, 
        ushort minor, 
        FileInfo zipFile, 
        Action<float> onProgress = null)
    {
        // Implement your custom logic for uploading update files.
        return true; // Return the upload result.
    }

    public override async Task<List<PackageInfo>> GetPackagesAsync(
        string applicationName, 
        Platform platform)
    {
        // Implement your custom logic for retrieving package information.
        return new List<PackageInfo>(); // Return the list of packages.
    }

    public override async Task<bool> DeleteVersionAsync(
        string applicationName, 
        Platform platform, 
        ushort major, 
        ushort minor)
    {
        // Implement your custom logic for deleting specific versions.
        return true; // Return the deletion result.
    }
}

In this example, CustomAdminApi extends AdminApi and provides concrete implementations for its abstract methods. You can customize the logic within each method to suit your specific update management requirements.

This approach allows you to integrate and extend the functionality of the AdminApi class to manage application updates according to your needs.