Merge pull request #295 from PetriAsi/fix/jorips1

Rebased Fix/jorips1 orginal PR

New/Set licenses
Removed Validate Length from New-SnipeitLicense -license_email, bringing it in line with Set. This was causing the parameter to fail as it cannot validate the mailaddress object.
Added code to convert -license_email to string, as required by the SnipeitAPI.
Added -purchase_order functionality.

New Supplier
Fixed typo in API which was causing the command to fail.
This commit is contained in:
Petri Asikainen 2022-11-29 05:44:21 +02:00 committed by GitHub
commit 29c23e92ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 2 deletions

View file

@ -47,6 +47,9 @@
.PARAMETER purchase_date .PARAMETER purchase_date
Date of license purchase Date of license purchase
.PARAMETER purchase_order
Purchase order number of license purchase
.PARAMETER reassignable .PARAMETER reassignable
Is license reassignable? Is license reassignable?
@ -89,7 +92,6 @@ function New-SnipeitLicense() {
[datetime]$expiration_date, [datetime]$expiration_date,
[ValidateLength(1, 120)]
[mailaddress]$license_email, [mailaddress]$license_email,
[ValidateLength(1, 100)] [ValidateLength(1, 100)]
@ -108,6 +110,8 @@ function New-SnipeitLicense() {
[datetime]$purchase_date, [datetime]$purchase_date,
[string]$purchase_order,
[bool]$reassignable, [bool]$reassignable,
[string]$serial, [string]$serial,
@ -140,6 +144,10 @@ function New-SnipeitLicense() {
$Values['termination_date'] = $Values['termination_date'].ToString("yyyy-MM-dd") $Values['termination_date'] = $Values['termination_date'].ToString("yyyy-MM-dd")
} }
if ($Values['license_email']) {
$Values['license_email'] = $Values['license_email'].address
}
$Parameters = @{ $Parameters = @{
Api = "/api/v1/licenses" Api = "/api/v1/licenses"
Method = 'POST' Method = 'POST'

View file

@ -102,7 +102,7 @@ function New-SnipeitSupplier() {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Parameters = @{ $Parameters = @{
Api = "/api/v1/suppilers" Api = "/api/v1/suppliers"
Method = 'POST' Method = 'POST'
Body = $Values Body = $Values
} }

View file

@ -50,6 +50,9 @@
.PARAMETER purchase_date .PARAMETER purchase_date
Date of license purchase Date of license purchase
.PARAMETER purchase_order
Purchase order number of license purchase
.PARAMETER reassignable .PARAMETER reassignable
Is license reassignable? Is license reassignable?
@ -116,6 +119,8 @@ function Set-SnipeitLicense() {
[datetime]$purchase_date, [datetime]$purchase_date,
[string]$purchase_order,
[bool]$reassignable, [bool]$reassignable,
[string]$serial, [string]$serial,
@ -151,6 +156,9 @@ function Set-SnipeitLicense() {
$Values['termination_date'] = $Values['termination_date'].ToString("yyyy-MM-dd") $Values['termination_date'] = $Values['termination_date'].ToString("yyyy-MM-dd")
} }
if ($Values['license_email']) {
$Values['license_email'] = $Values['license_email'].address
}
} }
process { process {