Superspace hosting plugin for HostFact
======================================

Connects HostFact's hosting module to the Superspace API. One HostFact server covers
three Superspace products; the HostFact package decides which:
  basic / lite / pro / max      -> managed WordPress site   (Superspace.php)
  cpanel_mini .. cpanel_max     -> cPanel hosting account   (SuperspaceHostingCpanel.php)
  mail_5 .. mail_500            -> Mailspace mail hosting    (SuperspaceHostingMailspace.php)
Without a package (some HostFact calls) the account is looked up as a site, then as a
cPanel account (by username or primary domain), then as a Mailspace (by domain).
DNS zones hosted at Superspace are edited from HostFact (SuperspaceHostingDns.php, shared with
the domain plugin). Since 1.3.0.

Install:
1. Copy the 'SuperspaceHosting' folder into HostFact at: Pro/3rdparty/hosting/SuperspaceHosting/
   (so you have Pro/3rdparty/hosting/SuperspaceHosting/SuperspaceHosting.php)
2. In HostFact: Settings > Hosting > Servers > add a server of type 'Superspace'.
3. Fill the server-connection fields:
     URL controlepaneel (Server_Address)  -> https://<instance>   (e.g. https://control.superspace.nl)
     Poort              (Server_AddressPort) -> 443  (HostFact requires a port; the module
                                                does not use it, the https URL above does)
     Gebruikersnaam     (Server_User)      -> Superspace Werkruimte-ID (UUID)
     Wachtwoord         (Server_Pass)      -> Superspace API Key (token)
   The module appends "/api" to the URL itself. Find the Werkruimte-ID via GET /api/accounts.
4. HostFact validates the connection on save (validateLogin -> GET /api/about).

Field mapping in code:
  Server_Address -> base URL (".../api")
  Server_User    -> header X-Auth-Account: <werkruimte-id>
  Server_Pass    -> header Authorization: Token <key>

Workspaces (since 1.2.0):
  Server_User is the workspace (account) new sites are ordered in. Existing sites are
  listed WITHOUT the X-Auth-Account header, so GET /api/sites returns every site the API
  user can reach, including sites in sub-workspaces (each row carries its "account").
  The list is then narrowed to the configured workspace and its descendants using
  GET /api/accounts (parent_account chain), so unrelated workspaces never show up.
  Site-scoped calls (get/resize/delete/domains/sso/metrics) are sent with the account
  id of the site itself, which is what a sub-workspace site requires.

Scope (v1):
  - validateLogin, listAccounts (sync), checkIfAccountExists
  - listPackages, getPackage, changePackage (plan change, async/cart)
  - createAccount (provision a site via an order), deleteAccount
  - addDomain, listDomains
  - getAccountUsage (disk; bandwidth best-effort via CDN metrics)
  - singleSignOn (WordPress login URL)

Not supported (Warning/stub):
  - suspendAccount        : Superspace suspension is billing/dunning-driven, no API.
  - changeAccountPassword : Superspace generates SSH/SFTP credentials, no set-password API.
  - createResellerAccount : creating a sub-workspace is out of scope (existing sub-workspace
                            sites ARE found and managed, see "Workspaces").
  - DNS zone management   : phase 2 (safe stubs; the API supports it).

Order defaults (TODO: make location/variant configurable):
  createAccount uses fixed location "amsterdam" and variant "vanilla". The location is
  validated against /api/about and falls back to the first available location, so an
  unknown default never blocks an order.

  Plan and billing term both come from the HostFact package name. HostFact does not pass
  the billing cycle to the plugin, so encode it in the package name:
    "Pro jaarlijks"   -> plan "pro",  term "annual"
    "Pro maandelijks" -> plan "pro",  term "monthly"
    "Pro"             -> plan "pro",  term "annual" (default when no cycle word is present)
  Cycle words (NL + EN: jaar/jaarlijks/jr/year/annual ; maand/maandelijks/mnd/month/monthly/mo)
  are detected and stripped, so they never break the plan mapping (basic/lite/pro/max).

Billing note: provisioning (createAccount) and plan changes (changePackage) are charged
OFF-SESSION on the Superspace account's saved payment method. They cost real money, so
test these write paths deliberately (read-only smoke first).

Verified read-only against the sandbox (https://control.superspace.nl, account SuperRuben):
  validateLogin, listAccounts, listPackages, getPackage, getAccountUsage, listDomains
  -- all correct, 0 errors. Write paths (order/delete/resize/add-domain/sso) are
  unit-tested against the verified API envelopes but await a supervised live test.
