lwhitelock / HuduAPI

A powershell API for Hudu Documentation
MIT License
53 stars 45 forks source link

Get-HuduCompanies returns a company object when Id is specified #42

Closed adamburley closed 1 year ago

adamburley commented 1 year ago

Cmdlet: Get-HuduCompanies

Issue

At least as of Hudu V2.24, the Hudu API returns a companies object at the root GET /companies/{id} call. This is not illustrated in the API docs.

This results in an inconsistent response from Get-HuduCompanies depending if you're calling by ID, name, or for all companies. A small change on Line 57 of Get-HuduCompanies.ps1 would resolve this inconsistency for both cases:

Current

$Company = Invoke-HuduRequest -Method get -Resource "/api/v1/companies/$Id"
return $Company

Potential Fix

$Company = Invoke-HuduRequest -Method get -Resource "/api/v1/companies/$Id"
if ($Company | Get-Member -Name company) { return $Company.company } else { return $Company }
greenlighttec commented 1 year ago

This has been fixed and will be live in the next version.