// Copyright 2026 Moko Consulting // SPDX-License-Identifier: GPL-3.0-or-later package structs import "time" // LicensePackage represents a license package (subscription tier). type LicensePackage struct { ID int64 `json:"id"` OwnerID int64 `json:"owner_id"` Name string `json:"name"` Description string `json:"description"` DurationDays int `json:"duration_days"` MaxSites int `json:"max_sites"` RepoScope string `json:"repo_scope"` AllowedChannels string `json:"allowed_channels"` IsActive bool `json:"is_active"` // swagger:strfmt date-time Created time.Time `json:"created_at"` // swagger:strfmt date-time Updated time.Time `json:"updated_at"` } // CreateLicensePackageOption options for creating a license package. type CreateLicensePackageOption struct { Name string `json:"name" binding:"Required"` Description string `json:"description"` DurationDays int `json:"duration_days"` MaxSites int `json:"max_sites"` RepoScope string `json:"repo_scope"` AllowedChannels string `json:"allowed_channels"` } // EditLicensePackageOption options for editing a license package. type EditLicensePackageOption struct { Name *string `json:"name"` Description *string `json:"description"` DurationDays *int `json:"duration_days"` MaxSites *int `json:"max_sites"` RepoScope *string `json:"repo_scope"` AllowedChannels *string `json:"allowed_channels"` IsActive *bool `json:"is_active"` } // LicenseKey represents a license key (response — never includes raw key except on creation). type LicenseKey struct { ID int64 `json:"id"` PackageID int64 `json:"package_id"` OwnerID int64 `json:"owner_id"` KeyPrefix string `json:"key_prefix"` LicenseeName string `json:"licensee_name"` LicenseeEmail string `json:"licensee_email"` DomainRestriction string `json:"domain_restriction"` MaxSites int `json:"max_sites"` IsInternal bool `json:"is_internal"` IsActive bool `json:"is_active"` // swagger:strfmt date-time StartsAt *time.Time `json:"starts_at"` // swagger:strfmt date-time ExpiresAt *time.Time `json:"expires_at"` // swagger:strfmt date-time LastHeartbeat *time.Time `json:"last_heartbeat,omitempty"` // swagger:strfmt date-time Created time.Time `json:"created_at"` } // LicenseKeyCreated is the response when a key is first created (includes raw key). type LicenseKeyCreated struct { LicenseKey // RawKey is the full license key string. Only returned on creation. RawKey string `json:"raw_key"` } // CreateLicenseKeyOption options for creating a license key. type CreateLicenseKeyOption struct { PackageID int64 `json:"package_id" binding:"Required"` LicenseeName string `json:"licensee_name"` LicenseeEmail string `json:"licensee_email"` DomainRestriction string `json:"domain_restriction"` MaxSites int `json:"max_sites"` // StartsAt is optional; defaults to now. StartsAt *time.Time `json:"starts_at"` // ExpiresAt is optional; auto-calculated from package duration if not set. ExpiresAt *time.Time `json:"expires_at"` } // EditLicenseKeyOption options for editing a license key. type EditLicenseKeyOption struct { LicenseeName *string `json:"licensee_name"` LicenseeEmail *string `json:"licensee_email"` DomainRestriction *string `json:"domain_restriction"` MaxSites *int `json:"max_sites"` IsActive *bool `json:"is_active"` ExpiresAt *time.Time `json:"expires_at"` } // PurchaseLicenseKeyOption options for purchasing a license key via webhook. type PurchaseLicenseKeyOption struct { PackageID int64 `json:"package_id" binding:"Required"` LicenseeName string `json:"licensee_name"` LicenseeEmail string `json:"licensee_email"` Domain string `json:"domain"` PaymentRef string `json:"payment_ref"` } // ValidateLicenseKeyOption options for validating a license key. type ValidateLicenseKeyOption struct { Key string `json:"key" binding:"Required"` Domain string `json:"domain"` } // ValidateLicenseKeyResponse is the response from license key validation. type ValidateLicenseKeyResponse struct { Valid bool `json:"valid"` Message string `json:"message,omitempty"` PackageName string `json:"package_name,omitempty"` Channels string `json:"channels,omitempty"` ExpiresAt *time.Time `json:"expires_at,omitempty"` SitesUsed int64 `json:"sites_used"` MaxSites int `json:"max_sites"` } // LicenseSettings represents the licensing/update stream configuration for a repo. type LicenseSettings struct { LicensingEnabled bool `json:"licensing_enabled"` RequireKey bool `json:"require_key"` DownloadGating string `json:"download_gating"` Platform string `json:"platform"` SupportURL string `json:"support_url"` ExtensionName string `json:"extension_name,omitempty"` DisplayName string `json:"display_name,omitempty"` ExtensionType string `json:"extension_type,omitempty"` Maintainer string `json:"maintainer,omitempty"` MaintainerURL string `json:"maintainer_url,omitempty"` InfoURL string `json:"info_url,omitempty"` TargetVersion string `json:"target_version,omitempty"` PHPMinimum string `json:"php_minimum,omitempty"` } // LicenseKeyUsage represents a usage tracking entry. type LicenseKeyUsage struct { ID int64 `json:"id"` KeyID int64 `json:"key_id"` RepoID int64 `json:"repo_id"` Domain string `json:"domain"` IPAddress string `json:"ip_address"` UserAgent string `json:"user_agent"` VersionFrom string `json:"version_from"` // swagger:strfmt date-time Created time.Time `json:"created_at"` }