Skip to content

feat: update VPS purchase API response structure#5

Merged
derrickobedgiu1 merged 1 commit into
mainfrom
vps
Jun 24, 2025
Merged

feat: update VPS purchase API response structure#5
derrickobedgiu1 merged 1 commit into
mainfrom
vps

Conversation

@derrickobedgiu1

Copy link
Copy Markdown
Owner

Summary

  • Updates the VPS virtual machine purchase endpoint to handle the new API response structure
  • Creates new VirtualMachineOrder class to encapsulate both order and virtual machine data
  • Maintains backward compatibility for all other endpoints

Changes Made

  • New Class: Added VirtualMachineOrder data class in src/Data/Vps/VirtualMachineOrder.php
  • Updated Method: Modified VirtualMachine::purchase() to return VirtualMachineOrder instead of Order
  • Enhanced Testing: Added TestFactory::virtualMachineOrder() method and updated related tests
  • Documentation: Updated README examples to show new response structure usage

API Changes Implemented

Based on the June 18, 2025 changelog for POST /api/vps/v1/virtual-machines:

Removed Properties (200 response):

  • id, subscription_id, status, currency, subtotal, total, billing_address, created_at, updated_at

Added Properties (200 response):

  • order - Contains all billing/order information
  • virtual_machine - Contains virtual machine details

Usage Example

// Before
$order = $hostinger->vps()->virtualMachines()->purchase($data);
$order->id; // 2957087
$order->status->value; // completed

// After
$response = $hostinger->vps()->virtualMachines()->purchase($data);
$response->order->id; // 2957087
$response->order->status->value; // completed

$response->virtual_machine->id; // 1268054
$response->virtual_machine->hostname; // my.server.tld

Breaking Changes

None. This change only affects the VPS purchase endpoint and maintains backward compatibility for all other Order-related functionality.

@derrickobedgiu1 derrickobedgiu1 merged commit 7f01a13 into main Jun 24, 2025
18 checks passed
@derrickobedgiu1 derrickobedgiu1 deleted the vps branch June 24, 2025 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant